pro norp_rdt2data_1g,rdata,timejo,mvalid,fi,fv $ ,nocalib=nocalib,ndata=ndata,npa=npa,stat=stt0 $ ,smax=smax,fimin=fimin,calibration=calibration $ ,firaw=amp0,fvraw=pol0 ;+ ; NAME: ; NORP_RDT2DATA_1G ; ; PURPOSE: ; This procedure is for getting 17GHz data from the raw NoRP data ; ; CALLING SEQUENCE: ; norp_rdt2data_1g,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 ; ; OPTIONAL INPUT KEYWORD: ; nocalib: if set no caliblation is done ; ; 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 ; ;- if not keyword_set(smax) then smax=50 if not keyword_set(fimin) then fimin=50 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) tamb=35.0 flxref=(tamb+234.3)/11.990 ; SFU of reference device case version of 0: begin ; old format print,'Warning: No data in this frequency' return end 1: begin ; new format if (anytim(date) lt anytim('1995-12-12')) then begin vatt=10.^[0.,0.7,1.4,2.1,2.8] endif else begin vatt=10.^[0.,0.7,1.4,2.1,2.8] vatt(1)=4.3 endelse iatt=0 npclb=0 dtsky=[30000,0] ; msec dtamb=[200,200] ; msec dtzero=[0,1000] ; msec dtatt=[0,0] ;msec dtmgn=[1100000,100000] ;msec flagsky=1 flagamb=2 flagzero=4 end endcase ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; intego=bytarr(n_elements(rdata))+1b integ=intego(ndata(0):ndata(1)) timej=timejo(ndata(0):ndata(1)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; amp=rdata.amp1g & pol=rdata.pol1g & stat=rdata.stat1g ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; extract the calibration data norp_nclb_stat,stat,flagsky,dtsky,timejo,mskyx,nsky,nskyi norp_nclb_stat,stat,flagamb,dtamb,timejo,mambx,namb,nambi 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 1G ! ' 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 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(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 1G ! ' 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 ; Cut the data after 15:00JST, ; that has an instrumental noise caused by the 35G/80G annthena if (version eq 1) then begin time1500=54000000L m1500=norp_t2i(timej.time,time1500) if (m1500 ne n_elements(timej)-1) then mvalid(m1500+1:*)=0b 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