plotOptions = plotOptionsSpec(plotfonts=getPaperFonts()) fig = viewSpectraStack( projData, "site1", "meas", coherences=[["Ex", "Hy"], ["Ey", "Hx"]], plotoptions=plotOptions, save=False, show=False, ) fig.savefig(imagePath / "viewSpectraStack_config_polreverse") # calculate impedance tensor from resistics.project.transfunc import processProject processProject(projData, outchans=["Ex", "Ey"]) # plot impedance tensor and save the plot from resistics.project.transfunc import viewImpedance from resistics.common.plot import plotOptionsTransferFunction plotoptions = plotOptionsTransferFunction(plotfonts=getPaperFonts()) plotoptions["xlim"] = [0.01, 1000000] plotoptions["phase_ylim"] = [-10, 100] figs = viewImpedance( projData, sites=["site1"], oneplot=True, polarisations=["ExHy", "EyHx"], plotoptions=plotoptions, save=True,
from resistics.project.io import loadProject from resistics.project.spectra import calculateSpectra from resistics.project.transfunc import processProject, viewImpedance from resistics.project.statistics import calculateStatistics from resistics.project.mask import newMaskData, calculateMask if __name__ == "__main__": projData = loadProject(projectPath, "multiconfig.ini") # calculate spectrum using standard options calculateSpectra(projData) projData.refresh() calculateStatistics(projData) # process project with standard options processProject(projData) figs = viewImpedance(projData, oneplot=False, show=False, save=False) figs[0].savefig(imagePath / "multproc_standard_process") # calculate mask for 128 maskData = newMaskData(projData, 128) maskData.setStats(["coherence"]) maskData.addConstraint("coherence", { "cohExHy": [0.7, 1.0], "cohEyHx": [0.7, 1.0] }) maskData.maskName = "coh70_100" calculateMask(projData, maskData, sites=["site1"]) # calculate mask for 4096 maskData = newMaskData(projData, 4096) maskData.setStats(["coherence"])
from datapaths import remotePath, remoteImages from resistics.project.io import loadProject from resistics.project.spectra import calculateSpectra from resistics.project.transfunc import processProject, viewImpedance from resistics.project.statistics import calculateRemoteStatistics, viewStatistic from resistics.project.mask import newMaskData, calculateMask from resistics.common.plot import plotOptionsTransferFunction, getPaperFonts plotOptions = plotOptionsTransferFunction(plotfonts=getPaperFonts()) proj = loadProject(remotePath, "remoteConfig.ini") calculateSpectra(proj, sites=["M6", "Remote"]) proj.refresh() # single site processing processProject(proj, sites=["M6", "Remote"]) figs = viewImpedance( proj, sites=["M6", "Remote"], sampleFreqs=[128], oneplot=False, plotoptions=plotOptions, save=False, show=False, ) figs[0].savefig(remoteImages / "singleSiteM6_128_dec8_5.png") figs[1].savefig(remoteImages / "singleSiteRemote_128_dec8_5.png") # calculate the statistic we are interested in calculateRemoteStatistics(proj, "Remote", sites=["M6"], sampleFreqs=[128])
fig = viewSpectraSection( projData, "site1", "meas_2012-02-10_11-30-00", specdir="notch", plotoptions=plotOptions, show=False, save=False, ) fig.savefig(imagePath / "multspec_viewspec_notch_section") # process the new set of spectra from resistics.project.transfunc import processProject processProject(projData, sites=["site1"], specdir="notch") # plot the transfer functions, again with specifying the relevant specdir from resistics.project.transfunc import viewImpedance figs = viewImpedance( projData, sites=["site1"], sampleFreqs=[128], oneplot=False, specdir="notch", save=False, show=False, ) figs[0].savefig(imagePath / "multspec_viewimp_notch")
from datapaths import projectPath, imagePath from resistics.project.io import loadProject # load project and configuration file projData = loadProject(projectPath, configFile="tutorialConfig.ini") # Process the data with this mask from resistics.project.transfunc import processProject processProject( projData, sampleFreqs=[4096, 128], sites=["site1"], outchans=["Ex", "Ey"], masks={"site1": "coh70_100"}, postpend="coh70_100", ) from resistics.project.transfunc import viewImpedance figs = viewImpedance( projData, sites=["site1"], postpend="coh70_100", oneplot=False, save=False, show=False, ) figs[0].savefig(imagePath / "runWithMask_coh70_100") processProject(
from datapaths import projectPath, imagePath from resistics.project.io import loadProject # load the project projData = loadProject(projectPath) # process the spectra with tippers from resistics.project.transfunc import processProject processProject(projData, sites=["site1"], outchans=["Ex", "Ey", "Hz"], postpend="with_Hz") # plot the tippers from resistics.project.transfunc import viewTipper figs = viewTipper(projData, sites=["site1"], postpend="with_Hz", save=True, show=False) figs[0].savefig(imagePath / "simpleRunWithTipper_viewtip_withHz") # plot the transfer function from resistics.project.transfunc import viewImpedance figs = viewImpedance( projData, sites=["site1"], polarisations=["ExHy", "EyHx"],
for fs in [512, 4096, 16384, 65536]: maskData = newMaskData(projData, fs) maskData.setStats(["coherence"]) maskData.addConstraint("coherence", { "cohExHy": [0.8, 1.0], "cohEyHx": [0.8, 1.0] }) # finally, lets give maskData a name, which will relate to the output file maskData.maskName = "coh_80_100" calculateMask(projData, maskData, sites=["M6"]) maskData.printInfo() processProject( projData, sites=["M6"], sampleFreqs=[512, 4096, 16384, 65536], masks={"M6": "coh_80_100"}, postpend="coh_80_100", ) viewImpedance( projData, sites=["M6"], sampleFreqs=[512, 4096, 16384, 65536], postpend="coh_80_100", oneplot=False, save=True, show=False, ) # # try this
from datapaths import projectPath, imagePath from resistics.project.io import loadProject proj = loadProject(projectPath, "customconfig.ini") proj.printInfo() from resistics.project.spectra import calculateSpectra from resistics.project.statistics import calculateStatistics from resistics.project.transfunc import processProject, viewImpedance from resistics.common.plot import plotOptionsTransferFunction, getPaperFonts calculateSpectra(proj) proj.refresh() calculateStatistics(proj) processProject(proj) plotOptions = plotOptionsTransferFunction(figsize=(24, 12), plotfonts=getPaperFonts()) plotOptions["res_ylim"] = [1, 1000000] figs = viewImpedance(proj, oneplot=False, plotoptions=plotOptions, show=False, save=False) figs[0].savefig(imagePath / "impedance_config.png") # now try again with some statistics for the dead band from resistics.project.mask import newMaskData, calculateMask maskData = newMaskData(proj, 500) maskData.setStats(["coherence"]) maskData.addConstraintLevel("coherence", {
from resistics.project.io import loadProject # load the project projData = loadProject(projectPath, configFile="tutorialConfig.ini") # define date/time constraints - only time windows within the constraints will be used datetimes = list() datetimes.append( {"type": "datetime", "start": "2012-02-10 19:00:00", "stop": "2012-02-11 07:00:00"} ) # process the spectra from resistics.project.transfunc import processProject processProject( projData, sampleFreqs=[128], datetimes=datetimes, postpend="datetimeConstraint" ) # plot transfer function and save the plot from resistics.project.transfunc import viewImpedance figs = viewImpedance( projData, sites=["site1"], postpend="datetimeConstraint", oneplot=False, save=False, show=False, ) figs[0].savefig(imagePath / "datetimeConstraints_viewimp")
def test_masked_processing() -> None: """Test masked processing the project""" from datapaths import path_integrated_singlesite, path_integrated_singlesite_config from resistics.project.io import loadProject from resistics.project.spectra import calculateSpectra from resistics.project.statistics import calculateStatistics from resistics.project.mask import newMaskData, calculateMask from resistics.project.transfunc import processProject from resistics.project.transfunc import getTransferFunctionData, viewImpedance # load project sites = ["M7_4096"] proj = loadProject(path_integrated_singlesite, str(path_integrated_singlesite_config)) # calculateSpectra(proj) # proj.refresh() # calculateStatistics(proj) # calculate out a mask maskData = newMaskData(proj, 4096) maskData.setStats(["coherence", "transferFunction", "resPhase"]) maskData.addConstraintLevel("coherence", { "cohExHy": [0.8, 1.0], "cohEyHx": [0.8, 1.0] }, 0) maskData.addConstraintLevel("coherence", { "cohExHy": [0.8, 1.0], "cohEyHx": [0.8, 1.0] }, 1) maskData.addConstraintLevel("coherence", { "cohExHy": [0.8, 1.0], "cohEyHx": [0.7, 1.0] }, 2) maskData.addConstraintLevel("coherence", { "cohExHy": [0.7, 1.0], "cohEyHx": [0.7, 1.0] }, 3) maskData.addConstraintLevel("coherence", { "cohExHy": [0.7, 1.0], "cohEyHx": [0.7, 1.0] }, 4) maskData.addConstraintFreq("transferFunction", { "EyHxReal": [0, 150], "EyHxImag": [0, 220] }, 0, 4) maskData.addConstraintFreq("transferFunction", { "ExHyReal": [-120, 0], "ExHyImag": [-200, -30] }, 1, 0) maskData.addConstraintFreq("transferFunction", { "ExHyReal": [-100, 0], "ExHyImag": [-160, -30] }, 1, 1) maskData.addConstraintFreq("transferFunction", { "ExHyReal": [-90, 0], "ExHyImag": [-120, -30] }, 1, 2) maskData.addConstraintFreq("transferFunction", { "ExHyReal": [-60, -25], "ExHyImag": [-90, -75] }, 1, 3) maskData.addConstraintFreq("transferFunction", { "ExHyReal": [-80, 0], "ExHyImag": [-100, -20] }, 1, 4) # finally, lets give maskData a name, which will relate to the output file maskData.maskName = "coh_tf" calculateMask(proj, maskData, sites=sites) # process processProject( proj, sites=sites, masks={"M7_4096": "coh_tf"}, postpend="coh_tf", ) # tf = getTransferFunctionData(proj, "M7_4096", 4096) # test the transfer function viewImpedance( proj, sites=sites, postpend="coh_tf", polarisations=["ExHy", "EyHx"], oneplot=False, show=False, save=True, )
from datapaths import projectPath, imagePath from resistics.project.io import loadProject # load the project projData = loadProject(projectPath) # calculate spectrum using standard options from resistics.project.spectra import calculateSpectra calculateSpectra(projData) projData.refresh() # process the spectra from resistics.project.transfunc import processProject processProject(projData) # plot transfer function and save the plot from resistics.project.transfunc import viewImpedance figs = viewImpedance(projData, sites=["site1"], show=False, save=False) figs[0].savefig(imagePath / "simpleRun_viewimp_default") # or keep the two most important polarisations on the same plot figs = viewImpedance(projData, sites=["site1"], polarisations=["ExHy", "EyHx"], save=False, show=False) figs[0].savefig(imagePath / "simpleRun_viewimp_polarisations")
# view time from resistics.project.time import viewTime fig = viewTime( proj, startDate="2019-05-27 14:15:00", endDate="2019-05-27 15:00:00", filter={"lpfilt": 4}, save=False, show=False, ) fig.savefig(imagePath / "viewTime.png") from resistics.project.spectra import calculateSpectra from resistics.project.statistics import calculateStatistics from resistics.project.transfunc import processProject, viewImpedance from resistics.common.plot import plotOptionsTransferFunction, getPaperFonts calculateSpectra(proj) proj.refresh() calculateStatistics(proj) processProject(proj) plotOptions = plotOptionsTransferFunction(figsize=(24, 12), plotfonts=getPaperFonts()) plotOptions["res_ylim"] = [1, 1000000] figs = viewImpedance(proj, oneplot=False, plotoptions=plotOptions, show=False, save=False) figs[0].savefig(imagePath / "impedance_default.png")
maskData = newMaskData(projData, 0.5) maskData.setStats(["coherence"]) maskData.addConstraint("coherence", { "cohExHy": [0.3, 1.0], "cohEyHx": [0.3, 1.0] }) maskData.maskName = "coh30_100" calculateMask(projData, maskData, sites=["site1"]) fig = maskData.view(0) fig.savefig(imagePath / "maskcoh") # calculate impedance tensor from resistics.project.transfunc import processProject processProject(projData, outchans=["Ex", "Ey"], masks={"site1": maskData.maskName}, postpend=maskData.maskName) # plot transfer function and save the plot from resistics.project.transfunc import viewImpedance from resistics.common.plot import plotOptionsTransferFunction, getPaperFonts plotoptions = plotOptionsTransferFunction(plotfonts=getPaperFonts()) plotoptions["xlim"] = [0.01, 1000000] plotoptions["phase_ylim"] = [-10, 100] figs = viewImpedance( projData, sites=["site1"], postpend=maskData.maskName, oneplot=True, polarisations=["ExHy", "EyHx"],
from resistics.project.io import loadProject from resistics.project.spectra import calculateSpectra from resistics.project.transfunc import processProject, viewImpedance from resistics.project.statistics import calculateStatistics, viewStatistic from resistics.project.mask import newMaskData, calculateMask from resistics.common.plot import plotOptionsTransferFunction, getPaperFonts plotOptions = plotOptionsTransferFunction(plotfonts=getPaperFonts()) proj = loadProject(remotePath) # calculate spectrum using standard options calculateSpectra(proj, sites=["M6", "Remote"]) proj.refresh() # single site processing processProject(proj, sites=["M6", "Remote"]) # 128 Hz impedance tensor estimates figs = viewImpedance( proj, sites=["M6", "Remote"], sampleFreqs=[128], oneplot=False, plotoptions=plotOptions, show=False, save=False, ) figs[0].savefig(remoteImages / "singleSiteM6_128.png") figs[1].savefig(remoteImages / "singleSiteRemote_128.png") # all sampling frequencies for M6