; Directly download granules ;https://ladsweb.modaps.eosdis.nasa.gov/archive/allData/61/ ; Search for granules in a date time range ;https://search.earthdata.nasa.gov/search ; In the search box put MYD06_L2 and select the dataset. ; Enter time using calendar button. Enter box using spacial rectangle SW=-76,58 NE=-49,152 ; Click download all ; direct download ; click download data ; view/download data links ; download links file pro read_mod06_clouds_sb_test ; imac or chpc path_prefix='/uufs/chpc.utah.edu/common/home/' ;path_prefix='/Volumes/' ; Output path ;output_path='' ;output_path=path_prefix+'mace-group4/modis/hysplit/modis_histograms_v3/' output_path=path_prefix+'mace-group4/modis/hysplit/modis_histograms_sm/' ; Modis file directory fdir06=path_prefix+'mace-group4/modis/MYD06_L2/' fdir03=path_prefix+'mace-group4/modis/MYD03/' ; Loop through a range of day of the years for n=60,90 do begin ;for n=4,4 do begin print,'n',n,'*************' nstr=string(n,format='(I03)') ;mod06_files=file_search(fdir06+'MYD06_L2.A2017*hdf',count=num_mod06) ;mod06_files=file_search(fdir06+'MYD06_L2.A2017'+nstr+'*hdf',count=num_mod06) ;mod06_files=file_search(fdir06+'MYD06_L2.A2017354*hdf',count=num_mod06) ;mod06_files=file_search(fdir06+'MYD06_L2.A2017345.0545.061.2018011134700*.hdf',count=num_mod06) mod06_files=file_search(fdir06+'MYD06_L2.A2018'+nstr+'*hdf',count=num_mod06) ; Loop through the modis granules for that day of the year for f=0,num_mod06-1 do begin mod06_file=mod06_files[f] print, mod06_file ; Pulls out the string 'MYD06_L2.A2018006.0625.061.2018006194906' output_file_string=strmid(file_basename(mod06_file),0,40) ; Pick up the matching myd03 file parts=strsplit(file_basename(mod06_file),'.',/extract) syear=strmid(parts[1],1,4) sdoy=strmid(parts[1],5,3) mod03_file=file_search(fdir03+'MYD03.'+parts[1]+'.'+parts[2]+'.'+parts[3]+'*hdf',count=numfiles) mod03_file=mod03_file[0] ; If found a matching myd03 file if numfiles eq 1 then begin print,'found ',mod03_file ; Output directory out_dir=output_path+syear+'/'+sdoy+'/' file_mkdir,out_dir ; Read myd03 and myd06 hdf files file_id=hdf_sd_start(mod03_file) x_id=hdf_sd_nametoindex(file_id,'Latitude') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,lat_1km hdf_sd_endaccess,x_id2 x_id=hdf_sd_nametoindex(file_id,'Longitude') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,lon_1km hdf_sd_endaccess,x_id2 hdf_sd_end,file_id file_id=hdf_sd_start(mod06_file) x_id=hdf_sd_nametoindex(file_id,'Latitude') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,lat_5km hdf_sd_endaccess,x_id2 x_id=hdf_sd_nametoindex(file_id,'Longitude') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,lon_5km hdf_sd_endaccess,x_id2 x_id=hdf_sd_nametoindex(file_id,'Scan_Start_Time') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,scan_start_time hdf_sd_endaccess,x_id2 day=julday(1,1,1993,0,0,0) & julian_day=day+(scan_start_time/86400.d) ;caldat, julian_day[0,0], mm, dd, yy, hh, mi, ss x_id=hdf_sd_nametoindex(file_id,'Solar_Zenith') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,solar_zenith_angle hdf_sd_endaccess,x_id2 solar_zenith_angle=float(solar_zenith_angle)*0.01 x_id=hdf_sd_nametoindex(file_id,'Sensor_Zenith') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,sensor_zenith_angle hdf_sd_endaccess,x_id2 sensor_zenith_angle=float(sensor_zenith_angle)*0.01 ; scale_factor=0.01 offset=0 fillvalue=-9999 1KM x_id=hdf_sd_nametoindex(file_id,'Cloud_Effective_Radius') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,cloud_effective_radius2 hdf_sd_endaccess,x_id2 scaleid=hdf_sd_attrfind(x_id2,'scale_factor') hdf_sd_attrinfo,x_id2,scaleid,data=scale_factor ;0.01 scale_factor=scale_factor[0] cloud_effective_radius=float(cloud_effective_radius2)*scale_factor r=where(cloud_effective_radius2 eq -9999,c) if c gt 0 then cloud_effective_radius[r]=-9999 ; scale_factor=0.01 offset=-15000 fillvalue=-32768 5KM x_id=hdf_sd_nametoindex(file_id,'Cloud_Top_Temperature') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,cloud_top_temperature2 hdf_sd_endaccess,x_id2 scaleid=hdf_sd_attrfind(x_id2,'scale_factor') hdf_sd_attrinfo,x_id2,scaleid,data=scale_factor ;0.01 scale_factor=scale_factor[0] offsetid=hdf_sd_attrfind(x_id2,'add_offset') hdf_sd_attrinfo,x_id2,offsetid,data=offset ;-15000.000 offset=offset[0] cloud_top_temperature=((float(cloud_top_temperature2)-offset)*scale_factor) ;modis ;cloud_top_temperature=((float(cloud_top_temperature2))*scale_factor)+150.0 ;jay cloud_top_temperature=cloud_top_temperature-273. ;convert to celcius r=where(cloud_top_temperature2 eq -32768,c) if c gt 0 then cloud_top_temperature[r]=-9999 ; scale_factor=0.01 offset=-15000 fillvalue=-32768 x_id=hdf_sd_nametoindex(file_id,'Surface_Temperature') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,surface_temperature2 hdf_sd_endaccess,x_id2 scaleid=hdf_sd_attrfind(x_id2,'scale_factor') hdf_sd_attrinfo,x_id2,scaleid,data=scale_factor ;0.01 scale_factor=scale_factor[0] offsetid=hdf_sd_attrfind(x_id2,'add_offset') hdf_sd_attrinfo,x_id2,offsetid,data=offset ;-15000.000 offset=offset[0] surface_temperature=((float(surface_temperature2)-offset)*scale_factor) ;modis ;surface_temperature=((float(surface_temperature2))*scale_factor)+150. ;jay surface_temperature=surface_temperature-273. ;convert to celcius ; scale_factor=0.1 offset=0 fillvalue=-32768 5KM x_id=hdf_sd_nametoindex(file_id,'Cloud_Top_Pressure') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,cloud_top_pressure2 hdf_sd_endaccess,x_id2 scaleid=hdf_sd_attrfind(x_id2,'scale_factor') hdf_sd_attrinfo,x_id2,scaleid,data=scale_factor ;0.1 scale_factor=scale_factor[0] cloud_top_pressure=(float(cloud_top_pressure2)*scale_factor)*100. ; pa r=where(cloud_top_pressure2 eq -32768,c) if c gt 0 then cloud_top_pressure[r]=-9999 ; scale_factor=0.01 offset=0 fillvalue=-9999 1KM x_id=hdf_sd_nametoindex(file_id,'Cloud_Optical_Thickness') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,cloud_optical_thickness2 hdf_sd_endaccess,x_id2 scaleid=hdf_sd_attrfind(x_id2,'scale_factor') hdf_sd_attrinfo,x_id2,scaleid,data=scale_factor ;0.01 scale_factor=scale_factor[0] cloud_optical_thickness=float(cloud_optical_thickness2)*scale_factor r=where(cloud_optical_thickness2 eq -9999,c) if c gt 0 then cloud_optical_thickness[r]=-9999 ; scale_factor=1.0 offset=0 fillvalue=0 1KM x_id=hdf_sd_nametoindex(file_id,'Cloud_Phase_Optical_Properties') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2,cloud_phase hdf_sd_endaccess,x_id2 ; scale_factor=1 offset=0 fillvalue=-9999 x_id=hdf_sd_nametoindex(file_id,'Cloud_Water_Path') x_id2=hdf_sd_select(file_id,x_id) hdf_sd_getdata,x_id2, cloud_water_path hdf_sd_endaccess,x_id2 cloud_water_path=float(cloud_water_path) hdf_sd_end,file_id print,'finished reading data' ; The size of the data arrays s=size(lat_1km,/dimensions) numx_1km=s[0] ;lat_1km[*,0] numy_1km=s[1] ;lat_1km[0,*] s=size(lat_5km,/dimensions) numx_5km=s[0] ;lon_low_res[*,0] numy_5km=s[1] ;lat_low_res[0,*] ; Calculate colongitude colon_1km=lon_1km result=where(colon_1km lt 0,count) if count gt 0 then colon_1km[result]=360.0+colon_1km[result] colon_5km=lon_5km result=where(colon_5km lt 0,count) if count gt 0 then colon_5km[result]=360.0+colon_5km[result] ;**************************************************** ; Create an Nd array on the MODIS grid ;**************************************************** print,'start nd array' ; Increase resolution from 5km to 1km cloud_top_temp_1km=congrid(cloud_top_temperature,numx_1km,numy_1km) sensor_zenith_angle_1km=congrid(sensor_zenith_angle,numx_1km,numy_1km) solar_zenith_angle_1km=congrid(solar_zenith_angle,numx_1km,numy_1km) ;p0=contour(cloud_top_temp_1km,lon_1km,lat_1km,irregular=0) ;p1=contour(cloud_top_temperature,lon_5km,lat_5km,color='red',irregular=0) ; These arrrays are calculated nd_array=make_array(/float,numx_1km,numy_1km,value=-9999) cw=make_array(/float,numx_1km,numy_1km,value=-9999) r=where(cloud_effective_radius gt 0 and cloud_water_path gt 0 and cloud_phase eq 2,count) if count gt 0 then begin cw[r]=0.6+((0.9/20.)*((cloud_top_temp_1km[r])+20.)) ; parameterized fro Wood's figure 1 r2=where(cw lt 0.4 and cw ne -9999,c2) if c2 gt 0 then begin cw[r2]=0.4 endif nd_array[r]=((sqrt(5.)/(2.*!pi*0.8))*sqrt((0.8*cw[r]*(1.e-6)*$ cloud_optical_thickness[r])/(2.*1000.*(((1.e-6)*(cloud_effective_radius[r]))^5))))*1.e-6 ; Grosvenor et al 2018, eq 11 converted to 1/cm3 endif print,'end nd array' ;**************************************************************** ; Carve out the microphysics for histogram writing in lat-lon regions. ; Only liquid phase cloud data with LWP < 250 g/m2 is used. ; Require view zenith to be less than 30 and solar zenith to be less than 60 ;**************************************************************** ; Check to see if there is any data that meets our conditions ; 0