## calculating total # of consecutive dry and wet days using NASA's TRMM daily precipitation data

### Jocelyn (view profile)

on 22 Aug 2019
Latest activity Commented on by Jocelyn

### Jocelyn (view profile)

on 25 Aug 2019
Hello everyone.
I have 21 years (1998-2018) of daily precipitation data (individual nc4 files, each with lon, lat, precip and time variables).
I need to find the total # of events of consecutive dry/wet days per month during the summer season for each year in the US (June,July,August), if at all possible. For example: June 1998, July 1998, August 1998, June 1999, July 1999, August 1999, ... June 2018, July 2018, August 2018.
Wet days are precip > 1mm and dry days is precip < 0.1 mm. Unfortunately, I couldn't attach a file because it is not supported.
I am brand new to this, and unfortunately, my advisor only uses fortran and can't guide me with this task.

Jess Lovering

### Jess Lovering (view profile)

on 22 Aug 2019
Without seeing the data and how you read in the file, it is a bit difficult to give precise advice, but I would start would these steps and looking into the help for these functions:
Read in the data, convert the time data into a datetime format using the datetime() command:
precip_date = datetime(inputvariable);
You can trim down all of your data to only the summer months using the month() and find() functions:
summer_indices = find(month(precip_date)==6|month(precip_date)==7|month(precip_date)==8)
summer_dates = precip_date(summer_indices);
summer_precip = precip(summer_indices);
Make a varible to classify the data as wet or dry, then assign a value of 1 or 0 to determine if it is a wet or dry day from the precipitation value with something similar to this:
day_class = zeros(1,length(precip); day_class(precip>1) = 1;
Use the diff(day_class) function to see where the values change from wet to dry (-1 or 1 when it changes and zero when it is constant). Hopefully this will at least give you a starting point of where to look in the help.
Jocelyn

### Jocelyn (view profile)

on 25 Aug 2019
Hello Jessica,
This is how I am reading my data.
d1 = datenum('1998-01-01','yyyy-mm-dd');
d2 = datenum('2018-12-31','yyyy-mm-dd');
d = d1:d2;
datevector = datevec(d);