In my code below, I am having difficulty figuring out a way to sum up rainfall numbers from multiple netcdf files. I need to sum up averages for months, years, and certain hours of the day (00Z,03Z,06Z, and so on). Im not sure what type of coding i should use to sum up the rainfall regimes of a certain area using the rainfall array in the netcdf file. Could anyone give me a possible suggestion? Thank you for your time and help.
pro january_files
latmax = 3 & latmin = -3
lonmax = 36 & lonmin = 30
days_leap_year = [31,29,31,30,31,30,31,31,30,31,30,31]
days_normal_year = [31,28,31,30,31,30,31,31,30,31,30,31]
num_hours = 8
num_months = 12
data_years= [1998,2013]
num_years = data_years[1] - data_years[0] + 1
total_rainfall = []
for iyears=0, num_years - 1 do begin
year = iyears + data_years[0]
if year eq 2000 or 2004 or 2008 or 2012 then $
days_month = days_leap_year else days_month = days_normal_year
foreach element, days_month, index do num_days = element
for imonths=0, num_months -1 do begin
for idays=0, num_days -1 do begin
for ihours=0, num_hours -1 do begin
time_array= STRARR(num_years, num_months, num_days,num_hours)
time_array[iyears,imonths,idays,ihours] = '/media/TOSHIBA EXT/3B42V7_3hr/3B42.' + $
STRING(year, FORMAT ='(i04)') + STRING(imonths+1, FORMAT ='(i02)') + $
STRING(idays+1, FORMAT = '(i02)') + '.' + STRING(ihours*3, FORMAT = '(i02)') + '.Africa.7.nc'
exist = FILE_TEST(time_array[iyears,imonths,idays,ihours])
if not exist then print, 'Error! No File of ', time_array[iyears,imonths,idays,ihours]
if exist then begin
lun_rainfall = NCDF_OPEN(time_array[iyears,imonths,idays,ihours])
NCDF_VARGET, lun_rainfall, 'longitude', longitude
NCDF_VARGET, lun_rainfall, 'latitude', latitude
ncdf_varget, lun_rainfall, 'pcp', rainfall
NCDF_CLOSE, lun_rainfall
total_rainfall = total_rainfall + rainfall (this command would not work so I dont know how to separate each rainfall variable from each netcdf file)
endif
endfor
endfor
endfor
endfor
|