;---------------------------------------------- ; ; written by Gary M. Burgess, Code 587 ; ; update : Jan. 19,2001 ; ;---------------------------------------------- FUNCTION marray,xx ON_ERROR,1 n = n_elements(xx) aa = long(xx(0)) for i = 1,n-1 do aa = aa*xx(i) return,aa end ; The following program will load all of the data for a specific CDF file and ; variable into IDL or Part of the file by using REC_COUNT & REC_START ; If REC_COUNT IS too large the file will be loaded to the end of file ; ; Modified 10/06/1995 to fix single record access ; pro loadcdf,CDF_file,CDF_var,x,REC_COUNT=rcnt,REC_START=rstr ON_IOERROR,BAD ; Open CDF file id = -1 id = cdf_open(CDF_file) ; Get file CDF structure information inq = cdf_inquire(id) ; Get variable structure information vinq = cdf_varinq(id,CDF_var) ; Check to see if REC_START keyword is used IF KEYWORD_SET(rstr) EQ 0 THEN rstr = 0 ; Check to see if variable requested is a Z variable case 1 of (vinq.is_zvar eq 0): begin ; NOT Z var dims = total(vinq.dimvar) dimc = vinq.dimvar * inq.dim dimw = where(dimc eq 0) if (dimw(0) ne -1) then dimc(dimw) = 1 IF KEYWORD_SET(rcnt) EQ 0 THEN rcnt = inq.maxrec+1 if (vinq.recvar eq 'NOVARY') then rcnt = 1 if ((rstr+rcnt) gt inq.maxrec+1) then rcnt = inq.maxrec+1 - rstr CDF_varget,id,CDF_var,x,COUNT=dimc,REC_COUNT=rcnt,REC_START=rstr end else: begin ; IS Z var dims = total(vinq.dimvar) dimc = vinq.dimvar * vinq.dim dimw = where(dimc eq 0) if (dimw(0) ne -1) then dimc(dimw) = 1 CDF_control,id,variable=CDF_var,/zvariable,get_var_info=vinfo $ ,set_padvalue=0.0 ; Removed 06/01/1996 JBB ; Caused read-only files to fail ;CDF_control,id,variable=CDF_var,/zvariable,set_padvalue=0.0 IF KEYWORD_SET(rcnt) EQ 0 THEN rcnt = vinfo.maxrec+1 if (vinq.recvar eq 'NOVARY') then rcnt = 1 if ((rstr+rcnt) gt vinfo.maxrec+1) then rcnt = vinfo.maxrec+1 - rstr CDF_varget,id,CDF_var,x,COUNT=dimc,REC_COUNT=rcnt,REC_START=rstr $ ,/zvariable end endcase sa = size(x) if sa(0) gt 0 then sa = sa(1:sa(0)) else sa(0) = 0 if (vinq.recvar eq 'VARY' and dims ne 0 and rcnt gt 1) then begin x = reform(x,[marray(sa(0:(n_elements(sa)-2))),sa(n_elements(sa)-1)]) x = transpose(x) sa = shift(sa,1) x = reform(x,sa) endif saw = where(sa ne 1) if sa(0) gt 0 then x = reform(x,sa(saw)) goto, DONE BAD: x = -1 DONE: if (id ne -1) then CDF_close,id return end pro read_cdf,infile_cdf,state ; prompt user for the name of a ISIS ionogram CDF file and open the file ; infile_cdf = '' ; print, 'Enter name of ISIS full or average ionogram CDF file' ; read, infile_cdf ; print,infile_cdf cdf_var = 'satellite' loadcdf,infile_cdf,cdf_var,sat cdf_var = 'station_id' loadcdf,infile_cdf,cdf_var,station cdf_var = 'fix_freq' loadcdf,infile_cdf,cdf_var,fixfreq ;print,cdf_var,fixfreq cdf_var = 'swept_start' loadcdf,infile_cdf,cdf_var,numss ;print,cdf_var,numss cdf_var = 'Time_mark' loadcdf,infile_cdf,cdf_var,timemark ;print,cdf_var,timemark cdf_var = 'freq_mark' loadcdf,infile_cdf,cdf_var,freqmark ;print,cdf_var,freqmark cdf_var = 'vh_num' loadcdf,infile_cdf,cdf_var,numsl ;print,cdf_var,numsl cdf_var = 'f_num' loadcdf,infile_cdf,cdf_var,maxlen ;print,cdf_var,maxlen cdf_var = 'delay_time' loadcdf,infile_cdf,cdf_var,time_range_cdf time_range_cdf=time_range_cdf(0:maxlen-1) cdf_var = 'v_height' loadcdf,infile_cdf,cdf_var,appar_range_cdf appar_range_cdf=appar_range_cdf(0:maxlen-1) cdf_var = 'Epoch' ;stop loadcdf,infile_cdf,cdf_var,epoch if n_elements(epoch) gt 1 then begin epoch=epoch(0:numsl-1) endif else begin epoch = dblarr(numsl) endelse time_iono_cdf = dblarr(numsl) freq_iono_cdf = dblarr(numsl) sec = 0.d for k=0,numsl-1 do begin cdf_epoch,epoch(k), ye,mone,daye,hre,mne,sce,mille, /break ;print,format='(8i7)',k,ye,mone,daye,hre,mne,sce,mille if k eq 0 then begin yr = ye mon = mone day = daye hr = hre min = mne sec = sce + mille/1000.d sec0 = sce mille0 = mille endif time_iono_cdf(k) = sce*1000.d + mille if k gt 0 then begin if time_iono_cdf(k) lt time_iono_cdf(0) then begin time_iono_cdf(k)=time_iono_cdf(k) + 60000.d endif time_iono_cdf(k)=time_iono_cdf(k) - time_iono_cdf(0) endif endfor time_iono_cdf(0)=0.d cdf_var = 'freq' loadcdf,infile_cdf,cdf_var,freq_iono_cdf ;freq_iono_cdf=freq_iono_cdf(0:numsl-1) if n_elements(freq_iono_cdf) gt 1 then begin freq_iono_cdf=freq_iono_cdf(0:numsl-1) endif else begin freq_iono_cdf = dblarr(numsl) endelse print,'numsl=',numsl,' maxlen=',maxlen cdf_var = 'ampl' loadcdf,infile_cdf,cdf_var,iono_cdf iono_cdf = iono_cdf(0:numsl-1,0:maxlen-1) iono_cdf = rotate(iono_cdf,2) iono_cdf = reverse(iono_cdf) iono_cdf_org = iono_cdf time_iono_cdf=time_iono_cdf/1000.d time_range_cdf=reverse(time_range_cdf) appar_range_cdf=reverse(appar_range_cdf) freq_iono_cdf_org = freq_iono_cdf time_iono_cdf_org = time_iono_cdf date_cdf=lonarr(7) date_cdf(0) = yr date_cdf(1) = mon date_cdf(2) = day date_cdf(3) = hr date_cdf(4) = min date_cdf(5) = sec0 date_cdf(6) = mille0 xnum = numsl ynum = maxlen sat=strtrim(sat,2) if sat eq '1' then sat = 'A1' if sat eq '2' then sat = 'A2' if sat eq '3' then sat = 'I1' if sat eq '4' then sat = 'I2' state.iono.satellite = sat state.iono.stationid = station state.iono.fixfreq = fixfreq state.iono.nmark = numss state.iono.freq_mark = freqmark state.iono.time_mark = timemark state.iono.file_cdf = infile_cdf state.iono.iono_cdf[0:xnum-1,0:ynum-1] = iono_cdf[0:xnum-1,0:ynum-1] state.iono.time_iono_cdf = time_iono_cdf state.iono.freq_iono_cdf = freq_iono_cdf state.iono.time_range_cdf = time_range_cdf state.iono.appar_range_cdf = appar_range_cdf state.iono.xnum = xnum state.iono.ynum = ynum state.iono.date_cdf = date_cdf state.tfmark.time_mark = timemark state.tfmark.freq_mark = freqmark state.tfmark.xniono = xnum state.tfmark.time_iono = time_iono_cdf state.tfmark.freq_iono = freq_iono_cdf fmark = ['0.1 : ','0.25: ','0.5 : ','0.75: ','1.0 : ','1.25: ', $ '1.5 : ','1.75: ','2.0 : ','3.0 : ','4.0 : ','5.0 : ', $ '6.0 : ','7.0 : ','8.0 : ','9.0 : ','10.0: ','12.0: ', $ '14.0: ','16.0: ','18.0: ','20.0: ' ] for i=0,21 do begin a = fmark(i) + string(format='(f9.3)',timemark(i)) widget_control,state.tfmark.mfreq(i),set_value=a endfor outunit = 1 openw, outunit,'scanline.out' ;,/get_lun ;print,'scan lines= ',xnum printf,outunit,xnum,' scan lines' for i=1,xnum do begin ;print,format='(i6,1x,f10.6,1x,f16.6)',i,time_iono_cdf[i-1],freq_iono_cdf[i-1] printf,outunit,format='(i6,1x,f10.6,1x,f16.6,1x,f26.8)', $ i,time_iono_cdf[i-1],freq_iono_cdf[i-1],epoch[i-1] endfor close,outunit ;stop return end