Module of tool that can be applied to BIRRP outputs
Created on %(date)s
@author: %(Jared Peacock)s
bbcalfunc(bbfile,nfreqlst) will generate a function fitting the calibration data in bbfile to the frequencies in nfreqlst using a cubic interpolation algorithm. The output is the real and imaginary functions as a function of the nfreqlst in units of microV/nT.
bbconvz(dirpath,bbfile,dlgain)will convert the .rf output files of BIRRP into correct units using broadband calibrations given by file bbcalfile that has format log(freq),breal,bimag. dlgain is the data logger gain (verylow= 2.5,low=1,high=.1) The output is period,freq,z[[zijr,ziji,zije]]. Note that it assumes the efields are already converted.
callBIRRP(scriptfile,birrploc) will call BIRRP from a command window and run the script file provided.
scriptfile = full path script file birrploc = path to BIRRP on your computer, can be the full path to a
BIRRP executable C:BIRRPirrp5.exe
convertBIRRPoutputs(bfpath,stationinfodict) will take the outputs of BIRRP and manipulate them into .edi, .dat, .coh, .imp files as well as generate plots of apparent resistivity and phase and coherence.
bfpath = path to BIRRP output files stationinfodict = dictionary containing pertanent information with keys:
station = station to process rrstation = remote reference station name bbfile = broad band calibration file path birrpdict = dictionary of birrp parameters used ffactor = scaling factor for apparent resistivities and phase edipath = path to save edifile to
Convert the magnetic field from counts to units of microV/nT. bfield is a list of numbers. dlain is amount of gain applied by data logger(verylow=2.5,low=1, high=.1)
plotFiles(edifile,cohfile,cfilelst) will plot the apparent resisitivty and phase calculated from edifile as 2 seperate plots for the different polarizations. It will plot the coherency between components and if input will plot the time series.
Outputs:
read2c2(filename) will read in a .2c2 file output from BIRRP and return a list containing [period],[freq],[coh],[zcoh]. Note if any of the coherences are negative a value of 0 will be given to them.
readProDict will read in the information from processing infofile and output as a list of dictionaries. Inputs:
processinginfofile=tab delimited text file with appropriate information. dirpath = directory path to where station folders are
readcoh(filename) will read a coherence file writen by writecoh. The output is period,frequency,coh1,zcoh1,coh2,zcoh2,coh3,zcoh3
readdat(filename) will read in a .dat file written by writedat and output ofil, period,[resistivity,resistivityerr],[phase,phaseerr]
readimp(filename) will read in the impedances from a .imp file written by writeimp. the output is ofil,period,z[zr,zi]
readini(inifilename) will read in an inifile and return a dictionary of initial parameters for the burpinterface program.
readj will read in the .j file output by BIRRP, which is better than reading in the .irj.rf files.
readrf(dirpath) will read in .irj.rf file output by BIRRP that reside in the folder nominated by dirpath. Returns: period, freq, z[ijreal,ijimag,ijvar] as array. If any of the numbers are NaN or +Inf they are set to zero
runBIRRPpp will processes a station from start to finish on seperate processors
dirpath = full path to station folders processinginfodict = dictionary of processing info
birrploc = location of BIRRP and bbconv.csv ffactor = factor to scale apparent resistivities and phases edipath = common folder to copy edifiles
dirpath = dirpath to station folders -> d:Data cdirpath = full path to time series files if not entered will default to
dirpathstationday
station = station name day = UTC day string of length 3 -> 035 rrstation = remote reference station name cacherate = length of data files string of hhmmss -> 1 hour data files
is 010000, 10 min is 001000start = start time for combining files in hhmmss stop = stop time for combining files in hhmmss rrstart = start time of remote reference in hhmmss rrstop = stop time of remote reference in hhmmss dec = decimation factor (0 for no decimation, needs to be an integer) df = sampling frequency in Hz magori = orientation of magnetic components as N,E,Z -> for measured BX
to East input as [BY,BX,BZ] omit BZ if not measured
- elecori = orientation of electric components as N,E -> for EX measured
- to N input as [EX,EY]
- rrmagori = orientation of remote reference magnetometers as N,E,Z omit
- Z if not measured
filtered = ‘Filtered’ if filtered, don’t enter if not filtered rrfiltered = ‘Filtered’ if remote reference is filtered fdict = dictionary for adaptive notch filter see
MTtools.adaptiveNotchFilter() for details
sigfigs(numstr,digits=8,fmt=’g’) will return a string with the proper amount of significant digits for the input number, can be str or float.
sil(iniline) will split a single line written in an .ini file for burpinterface and return the list of strings.
writeLogfile will write a log file of how a station was processed
writeScriptfile(processingdict will write a script file for BIRRP using info in processingdict which is a dictionary with keys:
- cfilelst = list of combined filenames (full path) ordered as:
- [electric N, electric E, mag N, mag E, mag Z] can omit Z if not measured
- rrcfilelst = list of combined remote reference filenames (full
- path) ordered as: [mag N, mag E, mag Z] omit z if not measured
station = station name magtype = bb for broadband lp for longperiod any BIRRP parameters you desire, (if not input default values will be assigned) namely:
ilev = processing mode 0 for basic and 1 for advanced RR-2 stage nout = Number of Output time series (2 or 3-> for BZ) ninp = Number of input time series for E-field (1,2,3) nref = Number of reference channels (2 for MT) nrr = bounded remote reference (0) or 2 stage bounded influence (1) tbw = Time bandwidth for Sepian sequence deltat = Sampling rate (+) for (s), (-) for (Hz) nfft = Length of FFT (should be even) nsctinc = section increment divisor (2 to divide by half) nsctmax = Number of windows used in FFT nf1 = 1st frequency to extract from FFT window (>=3) nfinc = frequency extraction increment nfsect = number of frequencies to extract mfft = AR filter factor, window divisor (2 for half) uin = Quantile factor determination ainlin = Residual rejection factor low end (usually 0) ainuin = Residual rejection factor high end (.95-.99) c2threshb = Coherence threshold for magnetics (0 if undesired) c2threshe = Coherence threshold for electrics (0 if undesired) nz= Threshold for Bz (0=separate from E, 1=E threshold, 2=E and B)
Input if 3 B components else Nonec2thresh1= Squared coherence for Bz, input if NZ=0, Nout=3 perlo = longest period to apply coherence threshold over perhi = shortes period to apply coherence threshold over ofil = Output file root(usually three letters, can add full path) nlev = Output files (0=Z; 1=Z,qq; 2=Z,qq,w; 3=Z,qq,w,d) nprej = number of frequencies to reject prej = frequencies to reject (+) for period, (-) for frequency npcs = Number of independent data to be processed (1 for one
segement)nar = Prewhitening Filter (3< >15) or 0 if not desired’, imode = Output file mode (0=ascii; 1=binary; 2=headerless ascii;
3=ascii in TS mode’,
- jmode = nput file mode (0=user defined; 1=start time
- YYYY-MM-DD HH:MM:SS)’,
- nread = Number of points to be read for each data set
- (if segments>1 -> npts1,npts2...)’,
nfil = Filter parameters (0=none; >0=input parameters; <0=filename nskip = Skip number of points in time series (0) if no skip,
(if segements >1 -> input1,input2...)’,
- nskipr = Number of points to skip over (0) if none,
- (if segements >1 -> input1,input2...)’,
- thetae = Rotation angles for electrics (relative to geomagnetic
- North)(N,E,rot)’,
- thetab = Rotation angles for magnetics (relative to geomagnetic
- North)(N,E,rot)’,
- thetar = Rotation angles for calculation (relative to geomagnetic
- North)(N,E,rot)’
=> see BIRRP Manual for more details on the parameters => see A. D. Chave and D. J. Thomson [1989,2003,2004] for more
information on Bounded influence and robust processing.
writecoh(dirpath) will write a coherence file using the BIRRP outputs residing in the dirpath folder. The output file is tab delimited and if any values are negative they are put to 0. Each value has 7 significant digits. Returns written to filename.
writebbdat(dirpath,magtype,df,dlgain,bbfile=None) will write a .dat (resistivity and phase) file from .rf output files from birrp after converting the broadband magnetic channels. dirpath is where the .rf files reside, bb file is where the conversion file resides and df is the sampling frequency. Returns written to filename.
writeedi2(dirpath,stationinfofile,station,bbfile= r’c:PeacockPHDBIRRPbconv.txt’) will write an .edi file for a station processed by BIRRP given the station info file, station and bbfile if applicable. Returns the full path to the .edi file.
writebbimp(dirpath,magtype,dlgain,bbfile=None)writes a tab delimited .imp file of converted impedances from.rf outputs of BIRRP and calibrates using file bbfile and dlgain which is the data logger gain (verylow=2.5,low=1,high=.1). Returns written to filename.
writeini(filepath,station,argsdict) will write an .ini file from the to the filepath as station.ini. The argsdict must be len 40 or will not write, the variables should be: dict[defdirpath,station,magtype,lpyn,eyn,mcomps,magdec, df,cacherate, dlength,dlgain,egain,lpbzcor,bbcal,magori,birrploc,ilev,nout, ninp,tbw,nfft,nsctmax,uin,ainuin,c2threshe,nz,c2threshe1,ofil, nlev,nar,imode,jmode,nfil,complstr,thetae,thetab,thetaf].