function tab,xt,yt,n,k,x ; ; this routine uses aiken's method of interpolation. ; for a given independent variable x, an interpolation ; of order k is performed. ; the calling sequence is y = tab,xt,yt,n,k,x where: ; xt = array of independent values in a monotonic sequence. ; yt = array of dependent values. ; n = number of independent values. ; k = order of interpolation (must be less than 6). ; x = independent value for which interpolation is desired. ; x1 = dblarr(6) y1 = dblarr(6) ; if k ge 6 then k = 5 ; if n ge k then k = n - 1 npts = k + 1 ; ; check for asending or descending sequence ; if (xt(0) - xt(n-1)) gt 0.0 then begin ; ; sequence is descending, check if extrapolation is needed ; if (x - xt(0)) gt 0.0 then goto,skip10 if (x - xt(n-1)) lt 0.0 then goto,skip30 for i=1,n do begin if (x - xt(i-1)) gt 0.0 then goto,skip50 endfor endif ; ; sequence is ascending, check if extrapolation is needed ; if (x - xt(0)) gt 0.0 then goto,skip20 ; skip10: for i=1,npts do begin x1(i-1) = xt(i-1) y1(i-1) = yt(i-1) endfor goto,skip100 ; skip20: if (x - xt(n-1)) lt 0.0 then goto,skip40 ; ; set up for extrapolation at end of table ; skip30: for i=1,npts do begin nn = n - npts + i x1(i-1)=xt(nn-1) y1(i-1)=yt(nn-1) endfor goto,skip100 ; ; interpolation needed, find the two table values that the ; independent variable, x, lies between ; skip40: for i=1,n do begin if(x - xt(i-1)) lt 0.0 then goto,skip50 endfor i = n ; ; choose k+1 independent table values closest to x ; skip50: if (k mod 2) gt 0 then goto,skip60 if (abs(x-xt(i-1-1))-abs(xt(i-1)-x)) ge 0.0 then goto,skip56 if (i-2-k/2) lt 0 then goto,skip10 if (i-1+k/2-n) gt 0 then goto,skip30 for j=1,npts do begin nn=i-2-k/2+j x1(j-1)=xt(nn-1) y1(j-1)=yt(nn-1) endfor goto,skip100 skip56: if (i-1-k/2) lt 0 then goto,skip10 if (i+k/2-n) gt 0 then goto,skip30 for j=1,npts do begin nn=i-k/2+j-1 x1(j-1)=xt(nn-1) y1(j-1)=yt(nn-1) endfor goto,skip100 skip60: if (i-1+(k+1)/2-n) gt 0 then goto,skip30 if (i-2-(k-1)/2) lt 0 then goto,skip10 for j=1,npts do begin nn=i-1-(k+1-2*j)/2 x1(j-1)=xt(nn-1) y1(j-1)=yt(nn-1) endfor skip100: for ii=1,k do begin savey1=y1(0) l=ii+1 for jj=l,npts do begin nn=jj-ii ll=nn+1 y1(nn-1) = (savey1*(x1(jj-1)-x)-y1(ll-1)*(x1(ii-1)-x)) / $ (x1(jj-1)-x1(ii-1)) endfor endfor result = y1(0) return, result end pro reinterp_freq,fixfreq,fmtime,fmfreq,numfm,sltime,slfreq,numsl ; ; user should supply ; frequenecy of the fixed frequency protion of ionogram (fixfreq), ; the number of freq. markers (numfm), ; the times of the freq. markers (fmtime), ; the frequencies of the freq. markers (fmfreq), ; the number of scan lines in the ionogram (numsl) ; and the times of the scan lines (sltime). ; ; INPUT - ; fixfreq: frequenecy of the fixed frequency protion of ionogram ; fmtime: times of the freq. markers ; fmfreq: frequencies of the freq. markers ; numfm: number of freq. markers ; sltime: times of the scan lines ; numsl: number of scan lines in the ionogram ; ; OUTPUT - ; slfreq: freq of scan lines ; ; delta times between frequency markers from table. (millseconds) deltatfmtime = [3309.875d,418.675,696.550,695.575,693.675, $ 695.325,693.000,691.125,689.850,965.675,963.625, $ 971.900,513.200,523.250,536.500,551.025,568.475, $ 1195.725,1295.450,1433.775,1657.475,2025.425 ] deltatfmtime = deltatfmtime * 0.001 ; (seconds) ; Frequency marker times from table fm = [0.1d,0.25,0.5,0.75,1.0,1.25,1.5,1.75,2.,3.,4.,5., $ 6.,7.,8.,9.,10.,12.,14.,16.,18.,20. ] numfm=22 maxfm=numfm stfmtime = fmtime[0] ; get a count of freq markers up to the point (if it exists) where the ; default value (-1.0e+31) is used. This signifies the end of detected ; freq. markers. for ja = 1, numfm do begin if fmtime(ja-1) lt 0 then begin numfm = ja - 1 goto, skip721 endif endfor skip721: fmerr = 0 ; Check to see that valid frequency marker times are increasing. for kv = 1, numfm-1 do begin if fmtime(kv+1-1) le fmtime(kv-1) then begin print,format='(a,i2,a,f10.3,a,i2,a,f10.3,a)', $ ' FM(',kv+1,') Time ',fmtime(kv+1-1), $ ' msec is less than FM(',kv,') Time ',fmtime(kv-1),' msec' print,' Freq Marker times not increasing. STOP RUN' stop return endif endfor ; calculate delta times between detected freq markers. deltafmtime = dblarr(numfm) deltafmtime(0) = fmtime(0) for k = 2, numfm do begin deltafmtime(k-1) = fmtime(k-1) - fmtime(k-1-1) endfor ;for now for only isis-1 if fmerr eq 0 then goto,skip81 ; compare table and detected FM deltimes and see if detected are within ; +- X % (perc) of table. Do not compare first delta time (0.1mhz). For ; 0.25mhz delta time double the % when comparing. perc = 10.0d for k = 2, numfm do begin percent = perc/100.0d if k eq 2 then percent = 2.0d * percent pmv = percent * deltatfmtime(k-1) rminfm = deltatfmtime(k-1) - pmv rmaxfm = deltatfmtime(k-1) + pmv ; if the detected FM delta time are not within +- "perc" percent of ; table delta times then set maximum freq marker limit for performing ; frequency interpolation. All beyond this point will be set to ; default. if deltafmtime(k-1) lt rminfm or $ deltafmtime(k-1) gt rmaxfm then begin fmerr=k goto,skip81 endif endfor skip81: ; FILL FREQUENCIES FOR ALL SCAN LINES WITH DEFAULT OF -1.0e+31. slfreq=dblarr(numsl) ; for jh = 1, numsl do begin ; slfreq(jh-1) = -1.0d+31 ; endfor slfreq[*] = -1.0d+31 ; do not interpolate if less than 3 good detected freq markers. if (fmerr eq 1 or fmerr eq 2) or $ (numfm eq 1 or numfm eq 2) then begin print,'Do not interpolate if less than 3 good detected freq markers.' numsl1 = 0 for m = 1,numsl do begin if sltime(m-1) lt stfmtime then begin slfreq(m-1) = fixfreq numsl1=numsl1+1 endif endfor return endif ; kk = numfm if fmerr ne 0 then begin kk=fmerr-1 endif ; ; assign first freq. marker frequency and time to variables. ; stfm = fmfreq(0) endfm = fmfreq(kk-1) stfmtime = fmtime(0) endfmtime = fmtime(kk-1) ; ; get the freq. marker frequencies and times ; within each sweep rate group (.1-2, 2-5, 5-20 MHZ). ; interpolation will be performed within each sweep rate group. ; do not want interpolation that spans more than one sweep rate group. ; i1 = 0 i2 = 0 i3 = 0 fmtm1 = dblarr(15) fmtm2 = dblarr(15) fmtm3 = dblarr(15) fmfr1 = dblarr(15) fmfr2 = dblarr(15) fmfr3 = dblarr(15) for k=1,kk do begin if fmfreq(k-1) ge 0.0 and fmfreq(k-1) le 2.0 then begin i1=i1+1 fmtm1(i1-1) = fmtime(k-1) fmfr1(i1-1) = fmfreq(k-1) endif if fmfreq(k-1) ge 2.0 and fmfreq(k-1) le 5.0 then begin i2=i2+1 fmtm2(i2-1) = fmtime(k-1) fmfr2(i2-1) = fmfreq(k-1) endif if fmfreq(k-1) ge 5.0 and fmfreq(k-1) le 20.0 then begin i3=i3+1 fmtm3(i3-1) = fmtime(k-1) fmfr3(i3-1) = fmfreq(k-1) endif endfor ; ; determine if interpolation will be 2nd or 3rd degree based on ; the number of freq. markers in that group. ; ideg1 = 3 if i1 le 2 then ideg1 = 2 ideg2 = 3 if i2 le 2 then ideg2 = 2 ideg3 = 3 if i3 le 2 then ideg3 = 2 ; ; set freq = fix freq for fixed freq portion of iono then ; determine freq of each scan line in the swept freq portion. ; interpolation or extrapolation will be used. ; numsl1=0 for k=1,numsl do begin stime=sltime(k-1) if stime lt stfmtime then begin slfreq(k-1) = fixfreq numsl1=numsl1+1 endif else if kk ne maxfm and $ sltime(k-1) gt endfmtime then begin return endif else if stime ge fmtm1(0) and stime le fmtm1(i1-1) then begin slfreq(k-1) = tab(fmtm1,fmfr1,i1,ideg1,stime) endif else if stime gt fmtm1(i1-1) and fmtm2(0) eq 0 then begin slfreq(k-1) = tab(fmtm1,fmfr1,i1,ideg1,stime) endif else if stime ge fmtm2(0) and stime le fmtm2(i2-1) then begin slfreq(k-1) = tab(fmtm2,fmfr2,i2,ideg2,stime) endif else if stime gt fmtm2(i2-1) and fmtm3(0) eq 0 then begin slfreq(k-1) = tab(fmtm2,fmfr2,i2,ideg2,stime) endif else if stime ge fmtm3(0) and stime le fmtm3(i3-1) then begin slfreq(k-1) = tab(fmtm3,fmfr3,i3,ideg3,stime) endif else if stime gt fmtm3(i3-1) then begin slfreq(k-1) = tab(fmtm3,fmfr3,i3,ideg3,stime) endif endfor return end