pro norp_rd_fits, file, mvalid, tim, fi, fv, freq $ ,rdfreq=rdfreq, timerange=timerange, dir=dir $ ,calib1g=calib1g,calib2g=calib2g,calib4g=calib4g $ ,calib9g=calib9g,calib17=calib17,calib35=calib35 $ ,firaw1g=firaw1g,fvraw1g=fvraw1g,npa1g=npa1g,stat1g=stat1g $ ,firaw2g=firaw2g,fvraw2g=fvraw2g,npa2g=npa2g,stat2g=stat2g $ ,firaw4g=firaw4g,fvraw4g=fvraw4g,npa4g=npa4g,stat4g=stat4g $ ,firaw9g=firaw9g,fvraw9g=fvraw9g,npa9g=npa9g,stat9g=stat9g $ ,firaw17=firaw17,fvraw17=fvraw17,npa17=npa17,stat17=stat17 $ ,firaw35=firaw35,fvraw35=fvraw35,npa35=npa35,stat35=stat35 $ ,npa80=npa80,stat80=stat80,sqd80=sqd80 ;+ ; NAME: ; NORP_RD_FITS ; ; PURPOSE: ; This procedure is for reading the FITS file of the NoRP data. ; ; CALLING SEQUENCE: ; norp_rd_fits,file,mvalid,time,fi,fv ; ; INPUTS: ; file: file name of NoRP data ; ; OPTIONAL INPUT KEYWORDS: ; rdfreq: 7-elements byte array indicating the data to be read. ; If rdfreq(0)=1, 1GHz data will be read. ; If rdfreq(1)=1, 2GHz data will be read. ; If rdfreq(2)=1, 4GHz data will be read. ; If rdfreq(3)=1, 9GHz data will be read. ; If rdfreq(4)=1, 17GHz data will be read. ; If rdfreq(5)=1, 35GHz data will be read. ; If rdfreq(6)=1, 80GHz data will be read. ; If NOT given, ALL data will be read. ; timerange: 2-elements string array indicating the ; time range of the data to be read ; e.g. ['1998-1-1 4:00','1998-1-1 5:00'] ; ; 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. ; time: structure array with 'time internal format'. Time is in UT. ; 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) ; ; HISTORY: ; 2021-08-04 programmed by M.Shimojo based on "norp_rd_dat.pro" ; ;- if (strpos(file,'norp') eq -1) then begin ; 'file' is date day=file ex=anytim(day,/ex) yyyy=reform(ex(6,*)) mm=reform(ex(5,*)) dd=reform(ex(4,*)) yy=yyyy-yyyy/100*100 yymmdd=$ string(transpose([[yy],[mm],[dd]]),format="(i2.2,i2.2,i2.2)") year=strtrim(string(yyyy),2) files='norp'+yymmdd+'.fits.gz' if not keyword_set(dir) then begin dir0=getenv('NORP_FITS') dir=[dir0+'/'+year+'/'+string(mm,format="(i2.2)")] endif infil=file_list(dir,files) file_copy, infil[0],'/tmp/norp_fits_tmp.fits.gz' file_gunzip, '/tmp/norp_fits_tmp.fits.gz',/delete infil='/tmp/norp_fits_tmp.fits' endif else begin infil=file endelse infil=infil(0) if (infil(0) eq '') then begin box_message,'No files found: '+infile[0] mvalid=-1 return endif fxbopen, unit, infil[0], 'NoRP_Data', bheader fxbread, unit, timo, 'Time' tim=anytim(timo,/ints) dNum = n_elements(timo) if not keyword_set(rdfreq) then rdfreq = [1, 1, 1, 1, 1, 1, 1] freqNum = total(rdfreq) if keyword_set(timerange) then begin tims = anytim(timo,/sec) stTim = anytim(timerange[0],/sec) edTim = anytim(timerange[1],/sec) tsel = where((tims ge stTim) and (tims le edTim)) if tsel[0] eq -1 then begin box_message,'There is no data of the timerange in the file' mvalid=-1 fxbclose, unit return endif st_sel = tsel[0] ed_sel = tsel[n_elements(tsel) - 1] endif else begin st_sel = 0 ed_sel = n_elements(timo) - 1 endelse if freqNum ne 0 then begin mvalid = bytarr(freqNum, dNum) fi = fltarr(freqNum, dNum) fv = fltarr(freqNum, dNum) endif else begin box_message,'Please select one frequency at least' mvalid=-1 fxbclose, unit return endelse fxbfind, bheader, 'TTYPE', columns, values, n_found colNum = 0 freq = 0 ;-1GHz if rdfreq[0] eq 1 then begin tbInc = where(values eq 'DVal_1GHz') if tbInc[0] ne -1 then begin fxbread, unit, mvd, 'DVal_1GHz' fxbread, unit, fit, 'CalI_1GHz' fxbread, unit, fvt, 'CalV_1GHz' mvalid[colNum, *] = mvd fi[colNum, *] = fit fv[colNum, *] = fvt endif else begin mvalid[colNum, *] = 0 fi[colNum, *] = 0. fv[colNum, *] = 0. endelse freq = [freq, 1.0] colNum = colNum + 1 endif ;-2GHz if rdfreq[1] eq 1 then begin tbInc = where(values eq 'DVal_2GHz') if tbInc[0] ne -1 then begin fxbread, unit, mvd, 'DVal_2GHz' fxbread, unit, fit, 'CalI_2GHz' fxbread, unit, fvt, 'CalV_2GHz' mvalid[colNum, *] = mvd fi[colNum, *] = fit fv[colNum, *] = fvt endif else begin mvalid[colNum, *] = 0 fi[colNum, *] = 0. fv[colNum, *] = 0. endelse freq = [freq, 2.0] colNum = colNum + 1 endif ;-3.75 GHz if rdfreq[2] eq 1 then begin tbInc = where(values eq 'DVal_4GHz') if tbInc[0] ne -1 then begin fxbread, unit, mvd, 'DVal_4GHz' fxbread, unit, fit, 'CalI_4GHz' fxbread, unit, fvt, 'CalV_4GHz' mvalid[colNum, *] = mvd fi[colNum, *] = fit fv[colNum, *] = fvt endif else begin mvalid[colNum, *] = 0 fi[colNum, *] = 0. fv[colNum, *] = 0. endelse freq = [freq, 3.75] colNum = colNum + 1 endif ;-9.4GHz if rdfreq[3] eq 1 then begin tbInc = where(values eq 'DVal_9GHz') if tbInc[0] ne -1 then begin fxbread, unit, mvd, 'DVal_9GHz' fxbread, unit, fit, 'CalI_9GHz' fxbread, unit, fvt, 'CalV_9GHz' mvalid[colNum, *] = mvd fi[colNum, *] = fit fv[colNum, *] = fvt endif else begin mvalid[colNum, *] = 0 fi[colNum, *] = 0. fv[colNum, *] = 0. endelse freq = [freq, 9.4] colNum = colNum + 1 endif ;-17GHz if rdfreq[4] eq 1 then begin tbInc = where(values eq 'DVal_17GHz') if tbInc[0] ne -1 then begin fxbread, unit, mvd, 'DVal_17GHz' fxbread, unit, fit, 'CalI_17GHz' fxbread, unit, fvt, 'CalV_17GHz' mvalid[colNum, *] = mvd fi[colNum, *] = fit fv[colNum, *] = fvt endif else begin mvalid[colNum, *] = 0 fi[colNum, *] = 0. fv[colNum, *] = 0. endelse freq = [freq, 17] colNum = colNum + 1 endif ;-35GHz if rdfreq[5] eq 1 then begin tbInc = where(values eq 'DVal_35GHz') if tbInc[0] ne -1 then begin fxbread, unit, mvd, 'DVal_35GHz' fxbread, unit, fit, 'CalI_35GHz' fxbread, unit, fvt, 'CalV_35GHz' mvalid[colNum, *] = mvd fi[colNum, *] = fit fv[colNum, *] = fvt endif else begin mvalid[colNum, *] = 0 fi[colNum, *] = 0. fv[colNum, *] = 0. endelse freq = [freq, 35] colNum = colNum + 1 endif ;-80GHz if rdfreq[6] eq 1 then begin tbInc = where(values eq 'DVal_80GHz') if tbInc[0] ne -1 then begin fxbread, unit, mvd, 'DVal_80GHz' fxbread, unit, fit, 'CalI_80GHz' fxbread, unit, fvt, 'CalV_80GHz' mvalid[colNum, *] = mvd fi[colNum, *] = fit fv[colNum, *] = fvt endif else begin mvalid[colNum, *] = 0 fi[colNum, *] = 0. fv[colNum, *] = 0. endelse freq = [freq, 80] colNum = colNum + 1 endif freq = freq[1:*] tim = tim[st_sel:ed_sel] mvalid = mvalid[*, st_sel:ed_sel] fi = fi[*, st_sel:ed_sel] fv = fv[*, st_sel:ed_sel] ;--------- Optinal Outputs ;---1GHz tbInc = where(values eq 'RawI_1GHz') if tbInc[0] ne -1 then begin fxbread, unit, firaw1g, 'RawI_1GHz' firaw1g = firaw1g[st_sel:ed_sel] endif else begin firaw1g ='No data' endelse tbInc = where(values eq 'RawV_1GHz') if tbInc[0] ne -1 then begin fxbread, unit, fvraw1g, 'RawV_1GHz' fvraw1g = fvraw1g[st_sel:ed_sel] endif else begin fvraw1g ='No data' endelse tbInc = where(values eq 'ATT_1GHz') if tbInc[0] ne -1 then begin fxbread, unit, npa1g,'ATT_1GHz' npa1g = npa1g[st_sel:ed_sel] endif else begin npa1g ='No data' endelse tbInc = where(values eq 'Cal_1GHz') if tbInc[0] ne -1 then begin fxbread, unit, stat1g,'Cal_1GHz' stat1g = stat1g[st_sel:ed_sel] endif else begin stat1g ='No data' endelse tbInc = where(values eq 'CalD_1GHz') if tbInc[0] ne -1 then begin fxbread, unit, cal1g,'CalD_1GHz' calib1g = {SCALE:cal1g[0],FISKY:cal1g[1],FVSKY:cal1g[2],$ FIZERO:cal1g[3],FVZERO:cal1g[4],FIAMB:cal1g[5]} endif else begin calib1g ='No data' endelse ;---2GHz tbInc = where(values eq 'RawI_2GHz') if tbInc[0] ne -1 then begin fxbread, unit, firaw2g, 'RawI_2GHz' firaw2g = firaw2g[st_sel:ed_sel] endif else begin firaw2g ='No data' endelse tbInc = where(values eq 'RawV_2GHz') if tbInc[0] ne -1 then begin fxbread, unit, fvraw2g, 'RawV_2GHz' fvraw2g = fvraw2g[st_sel:ed_sel] endif else begin fvraw2g ='No data' endelse tbInc = where(values eq 'ATT_2GHz') if tbInc[0] ne -1 then begin fxbread, unit, npa2g,'ATT_2GHz' npa2g = npa2g[st_sel:ed_sel] endif else begin npa2g ='No data' endelse tbInc = where(values eq 'Cal_2GHz') if tbInc[0] ne -1 then begin fxbread, unit, stat2g,'Cal_2GHz' stat2g = stat2g[st_sel:ed_sel] endif else begin stat2g ='No data' endelse tbInc = where(values eq 'CalD_2GHz') if tbInc[0] ne -1 then begin fxbread, unit, cal2g,'CalD_2GHz' calib2g = {SCALE:cal2g[0],FISKY:cal2g[1],FVSKY:cal2g[2],$ FIZERO:cal2g[3],FVZERO:cal2g[4],FIAMB:cal2g[5]} endif else begin calib2g ='No data' endelse ;---3.75GHz tbInc = where(values eq 'RawI_4GHz') if tbInc[0] ne -1 then begin fxbread, unit, firaw4g, 'RawI_4GHz' firaw4g = firaw4g[st_sel:ed_sel] endif else begin firaw4g ='No data' endelse tbInc = where(values eq 'RawV_4GHz') if tbInc[0] ne -1 then begin fxbread, unit, fvraw4g, 'RawV_4GHz' fvraw4g = fvraw4g[st_sel:ed_sel] endif else begin fvraw4g ='No data' endelse tbInc = where(values eq 'ATT_4GHz') if tbInc[0] ne -1 then begin fxbread, unit, npa4g,'ATT_4GHz' npa4g = npa4g[st_sel:ed_sel] endif else begin npa4g ='No data' endelse tbInc = where(values eq 'Cal_4GHz') if tbInc[0] ne -1 then begin fxbread, unit, stat4g,'Cal_4GHz' stat4g = stat4g[st_sel:ed_sel] endif else begin stat4g ='No data' endelse tbInc = where(values eq 'CalD_4GHz') if tbInc[0] ne -1 then begin fxbread, unit, cal4g,'CalD_4GHz' calib4g = {SCALE:cal4g[0],FISKY:cal4g[1],FVSKY:cal4g[2],$ FIZERO:cal4g[3],FVZERO:cal4g[4],FIAMB:cal4g[5]} endif else begin calib4g ='No data' endelse ;---9.4GHz tbInc = where(values eq 'RawI_9GHz') if tbInc[0] ne -1 then begin fxbread, unit, firaw9g, 'RawI_9GHz' firaw9g = firaw9g[st_sel:ed_sel] endif else begin firaw9g ='No data' endelse tbInc = where(values eq 'RawV_9GHz') if tbInc[0] ne -1 then begin fxbread, unit, fvraw9g, 'RawV_9GHz' fvraw9g = fvraw9g[st_sel:ed_sel] endif else begin fvraw9g ='No data' endelse tbInc = where(values eq 'ATT_9GHz') if tbInc[0] ne -1 then begin fxbread, unit, npa9g,'ATT_9GHz' npa9g = npa9g[st_sel:ed_sel] endif else begin npa9g ='No data' endelse tbInc = where(values eq 'Cal_9GHz') if tbInc[0] ne -1 then begin fxbread, unit, stat9g,'Cal_9GHz' stat9g = stat9g[st_sel:ed_sel] endif else begin stat9g ='No data' endelse tbInc = where(values eq 'CalD_9GHz') if tbInc[0] ne -1 then begin fxbread, unit, cal9g,'CalD_9GHz' calib9g = {SCALE:cal9g[0],FISKY:cal9g[1],FVSKY:cal9g[2],$ FIZERO:cal9g[3],FVZERO:cal9g[4],FIAMB:cal9g[5]} endif else begin calib9g ='No data' endelse ;---17GHz tbInc = where(values eq 'RawI_17GHz') if tbInc[0] ne -1 then begin fxbread, unit, firaw17, 'RawI_17GHz' firaw17 = firaw17[st_sel:ed_sel] endif else begin firaw17 ='No data' endelse tbInc = where(values eq 'RawV_17GHz') if tbInc[0] ne -1 then begin fxbread, unit, fvraw17, 'RawV_17GHz' fvraw17 = fvraw17[st_sel:ed_sel] endif else begin fvraw17 ='No data' endelse tbInc = where(values eq 'ATT_17GHz') if tbInc[0] ne -1 then begin fxbread, unit, npa17,'ATT_17GHz' npa17 = npa17[st_sel:ed_sel] endif else begin npa17 ='No data' endelse tbInc = where(values eq 'Cal_17GHz') if tbInc[0] ne -1 then begin fxbread, unit, stat17,'Cal_17GHz' stat17 = stat17[st_sel:ed_sel] endif else begin stat17 ='No data' endelse tbInc = where(values eq 'CalD_17GHz') if tbInc[0] ne -1 then begin fxbread, unit, cal17,'CalD_17GHz' calib17 = {SCALE:cal17[0],FISKY:cal17[1],FVSKY:cal17[2],$ FIZERO:cal17[3],FVZERO:cal17[4],FIAMB:cal17[5]} endif else begin calib17 ='No data' endelse ;---35GHz tbInc = where(values eq 'RawI_35GHz') if tbInc[0] ne -1 then begin fxbread, unit, firaw35, 'RawI_35GHz' firaw35 = firaw35[st_sel:ed_sel] endif else begin firaw35 ='No data' endelse tbInc = where(values eq 'RawV_35GHz') if tbInc[0] ne -1 then begin fxbread, unit, fvraw35, 'RawV_35GHz' fvraw35 = fvraw35[st_sel:ed_sel] endif else begin fvraw35 ='No data' endelse tbInc = where(values eq 'ATT_35GHz') if tbInc[0] ne -1 then begin fxbread, unit, npa35,'ATT_35GHz' npa35 = npa35[st_sel:ed_sel] endif else begin npa35 ='No data' endelse tbInc = where(values eq 'Cal_35GHz') if tbInc[0] ne -1 then begin fxbread, unit, stat35,'Cal_35GHz' stat35 = stat35[st_sel:ed_sel] endif else begin stat35 ='No data' endelse tbInc = where(values eq 'CalD_35GHz') if tbInc[0] ne -1 then begin fxbread, unit, cal35,'CalD_35GHz' calib35 = {SCALE:cal35[0],FISKY:cal35[1],FVSKY:cal35[2]} endif else begin calib35 ='No data' endelse ;---80GHz tbInc = where(values eq 'ATT_80GHz') if tbInc[0] ne -1 then begin fxbread, unit, npa80,'ATT_80GHz' npa80 = npa80[st_sel:ed_sel] endif else begin npa80 ='No data' endelse tbInc = where(values eq 'Cal_80GHz') if tbInc[0] ne -1 then begin fxbread, unit, stat80,'Cal_80GHz' stat80 = stat80[st_sel:ed_sel] endif else begin stat80 ='No data' endelse tbInc = where(values eq 'SQLD_80GHz') if tbInc[0] ne -1 then begin fxbread, unit, sqd80,'SQLD_80GHz' sqd80 = sqd80[st_sel:ed_sel] endif else begin sqd80 ='No data' endelse fxbclose, unit if (strpos(file,'norp') eq -1) then file_delete,infil end