FUNCTION Extract_SPIREdry, input_file, $ data_this_profile return_code=0B ; 1 is good ; 0 is bad mission='spire' agency='SPIREdry' ;print, input_file cmd='ncfileid = NCDF_OPEN(input_file)' res=execute(cmd) if res eq 0 then begin error_string=input_file+' cannot be openned' goto, jump_end endif NCDF_attget, ncfileid, 'year',year, /global if year lt 1000 then begin ncdf_close, ncfileid error_string='Global attribute "year" is invalid in: '+input_file+'\njump to the next file' goto, jump_end endif ncdf_varget, ncfileid, 'rfict', rfict NCDF_VARGET, ncfileid, 'WLC', WLC ; Weight of the observations in statistical optimization NCDF_VARGET, ncfileid, 'Azim', Azim NCDF_VARGET, ncfileid, 'Z_oro', Z_oro ; Orography height below the perigee point NCDF_VARGET, ncfileid, 'Impact_parm',Impact_parm Impact_height = Impact_parm - rfict NCDF_VARGET, ncfileid, 'MSL_alt', MSL_alt NCDF_VARGET, ncfileid, 'lat', lat_tangent ; lower case NCDF_VARGET, ncfileid, 'lon', lon_tangent ; upper case NCDF_VARGET, ncfileid, 'Lat', lat_profile NCDF_VARGET, ncfileid, 'Lon', lon_profile NCDF_VARGET, ncfileid, 'Bend_ang', Bend_ang NCDF_VARGET, ncfileid, 'Bend_ang_stdv', Bend_ang_stdv NCDF_VARGET, ncfileid, 'Opt_bend_ang', Opt_bend_ang NCDF_VARGET, ncfileid, 'Opt_bend_ang_stdv', Opt_bend_ang_stdv NCDF_VARGET, ncfileid, 'Ref', Ref NCDF_VARGET, ncfileid, 'Temp', Temp NCDF_VARGET, ncfileid, 'Pres', Pres NCDF_VARGET, ncfileid, 'bad', is_bad ; 1 = Profile flunked quality control, 0 = Profile passed QC NCDF_VARGET, ncfileid, 'bScore', bScore ; [bScore<35 == good] ;this_id = where(floor(MSL_alt) eq 5) ;lat = lat_profile[this_id[0]] ;lon = lon_profile[this_id[0]] NCDF_attget, ncfileid, 'month',month, /global NCDF_attget, ncfileid, 'day',day, /global NCDF_attget, ncfileid, 'hour',hour, /global NCDF_attget, ncfileid, 'minute',minute, /global NCDF_attget, ncfileid, 'second',second, /global & second=floor(second) ncdf_attget, ncfileid, 'irs', irs_spire, /global ; "rising" is 1; "setting" is -1 ;ncdf_attget, ncfileid, 'occdir', irs_spire, /global if irs_spire eq -1 then irs = 1 else irs = -1 ncdf_attget, ncfileid, 'LEO', leo, /global ncdf_attget, ncfileid, 'occulting_sat_id', gps, /global ;ncdf_attget, ncfileid, 'leo_sat', leo, /global ; not work from 2021-10-07 to 2022-04-30 ;ncdf_attget, ncfileid, 'occultation_sat', gps, /global ncdf_close, ncfileid leo_full=string(leo) gps=strlowcase(string(gps)) ;print, leo_full ;print, mission ;cic085_2018-12-17T00:07:08_r21_GeoOptics_CICERO title= leo_full+'_'+$ string(year,format='(i4)') +'-'+$ string(month,format='(i2.2)') +'-'+$ string(day,format='(i2.2)') +'T'+$ string(hour,format='(i2.2)') +':'+$ string(minute,format='(i2.2)')+':'+$ string(second,format='(i2.2)')+'_'+$ gps+'_'+$ agency+'_'+mission ; print, title ; --- if !false then begin valid_id = where(ref gt -990 and $ temp gt -990 and $ bend_ang gt -990 and $ pres gt -990, valid_num) if valid_num eq 0 then begin ;cmd=string('echo -e "All data are bad in: '+input_file+'" | mail -s "Alert: something is wrong in Extract_SPIREdry.pro " xinjia.zhou@noaa.gov') ;spawn,cmd print,cmd endif endif ; --- height_ba_structure={data: Impact_height, $ name: 'Impact Height, km'} height_structure={data: MSL_alt, $ name: 'Height, km'} ; --- WLC_structure={data: float(WLC), $ name: 'Weight of the observations in statistical optimization', $ vertical: 'Height_ba'} Azim_structure={data: float(Azim), $ name: 'Azimuth angle of the occultation plane with respect to North, degree', $ vertical: 'Height_ba'} Z_oro_structure={data: float(Z_oro), $ name: 'Orography height below the perigee point, km', $ vertical: 'Height_ba'} lat_structure={data: float(lat_profile), $ name: 'Latitude, degree', $ vertical: 'Height_ba'} lon_structure={data: float(lon_profile), $ name: 'Longitude, degree', $ vertical: 'Height_ba'} bending_angle_structure={data: float(bend_ang), $ name: 'Bending Angle, rad', $ vertical: 'Height_ba'} bending_angle_stdv_structure={data: float(bend_ang_stdv), $ name: 'Bending Angle uncertainty, rad', $ vertical: 'Height_ba'} opt_bending_angle_structure={data: float(opt_bend_ang), $ name: '"Optimized Bending Angle, rad', $ vertical: 'Height_ba'} opt_bending_angle_stdv_structure={data: float(opt_bend_ang_stdv), $ name: '"Optimized Bending Angle uncertainty, rad', $ vertical: 'Height_ba'} temperature_structure={data: temp, $ name: 'Dry Temperature, K', $ vertical: 'Height'} pressure_structure={data: pres, $ name: 'Pressure, hPa', $ vertical: 'Height'} refractivity_structure={data: ref, $ name: 'Refractivity, N-units', $ vertical: 'Height'} ;if is_bad eq 1 and irs lt 1 and strpos(errstr, 'Failed: abs(rising azimuth)') eq 0 and strlen(errstr) lt 80 then begin ; is_bad = 0 ; ;endif time = julday(month, day, year, hour, minute, second) ; --- data_this_profile = {title: title, $ is_bad: is_bad, $ bScore: bScore, $ irs: irs, $ ELRC: float(rfict),$ lat: float(lat_tangent), $ lon: float(lon_tangent), $ time: time, $ leo: leo_full, $ gnss: gps, $ ; --- Height_ba: ptr_new(height_ba_structure), $ Height: ptr_new(height_structure), $ ; --- azim: ptr_new(azim_structure), $ Z_oro: ptr_new(Z_oro_structure), $ WLC: ptr_new(WLC_structure), $ lat_profile: ptr_new(lat_structure), $ lon_profile: ptr_new(lon_structure), $ Temperature: ptr_new(temperature_structure), $ Pressure: ptr_new(pressure_structure), $ Refractivity: ptr_new(refractivity_structure), $ BendingAngle: ptr_new(bending_angle_structure),$ BendingAngle_stdv: ptr_new(bending_angle_stdv_structure), $ Opt_BendingAngle: ptr_new(Opt_bending_angle_structure),$ Opt_BendingAngle_stdv: ptr_new(Opt_bending_angle_stdv_structure) $ } ;print,'read end at: ', systime() return_code = 1B ; good profile jump_end: if return_code ne 1B then begin cmd=string('echo -e "'+error_string+'" | mail -s "Alert: something is wrong in Extract_SPIREdry.pro " xinjia.zhou@noaa.gov') spawn, cmd endif RETURN, return_code END