;+ ; Contains the read_data_opmode procedure ; ; :Author: ; Baptiste Cecconi ; ; :History: ; ; 28/02/2006: Created ; ; 21/02/2007: time_list keyword enabled ; ; 23/07/2007: keep_valid_only keyword enabled ; ; 30/05/2009: lis_file keyword added ; ; 2013/03/01: Last Edit ;- ; ;+ ; reads .lis files for the period aaaajjjd, hd -> aaaajjjf, hf ; and builds a data_opmode structure with that ; ; :Params: ; aaaajjjd: in, required, type=sometype ; A parameter named aaaajjjd ; hd: in, required, type=sometype ; A parameter named hd ; aaaajjjf: in, required, type=sometype ; A parameter named aaaajjjf ; hf: in, required, type=sometype ; A parameter named hf ; opmode: in, required, type=sometype ; A parameter named opmode ; ; :Keywords: ; lis_file: in, optional, type=sometype ; A keyword named lis_file ; verbose: in, optional, type=sometype ; A keyword named verbose ; time_list: in, optional, type=sometype ; A keyword named time_list ; keep_valid_only: in, optional, type=sometype ; A keyword named keep_valid_only ;- PRO READ_DATA_OPMODE, aaaajjjd, hd, aaaajjjf, hf, opmode, lis_file=lis_file, $ verbose=verbose, time_list=time_list, keep_valid_only=keep_valid_only tABC=[ [[273,264,242],[364,365.5,356],[399,395,378],[896,892,864]], $ [[546,530,504],[728,733,737],[798,792,782],[1690,1680,1660]], $ [[1089,1056,1008],[1456,1464.5,1474],[1596,1580,1560],[3280,3260,3220]], $ [[2180,2110,2003],[2905,2925,2945],[3192,3160,3120],[6420,6400,6340]] ] tABC=float(tABC) tH1_1=[[21.2,24.5,25.8,27.4,56.8],[36.4,42.8,45.7,49,98], $ [66.8,80,85.9,91.8,181],[128.3,154,165.5,178,347.4]] tH1_2=[[20.1,23.1,24.6,26.2,50.4],[34.7,41.9,41.45,47.5,90.2], $ [65.5,78.2,84.1,91.2,171.7],[125.9,153.6,163.3,175.7,336.7]] tH2_1=[[12.5,14.2,14.75,15.6,34.9],[20.2,23.5,24.9,26.4,55.5], $ [35.3,42,44.9,47.6,96.1],[65.7,79,84.8,90.5,178]] tH2_2=[[12.3,13.9,14.75,15.2,29.6],[20.3,23.4,25,26.2,50.3], $ [35.2,41.4,44.3,47.3,90.4],[66,78,84.5,89.5,172]] if keyword_set(lis_file) then lis_in=1b else lis_in = 0b ; loading data file list if ~lis_in then begin ptrDataFileList = make_file_list(aaaajjjd, hd, aaaajjjf, hf, level='lis',verbose=verbose) if (ptr_valid(ptrDataFileList) eq 0) then begin nFileList=0 if keyword_set(verbose) then message,"Warning ! No .lis data file selected...",/info opmode = [{data_opmode}] return endif else begin fileList=*ptrDataFileList nFileList = n_elements(FileList) ptr_free, ptrDataFileList endelse endif else begin fileList = lis_file nFileList = 1l endelse opmode_time = [0.d0] opmode_lis = [''] opmode_lis_curr = '' opmode_lis_prev = '' ydh_curr = 0L ydh_prev = 0L opmode_time_list = [{data_opmode_time_list}] opmode_time_list_curr = opmode_time_list for ifile = 0l,nFileList-1 do begin if keyword_set(verbose) then message,fileList(ifile),/info openr,lun,fileList(ifile),/get_lun while not eof(lun) do begin data_lis_curr = '' readf,lun,data_lis_curr opmode_lis_curr = strmid(data_lis_curr,48) opmode_time_curr = aj_t97(double(strmid(data_lis_curr,1,7))+ $ double(strmid(data_lis_curr,9,2))/24.d0+ $ double(strmid(data_lis_curr,26,2))/1440.d0+ $ double(strmid(data_lis_curr,29,2))/86400.d0) ydh_curr = long(strmid(data_lis_curr,1,7))*100L+long(strmid(data_lis_curr,9,2)) ; if ydh_curr ne ydh_prev and if long(strmid(data_lis_curr,42,5)) gt 1l then begin if keyword_set(keep_valid_only) then begin ww = where(opmode_lis eq opmode_lis_curr or strpos(opmode_lis_curr,'*') ne -1,count) endif else begin ww = where(opmode_lis eq opmode_lis_curr,count) endelse if count eq 0 then begin opmode_lis = [opmode_lis, opmode_lis_curr ] opmode_time = [opmode_time, opmode_time_curr] opmode_lis_prev = opmode_lis_curr ydh_prev = ydh_curr endif endif opmode_time_list_curr.t97_in = opmode_time_curr opmode_time_list_curr.opmode_index = where(opmode_lis eq opmode_lis_curr) if opmode_time_list_curr.opmode_index ne -1 then $ opmode_time_list = [opmode_time_list,opmode_time_list_curr] endwhile close,lun free_lun,lun endfor ;stop opmode_time_list = opmode_time_list(1:*) opmode_time_list.opmode_index -= 1 opmode_time_list_uniq = opmode_time_list([0,uniq(opmode_time_list.opmode_index)+1]) opmode_time_list_uniq.t97_out = [opmode_time_list_uniq(1:*).t97_in,aj_t97(double(aaaajjjf)+double(hf)/24.d0)] time_list = opmode_time_list_uniq opmode_time = opmode_time(1:*) opmode_lis = opmode_lis(1:*) nopmode = n_elements(opmode_time) opmode = replicate({data_opmode},nopmode) opmode.t97 = opmode_time opmode.rc = fix(strmid(opmode_lis,1,3)) opmode.lis = opmode_lis opmode.abc.band = strtrim(strmid(opmode_lis,11,3),2) opmode.abc.nsteps = strlen(opmode.abc.band) opmode.abc.nant = (strmid(opmode_lis,29,1) eq 'Z') + 1b opmode.abc.nfreqs = fix(strmid(opmode_lis,15,2)) opmode.abc.auto = (strmid(opmode_lis,23,1) eq 'a') opmode.abc.cross = (strmid(opmode_lis,24,1) eq 'c') opmode.abc.df = (strmid(opmode_lis,25,2) eq 'Df') opmode.abc.integ = fix(strmid(opmode_lis,18,4)) opmode.abc.rc = fix(strmid(opmode_lis,7,3)) opmode.abc.mode = opmode.abc.band + '_' + $ strtrim(fix(opmode.abc.nant),2) + 'E' + $ (['','a'])(opmode.abc.auto) + $ (['','c'])(opmode.abc.cross) + '_' + $ strtrim(fix(opmode.abc.nfreqs),2) + $ (['','/DF'])(opmode.abc.df) + $ ' (' + string(fix(opmode.abc.integ),format='(i4)') + ') ['+ $ string(fix(opmode.ABC.rc),format='(i3)')+']' m = long(alog(opmode.abc.integ/125.)/alog(2.)+0.5) j = long(alog(opmode.abc.nfreqs/8.)/alog(2.)+0.5) k = (opmode.abc.nant eq 2)*(opmode.abc.auto + opmode.abc.cross + opmode.abc.df) opmode.abc.msec = tABC(j,k,m)*float(opmode.abc.nsteps)/3. opmode.abc.Nbytes = (opmode.abc.df+1L) * $ opmode.abc.nsteps * $ opmode.abc.nant * $ (1L+opmode.abc.nfreqs*(opmode.abc.auto+opmode.abc.cross)) + $ 2L*opmode.abc.cross * $ ceil((1.+opmode.abc.df)*opmode.abc.nsteps*opmode.abc.nfreqs/8.) opmode.hf1.band = 'H1' opmode.hf1.nsteps = fix(strmid(opmode_lis,63,3)) opmode.hf1.nant = (strmid(opmode_lis,51,1) eq 'Z') + 1b opmode.hf1.nfreqs = fix(strmid(opmode_lis,39,1)) opmode.hf1.auto = (strmid(opmode_lis,45,1) eq 'a') opmode.hf1.cross = (strmid(opmode_lis,46,1) eq 'c') opmode.hf1.df = (strmid(opmode_lis,47,2) eq 'Df') opmode.hf1.integ = fix(strmid(opmode_lis,41,3)) opmode.hf1.rc = fix(strmid(opmode_lis,32,3)) opmode.hf1.mode = 'H1_' + strtrim(fix(opmode.hf1.nant),2) + 'E' + $ (['','a'])(opmode.hf1.auto) + $ (['','c'])(opmode.hf1.cross) + '_' + $ strtrim(fix(opmode.hf1.nfreqs),2) + $ (['','/DF'])(opmode.hf1.df) + $ ' (' + string(fix(opmode.hf1.integ),format='(i3)') + ') ['+ $ string(fix(opmode.hf1.rc),format='(i3)')+']' opmode.hf1.fmin = long(strmid(opmode_lis,53,4)) opmode.hf1.fmax = long(strmid(opmode_lis,58,4)) opmode.hf1.fstep = long(strmid(opmode_lis,67,3)) m = long(alog(opmode.hf1.integ/20.)/alog(2.)+0.5) k = (opmode.hf1.nant eq 2)*(1l + opmode.hf1.auto + opmode.hf1.cross + opmode.hf1.df) opmode.hf1.msec = tH1_1(k,m)+(opmode.hf1.nsteps-1)*tH1_2(k,m) opmode.hf1.Nbytes = (opmode.hf1.df+1L) * $ opmode.hf1.nsteps * $ opmode.hf1.nant * $ (1L+opmode.hf1.nfreqs*(opmode.hf1.auto+opmode.hf1.cross)) + $ 2L*opmode.hf1.cross * $ ceil((1.+opmode.hf1.df)*opmode.hf1.nsteps*opmode.hf1.nfreqs/8.) opmode.hf2.band = 'H2' opmode.hf2.nsteps = fix(strmid(opmode_lis,104,3)) opmode.hf2.nant = (strmid(opmode_lis,90,1) eq 'Z') + 1b opmode.hf2.nfreqs = fix(strmid(opmode_lis,79,1)) opmode.hf2.auto = (strmid(opmode_lis,84,1) eq 'a') opmode.hf2.cross = (strmid(opmode_lis,85,1) eq 'c') opmode.hf2.df = (strmid(opmode_lis,86,2) eq 'Df') opmode.hf2.integ = fix(strmid(opmode_lis,81,2)) opmode.hf2.rc = fix(strmid(opmode_lis,72,3)) opmode.hf2.mode = 'H2_' + strtrim(fix(opmode.hf2.nant),2) + 'E' + $ (['','a'])(opmode.hf2.auto) + $ (['','c'])(opmode.hf2.cross) + '_' + $ strtrim(fix(opmode.hf2.nfreqs),2) + $ (['','/DF'])(opmode.hf2.df) + $ ' (' + string(fix(opmode.hf2.integ),format='(i2)') + ') ['+ $ string(fix(opmode.hf2.rc),format='(i3)')+']' opmode.hf2.fmin = long(strmid(opmode_lis,92,5)) opmode.hf2.fmax = long(strmid(opmode_lis,98,5)) opmode.hf2.fstep = long(strmid(opmode_lis,108,4)) m = long(alog(opmode.hf2.integ/10.)/alog(2.)+0.5) k = (opmode.hf2.nant eq 2)*(1l + opmode.hf2.auto + opmode.hf2.cross + opmode.hf2.df) opmode.hf2.msec = tH2_1(k,m)+(opmode.hf2.nsteps-1)*tH2_2(k,m) opmode.hf2.Nbytes = (opmode.hf2.df+1L) * $ opmode.hf2.nsteps * $ opmode.hf2.nant * $ (1L+opmode.hf2.nfreqs*(opmode.hf2.auto+opmode.hf2.cross)) + $ 2L*opmode.hf2.cross * $ ceil((1.+opmode.hf2.df)*opmode.hf2.nsteps*opmode.hf2.nfreqs/8.) end