; ;$Header: /cassini2/uvis_fm/daps_tools/RCS/feuv_reader.pro,v 1.3 1999/10/26 19:27:59 uvis_fm Exp $ ; FORWARD_FUNCTION ATTGET PRO cg_FEUV_READER, file, pinfo, desc, window, w1, w2, w3, w4, w5, w6, w7,$ w8, w9, w10 ; History: ; Modified from get_feuv.pro to handle multiple integrations ; get_feuv.pro by Fred Lacy. Initial get_feuv_dp.pro by Dave Judd. ; Modified get_feuv_dp.pro by Alain Jouchoux. ; User interface modifications begun April 30, 1999 - Joshua Colwell ; Name changed to FEUV_READER ; desc structure modified, calling sequence changed 6/17/99 - aj ; 6/25/99 aj small change in function winsum ; 9/22/99 aj adapted for netcdfwriter version 1.0 (version and netcdfwriter ; version available) ; 9/27/99 aj added support for wildcard ; LASP, University of Colorado. IF N_PARAMS() LE 0 THEN BEGIN PRINT, ' To read data, enter the following at the IDL prompt:' PRINT, ' feuv_reader,filename,pinfo,desc,window,w1,w2,w3,w4,w5,w6,w7,w8,w9,w10' PRINT, ' where filename is in single quotation marks, and all other parameters' PRINT, ' are optional. w1 through w10 contain the data for the 10 possible' PRINT, ' windows. If only one window defined for this data, then' PRINT, ' IDL> feuv_reader,filename,pinfo, desc, window, w1' PRINT, ' will put the data for that window in the variable named w1.' PRINT, ' pinfo is a structure containing version information' PRINT, ' desc is a structure that characterizes the data product' PRINT, ' window is a structure that describes the window parameters' PRINT, ' IDL> feuv_reader,filename' PRINT, ' will result in program execution stopping allowing interactive' PRINT, ' examination of all variables using' PRINT, ' IDL> help' RETURN ENDIF ; Verify file exists file=cg_get_filename(file) IF file eq 'NONE_FOUND' then return ; Initialize structure: cg_INIT_STRUCTURES_DP ; Open NetCDF file: fid = NCDF_OPEN(file) file_info = NCDF_INQUIRE(fid) ; Get all the global attribute names and values: attnames = STRARR(file_info.ngatts) FOR i = 0, file_info.ngatts-1 DO $ attnames(i) = NCDF_ATTNAME(fid, i, /GLOBAL) ; get the global attributes: channel = cg_ATTGET('channel', attnames, file_info.ngatts, fid) windows = cg_ATTGET('windows', attnames, file_info.ngatts, fid) compression = cg_ATTGET('compression', attnames, file_info.ngatts, fid) odc_id = cg_ATTGET('odc_id', attnames, file_info.ngatts, fid) integration = cg_ATTGET('integration', attnames, file_info.ngatts, fid) hvps_level = cg_ATTGET('hvps_level', attnames, file_info.ngatts, fid) occ_cover = cg_ATTGET('occ_cover', attnames, file_info.ngatts, fid) slit_position = cg_ATTGET('slit_position', attnames, file_info.ngatts, fid) test_pulse = cg_ATTGET('test_pulse', attnames, file_info.ngatts, fid) ;start_time = ATTGET('start_time', attnames, file_info.ngatts, fid) ;stop_time = ATTGET('stop_time', attnames, file_info.ngatts, fid) sctime_start = cg_ATTGET('SCTime', attnames, file_info.ngatts, fid) sctimefine_start = cg_ATTGET('SCTimeFine', attnames, file_info.ngatts, fid) ; need to add info such as creation date. version # Version =cg_ATTGET('Version',attnames,file_info.ngatts,fid) NCDFVersion = cg_ATTGET('NetCDFWriter Version',attnames,file_info.ngatts,fid) ; Create and fill product info NOT SUPPORTED YET pinfo = {product_info_dp} IF STRING(Version(0)) NE 'UNDEFINED' THEN pinfo.l02l1version = Version IF STRING(NCDFVersion(0)) NE 'UNDEFINED' THEN pinfo.netcdfversion = $ NCDFVersion ; Create and fill product description desc = {feuv_des_dp} IF STRING(sctime_start(0)) NE 'UNDEFINED' THEN desc.sctime_sec_start = $ sctime_start IF STRING(sctimefine_start(0)) NE 'UNDEFINED' THEN $ desc.sctime_ms_start = sctimefine_start IF desc.sctime_sec_start NE 0 THEN BEGIN cg_convert_sclk,desc.sctime_sec_start, desc.sctime_ms_start, tmp desc.year_start = tmp.year desc.doy_start = tmp.doy desc.hour_start = tmp.hour desc.min_start = tmp.min desc.sec_start = tmp.sec ENDIF IF STRING(windows(0)) NE 'UNDEFINED' THEN desc.windows = windows IF STRING(compression(0)) NE 'UNDEFINED' THEN desc.compression = compression IF STRING(odc_id(0)) NE 'UNDEFINED' THEN desc.odc_id = odc_id IF STRING(integration(0)) NE 'UNDEFINED' THEN desc.integration = integration IF pinfo.netcdfversion NE 0 THEN desc.integration = desc.integration * 0.125 IF STRING(hvps_level(0)) NE 'UNDEFINED' THEN desc.hvps_level = hvps_level IF STRING(occ_cover(0)) NE 'UNDEFINED' THEN desc.occ_cover = occ_cover IF STRING(slit_position(0)) NE 'UNDEFINED' THEN desc.slit_position = $ slit_position IF STRING(test_pulse(0)) NE 'UNDEFINED' THEN desc.test_pulse = test_pulse ;IF STRING(start_time(0)) NE 'UNDEFINED' THEN desc.start_time = start_time ;IF STRING(stop_time(0)) NE 'UNDEFINED' THEN desc.stop_time = stop_time IF STRING(channel(0)) NE 'UNDEFINED' THEN desc.channel = string(channel) window = REPLICATE({feuv_win_dp}, desc.windows) w1 = LONG(-1) w2 = LONG(-1) w3 = LONG(-1) w4 = LONG(-1) w5 = LONG(-1) w6 = LONG(-1) w7 = LONG(-1) w8 = LONG(-1) w9 = LONG(-1) w10 = LONG(-1) num_windows = desc.windows FOR i = 0, num_windows-1 DO BEGIN swin = STRCOMPRESS(i, /rem) vname = 'window_'+swin vid = NCDF_VARID(fid, vname) IF vid NE -1 THEN BEGIN NCDF_VARGET, fid, vid, tmpwin tmpwin = LONG(tmpwin) idx = WHERE(tmpwin LT 0, tally) IF tally GT 0 THEN tmpwin(idx) = tmpwin(idx)+LONG(2)^16 ENDIF ELSE tmpwin = LONARR(1,1) CASE i OF 0: w1 = tmpwin 1: w2 = tmpwin 2: w3 = tmpwin 3: w4 = tmpwin 4: w5 = tmpwin 5: w6 = tmpwin 6: w7 = tmpwin 7: w8 = tmpwin 8: w9 = tmpwin 9: w10 = tmpwin ELSE: STOP, 'ERROR: Invalid window number: ',i ENDCASE tmp = 'UNDEFINED' NCDF_ATTGET, fid, vid, 'spaul', tmp IF STRING(tmp(0)) NE 'UNDEFINED' THEN window(i).w_spaul = tmp tmp='UNDEFINED' NCDF_ATTGET, fid, vid, 'specul', tmp IF STRING(tmp(0)) NE 'UNDEFINED' THEN window(i).w_specul = tmp tmp = 'UNDEFINED' NCDF_ATTGET, fid, vid, 'spalr', tmp IF STRING(tmp(0)) NE 'UNDEFINED' THEN window(i).w_spalr = tmp tmp = 'UNDEFINED' NCDF_ATTGET, fid, vid, 'spabin', tmp IF STRING(tmp(0)) NE 'UNDEFINED' THEN window(i).w_spabin = tmp tmp = 'UNDEFINED' NCDF_ATTGET, fid, vid, 'speclr', tmp IF STRING(tmp(0)) NE 'UNDEFINED' THEN window(i).w_speclr = tmp tmp = 'UNDEFINED' NCDF_ATTGET, fid, vid, 'specbin', tmp IF STRING(tmp(0)) NE 'UNDEFINED' THEN window(i).w_specbin = tmp ENDFOR goto,jump PRINT,'Number of windows: ', desc.windows PRINT,' ' PRINT,'********* Window summary ******* ' FOR i = 1, desc.windows DO BEGIN PRINT,'Window number '+ STRCOMPRESS(i) CASE i OF 1: BEGIN PRINT,' Data stored in array "w1":' cg_WINSUM, w1 END 2: BEGIN PRINT,' Data stored in array "w2":' cg_WINSUM, w2 END 3: BEGIN PRINT,' Data stored in array "w3":' cg_WINSUM, w3 END 4: BEGIN PRINT,' Data stored in array "w4":' cg_WINSUM, w4 END 5: BEGIN PRINT,' Data stored in array "w5":' cg_WINSUM, w5 END 6: BEGIN PRINT,' Data stored in array "w6":' cg_WINSUM, w6 END 7: BEGIN PRINT,' Data stored in array "w7:"' cg_WINSUM, w7 END 8: BEGIN PRINT,' Data stored in array "w8":' cg_WINSUM, w8 END 9: BEGIN PRINT,' Data stored in array "w9":' cg_WINSUM, w9 END 10: BEGIN PRINT,' Data stored in array "w10":' cg_WINSUM, w10 END ELSE: PRINT, 'ERROR: Invalid window number.' ENDCASE PRINT,' ' ENDFOR jump:; sze=size(w1) ; if sze(0) eq 0 then print,'w1: scalar' ; if sze(0) eq 1 then print,'$(a30,i4,i8)', $ ; 'w1: # dims, elems -',sze(0:1) ; if sze(0) eq 2 then print,'$(a35,i4,i8,i4)', $ ; 'w1: # dimensions, cols, rows -',sze(0:2) ; if sze(0) eq 3 then print,'$(a40,i4,i8,i4,i8)', $ ; 'w1: # dims, cols, rows, readouts -',sze(0:3) ; if sze(0) ge 4 then print,'w1: size -',sze ; Close the file: NCDF_CLOSE, fid IF N_PARAMS() EQ 1 THEN BEGIN PRINT,'Stopping program execution. Use IDL>help to examine variables.' STOP,'Program executed normally.' ENDIF RETURN END PRO cg_WINSUM, win nspat = N_ELEMENTS(win(0,*,0)) nspec = N_ELEMENTS(win(*,0,0)) nrec = N_ELEMENTS(win(0,0,*)) PRINT,' Number of spectral elements: ' + STRCOMPRESS(nspec) PRINT,' Number of spatial elements: ' + STRCOMPRESS(nspat) PRINT,' Number of records: ' + STRCOMPRESS(nrec) RETURN END