Пример #1
0
proj.refresh()

# calculate statistics for MT site
from resistics.project.statistics import calculateStatistics

calculateStatistics(proj, sites=["site1_mt"])

# intersite
from resistics.project.transfunc import (
    processProject,
    processSite,
    viewImpedance,
)
from resistics.common.plot import plotOptionsTransferFunction, getPaperFonts

plotOptions = plotOptionsTransferFunction(figsize=(24, 12),
                                          plotfonts=getPaperFonts())
plotOptions["res_ylim"] = [1, 1000000]
processSite(
    proj,
    "site2_te",
    500,
    inputsite="site1_mt",
    postpend="intersite",
)
figs = viewImpedance(
    proj,
    sites=["site2_te"],
    postpend="intersite",
    plotoptions=plotOptions,
    oneplot=False,
    save=False,
Пример #2
0
    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,
)
figs[0].savefig(imagePath / "impedance_config")

# process for the tipper
processProject(projData, outchans=["Ex", "Ey", "Hz"], postpend="withHz")
Пример #3
0
def viewImpedance(projData: ProjectData, **kwargs) -> List[Figure]:
    """View impedance tensor data

    Parameters
    ----------
    projData : projecData
        The project data
    sites : List[str], optional
        List of sites to plot transfer functions for
    sampleFreqs : List[float], optional 
        List of samples frequencies for which to plot transfer functions
    polarisations : List[str], optional 
        A list of polarisations to plot. For example, ["ExHx", "ExHy", "EyHx", "EyHy"]
    specdir : str, optional
        The spectra directories used
    postpend : str, optional
        The postpend on the transfer function files
    oneplot : bool, optional
        Plot the polarisation on a single plot
    show : bool, optional
        Show the spectra plot
    save : bool, optional
        Save the plot to the images directory
    plotoptions : Dict
        A dictionary of plot options. For example, set the resistivity y limits using res_ylim, set the phase y limits using phase_ylim and set the xlimits using xlim
    """
    from resistics.common.plot import (
        savePlot,
        plotOptionsTransferFunction,
        getTransferFunctionFigSize,
        transferFunctionColours,
    )

    options = {}
    options["sites"] = projData.getSites()
    options["sampleFreqs"] = projData.getSampleFreqs()
    options["polarisations"] = ["ExHx", "ExHy", "EyHx", "EyHy"]
    options["specdir"] = projData.config.configParams["Spectra"]["specdir"]
    options["postpend"] = ""
    options["oneplot"] = True
    options["save"] = False
    options["show"] = True
    options["plotoptions"] = plotOptionsTransferFunction()
    options = parseKeywords(options, kwargs)

    # loop over sites
    figs = []
    for site in options["sites"]:
        siteData = projData.getSiteData(site)
        sampleFreqs = set(siteData.getSampleFreqs())
        # find the intersection with the options["freqs"]
        sampleFreqs = sampleFreqs.intersection(options["sampleFreqs"])
        sampleFreqs = sorted(list(sampleFreqs))

        # if prepend is a string, then make it a list
        if isinstance(options["postpend"], str):
            options["postpend"] = [options["postpend"]]

        plotfonts = options["plotoptions"]["plotfonts"]
        # now loop over the postpend options
        for pp in options["postpend"]:
            # add an underscore if not empty
            postpend = "_{}".format(pp) if pp != "" else pp

            if options["plotoptions"]["figsize"] is None:
                figsize = getTransferFunctionFigSize(
                    options["oneplot"], len(options["polarisations"]))
            else:
                figsize = options["plotoptions"]["figsize"]
            fig = plt.figure(figsize=figsize)
            mks = ["o", "*", "d", "^", "h"]
            lstyles = ["solid", "dashed", "dashdot", "dotted"]
            colours = transferFunctionColours()

            # loop over sampling frequencies
            includedFreqs = []
            for idx, sampleFreq in enumerate(sampleFreqs):

                tfData = getTransferFunctionData(projData,
                                                 site,
                                                 sampleFreq,
                                                 specdir=options["specdir"],
                                                 postpend=pp)
                if not tfData:
                    continue

                includedFreqs.append(sampleFreq)
                projectText(
                    "Plotting transfer function for site {}, sample frequency {}"
                    .format(site, sampleFreq))

                # plot
                mk = mks[idx % len(mks)]
                ls = lstyles[idx % len(lstyles)]
                tfData.viewImpedance(
                    fig=fig,
                    polarisations=options["polarisations"],
                    mk=mk,
                    ls=ls,
                    colours=colours,
                    oneplot=options["oneplot"],
                    res_ylim=options["plotoptions"]["res_ylim"],
                    phase_ylim=options["plotoptions"]["phase_ylim"],
                    xlim=options["plotoptions"]["xlim"],
                    label="{}".format(sampleFreq),
                    plotfonts=options["plotoptions"]["plotfonts"],
                )

            # check if any files found
            if len(includedFreqs) == 0:
                continue

            # sup title
            sub = "Site {}: {}".format(site, options["specdir"] + postpend)
            sub = "{}\nfs = {}".format(
                sub, arrayToString(includedFreqs, decimals=3))
            st = fig.suptitle(sub, fontsize=plotfonts["suptitle"])
            st.set_y(0.99)
            fig.tight_layout()
            fig.subplots_adjust(top=0.92)
            figs.append(fig)

            if options["save"]:
                impath = projData.imagePath
                filename = "transFunction_{}_{}{}".format(
                    site, options["specdir"], postpend)
                savename = savePlot(impath, filename, fig)
                projectText("Image saved to file {}".format(savename))

        if not options["show"]:
            plt.close("all")
        else:
            plt.show(block=options["plotoptions"]["block"])

    return figs