X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 04 Apr 2014 02:49 PM by  anon
averaging the rainfall in netcdf files
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
04 Apr 2014 02:49 PM
    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

    Berangere Casson



    New Member


    Posts:61
    New Member


    --
    10 Apr 2014 07:54 AM
    What is the error message returned when running the command ? total_rainfall = total_rainfall + rainfall and what si the contain of the variables rainfall and total_rainfall before running the command above, i.e.e what is the output from help, total_rainfall and help, rainfall commands before running the command above. Thanks.
    You are not authorized to post a reply.