pro norp_rdt2data_17g,rdata,timejo,mvalid,fi,fv $ ,nocalib=nocalib,ndata=ndata,npa=npa,stat=stt $ ,smax=smax,fimin=fimin,calibration=calibration $ ,firaw=amp0,fvraw=pol0 ;+ ; NAME: ; NORP_RDT2DATA_17G ; ; PURPOSE: ; This procedure is for getting 17GHz data from the raw NoRP data ; ; CALLING SEQUENCE: ; norp_rdt2data_17g,rdata,mvalid,timejo,fi,fv ; ; INPUTS: ; rdata: structure of the raw data ; timejo: structure array with 'time internal format' ; that must be given by 'norp_rdt2timej'. ; ; OPTIONAL INPUT: ; ndata: 2-elements long-integer array indicating the ; position of data corresponding to the given timerange ; ; OUTPUTS: ; mvalid: byte array indicating the data is valid or not. ; e.g. if the data(123) obtained at time(123) ; was the calibration data mvalid(123)=0. ; If the data(124) was the real Sun flux mvalid(124)=1. ; fi: I (R+L) data array (mfreq,ndata) ; data(0,*) is the time-sequencial array of the 1st ; frequency which are read (indicated by 'rdfreq'). ; fv: V (R-L) data array (mfreq,ndata) ; ; OPTIONAL OUTPUT: ; ; HISTORY: ; programmed by T. Kosugi in 1984 May as Fortran program ; for old NoRP data format ; re-programmed by H.Sekiguchi 1987 July - 1988 Dec. ; ; 1995 July,20 N,Shinox for new format NoRP data ; 95.04.19 ed. add ATT correction for pol data ,correction data type ; changed intarr() to fltarr()., ; 95.09.04 Ver.2.0 M. Nishio and K. Hori ; 95.11.10 Ver.3.0 M. Nishio refernce level at 9.4GHz= amb -> zero ; <> ; 95.12.12 Ver.3.1 M. Nishio and K. Shibasaki (1GHz ATT 7dB -> 4.3) ; 98.09.03 sekix & shinox add 80GHz ; 98.11.20 K. Hori ; 1999-1-12 TY unify program for old/new NoRP data ; 1999-3-12 TY fimin,smax ; 2000-12-12 TY include fix for instrumental AMB data error in 1996 ; ; ;- if not keyword_set(smax) then smax=50 if not keyword_set(fimin) then fimin=400 if not keyword_set(ndata) then begin ndata=lonarr(2) ndata(0)=0 & ndata(1)=n_elements(timejo)-1 endif case tag_names(rdata,/structure_name) of 'NORP0' : version =0 'NORP' : version =1 endcase date=gt_day(timejo(0),/st) ; SFU of reference device case 1 of (anytim(date) lt anytim('1994-4-01')): flxref=360.0 (anytim(date) ge anytim('1994-4-01')) and $ (anytim(date) lt anytim('1996-6-05')): flxref=338.0 (anytim(date) ge anytim('1996-6-05')) and $ (anytim(date) lt anytim('2000-3-09')): flxref=309.7 (anytim(date) ge anytim('2000-3-09')) and $ (anytim(date) lt anytim('2000-4-14')): flxref=375.0 else : flxref=347.0 endcase skymax=0. ambmax=0. case version of 0: begin ; old format vatt=[119.41,119.41,24.93,4.79,1.0] npclb=4 iatt=[-1126,-307,307,1250] timejsky=date+' '+[ $ [' 8:30:08',' 8:31:25'], ['11:30:08','11:31:25'], ['14:30:08','14:31:25']] timejamb=date+' '+[ $ [' 7:00:03',' 7:00:12'], [' 8:00:03',' 8:00:12'], [' 9:00:03',' 9:00:12'], $ ['10:00:03','10:00:12'], ['11:00:03','11:00:12'], ['12:00:03','12:00:12'], $ ['13:00:03','13:00:12'], ['14:00:03','14:00:12'], ['15:00:03','15:00:12'], $ ['16:00:03','16:00:12']] timejzero=date+' '+[ ['10:15:04','10:15:30'] ] dtsky=[6000,6000] ; msec dtamb=[2000,2000] ; msec dtzero=[2000,2000] ; msec dtatt=[1500,1500] ;msec dtmgn=[300000,300000] ;msec end 1: begin ; new format if (anytim(date) lt anytim('1997-4-24')) then begin vatt=10.^[0.,0.68,1.0,1.5,2.0] endif else begin vatt=10.^[0.,0.5,1.0,1.5,2.0] endelse iatt=0 npclb=0 dtsky=[30000,1000] ; msec dtamb=[0,1000] ; msec dtzero=[0,1000] ; msec dtatt=[0,0] ;msec dtmgn=[300000,300000] ;msec flagsky=1 flagamb=2 flagzero=4 end endcase ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; case version of 0: intego=rdata.integ 1: intego=bytarr(n_elements(rdata))+1b endcase integ=intego(ndata(0):ndata(1)) timej=timejo(ndata(0):ndata(1)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; amp=rdata.amp17 & pol=rdata.pol17 & stat=rdata.stat17 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; extract the calibration data if (version eq 0) then norp_nclb_time,timejsky,dtsky,timejo,mskyx,nsky,nskyi $ else norp_nclb_stat,stat,flagsky,dtsky,timejo,mskyx,nsky,nskyi if (version eq 0) then norp_nclb_time,timejamb,dtamb,timejo,mambx,namb,nambi $ else norp_nclb_stat,stat,flagamb,dtamb,timejo,mambx,namb,nambi if (version eq 0) then $ norp_nclb_time,timejzero,dtzero,timejo,mzerox,nzero,nzeroi $ else norp_nclb_stat,stat,flagzero,dtzero,timejo,mzerox,nzero,nzeroi if keyword_set(nocalib) then begin scale=1. fisky=0. fvsky=0. fizero=0. fvzero=0. goto,L100 endif ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; check the calibration data if ((mskyx eq 0) or (mambx eq 0) or (mzerox eq 0)) then begin print,'***************************************' print,' There is no calibration data for 17G ! ' print,' # of valid data for SKY ',mskyx print,' # of valid data for AMB ',mambx print,' # of valid data for ZERO ',mzerox print,'***************************************' ndx=ndata(1)-ndata(0)+1 fi=fltarr(ndx) fv=fltarr(ndx) mvalid=bytarr(ndx) return endif ; fix instrumental error for AMB data ; initial 10 sec data is invalid (contaminated by Sun). if ((version eq 1) and (anytim(date) lt anytim('1996-6-01'))) then $ namb(0,*)=namb(0,*)+100 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; integarage the calibration data norp_clb_integ,mskyx,nsky,npclb,stat,vatt,oksky,intego $ ,timejo,timejsky_m,amp,fisky_m,pol,fvsky_m,iatt=iatt norp_clb_integ,mambx,namb,npclb,stat,vatt,okamb,intego $ ,timejo,timejamb_m,amp,fiamb_m,iatt=iatt norp_clb_integ,mzerox,nzero,npclb,stat,vatt,okzero,intego $ ,timejo,timejzero_m,amp,fizero_m,pol,fvzero_m,iatt=iatt ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; check calibration data whr=where(fiamb_m gt ambmax,cnt) if cnt ge 1 then okamb(whr)=0 whr=where(fisky_m gt skymax,cnt) if cnt ge 1 then oksky(whr)=0 whr=where(oksky,moksky) whr=where(okamb,mokamb) whr=where(okzero,mokzero) if ((moksky eq 0) or (mokamb eq 0) or (mokzero eq 0)) then begin print,'***************************************' print,' There is no calibration data 17G ! ' print,' # of valid data for SKY ',moksky print,' # of valid data for AMB ',mokamb print,' # of valid data for ZERO ',mokzero print,'***************************************' ndx=ndata(1)-ndata(0)+1 fi=fltarr(ndx) fv=fltarr(ndx) mvalid=bytarr(ndx) return endif ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; spline fit whr=where(oksky,mok) case 1 of (mok ge 3) : begin ; fisky=spline(timejsky_m(whr).time,fisky_m(whr),timej.time) ; fvsky=spline(timejsky_m(whr).time,fvsky_m(whr),timej.time) ; res=linfit(timejsky_m(whr).time,fisky_m(whr)) ; fisky=res(0)+res(1)*timej.time ; res=linfit(timejsky_m(whr).time,fvsky_m(whr)) ; fvsky=res(0)+res(1)*timej.time fisky=total(fisky_m(whr))/n_elements(fisky_m(whr)) fvsky=total(fvsky_m(whr))/n_elements(fvsky_m(whr)) end (mok eq 2) : begin fisky=total(fisky_m(whr))*0.5 fvsky=total(fvsky_m(whr))*0.5 end (mok eq 1) : begin fisky=(fisky_m(whr))(0) fvsky=(fvsky_m(whr))(0) end endcase whr=where(okamb,mok) case 1 of (mok ge 3) : begin ; fiamb=spline(timejamb_m(whr).time,fiamb_m(whr),timej.time) ; res=linfit(timejamb_m(whr).time,fiamb_m(whr)) ; fiamb=res(0)+res(1)*timej.time fiamb=total(fiamb_m(whr))/n_elements(fiamb_m(whr)) end (mok eq 2) : begin fiamb=total(fiamb_m(whr))*0.5 end (mok eq 1) : begin fiamb=(fiamb_m(whr))(0) end endcase whr=where(okzero,mok) case 1 of (mok ge 3) : begin ; fizero=spline(timejzero_m(whr).time,fizero_m(whr),timej.time) ; fvzero=spline(timejzero_m(whr).time,fvzero_m(whr),timej.time) ; res=linfit(timejzero_m(whr).time,fizero_m(whr)) ; fizero=res(0)+res(1)*timej.time ; res=linfit(timejzero_m(whr).time,fvzero_m(whr)) ; fvzero=res(0)+res(1)*timej.time fizero=total(fizero_m(whr))/n_elements(fizero_m(whr)) fvzero=total(fvzero_m(whr))/n_elements(fvzero_m(whr)) end (mok eq 2) : begin fizero=total(fizero_m(whr))*0.5 fvzero=total(fvzero_m(whr))*0.5 end (mok eq 1) : begin fizero=(fizero_m(whr))(0) fvzero=(fvzero_m(whr))(0) end endcase scale=flxref/(fiamb-fisky) ; ??? maybe incorrect L100: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; restore the attainator, and check the valid data stt0=stat(ndata(0):ndata(1)) amp0=float(amp(ndata(0):ndata(1)))/float(integ) pol0=float(pol(ndata(0):ndata(1)))/float(integ) npa=norp_gt_npa(stt0,iatt=iatt) natti=norp_gt_natti(npa,timej,dtatt) fi=vatt(npa)*(amp0-fizero)+fizero fv=vatt(npa)*(pol0-fvzero)+fvzero fi=scale*(fi-fisky) fv=scale*(fv-fvsky) ndx=ndata(1)-ndata(0)+1 mvalid=(norp_mvalid(ndx,natti) $ and norp_mvalid(ndx,nskyi-ndata(0)) $ and norp_mvalid(ndx,nambi-ndata(0)) $ and norp_mvalid(ndx,nzeroi-ndata(0)) $ and (fi gt fimin) $ and (scale gt 0) $ and (scale lt smax)) if 0 then begin if (ndata(0) eq 0) then begin whr=min(where(mvalid,cnt)) if cnt ge 1 then begin tstt=anytim2ints(timej(whr),offset=dtmgn(0)*1.e-3) mstt=norp_t2i(timej.time,tstt.time) mvalid(0:mstt)=0b endif endif if (ndata(1) eq n_elements(timejo)-1) then begin whr=max(where(mvalid,cnt)) if cnt ge 1 then begin tend=anytim2ints(timej(whr),offset=-dtmgn(1)*1.e-3) mend=norp_t2i(timej.time,tend.time) mvalid(mend:*)=0b endif endif endif calibration={ $ scale:scale $ ,oksky:oksky,timejsky_m:timejsky_m,fisky_m:fisky_m,fvsky_m:fvsky_m $ ,fisky:fisky,fvsky:fvsky $ ,okzero:okzero,timejzero_m:timejzero_m,fizero_m:fizero_m,fvzero_m:fvzero_m $ ,fizero:fizero,fvzero:fvzero $ ,okamb:okamb,timejamb_m:timejamb_m,fiamb_m:fiamb_m,fiamb:fiamb $ } return end