<commit_before>import numpy as NP
import pylab as PL
from scipy.constants import mu_0

from pyrsss.emtf.calc_e_3d import parse_xml, Zw_interpolator


def plot_3D_reponse(xml_fname,
                    fmin=1e-3,
                    fmax=1/60/2,
                    N=100,
                    figsize=(10,7),
                    **kwds):
    """
    Generate two figures, each a 2x2 grid plot (Zxx, Zxy, Zyx, and
    Zyy) showing the magnitude (figure 1) and phase (figure 2) for the
    3-D EMTF given in *xml_fname*. Plot the frequency response for $N$
    uniformly spaced frequencies over the interval from *fmin* to
    *fmax* (in Hz). Use *figsize* sized plots and pass *kwds* as
    keyword arguments to all calls to :func:`PL.plot` and
    :func:`PL.scatter`. Return a tuple with the handles to the two
    generated figures.
    """
    f = NP.linspace(fmin, fmax, N)
    f_mHz = f * 1e3
    fmin_mHz = fmin * 1e3
    fmax_mHz = fmax * 1e3
    omega = 2 * NP.pi * f
    # setup surface impedance function
    Z_map = parse_xml(xml_fname)
    interp = Zw_interpolator(Z_map)
    # mu_0 * 1e3 converts from [mv / km] / [nT] to [Ohm]
    Zxx_function = lambda omega: interp(omega, 'xx') * mu_0 * 1e3
    Zxy_function = lambda omega: interp(omega, 'xy') * mu_0 * 1e3
    Zyx_function = lambda omega: interp(omega, 'yx') * mu_0 * 1e3
    Zyy_function = lambda omega: interp(omega, 'yy') * mu_0 * 1e3
    # compute transer function response at specified frequencies
    Zxx = map(Zxx_function, omega)
    Zxy = map(Zxy_function, omega)
    Zyx = map(Zyx_function, omega)
    Zyy = map(Zyy_function, omega)
    # retrieve EMTF values (those provided in the XML file before interpolation)
    Zxx_xml = NP.array([x[0,0] for x in Z_map.values()]) * mu_0 * 1e3
    Zxy_xml = NP.array([x[0,1] for x in Z_map.values()]) * mu_0 * 1e3<commit_msg>Exposed interpolator_opts.<commit_after>import numpy as NP
import pylab as PL
from scipy.constants import mu_0

from pyrsss.emtf.calc_e_3d import parse_xml, Zw_interpolator


def plot_3D_reponse(xml_fname,
                    fmin=1e-3,
                    fmax=1/60/2,
                    N=100,
                    figsize=(10,7),
                    interpolator_opts={},
                    **kwds):
    """
    Generate two figures, each a 2x2 grid plot (Zxx, Zxy, Zyx, and
    Zyy) showing the magnitude (figure 1) and phase (figure 2) for the
    3-D EMTF given in *xml_fname*. Plot the frequency response for $N$
    uniformly spaced frequencies over the interval from *fmin* to
    *fmax* (in Hz). Use *figsize* sized plots and pass *kwds* as
    keyword arguments to all calls to :func:`PL.plot` and
    :func:`PL.scatter`. Return a tuple with the handles to the two
    generated figures.
    """
    f = NP.linspace(fmin, fmax, N)
    f_mHz = f * 1e3
    fmin_mHz = fmin * 1e3
    fmax_mHz = fmax * 1e3
    omega = 2 * NP.pi * f
    # setup surface impedance function
    Z_map = parse_xml(xml_fname)
    interp = Zw_interpolator(Z_map, **interpolator_opts)
    # mu_0 * 1e3 converts from [mv / km] / [nT] to [Ohm]
    Zxx_function = lambda omega: interp(omega, 'xx') * mu_0 * 1e3
    Zxy_function = lambda omega: interp(omega, 'xy') * mu_0 * 1e3
    Zyx_function = lambda omega: interp(omega, 'yx') * mu_0 * 1e3
    Zyy_function = lambda omega: interp(omega, 'yy') * mu_0 * 1e3
    # compute transer function response at specified frequencies
    Zxx = Zxx_function(omega)
    Zxy = Zxy_function(omega)
    Zyx = Zyx_function(omega)
    Zyy = Zyy_function(omega)
    # retrieve EMTF values (those provided in the XML file before interpolation)
    Zxx_xml = NP.array([x[0,0] for x in Z_map.values()]) * mu_0 * 1e3
    Zxy_xml = NP.array([x[0,1] for x in Z_map.values()]) * mu_0 * 1e3
{'fraction_non_alphanumeric': 0.10224839400428265, 'fraction_numerical': 0.027837259100642397, 'mean_word_length': 2.6817733990147783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6772233', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1331, 'n_words': 412}