;***************************************** ; This subroutine picks out the cloudsat ecmwf filename that ; we need based on a date and time ;***************************************** pro get_cloudsat_ecmwf,date,time,geoprofname,cdir ; Input desired date and time ;date='20060716' ;time='130000' ; Split the date and time into parts year=strmid(date,0,4) month=strmid(date,4,2) day=strmid(date,6,2) hour=strmid(time,0,2) minute=strmid(time,2,2) second=strmid(time,4,2) ; Get the day of the year (doy) julian_date,year,month,day,doy_num doy=strcompress(doy_num,/remove_all) doy_before=strcompress(doy_num-1,/remove_all) ; Now get a list of ecmwf-cloudsat files searchdir='/data/mace31/cloudsat/CS_ECMWF-AUX_GRANULE_P_R04/' searchname=year+doy+'*_CS_ECMWF*hdf' files=file_search(searchdir+searchname,count=num_files) ; Grab the files for the day before searchname_before=year+doy_before+'*_CS_ECMWF*hdf' files_before=file_search(searchdir+searchname_before,count=num_files_before) ; Add the day before files to the files array if some exist if num_files_before gt 0 then begin files=[files_before,files] num_files=num_files+num_files_before endif ; If some files for this day exist then continue if num_files ge 1 then begin ; Parse the filenames to get the start times for each file parts=strsplit(files[0],year,/regex) gjday=strmid(files,parts[1],3) gtimes=strmid(files,parts[1]+3,6) ghour=strmid(gtimes,0,2) gminute=strmid(gtimes,2,2) gsecond=strmid(gtimes,4,2) julian_date_to_standard_date,year,gmonth,gday,gjday ; Convert these times to julian day gjulday=julday(gmonth,gday,year,ghour,gminute,gsecond) ojulday=julday(month,day,year,hour,minute,second) ; Now find the closest time result=where(gjulday lt ojulday,count) if count gt 0 then begin tjulday=gjulday[result[count-1]] ttime=gtimes[result[count-1]] geoprofname=files[result[count-1]] parts=strsplit(geoprofname,'/',/extract) cdir='/'+strjoin(parts[0:n_elements(parts)-2],'/')+'/' geoprofname=parts[n_elements(parts)-1] print,cdir print,geoprofname endif else begin print,'found no cloudsat file' endelse endif else begin print,'no cloudsat file' endelse end