FUNCTION Extract_UCARwet, input_file, $ data_this_profile, $ version=version return_code=0B ; 1 is good ; 0 is bad if keyword_set(version) then begin mission=version endif else begin path=strsplit(file_dirname(input_file),'/',/extract) mission=path[-4] endelse agency='UCARwet' variable_list = [ $ 'MSL_alt', $ 'Lat' , $ 'Lon' , $ 'Temp' , $ 'Vp' , $ 'Pres' , $ 'Ref' , $ ; Analyzed refractivity, consistent with Temp, Vp, and Pres 'Ref_obs'] ; Observed refractivity, interpolated from the atmPrf 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 for variable_loop = 0, n_elements(variable_list)-1 do begin ; --- get variable_id --- cmd='varid=NCDF_VARID('+string(ncfileid)+', "'+variable_list[variable_loop]+'")' rt = execute(cmd) if rt eq 0 or varid eq -1 then begin cmd=string('echo -e "NCDF_VARID err: '+variable_list[variable_loop]+'" | mail -s "Alert: something is wrong in Extract_UCARwet.pro " xinjia.zhou@noaa.gov') stop endif ; --- read data --- cmd='NCDF_VARGET, '+string(ncfileid)+', '+strtrim(string(varid),2)+', '+variable_list[variable_loop] rt = execute(cmd) if rt eq 0 then begin error_string='NCDF_VARGET err: '+variable_list[variable_loop]+' in '+input_file goto,jump_end endif endfor ; variable_list NCDF_attget, ncfileid, 'lat',lat_tangent, /global NCDF_attget, ncfileid, 'lon',lon_tangent, /global NCDF_attget, ncfileid, 'year',year, /global 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, 'bad',is_bad, /global & is_bad=fix(string(is_bad)) NCDF_attget, ncfileid, 'fileStamp',fileStamp, /global ncdf_close, ncfileid fileStamp_array=strsplit(string(fileStamp),'.',/extract) leo=fileStamp_array[0] gps=strlowcase(fileStamp_array[-1]) if leo eq 'C001' then leo_full = 'COSMIC-1' $ else if leo eq 'C002' then leo_full = 'COSMIC-2' $ else if leo eq 'C003' then leo_full = 'COSMIC-3' $ else if leo eq 'C004' then leo_full = 'COSMIC-4' $ else if leo eq 'C005' then leo_full = 'COSMIC-5' $ else if leo eq 'C006' then leo_full = 'COSMIC-6' $ else if leo eq 'KOM5' then leo_full = 'KOMPSAT5' $ else if leo eq 'CHAM' then leo_full = 'CHAMP' $ else if leo eq 'MTPA' then leo_full = 'MetopA' $ else if leo eq 'MTPB' then leo_full = 'MetopB' $ else if leo eq 'MTPC' then leo_full = 'MetopC' $ else if leo eq 'TSRX' then leo_full = 'TerraSAR-X' $ else if leo eq 'TDMX' then leo_full = 'TanDem-X' $ else if leo eq 'GRC1' then leo_full = 'GRACE-A' $ else if leo eq 'GRC2' then leo_full = 'GRACE-B' $ else if leo eq 'CNFS' then leo_full = 'C-NOFS' $ else if leo eq 'GEO1' then leo_full = 'cic085' $ else if leo eq 'GEO2' then leo_full = 'cic086' $ else if leo eq 'GEO3' then leo_full = 'cic087' $ else if leo eq 'GPSM' then leo_full = 'GPSMET' $ else if leo eq 'PAZ1' then leo_full = 'PAZ' $ else leo_full = leo if mission eq 'gpsmetas' and leo_full eq 'GPSMET' then leo_full = 'GPSMETAS' ;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 is_empty_profile eq 1 then continue ; --- if !false then begin valid_id = where(ref_obs gt -990 and $ temp gt -990 and $ vp gt -990 and $ pres gt -990, valid_num) if valid_num eq 0 then begin ;cmd=string('echo -e "empty file: '+input_file+'" | mail -s "Alert: something is wrong in Extract_UCARwet.pro " xinjia.zhou@noaa.gov') ;spawn,cmd ;print,cmd ;error_string='line 106, valid_num eq 0, in :'+input_file ;goto, jump_end endif endif ; --- height_structure={data: MSL_alt, $ name: 'Height, km'} ; --- lat_structure={data: lat, $ name: 'Latitude, degree', $ vertical: 'Height'} lon_structure={data: lon, $ name: 'Longitude, degree', $ vertical: 'Height'} temperature_structure={data: temp+273.15, $ name: 'Temperature, K', $ vertical: 'Height'} pressure_structure={data: pres, $ name: 'Pressure, hPa', $ vertical: 'Height'} refractivity_ana_structure={data: ref, $ name: 'Refractivity (Analyzed), N-units', $ vertical: 'Height'} refractivity_structure={data: ref_obs, $ name: 'Refractivity (Observed), N-units', $ vertical: 'Height'} water_vapor_structure={data: vp, $ name: 'Water vapor pressure, hPa', $ vertical: 'Height'} time = julday(month, day, year, hour, minute, second) ; --- data_this_profile = {title: title, $ is_bad: is_bad, $ lat: float(lat_tangent), $ ; from global attributes lon: float(lon_tangent), $ leo: leo_full, $ gnss: gps, $ time: time, $ ; --- Height: ptr_new(height_structure), $ lat_profile: ptr_new(lat_structure), $ lon_profile: ptr_new(lon_structure), $ ; --- Temperature: ptr_new(temperature_structure), $ WaterVapor: ptr_new(water_vapor_structure), $ Pressure: ptr_new(pressure_structure), $ refractivity_ana: ptr_new(refractivity_ana_structure),$ Refractivity: ptr_new(refractivity_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_UCARwet.pro " xinjia.zhou@noaa.gov') spawn, cmd endif RETURN, return_code END