;+ ; Describes the mode class ; ; :Author: ; Baptiste Cecconi ; ; :History: ; 2005/11/15: Created ; ; 2005/11/15: Last Edit ;- ; ;+ ; Creates a name for the result data file ;- FUNCTION mode::get_filename_result case self.data of 1: begin filename='R_' end 2: begin filename='P_' end 3: begin filename='N3a_' end 4: begin filename='N3b_' end 5:begin filename='N3c_' end 6: begin filename='N3d_' end 7: begin filename='N3_' end endcase if (self.data gt 2) then begin filename=filename+'_' endif aj1=self.year1*1000L+self.ddday1 aj2=self.year2*1000L+self.ddday2 aj1=strtrim(string(aj1), 2) aj2=strtrim(string(aj2), 2) filename=filename+aj1+'_'+aj2 return, filename end ;+ ; Gives all selected parameters for the mode ;- FUNCTION mode::get_mode common MODE_TAB mode=strarr(60) i=0 if (self.name ne '') then begin mode[i]='Name of the mode: '+self.name i=i+1 endif if (self.month1 ne 0) then begin mode[i]='Time interval: From '+strtrim(string(self.year1), 2)+'/'+ $ strtrim(string(self.month1), 2)+'/'+strtrim(string(self.day1), 2)+' ('+ $ strtrim(string(self.hour1), 2)+':'+strtrim(string(self.minute1), 2)+':'+ $ strtrim(string(self.second1), 2)+') to '+strtrim(string(self.year2), 2)+'/'+ $ strtrim(string(self.month2), 2)+'/'+strtrim(string(self.day2), 2)+' ('+$ strtrim(string(self.hour2), 2)+':'+strtrim(string(self.minute2), 2)+':'+ $ strtrim(string(self.second2), 2)+')' i=i+1 endif else begin mode[i]='Time interval: From '+strtrim(string(self.year1), 2)+'/'+ $ strtrim(string(self.ddday1), 2)+' ('+strtrim(string(self.hour1), 2)+':' $ +strtrim(string(self.minute1), 2)+':'+strtrim(string(self.second1), 2)+') to ' $ +strtrim(string(self.year2), 2)+'/'+strtrim(string(self.ddday2), 2)+' ('+ $ strtrim(string(self.hour2), 2)+':'+strtrim(string(self.minute2), 2)+':'+ $ strtrim(string(self.second2), 2)+')' i=i+1 endelse if (ptr_valid(self.bandABC)) then begin band=ptr_new((*self.bandABC)->get_bandmode()) for j=i, i+(size(*band))[1]-1 do begin mode[j]=(*band)[j-i] endfor ptr_free, band i=j+1 endif if (ptr_valid(self.bandH1)) then begin band=ptr_new((*self.bandH1)->get_bandmode()) for j=i, (size(*band))[1]+i-1 do begin mode[j]=(*band)[j-i] endfor ptr_free, band i=j+1 endif if (ptr_valid(self.bandH2)) then begin band=ptr_new((*self.bandH2)->get_bandmode()) for j=i, (size(*band))[1]+i-1 do begin mode[j]=(*band)[j-i] endfor ptr_free, band i=j+1 endif if (self.modeind ne 0) then begin mode[i]='Mode: '+modetab[self.modeind] i=i+1 endif mode[i]='Level of data: '+datalevel[self.data] ;if (self.data gt 2) then begin ; if (self.antennaset ne '') then begin ; mode[i]='Antenna parameter set: '+self.antennaset ; i=i+1 ; endif ; if (self.radiosource ne '') then begin ; mode[i]='Radiosource: '+self.radiosource ; i=i+1 ; endif ;endif case 1 of (self.cycleind1 ne 0) and (self.cycleind2 ne 0): begin mode[i]='Cycle duration between '+strtrim(string(self.cycleind1), 2)+' s and ' $ +strtrim(string(self.cycleind2), 2)+' s' i=i+1 end (self.cycleind1 eq 0) and (self.cycleind2 ne 0): begin mode[i]='Cycle duration smaller than '+strtrim(string(self.cycleind2), 2)+' s' i=i+1 end (self.cycleind1 ne 0) and (self.cycleind2 eq 0): begin mode[i]='Cycle duration bigger than '+strtrim(string(self.cycleind1), 2)+' s' i=i+1 end else: endcase return, mode(0:i-1) end ;+ ; Compares the mode described in self with the mode described in line ; line is a line of a .lis file ; Returns 0 if they are not the same, 1 if they can be the same, 2 if ; the beginning of the time interval of the line is too early, 3 if ; the end of the time interval of the line is too late ;- FUNCTION mode::compare_mode, line common MODE_TAB ; TIME INTERVAL HOUR time1=hms_s(self.hour1, self.minute1, self.second1) time2=hms_s(self.hour2, self.minute2, self.second2) linehour1=strmid(line, 23, 1) ind=where(linehour1 eq ['0', '1', '2'], count) if (count) then begin linehour1=long(strtrim(strmid(line, 23, 2), 2)) endif else begin linehour1=long(strtrim(strmid(line, 24, 1), 2)) endelse min1=strmid(line, 26, 1) ind=where(min1 eq ['0', '1', '2', '3', '4', '5'], count) if (count) then begin min1=long(strtrim(strmid(line, 26, 2), 2)) endif else begin min1=long(strtrim(strmid(line, 27, 1), 2)) endelse sec1=strmid(line, 29, 1) ind=where(sec1 eq ['0', '1', '2', '3', '4', '5'], count) if (count) then begin sec1=long(strtrim(strmid(line, 29, 2), 2)) endif else begin sec1=long(strtrim(strmid(line, 30, 1), 2)) endelse linetime1=hms_s(linehour1, min1, sec1) linehour2=strmid(line, 32, 1) ind=where(linehour2 eq ['0', '1', '2'], count) if (count) then begin linehour2=long(strtrim(strmid(line, 32, 2), 2)) endif else begin linehour2=long(strtrim(strmid(line, 33, 1), 2)) endelse min2=strmid(line, 35, 1) ind=where(min2 eq ['0', '1', '2', '3', '4', '5'], count) if (count) then begin min2=long(strtrim(strmid(line, 35, 2), 2)) endif else begin min2=long(strtrim(strmid(line, 36, 1), 2)) endelse sec2=strmid(line, 38, 1) ind=where(sec2 eq ['0', '1', '2', '3', '4', '5'], count) if (count) then begin sec2=long(strtrim(strmid(line, 38, 2), 2)) endif else begin sec2=long(strtrim(strmid(line, 39, 1), 2)) endelse linetime2=hms_s(linehour2, min2, sec2) case 1 of ((linetime2 lt time1) or (linetime1 gt time2)): begin return, 0 end ((linetime1 lt time1) and (linetime2 gt time2)): begin res=4 end ((linetime1 lt time1) and (linetime2 gt time1) and (linetime2 le time2)): begin res=2 end ((linetime2 gt time2) and (linetime1 ge time1) and (linetime1 lt time2)): begin res=3 end else: begin res=1 end endcase ; BAND ABC tab0_9=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] if (ptr_valid(self.bandABC)) then begin ; Repeat count tmp=(*(self.bandABC))->get_repeatcount() if (tmp ne 0) then begin rc=strmid(line, 54, 2) first=strmid(rc, 0, 1) ind=where(first eq tab0_9, count) if (count eq 0) then begin rc=strmid(rc, 1, 1) endif rc1=fix(rc) if (tmp ne rc1) then begin return, 0 endif endif ; Freq/filt tmp=(*self.bandABC)->get_freqfilt() if (tmp ne 0) then begin freq=(strmid(line, 61, 1)) if ( (freq eq '1') or (freq eq '3') ) then begin freq=fix(strmid(line, 61, 2)) endif else begin freq=fix(strmid(line, 62, 2)) endelse if (freqfilt[tmp] ne freq) then begin return, 0 endif endif ; Integration time tmp=(*self.bandABC)->get_integtime() if (tmp ne 0) then begin if (strmid(line, 64, 1) eq '1') then begin it=strmid(line, 64, 4) endif else begin it=strmid(line, 65, 3) endelse it=it+' ms' if (timeinteg[tmp] ne it) then begin return, 0 endif endif ; Auto tmp=(*self.bandABC)->get_auto() if (tmp ne 0) then begin auto=strmid(line, 69, 1) if ((where(auto eq ['0', 'a', ' ']))[0] ne tmp) then begin return, 0 endif endif ; Cross tmp=(*self.bandABC)->get_cross() if (tmp ne 0) then begin cross=strmid(line, 70, 1) if ((where(cross eq ['0', 'c', ' ']))[0] ne tmp) then begin return, 0 endif endif ; Df tmp=(*self.bandABC)->get_df() if (tmp ne 0) then begin df=strmid(line,71, 2) if (((tmp eq 1) and (df ne 'Df')) or ((tmp eq 2) and (df eq 'Df'))) then begin return, 0 endif endif ; AntennaX tmp=(*self.bandABC)->get_antennaX() if (tmp ne 0) then begin antX=strmid(line, 73, 2) first=where(antX eq antenX, count) if (count ne 0) then begin if (first[0] ne tmp) then begin return, 0 endif endif endif ; AntennaZ tmp=(*self.bandABC)->get_antennaZ() if (tmp ne 0) then begin antZ=strmid(line, 75, 1) if ((where(antZ eq antenZ))[0] ne tmp) then begin return, 0 endif endif endif ; BAND H1 if (ptr_valid(self.bandH1)) then begin ; Repeat count tmp=(*(self.bandH1))->get_repeatcount() if (tmp ne 0) then begin rc=strmid(line, 78, 2) first=strmid(rc, 0, 1) ind=where(first eq tab0_9, count) if (count eq 0) then begin rc=strmid(rc, 1, 1) endif rc1=fix(rc) if (tmp ne rc1) then begin return, 0 endif endif ; Freq/filt tmp=(*self.bandH1)->get_freqfilt() if (tmp ne 0) then begin freq=fix(strmid(line, 84, 1)) if (freqfilt[tmp] ne freq) then begin return, 0 endif endif ; Integration time tmp=(*self.bandH1)->get_integtime() if (tmp ne 5) then begin it1=strmid(line, 86, 3) if (strmid(it1, 0, 1) ne '1') then begin it1=strmid(it1, 1, 2) endif it=it1+' ms' if (timeinteg[tmp] ne it) then begin return, 0 endif endif ; Auto tmp=(*self.bandH1)->get_auto() if (tmp ne 0) then begin auto=strmid(line, 90, 1) if ((where(auto eq ['0', 'a', ' ']))[0] ne tmp) then begin return, 0 endif endif ; Cross tmp=(*self.bandH1)->get_cross() if (tmp ne 0) then begin cross=strmid(line, 91, 1) if ((where(cross eq ['0', 'c', ' ']))[0] ne tmp) then begin return, 0 endif endif ; Df tmp=(*self.bandH1)->get_df() if (tmp ne 0) then begin df=strmid(line,92, 2) if (((tmp eq 1) and (df ne 'Df')) or ((tmp eq 2) and (df eq 'Df'))) then begin return, 0 endif endif ; AntennaX tmp=(*self.bandH1)->get_antennaX() if (tmp ne 0) then begin antX=strmid(line, 94, 2) first=where(antX eq antenX, count) if (count ne 0) then begin if (first[0] ne tmp) then begin return, 0 endif endif endif ; AntennaZ tmp=(*self.bandH1)->get_antennaZ() if (tmp ne 0) then begin antZ=strmid(line, 96, 1) if ((where(antZ eq antenZ))[0] ne tmp) then begin return, 0 endif endif ; Fmin tmp=(*self.bandH1)->get_fmin() if (tmp ne 0) then begin fmin=strmid(line, 98, 1) ind=where(fmin eq tab0_9(1:4), count) if ( count ne 0 ) then begin fmin=fix (strmid(line, 98, 4)) endif else begin fmin=fix(strmid(line, 99, 3)) endelse if ((*self.bandH1)->get_fminsup() eq 0) then begin if (fmin ne tmp) then begin return, 0 endif endif else begin if (fmin lt tmp) then begin return, 0 endif endelse endif ; Fmax tmp=(*self.bandH1)->get_fmax() if (tmp ne 0) then begin fmax=strmid(line, 103, 1) ind=where(fmax eq tab0_9(1:4), count) if (count ne 0 ) then begin fmax=fix (strmid(line, 103, 4)) endif else begin fmax=fix(strmid(line, 104, 3)) endelse if ((*self.bandH1)->get_fmaxinf() eq 0) then begin if (fmax ne tmp) then begin return, 0 endif endif else begin if (fmax gt tmp) then begin return, 0 endif endelse endif ; Steps tmp=(*self.bandH1)->get_step() if (tmp ne 0) then begin step=strmid(line, 112, 1) ind=where(step eq tab0_9(1:9), count) if (count ne 0) then begin step=fix(strmid(line, 112, 3))/25 endif else begin step=fix(strmid(line, 113, 2))/25 endelse if (tmp ne step) then begin return, 0 endif endif endif ; BAND H2 if (ptr_valid(self.bandH2)) then begin tmp=(*(self.bandH2))->get_repeatcount() ; Repeat count if (tmp ne 0) then begin rc=strmid(line, 117, 2) first=strmid(rc, 0, 1) ind=where(first eq tab0_9, count) if (count eq 0) then begin rc=strmid(rc, 1, 1) endif rc1=fix(rc) if (tmp ne rc1) then begin return, 0 endif endif ; Freq/filt tmp=(*self.bandH2)->get_freqfilt() if (tmp ne 0) then begin freq=fix(strmid(line, 123, 1)) if (freqfilt[tmp] ne freq) then begin return, 0 endif endif ; Integration time tmp=(*self.bandH2)->get_integtime() if (tmp gt 10) then begin it=strmid(line,125, 2)+' ms' if (timeinteg[tmp] ne it) then begin return, 0 endif endif ; Auto tmp=(*self.bandH2)->get_auto() if (tmp ne 0) then begin auto=strmid(line, 128, 1) ind=where(auto eq ['0', 'a', ' '], count) if (count ne 0) then begin if (ind[0] ne tmp) then begin return, 0 endif endif else begin return, 0 endelse endif ; Cross tmp=(*self.bandH2)->get_cross() if (tmp ne 0) then begin cross=strmid(line, 129, 1) ind=where(cross eq ['0', 'c', ' '], count) if (count ne 0) then begin if (ind[0] ne tmp) then begin return, 0 endif endif else begin return, 0 endelse endif ; Df tmp=(*self.bandH2)->get_df() if (tmp ne 0) then begin df=strmid(line,130, 2) if (((tmp eq 1) and (df ne 'Df')) or ((tmp eq 2) and (df eq 'Df'))) then begin return, 0 endif endif ; AntennaX tmp=(*self.bandH2)->get_antennaX() if (tmp ne 0) then begin antX=strmid(line, 132, 2) first=where(antX eq antenX, count) if (count ne 0) then begin if (first[0] ne tmp) then begin return, 0 endif endif endif ; AntennaZ tmp=(*self.bandH2)->get_antennaZ() if (tmp ne 0) then begin antZ=strmid(line, 96, 1) if ((where(antZ eq antenZ))[0] ne tmp) then begin return, 0 endif endif ; Fmin tmp=(*self.bandH2)->get_fmin() if (tmp ne 0) then begin if (strmid(line, 136, 1) eq '1') then begin fmin=fix (strmid(line, 136, 5)) endif else begin fmin=strmid(line, 137, 1) ind=where(fmin eq tab0_9(1:9), count) if ( count ne 0) then begin fmin=fix(strmid(line, 137, 4)) endif else begin fmin=fix(strmid(line, 138, 3)) endelse endelse if ((*self.bandH2)->get_fminsup() eq 0) then begin if (fmin ne tmp) then begin return, 0 endif endif else begin if (fmin lt tmp) then begin return, 0 endif endelse endif ; Fmax tmp=(*self.bandH2)->get_fmax() if (tmp ne 0) then begin if (strmid(line, 142, 1) eq '1') then begin fmax=fix (strmid(line, 142, 5)) endif else begin fmax=strmid(line, 143, 1) ind=where(fmax eq tab0_9(1:9), count) if (count ne 0) then begin fmax=fix(strmid(line, 143, 4)) endif else begin fmax=fix(strmid(line, 144, 3)) endelse endelse if ((*self.bandH2)->get_fmaxinf() eq 0) then begin if (fmax ne tmp) then begin return, 0 endif endif else begin if (fmax gt tmp) then begin return, 0 endif endelse endif ; Steps tmp=(*self.bandH2)->get_step() if (tmp ne 0) then begin step=strmid(line, 152, 1) ind=where(step eq tab0_9(1:9), count) if (count ne 0) then begin step=fix(strmid(line, 152, 3))/50 endif else begin step=fix(strmid(line, 153, 2))/50 endelse if (tmp ne step) then begin return, 0 endif endif endif ; MODE tmp=self.modeind if (tmp ne 0) then begin modind=where(strmid(line, 41, 1)) if (modind[0] ne strmid(modetab[tmp], 0, 1)) then begin return, 0 endif endif ; CYCLE if ((self.cycleind1 ne 0) or (self.cycleind2 ne 0)) then begin cycle=opmodes_hfr1(line) case 1 of (self.cycleind1 eq 0): begin if (cycle gt self.cycleind2) then begin return, 0 endif end (self.cycleind2 eq 0): begin if (cycle lt self.cycleind1) then begin return, 0 endif end else: begin if ((cycle lt self.cycleind1) or (cycle gt self.cycleind2)) then begin return, 0 endif end endcase endif return, res end ;------------------------------------------------- FUNCTION mode::init, bandABC, bandH1, bandH2, year1, month1, day1, ddday1, hour1, min1, sec1, $ year2, month2, day2, ddday2, hour2, min2, sec2, data, modeind, cycleind1, cycleind2, $ antset, radiosource ;------------------------------------------------- self.bandABC=bandABC self.bandH1=bandH1 self.bandH2=bandH2 self.year1=year1 self.hour1=hour1 self.minute1=min1 self.second1=sec1 self.year2=year2 self.hour2=hour2 self.minute2=min2 self.second2=sec2 self.data=data self.modeind=modeind self.cycleind1=cycleind1 self.cycleind2=cycleind2 if (month1 ne 0) then begin self.month1=month1 self.day1=day1 self.month2=month2 self.day2=day2 self.ddday1=ddmm_to_ddd(self.year1, self.month1, self.day1) self.ddday2=ddmm_to_ddd(self.year2, self.month2, self.day2) endif else begin self.ddday1=ddday1 self.ddday2=ddday2 endelse return, 1 end ;------------------------------------------------- PRO mode::cleanup ;------------------------------------------------- ptr_free, self.bandABC ptr_free, self.bandH1 ptr_free, self.bandH2 end ;+ ; Creates the list of the .lis files ;- FUNCTION mode::find_lisfilesnames, dirsnames datapath=getenv('NAS_RPWS') dirsnb=(size(dirsnames))[1] lisnames=ptrarr(dirsnb) for i=0,dirsnb-1 do begin lisfiles=findfile(datapath+dirsnames[i]+'/lis/', count=found) if (found gt 0) then begin lisnames[i]=ptr_new(lisfiles) endif else begin lisnames[i]=ptr_new() endelse endfor return, lisnames end ;+ ; Finds the datarecords in the .lis files with the parameters we want ;- FUNCTION mode::find_mode, tabfileinter datapath=getenv("NAS_RPWS") bandABC=['-', 'ABC'] tabb0_9=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] dirsnames=make_dir_tab(self.year1, self.ddday1, self.year2, self.ddday2) if (ptr_valid(dirsnames) eq 0) then begin return, 0 endif else begin dirsnames=*dirsnames endelse lisnames=self->find_lisfilesnames(dirsnames) dirsnb=(size(lisnames))[1] fileinter=strarr(100) internb=100 n=0 found=0 for i=0, dirsnb-1 do begin if (n eq internb) then begin fileinter2=strarr(internb) for m=0, internb-1 do begin fileinter2[m]=fileinter[m] endfor fileinter=strarr(internb*internb) for m=0, internb-1 do begin fileinter[m]=fileinter2[m] endfor endif fileinter[n]=dirsnames[i] n=n+1 if (ptr_valid(lisnames[i]) ) then begin lisnb=(size(*(lisnames[i])))[1] for j=0, lisnb-1 do begin ; Check if the lis-file contains some dates which are in the time interval year=long(strtrim(strmid((*(lisnames[i]))[j], 0, 4), 2)) day=long(strtrim(strmid((*(lisnames[i]))[j], 4, 3), 2)) if (not((year gt self.year2) or (year lt self.year1) or $ ( (year eq self.year2) and (day gt self.ddday2) ) or $ ( (year eq self.year1) and (day lt self.ddday1) ))) then begin openr, lisfile, datapath+dirsnames[i]+'/lis/'+(*(lisnames[i]))[j], /get_lun linesnb=file_lines(datapath+dirsnames[i]+'/lis/'+(*(lisnames[i]))[j]) filecontent=strarr(linesnb) readf, lisfile, filecontent free_lun, lisfile for k=0, linesnb-1 do begin a=self->compare_mode(filecontent[k]) if (a ne 0) then begin if (n eq internb) then begin fileinter2=strarr(internb) for m=0, internb-1 do begin fileinter2[m]=fileinter[m] endfor fileinter=strarr(internb*internb) for m=0, internb-1 do begin fileinter[m]=fileinter2[m] endfor endif case a of 1: begin fileinter[n]=' '+strmid(filecontent[k], 0, 11)+' '+$ strmid(filecontent[k], 23, 17) end 2: begin hour1=strtrim(string(self.hour1), 2) if (strlen(hour1) eq 1) then begin hour1='0'+hour1 endif min1=strtrim(string(self.minute1), 2) if (strlen(min1) eq 1) then begin min1='0'+min1 endif sec1=strtrim(string(self.second1), 2) if (strlen(sec1) eq 1) then begin sec1='0'+sec1 endif fileinter[n]=' '+strmid(filecontent[k], 0, 11)+' '+hour1+ ':'+ $ min1+':'+sec1+strmid(filecontent[k], 31, 9) end 3: begin hour2=strtrim(string(self.hour2), 2) if (strlen(hour2) eq 1) then begin hour2='0'+hour2 endif min2=strtrim(string(self.minute2), 2) if (strlen(min2) eq 1) then begin min2='0'+min2 endif sec2=strtrim(string(self.second2), 2) if (strlen(sec2) eq 1) then begin sec='0'+sec2 endif end 4: begin hour1=strtrim(string(self.hour1), 2) if (strlen(hour1) eq 1) then begin hour1='0'+hour1 endif min1=strtrim(string(self.minute1), 2) if (strlen(min1) eq 1) then begin min1='0'+min1 endif sec1=strtrim(string(self.second1), 2) if (strlen(sec1) eq 1) then begin sec1='0'+sec1 endif hour2=strtrim(string(self.hour2), 2) if (strlen(hour2) eq 1) then begin hour2='0'+hour2 endif min2=strtrim(string(self.minute2), 2) if (strlen(min2) eq 1) then begin min2='0'+min2 endif sec2=strtrim(string(self.second2), 2) if (strlen(sec2) eq 1) then begin sec='0'+sec2 endif fileinter[n]=' '+strmid(filecontent[k], 0, 11)+' '+hour1+':'+ $ min1+':'+sec1+'>'+hour2+':'+min2+':'+sec2 end endcase n=n+1 endif endfor endif endfor endif endfor ptr_free, lisnames tabfileinter=ptr_new(fileinter(0:n)) return, 1 end ;+ ; mode__define is a procedure that <behavior desc here> ; ; :Uses: ; ddmm_to_ddd, hms_s, make_dir_tab ;- PRO mode__define define={MODE, $ name:'', $ bandABC:ptr_new(), $ bandH1:ptr_new(), $ bandH2:ptr_new(), $ year1: 0, $ month1:0, $ day1:0, $ hour1:0, $ minute1:0, $ second1:0, $ year2: 0, $ month2:0, $ day2:0, $ hour2:0, $ minute2:0, $ second2:0, $ data:0, $ ddday1:0, $ ddday2:0, $ modeind:0, $ cycleind1:0, $ cycleind2:0};, $ ;antennaset:'', $ ;radiosource:''} end