FUNCTION FI_HFR_FREQ,FI
nfi = n_elements(fi)
if nfi eq 1 then ffi = [fi] else ffi = fi
fi_b = ffi/10000000l
fi_ccc = (ffi mod 10000000l) / 10000l
fi_ff = (ffi mod 10000l) / 100l
fi_nn = (ffi mod 100l)
wabc = where(fi_b le 2, count_abc)
wh12 = where(fi_b ge 3, count_h12)
ff = fltarr(nfi)
if count_abc ne 0 then begin
fabc = [freq_abc(8),freq_abc(16),freq_abc(32)]
ff(wabc) = fabc(fi_ff(wabc)*fi_b(wabc)+(fi_ff(wabc)-8l)*3l+fi_nn(wabc))
endif
if count_h12 ne 0 then begin
ff(wh12) = (float(fi_ccc(wh12))+float(2l*fi_nn(wh12)-fi_ff(wh12)+1l)/float(2l*fi_ff(wh12)))*25.
endif
return,ff
END
PRO UPDATE_N2_HFR_FREQ,ajd,hd,ajf,hf,output_path=output_path
ptrDataFileList = make_file_list(ajd, hd, ajf, hf, level='n1')
if (ptr_valid(ptrDataFileList) eq 0) then begin
nFileList=0
if keyword_set(verbose) then print,"# Warning ! No N1 data file selected..."
endif else begin
n1_fileList=*ptrDataFileList
nFileList = n_elements(n1_fileList)
ptr_free, ptrDataFileList
endelse
print,string(nFileList)+' N1 files detected'
ptrDataFileList = make_file_list(ajd, hd, ajf, hf, level='n2')
if (ptr_valid(ptrDataFileList) eq 0) then begin
nFileList2=0
if keyword_set(verbose) then print,"# Warning ! No N1 data file selected..."
endif else begin
n2_fileList=*ptrDataFileList
nFileList2 = n_elements(n2_fileList)
ptr_free, ptrDataFileList
endelse
print,string(nFileList2)+' N2 files detected'
if nFileList ne nFileList2 then stop,'Warning, Files missing, please check N1 and N2 files.'
for i=0,nFileList-1l do begin
print,'Updating HFR Freqs in '+n2_fileList(i)
read_data_binary,n1_fileList(i),n1,level='n1'
read_data_binary,n2_fileList(i),n2,level='n2'
n2.f = fi_hfr_freq(n1.fi)
if keyword_set(output_path) then n2FileOut = output_path+strmid(n2_fileList(i),10,/rev) $
else n2FileOut = n2_fileList(i)
write_data_binary,n2FileOut,n2
endfor
END