Calculating seasonal rainfall precentage from netcdf file
8 views (last 30 days)
Disclaimer- I am really new at MatLab so please forgive my ignorance (trying real hard to learn). MatLab 2017b
Here is my issue- I have downloaded a netcdf file (attached file) that contains monthly observations of precipitation from 1932-1991. What I need to do is calculate the percentage of rain that falls in the summer (July, August, September). I am beginning to set the problem up set-by-step so any help would be super awesome!! ;)
- The matrix is 708 x 1 so I need to tell Matlab that, from the top, every set of 12 numbers is a year
- then I need to add up all the values within each year for a total (annual precipiation)
- Followed by adding up every value at 7,8,9 within the 12 number block (year).
- Calculate % of summer rainfall, which should be JAS / annual for each year
- Finally, average each year's summer rainfall.
This is for the purpose of saying from 1932-1991 the average % of rain that fell during the summer was x (should be around 40-50% as I have calculated several years by hand)
I can do this for a single year using super simple indexing, but how I get this to repeat and scale this up to a large data set is where I am stuck
Jyotish Kumar on 29 May 2019
Edited: Jyotish Kumar on 29 May 2019
First, you can reshape your matrix X (which is 708*1)
Find sum of all the 59 columns which will give you Sum of all 12 months rainfall for every 59 year
Now initialize a matrix with Zeros of size 1*59 and compute sum of (July, August, September) rainfall for every 59 year.
A(i)= sum(Y(7:9, i));
Now calculate Percentage of (July, August, September) rainfall over year for all 59 year.
Calculate average of percentage
I hope, it helps you to solve your problem.