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

1 view (last 30 days)
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.
Your help is greatly appreciated.
  2 Comments
Jess Lovering
Jess Lovering 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 on 25 Aug 2019
Hello Jessica,
This is how I am reading my data.
I will follow your guideline and hopefully I can make it work. I appreciate your time in answering! :)
d1 = datenum('1998-01-01','yyyy-mm-dd');
d2 = datenum('2018-12-31','yyyy-mm-dd');
d = d1:d2;
datevector = datevec(d);
lon_trmm = ncread('3B42_Daily.19980101.7.nc4','lon');
lat_trmm = ncread('3B42_Daily.19980101.7.nc4','lat');
trmm_dailyUSA = zeros(100,240,numel(d));
for i = 1:numel(d)
data = ['3B42_Daily.',sprintf('%4d',datevector(i,1)),sprintf('%2.2d',datevector(i,2)),sprintf('%2.2d',datevector(i,3)),'.7.nc4'];
hh = ncread(data,'precipitation');
hhUSA = hh(lat_trmm>25 & lat_trmm<50 ,lon_trmm>-125 & lon_trmm<-65);
trmm_dailyUSA(:,:,i) = flipud(hhUSA);
end;

Sign in to comment.

Answers (0)

Categories

Find more on Weather and Atmospheric Science in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!