My code following my message here is messing up on creating a time series for my 3hr daily rainfall trmm net-cdf data that i am reading into IDL. It is only looping the years from 1998-2013 and the first 6 months 1-6. Basically I am trying to create my time array during each loop so it corresponds to the net-cdf file time. For an example a file name is: 3B42.19980101.00.7 this represents January 1, 1998 00Z time for the file. I know its my time array and how its taking in each variable, but I am completely stuck on what the problem is. Please help me figure this out!! Thank you for your time
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]
days_month = []
num_hours = 8
num_days = 31
num_months = 12
data_years= [1998,2013]
num_years = data_years[1] - data_years[0] + 1
hours = 03
days = 1
month = 1
map_limits = [LonMin, LonMax, LatMin, LatMax]
time_array = STRARR(num_years, num_months, num_days, num_hours)
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[iyears,imonths,idays, ihours] = '/media/TOSHIBA EXT/1998_files/3B42.' + $
STRING(year, FORMAT ='(i04)') + STRING(imonths+1, FORMAT ='(i02)') + $
STRING(idays+1, FORMAT = '(i02)') + '.' + STRING(hours, FORMAT = '(i02)') + '.7.nc'
exist = FILE_TEST(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
indices_lon = WHERE(longitude GE LonMin AND longitude LE LonMax)
use_lon = longitude[indices_lon]
num_lon = N_ELEMENTS(use_lon)
indices_lat = WHERE(latitude GE LatMin AND latitude LE LatMax)
use_lat = latitude[indices_lat]
num_lat = N_ELEMENTS(use_lat)
dimen_count = [num_lon, num_lat, 1]
dimen_offset = [MIN(indices_lon), MIN(indices_lat), 0]
ncdf_varget, lun_rainfall, 'pcp', rainfall, count = dimen_count, offset = dimen_offset
NCDF_CLOSE, lun_rainfall
endif
hours = hours + 03
if hours eq 24 then hours = 00 & days = days + 1
if days gt num_days then days = 1
endfor
endfor
endfor
endfor
print, rainfall
WINDOW, 3, XSIZE=900, YSIZE=900
DEVICE, DECOMPOSED=0
LOADCT, 39
!P.COLOR=2
!P.BACKGROUND=255
ERASE, 255
MAP_SET ,0,0,0, /CYLINDRICAL, LIMIT=[LatMin, LonMin, LatMax, LonMax], $
/ISOTROPIC, /NOBORDER, NOERASE
CONTOUR, rainfall, LONGITUDE, LATITUDE, /OVERPLOT
XCHAR=1
YCHAR=1
MAP_CONTINENTS, /COASTS, /COUNTRIES, COLOR=0, THICK=1, /HIRES
AXIS, XAXIS=0, XRANGE=[LonMin, LonMax], XSTYLE=1, COLOR=0, CHARSIZE=XCHAR, XTHICK=3, CHARTHICK=4, $
XTICKINTERVAL=1, XMINOR=4
AXIS, YAXIS=0, YRANGE=[LonMin, LonMax], YSTYLE=1, COLOR=0, CHARSIZE=YCHAR, YTHICK=3, CHARTHICK=4, $
YTICKINTERVAL=1, YMINOR=4
AXIS, XAXIS=1, XRANGE=[LonMin, LonMax], XSTYLE=1, COLOR=0, CHARSIZE=0.01, XTHICK=3, CHARTHICK=2, $
XTICKINTERVAL=1, XMINOR=4
AXIS, YAXIS=1, YRANGE=[LonMin, LonMax], YSTYLE=1, COLOR=0, CHARSIZE=0.01, YTHICK=3, CHARTHICK=2, $
YTICKINTERVAL=1, YMINOR=4
STOP
END
|