;***************************************** ; This subroutine picks out the geoprof file ; we need based on a date and time ;***************************************** pro get_geoprof,date,time,path_prefix,geoprofname,cdir ; Input desired date and time ;date='20070101' ;time='035815' ; 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) ; Calculate the julian day julian_day=julday(month,day,year,hour,minute,second) ; Get the day of the year (doy) julian_date,year,month,day,doy_num doy=string(doy_num,format='(I03)') ; Calculate the day before bjulian_day=julian_day-1D caldat,bjulian_day,bmonth,bday,byear,bhour,bminute,bsecond byear=string(byear,format='(I4)') bmonth=string(bmonth,format='(I02)') julian_date,byear,bmonth,bday,doy_num bdoy=string(doy_num,format='(I03)') ; Now get a list of geoprof files ;searchdir=path_prefix+'mace-group3/cloudsat/CS_2B-GEOPROF_GRANULE_P1rc1_R05/'+year+'/'+doy+'/' searchdir=path_prefix+'mace-group6/cloudsat/2B-GEOPROF.P1_R05/'+year+'/'+doy+'/' searchname=year+doy+'*_CS_2B-GEOPROF*hdf' files=file_search(searchdir+searchname,count=num_files) ; Grab the files for the day before ;searchdir_before=path_prefix+'mace-group3/cloudsat/CS_2B-GEOPROF_GRANULE_P1rc1_R05/'+byear+'/'+bdoy+'/' searchdir_before=path_prefix+'mace-group6/cloudsat/2B-GEOPROF.P1_R05/'+byear+'/'+bdoy+'/' searchname_before=byear+bdoy+'*_CS_2B-GEOPROF*hdf' files_before=file_search(searchdir_before+searchname_before,count=num_files_before) ; Add the day before files to the files array if some exist if num_files eq 0 and num_files_before gt 0 then begin files=files_before endif else if num_files gt 0 and num_files_before eq 0 then begin files=files endif else if num_files gt 0 and 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 base_name=file_basename(files) gyear=strmid(base_name,0,4) gjday=strmid(base_name,4,3) gtimes=strmid(base_name,7,6) ghour=strmid(gtimes,0,2) gminute=strmid(gtimes,2,2) gsecond=strmid(gtimes,4,2) julian_date_to_standard_date,gyear,gmonth,gday,gjday ; Convert these times to julian day gjulday=julday(gmonth,gday,gyear,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 geoprof file' endelse endif else begin print,'no cloudsat file' endelse end