signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
def ping(self, resource):
warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>return True<EOL>
A user implemented function that ensures the ``Resource`` object is open. :param obj resource: A ``Resource`` object. :return: A bool indicating if the resource is open (``True``) or closed (``False``).
f13168:c0:m20
def put_connection(self, connection):
warnings.warn(('<STR_LIT>'<EOL>'<STR_LIT>'),<EOL>DeprecationWarning)<EOL>return self.put_resource(connection)<EOL>
For compatibility with older versions, will be removed in 1.0.
f13168:c0:m21
def put_resource(self, resource):
rtracker = self._get_tracker(resource)<EOL>try:<EOL><INDENT>self._put(rtracker)<EOL><DEDENT>except PoolFullError:<EOL><INDENT>self._remove(rtracker)<EOL><DEDENT>
Adds a resource back to the pool or discards it if the pool is full. :param resource: A resource object. :raises UnknownResourceError: If resource was not made by the pool.
f13168:c0:m22
def available(self):
return self._weakref is None or self._weakref() is None<EOL>
Determine if resource available for use.
f13168:c1:m1
def wrap_resource(self, pool, resource_wrapper):
resource = resource_wrapper(self.resource, pool)<EOL>self._weakref = weakref.ref(resource)<EOL>return resource<EOL>
Return a resource wrapped in ``resource_wrapper``. :param pool: A pool instance. :type pool: :class:`CuttlePool` :param resource_wrapper: A wrapper class for the resource. :type resource_wrapper: :class:`Resource` :return: A wrapped resource. :rtype: :class:`Resource`
f13168:c1:m2
def __getattr__(self, name):
return getattr(self._resource, name)<EOL>
Gets attributes of resource object.
f13168:c2:m3
def __setattr__(self, name, value):
if name not in self.__dict__:<EOL><INDENT>setattr(self._resource, name, value)<EOL><DEDENT>else:<EOL><INDENT>object.__setattr__(self, name, value)<EOL><DEDENT>
Sets attributes of resource object.
f13168:c2:m4
def close(self):
if self._resource is not None:<EOL><INDENT>self._pool.put_resource(self._resource)<EOL>self._resource = None<EOL>self._pool = None<EOL><DEDENT>
Returns the resource to the resource pool.
f13168:c2:m5
def get_version():
VERSION_FILE = '<STR_LIT>'<EOL>mo = re.search(r'<STR_LIT>', open(VERSION_FILE, '<STR_LIT>').read(), re.M)<EOL>if mo:<EOL><INDENT>return mo.group(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>'.format(VERSION_FILE))<EOL><DEDENT>
Extracts the version number from the version.py file.
f13173:m0
def wrapped_target(target, q_stdout, q_stderr, q_error, robust, name, *args, **kwargs):
import sys<EOL>sys.stdout = IOQueue(q_stdout)<EOL>sys.stderr = IOQueue(q_stderr)<EOL>try:<EOL><INDENT>target(*args, **kwargs)<EOL><DEDENT>except:<EOL><INDENT>if not robust:<EOL><INDENT>s = '<STR_LIT>' + traceback.format_exc()<EOL>logger = daiquiri.getLogger(name)<EOL>logger.error(s)<EOL><DEDENT>else:<EOL><INDENT>raise<...
Wraps a target with queues replacing stdout and stderr
f13178:m0
def loop(self, max_seconds=None):
loop_started = datetime.datetime.now()<EOL>self._is_running = True<EOL>while self._is_running:<EOL><INDENT>self.process_error_queue(self.q_error)<EOL>if max_seconds is not None:<EOL><INDENT>if (datetime.datetime.now() - loop_started).total_seconds() > max_seconds:<EOL><INDENT>break<EOL><DEDENT><DEDENT>for subprocess i...
Main loop for the process. This will run continuously until maxiter
f13178:c2:m4
def __init__(self):
self.monitor = ProcessMonitor()<EOL>self._tab_list = []<EOL>
A Cron object runs many "tabs" of asynchronous tasks.
f13179:c0:m0
def __init__(self, name, robust=True, verbose=True):
self._name = name<EOL>self._robust = robust<EOL>self._verbose = verbose<EOL>self._starting_at = None<EOL>self._every_kwargs = None<EOL>self._func = None<EOL>self._func_args = None<EOL>self._func_kwargs = None<EOL>
Schedules a Tab entry in the cron runner :param name: Every tab must have a string name :param robust: A robust tab will be restarted if an error occures A non robust tab will not be restarted, but all other non-errored tabs should continue running :param verbose: Set the verbosity of ...
f13179:c1:m0
def starting_at(self, datetime_or_str):
if isinstance(datetime_or_str, str):<EOL><INDENT>self._starting_at = parse(datetime_or_str)<EOL><DEDENT>elif isinstance(datetime_or_str, datetime.datetime):<EOL><INDENT>self._starting_at = datetime_or_str<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return self<EOL>
Set the starting time for the cron job. If not specified, the starting time will always be the beginning of the interval that is current when the cron is started. :param datetime_or_str: a datetime object or a string that dateutil.parser can understand :return: self
f13179:c1:m1
def every(self, **kwargs):
if len(kwargs) != <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>self._every_kwargs = self._clean_kwargs(kwargs)<EOL>return self<EOL>
Specify the interval at which you want the job run. Takes exactly one keyword argument. That argument must be one named one of [second, minute, hour, day, week, month, year] or their plural equivalents. :param kwargs: Exactly one keyword argument :return: self
f13179:c1:m2
def run(self, func, *func_args, **func__kwargs):
self._func = func<EOL>self._func_args = func_args<EOL>self._func_kwargs = func__kwargs<EOL>return self<EOL>
Specify the function to run at the scheduled times :param func: a callable :param func_args: the args to the callable :param func__kwargs: the kwargs to the callable :return:
f13179:c1:m3
def _get_target(self):
if None in [self._func, self._func_kwargs, self._func_kwargs, self._every_kwargs]:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return self._loop<EOL>
returns a callable with no arguments designed to be the target of a Subprocess
f13179:c1:m6
def get_version():
file_dir = os.path.realpath(os.path.dirname(__file__))<EOL>with open(<EOL>os.path.join(file_dir, '<STR_LIT:..>', '<STR_LIT>', '<STR_LIT>')) as f:<EOL><INDENT>txt = f.read()<EOL><DEDENT>version_match = re.search(<EOL>r"""<STR_LIT>""", txt, re.M)<EOL>if version_match:<EOL><INDENT>return version_match.group(<NUM_LIT:1>)<E...
Obtain the packge version from a python file e.g. pkg/__init__.py See <https://packaging.python.org/en/latest/single_source_version.html>.
f13180:m0
def is_valid_file(parser,arg):
if not os.path.exists(arg):<EOL><INDENT>parser.error("<STR_LIT>"%arg)<EOL><DEDENT>else:<EOL><INDENT>return arg<EOL><DEDENT>
verify the validity of the given file. Never trust the End-User
f13182:m0
def getID(code_file):
json_path = ghostfolder+'<STR_LIT:/>'+json_file<EOL>if os.path.exists(json_path):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>download_file('<STR_LIT>')<EOL><DEDENT>lang = detect_lang(code_file)<EOL>json_data = json.load(file(json_path))<EOL>ID = '<STR_LIT>'<EOL>for i in range(len(json_data)):<EOL><INDENT>temp = le...
Get the language ID of the input file language
f13182:m4
def detect_lang(path):
blob = FileBlob(path, os.getcwd())<EOL>if blob.is_text:<EOL><INDENT>print('<STR_LIT>'.format(blob.language.name))<EOL>return blob.language.name<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL>sys.exit()<EOL><DEDENT>
Detect the language used in the given file.
f13182:m5
def green3d(src, rec, depth, res, freq, aniso, par, strength=<NUM_LIT:0>):
<EOL>rundir = join(dirname(__file__), '<STR_LIT>')<EOL>if par in [<NUM_LIT:9>, <NUM_LIT:10>]:<EOL><INDENT>srcstr = str(src[<NUM_LIT:0>]) + '<STR_LIT:U+0020>' + str(src[<NUM_LIT:1>]) + '<STR_LIT:U+0020>' + str(src[<NUM_LIT:2>]) + '<STR_LIT:U+0020>'<EOL>srcstr += str(src[<NUM_LIT:3>]) + '<STR_LIT:U+0020>' + str(src[<NUM_...
r"""Run model with green3d (CEMI). You must have Green3D installed (for which you need to be a member of the CEMI consortium). The following files must be in the folder `empymod/tests/green3d`: - `green3d.m` - `grint.mexa64` - (`grint.mexw64`) - (`normal.mexa64`) - (...
f13186:m0
def dipole1d(src, rec, depth, res, freq, srcpts=<NUM_LIT:5>):
<EOL>rundir = join(dirname(__file__), '<STR_LIT>')<EOL>os.makedirs(rundir, exist_ok=True)<EOL>if len(src) == <NUM_LIT:6>:<EOL><INDENT>dx = src[<NUM_LIT:1>] - src[<NUM_LIT:0>]<EOL>dy = src[<NUM_LIT:3>] - src[<NUM_LIT:2>]<EOL>dz = src[<NUM_LIT:5>] - src[<NUM_LIT:4>]<EOL>r = np.sqrt(dx**<NUM_LIT:2> + dy**<NUM_LIT:2> + dz*...
r"""Run model with dipole1d (Scripps). You must have Dipole1D installed and it must be in your system path. http://software.seg.org/2012/0003
f13186:m1
def emmod(dx, nx, dy, ny, src, rec, depth, res, freq, aniso, epermV, epermH,<EOL>mpermV, mpermH, ab, nd=<NUM_LIT:1000>, startlogx=-<NUM_LIT:6>, deltalogx=<NUM_LIT:0.5>, nlogx=<NUM_LIT>,<EOL>kmax=<NUM_LIT:10>, c1=<NUM_LIT:0>, c2=<NUM_LIT>, maxpt=<NUM_LIT:1000>, dopchip=<NUM_LIT:0>, xdirect=<NUM_LIT:0>):
<EOL>rundir = join(dirname(__file__), '<STR_LIT>')<EOL>os.makedirs(rundir, exist_ok=True)<EOL>with open(rundir + '<STR_LIT>', '<STR_LIT:wb>') as runfile:<EOL><INDENT>runfile.write(bytes(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'+str(freq)+'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'+str(nx)+'<STR_LIT>'<EOL>'<STR_L...
r"""Run model with emmod (Hunziker et al, 2015). You must have EMmod installed and it must be in your system path. http://software.seg.org/2015/0001 nd : number of integration domains startlogx : first integration point in space deltalogx : log sampling rate of integr. pts in space at firs...
f13186:m2
def bipole(src, rec, depth, res, freqtime, signal=None, aniso=None,<EOL>epermH=None, epermV=None, mpermH=None, mpermV=None, msrc=False,<EOL>srcpts=<NUM_LIT:1>, mrec=False, recpts=<NUM_LIT:1>, strength=<NUM_LIT:0>, xdirect=False,<EOL>ht='<STR_LIT>', htarg=None, ft='<STR_LIT>', ftarg=None, opt=None, loop=None,<EOL>verb=<...
<EOL>t0 = printstartfinish(verb)<EOL>htarg, opt = spline_backwards_hankel(ht, htarg, opt)<EOL>if signal is None:<EOL><INDENT>freq = freqtime<EOL><DEDENT>else:<EOL><INDENT>time, freq, ft, ftarg = check_time(freqtime, signal, ft, ftarg, verb)<EOL><DEDENT>model = check_model(depth, res, aniso, epermH, epermV, mpermH, mper...
r"""Return the electromagnetic field due to an electromagnetic source. Calculate the electromagnetic frequency- or time-domain field due to arbitrary finite electric or magnetic bipole sources, measured by arbitrary finite electric or magnetic bipole receivers. By default, the electromagnetic response ...
f13202:m0
def dipole(src, rec, depth, res, freqtime, signal=None, ab=<NUM_LIT:11>, aniso=None,<EOL>epermH=None, epermV=None, mpermH=None, mpermV=None, xdirect=False,<EOL>ht='<STR_LIT>', htarg=None, ft='<STR_LIT>', ftarg=None, opt=None, loop=None,<EOL>verb=<NUM_LIT:2>):
<EOL>t0 = printstartfinish(verb)<EOL>htarg, opt = spline_backwards_hankel(ht, htarg, opt)<EOL>if signal is not None:<EOL><INDENT>time, freq, ft, ftarg = check_time(freqtime, signal, ft, ftarg, verb)<EOL><DEDENT>else:<EOL><INDENT>freq = freqtime<EOL><DEDENT>model = check_model(depth, res, aniso, epermH, epermV, mpermH, ...
r"""Return the electromagnetic field due to a dipole source. Calculate the electromagnetic frequency- or time-domain field due to infinitesimal small electric or magnetic dipole source(s), measured by infinitesimal small electric or magnetic dipole receiver(s); sources and receivers are directed along ...
f13202:m1
def analytical(src, rec, res, freqtime, solution='<STR_LIT>', signal=None, ab=<NUM_LIT:11>,<EOL>aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None,<EOL>verb=<NUM_LIT:2>):
<EOL>t0 = printstartfinish(verb)<EOL>if signal is not None:<EOL><INDENT>freqtime = check_time_only(freqtime, signal, verb)<EOL><DEDENT>model = check_model([], res, aniso, epermH, epermV, mpermH, mpermV, True,<EOL>verb)<EOL>depth, res, aniso, epermH, epermV, mpermH, mpermV, _ = model<EOL>frequency = check_frequency(freq...
r"""Return the analytical full- or half-space solution. Calculate the electromagnetic frequency- or time-domain field due to infinitesimal small electric or magnetic dipole source(s), measured by infinitesimal small electric or magnetic dipole receiver(s); sources and receivers are directed along the p...
f13202:m2
def gpr(src, rec, depth, res, freqtime, cf, gain=None, ab=<NUM_LIT:11>, aniso=None,<EOL>epermH=None, epermV=None, mpermH=None, mpermV=None, xdirect=False,<EOL>ht='<STR_LIT>', htarg=None, ft='<STR_LIT>', ftarg=None, opt=None, loop=None,<EOL>verb=<NUM_LIT:2>):
if verb > <NUM_LIT:2>:<EOL><INDENT>print("<STR_LIT>")<EOL>print("<STR_LIT>" + str(cf))<EOL>print("<STR_LIT>" + str(gain))<EOL><DEDENT>time, freq, ft, ftarg = check_time(freqtime, <NUM_LIT:0>, ft, ftarg, verb)<EOL>EM = dipole(src, rec, depth, res, freq, None, ab, aniso, epermH, epermV,<EOL>mpermH, mpermV, xdirect, ht, h...
r"""Return the Ground-Penetrating Radar signal. THIS FUNCTION IS EXPERIMENTAL, USE WITH CAUTION. It is rather an example how you can calculate GPR responses; however, DO NOT RELY ON IT! It works only well with QUAD or QWE (``quad``, ``qwe``) for the Hankel transform, and with FFT (``fft``) for the Fou...
f13202:m3
def dipole_k(src, rec, depth, res, freq, wavenumber, ab=<NUM_LIT:11>, aniso=None,<EOL>epermH=None, epermV=None, mpermH=None, mpermV=None, verb=<NUM_LIT:2>):
<EOL>t0 = printstartfinish(verb)<EOL>modl = check_model(depth, res, aniso, epermH, epermV, mpermH, mpermV,<EOL>False, verb)<EOL>depth, res, aniso, epermH, epermV, mpermH, mpermV, _ = modl<EOL>f = check_frequency(freq, res, aniso, epermH, epermV, mpermH, mpermV, verb)<EOL>freq, etaH, etaV, zetaH, zetaV = f<EOL>ab_calc, ...
r"""Return the electromagnetic wavenumber-domain field. Calculate the electromagnetic wavenumber-domain field due to infinitesimal small electric or magnetic dipole source(s), measured by infinitesimal small electric or magnetic dipole receiver(s); sources and receivers are directed along the principal...
f13202:m4
def wavenumber(src, rec, depth, res, freq, wavenumber, ab=<NUM_LIT:11>, aniso=None,<EOL>epermH=None, epermV=None, mpermH=None, mpermV=None, verb=<NUM_LIT:2>):
<EOL>mesg = ("<STR_LIT>" +<EOL>"<STR_LIT>")<EOL>warnings.warn(mesg, DeprecationWarning)<EOL>return dipole_k(src, rec, depth, res, freq, wavenumber, ab, aniso, epermH,<EOL>epermV, mpermH, mpermV, verb)<EOL>
r"""Depreciated. Use `dipole_k` instead.
f13202:m5
def fem(ab, off, angle, zsrc, zrec, lsrc, lrec, depth, freq, etaH, etaV, zetaH,<EOL>zetaV, xdirect, isfullspace, ht, htarg, use_ne_eval, msrc, mrec,<EOL>loop_freq, loop_off, conv=True):
<EOL>fEM = np.zeros((freq.size, off.size), dtype=complex)<EOL>kcount = <NUM_LIT:0><EOL>if ab in [<NUM_LIT>, ]:<EOL><INDENT>return fEM, kcount, conv<EOL><DEDENT>if xdirect and (isfullspace or lsrc == lrec):<EOL><INDENT>fEM += kernel.fullspace(off, angle, zsrc, zrec, etaH[:, lrec],<EOL>etaV[:, lrec], zetaH[:, lrec], zeta...
r"""Return the electromagnetic frequency-domain response. This function is called from one of the above modelling routines. No input-check is carried out here. See the main description of :mod:`model` for information regarding input and output parameters. This function can be directly used if you are ...
f13202:m6
def tem(fEM, off, freq, time, signal, ft, ftarg, conv=True):
<EOL>if signal in [-<NUM_LIT:1>, <NUM_LIT:1>]:<EOL><INDENT>fact = signal/(<NUM_LIT>*np.pi*freq)<EOL><DEDENT>else:<EOL><INDENT>fact = <NUM_LIT:1><EOL><DEDENT>tEM = np.zeros((time.size, off.size))<EOL>for i in range(off.size):<EOL><INDENT>out = getattr(transform, ft)(fEM[:, i]*fact, time, freq, ftarg)<EOL>tEM[:, i] += ou...
r"""Return the time-domain response of the frequency-domain response fEM. This function is called from one of the above modelling routines. No input-check is carried out here. See the main description of :mod:`model` for information regarding input and output parameters. This function can be directly ...
f13202:m7
def fht(zsrc, zrec, lsrc, lrec, off, factAng, depth, ab, etaH, etaV, zetaH,<EOL>zetaV, xdirect, fhtarg, use_ne_eval, msrc, mrec):
<EOL>fhtfilt = fhtarg[<NUM_LIT:0>]<EOL>pts_per_dec = fhtarg[<NUM_LIT:1>]<EOL>lambd = fhtarg[<NUM_LIT:2>]<EOL>int_pts = fhtarg[<NUM_LIT:3>]<EOL>PJ = kernel.wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH,<EOL>zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval)<EOL>fEM = dlf(PJ, lambd, off, fhtfilt, pts_per_d...
r"""Hankel Transform using the Digital Linear Filter method. The *Digital Linear Filter* method was introduced to geophysics by [Ghos70]_, and made popular and wide-spread by [Ande75]_, [Ande79]_, [Ande82]_. The DLF is sometimes referred to as the *Fast Hankel Transform* FHT, from which this routine ha...
f13203:m0
def hqwe(zsrc, zrec, lsrc, lrec, off, factAng, depth, ab, etaH, etaV, zetaH,<EOL>zetaV, xdirect, qweargs, use_ne_eval, msrc, mrec):
<EOL>etaH = etaH[<NUM_LIT:0>, :]<EOL>etaV = etaV[<NUM_LIT:0>, :]<EOL>zetaH = zetaH[<NUM_LIT:0>, :]<EOL>zetaV = zetaV[<NUM_LIT:0>, :]<EOL>rtol, atol, nquad, maxint, pts_per_dec = qweargs[:<NUM_LIT:5>]<EOL>g_x, g_w = special.p_roots(nquad)<EOL>b_zero = np.pi*np.arange(<NUM_LIT>, maxint+<NUM_LIT:1>)<EOL>for i in range(<NU...
r"""Hankel Transform using Quadrature-With-Extrapolation. *Quadrature-With-Extrapolation* was introduced to geophysics by [Key12]_. It is one of many so-called *ISE* methods to solve Hankel Transforms, where *ISE* stands for Integration, Summation, and Extrapolation. Following [Key12]_, but withou...
f13203:m1
def hquad(zsrc, zrec, lsrc, lrec, off, factAng, depth, ab, etaH, etaV, zetaH,<EOL>zetaV, xdirect, quadargs, use_ne_eval, msrc, mrec):
<EOL>rtol, atol, limit, a, b, pts_per_dec = quadargs<EOL>la = np.log10(a)<EOL>lb = np.log10(b)<EOL>ilambd = np.logspace(la, lb, (lb-la)*pts_per_dec + <NUM_LIT:1>)<EOL>PJ0, PJ1, PJ0b = kernel.wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH,<EOL>etaV, zetaH, zetaV,<EOL>np.atleast_2d(ilambd), ab, xdirect,<EOL>msrc, mrec, u...
r"""Hankel Transform using the ``QUADPACK`` library. This routine uses the ``scipy.integrate.quad`` module, which in turn makes use of the Fortran library ``QUADPACK`` (``qagse``). It is massively (orders of magnitudes) slower than either ``fht`` or ``hqwe``, and is mainly here for completeness and co...
f13203:m2
def ffht(fEM, time, freq, ftarg):
<EOL>ffhtfilt = ftarg[<NUM_LIT:0>]<EOL>pts_per_dec = ftarg[<NUM_LIT:1>]<EOL>kind = ftarg[<NUM_LIT:2>] <EOL>if pts_per_dec == <NUM_LIT:0>:<EOL><INDENT>fEM = fEM.reshape(time.size, -<NUM_LIT:1>)<EOL><DEDENT>tEM = dlf(fEM, <NUM_LIT:2>*np.pi*freq, time, ffhtfilt, pts_per_dec, kind=kind)<EOL>return tEM, True<EOL>
r"""Fourier Transform using the Digital Linear Filter method. It follows the Filter methodology [Ande75]_, using Cosine- and Sine-filters; see ``fht`` for more information. The function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a description of...
f13203:m3
def fqwe(fEM, time, freq, qweargs):
<EOL>rtol, atol, nquad, maxint, _, diff_quad, a, b, limit, sincos = qweargs<EOL>xint = np.concatenate((np.array([<NUM_LIT>]), np.arange(<NUM_LIT:1>, maxint+<NUM_LIT:1>)*np.pi))<EOL>if sincos == np.cos: <EOL><INDENT>xint[<NUM_LIT:1>:] -= np.pi/<NUM_LIT:2><EOL><DEDENT>intervals = xint/time[:, None]<EOL>g_x, g_w = specia...
r"""Fourier Transform using Quadrature-With-Extrapolation. It follows the QWE methodology [Key12]_ for the Hankel transform, see ``hqwe`` for more information. The function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a description of the input and...
f13203:m4
def fftlog(fEM, time, freq, ftarg):
<EOL>_, _, q, mu, tcalc, dlnr, kr, rk = ftarg<EOL>if mu > <NUM_LIT:0>: <EOL><INDENT>a = -fEM.imag<EOL><DEDENT>else: <EOL><INDENT>a = fEM.real<EOL><DEDENT>n = a.size<EOL>ln2kr = np.log(<NUM_LIT>/kr)<EOL>d = np.pi/(n*dlnr)<EOL>m = np.arange(<NUM_LIT:1>, (n+<NUM_LIT:1>)/<NUM_LIT:2>)<EOL>y = m*d <EOL>if q == <NUM_L...
r"""Fourier Transform using FFTLog. FFTLog is the logarithmic analogue to the Fast Fourier Transform FFT. FFTLog was presented in Appendix B of [Hami00]_ and published at <http://casa.colorado.edu/~ajsh/FFTLog>. This function uses a simplified version of ``pyfftlog``, which is a python-version of ...
f13203:m5
def fft(fEM, time, freq, ftarg):
<EOL>dfreq, nfreq, ntot, pts_per_dec = ftarg<EOL>if pts_per_dec:<EOL><INDENT>sfEMr = iuSpline(np.log(freq), fEM.real)<EOL>sfEMi = iuSpline(np.log(freq), fEM.imag)<EOL>freq = np.arange(<NUM_LIT:1>, nfreq+<NUM_LIT:1>)*dfreq<EOL>fEM = sfEMr(np.log(freq)) + <NUM_LIT>*sfEMi(np.log(freq))<EOL><DEDENT>fEM = np.pad(fEM, (<NUM_...
r"""Fourier Transform using the Fast Fourier Transform. The function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a description of the input and output parameters. Returns ------- tEM : array Returns time-domain EM response of ``fEM...
f13203:m6
def dlf(signal, points, out_pts, filt, pts_per_dec, kind=None, factAng=None,<EOL>ab=None, int_pts=None):
<EOL>if isinstance(signal, tuple):<EOL><INDENT>hankel = True<EOL>if factAng is None:<EOL><INDENT>has_angle_factors = False<EOL><DEDENT>else:<EOL><INDENT>one_angle = factAng.min() == factAng.max()<EOL>if one_angle:<EOL><INDENT>has_angle_factors = factAng[<NUM_LIT:0>] != <NUM_LIT:1.0><EOL>factAng = factAng[<NUM_LIT:0>]<E...
r"""Digital Linear Filter method. This is the kernel of the DLF method, used for the Hankel (``fht``) and the Fourier (``ffht``) Transforms. See ``fht`` for an extensive description. For the Hankel transform, `signal` contains 3 complex wavenumber-domain signals: (PJ0, PJ1, PJ0b), as returned from `ke...
f13203:m7
def qwe(rtol, atol, maxint, inp, intervals, lambd=None, off=None,<EOL>factAng=None):
def getweights(i, inpint):<EOL><INDENT>r"""<STR_LIT>"""<EOL>return (np.atleast_2d(inpint)[:, i+<NUM_LIT:1>] - np.atleast_2d(inpint)[:, i])/<NUM_LIT:2><EOL><DEDENT>if hasattr(inp, '<STR_LIT>'): <EOL><INDENT>EM0 = inp(<NUM_LIT:0>, lambd, off, factAng)<EOL><DEDENT>else: <EOL><INDENT>EM0 = inp[:, ...
r"""Quadrature-With-Extrapolation. This is the kernel of the QWE method, used for the Hankel (``hqwe``) and the Fourier (``fqwe``) Transforms. See ``hqwe`` for an extensive description. This function is based on ``qwe.m`` from the source code distributed with [Key12]_.
f13203:m8
def quad(sPJ0r, sPJ0i, sPJ1r, sPJ1i, sPJ0br, sPJ0bi, ab, off, factAng, iinp):
<EOL>def quad_PJ0(klambd, sPJ0, koff):<EOL><INDENT>r"""<STR_LIT>"""<EOL>return sPJ0(np.log(klambd))*special.j0(koff*klambd)<EOL><DEDENT>def quad_PJ1(klambd, sPJ1, ab, koff, kang):<EOL><INDENT>r"""<STR_LIT>"""<EOL>tP1 = kang*sPJ1(np.log(klambd))<EOL>if ab in [<NUM_LIT:11>, <NUM_LIT:12>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, ...
r"""Quadrature for Hankel transform. This is the kernel of the QUAD method, used for the Hankel transforms ``hquad`` and ``hqwe`` (where the integral is not suited for QWE).
f13203:m9
def get_spline_values(filt, inp, nr_per_dec=None):
<EOL>if nr_per_dec == <NUM_LIT:0>:<EOL><INDENT>return filt.base/inp[:, None], inp<EOL><DEDENT>outmax = filt.base[-<NUM_LIT:1>]/inp.min()<EOL>outmin = filt.base[<NUM_LIT:0>]/inp.max()<EOL>if nr_per_dec < <NUM_LIT:0>: <EOL><INDENT>pts_per_dec = <NUM_LIT:1>/np.log(filt.factor)<EOL>nout = int(np.ceil(np.log(outmax/outmin)...
r"""Return required calculation points.
f13203:m10
def fhti(rmin, rmax, n, q, mu):
<EOL>logrc = (rmin + rmax)/<NUM_LIT:2><EOL>nc = (n + <NUM_LIT:1>)/<NUM_LIT><EOL>dlogr = (rmax - rmin)/n<EOL>dlnr = dlogr*np.log(<NUM_LIT>)<EOL>y = <NUM_LIT>*np.pi/(<NUM_LIT>*dlnr)<EOL>zp = special.loggamma((mu + <NUM_LIT:1.0> + q)/<NUM_LIT> + y)<EOL>zm = special.loggamma((mu + <NUM_LIT:1.0> - q)/<NUM_LIT> + y)<EOL>arg ...
r"""Return parameters required for FFTLog.
f13203:m11
def kong_61_2007():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>,...
r"""Kong 61 pt Hankel filter, as published in [Kong07]_. Taken from file ``FilterModules.f90`` provided with 1DCSEM_. License: `Apache License, Version 2.0, <http://www.apache.org/licenses/LICENSE-2.0>`_.
f13204:m0
def kong_241_2007():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>,...
r"""Kong 241 pt Hankel filter, as published in [Kong07]_. Taken from file ``FilterModules.f90`` provided with 1DCSEM_. License: `Apache License, Version 2.0, <http://www.apache.org/licenses/LICENSE-2.0>`_.
f13204:m1
def key_101_2009():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, ...
r"""Key 101 pt Hankel filter, as published in [Key09]_. Taken from file ``FilterModules.f90`` provided with 1DCSEM_. License: `Apache License, Version 2.0, <http://www.apache.org/licenses/LICENSE-2.0>`_.
f13204:m2
def key_201_2009():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, ...
r"""Key 201 pt Hankel filter, as published in [Key09]_. Taken from file ``FilterModules.f90`` provided with 1DCSEM_. License: `Apache License, Version 2.0, <http://www.apache.org/licenses/LICENSE-2.0>`_.
f13204:m3
def key_401_2009():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, ...
r"""Key 401 pt Hankel filter, as published in [Key09]_. Taken from file ``FilterModules.f90`` provided with 1DCSEM_. License: `Apache License, Version 2.0, <http://www.apache.org/licenses/LICENSE-2.0>`_.
f13204:m4
def anderson_801_1982():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, ...
r"""Anderson 801 pt Hankel filter, as published in [Ande82]_. Taken from file ``wa801Hankel.txt`` provided with SEG-2012-003_. License: http://software.seg.org/disclaimer.txt.
f13204:m5
def key_51_2012():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, ...
r"""Key 51 pt Hankel filter, as published in [Key12]_. Taken from file ``kk51Hankel.txt`` provided with SEG-2012-003_. License: http://software.seg.org/disclaimer.txt.
f13204:m6
def key_101_2012():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, ...
r"""Key 101 pt Hankel filter, as published in [Key12]_. Taken from file ``kk101Hankel.txt`` provided with SEG-2012-003_. License: http://software.seg.org/disclaimer.txt.
f13204:m7
def key_201_2012():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, ...
r"""Key 201 pt Hankel filter, as published in [Key12]_. Taken from file ``kk201Hankel.txt`` provided with SEG-2012-003_. License: http://software.seg.org/disclaimer.txt.
f13204:m8
def wer_201_2018():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>,...
r"""Werthmüller 201 pt Hankel filter, 2018. Designed with the empymod add-on ``fdesign``, see https://github.com/empymod/article-fdesign. License: `Apache License, Version 2.0, <http://www.apache.org/licenses/LICENSE-2.0>`_.
f13204:m9
def key_81_CosSin_2009():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_...
r"""Key 81 pt CosSin filter, as published in [Key09]_. Taken from file ``FilterModules.f90`` provided with 1DCSEM_. License: `Apache License, Version 2.0, <http://www.apache.org/licenses/LICENSE-2.0>`_.
f13204:m10
def key_241_CosSin_2009():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_...
r"""Key 241 pt CosSin filter, as published in [Key09]_. Taken from file ``FilterModules.f90`` provided with 1DCSEM_. License: `Apache License, Version 2.0, <http://www.apache.org/licenses/LICENSE-2.0>`_.
f13204:m11
def key_601_CosSin_2009():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_...
r"""Key 601 pt CosSin filter, as published in [Key09]_. Taken from file ``FilterModules.f90`` provided with 1DCSEM_. License: `Apache License, Version 2.0, <http://www.apache.org/licenses/LICENSE-2.0>`_.
f13204:m12
def key_101_CosSin_2012():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, ...
r"""Key 101 pt CosSin filter, as published in [Key12]_. Taken from file ``kk101CosSin.txt`` provided with SEG-2012-003_. License: http://software.seg.org/disclaimer.txt.
f13204:m13
def key_201_CosSin_2012():
dlf = DigitalFilter('<STR_LIT>', '<STR_LIT>')<EOL>dlf.base = np.array([<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT>, ...
r"""Key 201 pt CosSin filter, as published in [Key12]_. Taken from file ``kk201CosSin.txt`` provided with SEG-2012-003_. License: http://software.seg.org/disclaimer.txt.
f13204:m14
def __init__(self, name, savename=None):
self.name = name<EOL>if savename is None:<EOL><INDENT>self.savename = name<EOL><DEDENT>else:<EOL><INDENT>self.savename = savename<EOL><DEDENT>
r"""Add filter name.
f13204:c0:m0
def tofile(self, path='<STR_LIT>'):
<EOL>name = self.savename<EOL>path = os.path.abspath(path)<EOL>os.makedirs(path, exist_ok=True)<EOL>basefile = os.path.join(path, name + '<STR_LIT>')<EOL>with open(basefile, '<STR_LIT:w>') as f:<EOL><INDENT>self.base.tofile(f, sep="<STR_LIT:\n>")<EOL><DEDENT>for val in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>...
r"""Save filter values to ascii-files. Store the filter base and the filter coefficients in separate files in the directory `path`; `path` can be a relative or absolute path. Examples -------- >>> import empymod >>> # Load a filter >>> filt = empymod.filters.wer...
f13204:c0:m1
def fromfile(self, path='<STR_LIT>'):
<EOL>name = self.savename<EOL>path = os.path.abspath(path)<EOL>basefile = os.path.join(path, name + '<STR_LIT>')<EOL>with open(basefile, '<STR_LIT:r>') as f:<EOL><INDENT>self.base = np.fromfile(f, sep="<STR_LIT:\n>")<EOL><DEDENT>for val in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>attrfile = os....
r"""Load filter values from ascii-files. Load filter base and filter coefficients from ascii files in the directory `path`; `path` can be a relative or absolute path. Examples -------- >>> import empymod >>> # Create an empty filter; >>> # Name has to be the bas...
f13204:c0:m2
def wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd,<EOL>ab, xdirect, msrc, mrec, use_ne_eval):
<EOL>PTM, PTE = greenfct(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH,<EOL>zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval)<EOL>PJ0 = None<EOL>PJ1 = None<EOL>PJ0b = None<EOL>Ptot = (PTM + PTE)/(<NUM_LIT:4>*np.pi)<EOL>if mrec:<EOL><INDENT>sign = -<NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>sign = <NUM_LIT:1><EOL><D...
r"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the frequency domain. ``PJ0``/``PJ0b`` and ``PJ1`` have to be transformed with Bessel functions of order 0 (:math:`J_0`) and 1 (:math:...
f13205:m0
def greenfct(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd,<EOL>ab, xdirect, msrc, mrec, use_ne_eval):
<EOL>if mrec:<EOL><INDENT>if msrc: <EOL><INDENT>etaH, zetaH = -zetaH, -etaH<EOL>etaV, zetaV = -zetaV, -etaV<EOL><DEDENT>else: <EOL><INDENT>zsrc, zrec = zrec, zsrc<EOL>lsrc, lrec = lrec, lsrc<EOL><DEDENT><DEDENT>for TM in [True, False]:<EOL><INDENT>if TM and ab in [<NUM_LIT:16>, <NUM_LIT>]:<EOL><INDENT>continue<EOL><D...
r"""Calculate Green's function for TM and TE. .. math:: \tilde{g}^{tm}_{hh}, \tilde{g}^{tm}_{hz}, \tilde{g}^{tm}_{zh}, \tilde{g}^{tm}_{zz}, \tilde{g}^{te}_{hh}, \tilde{g}^{te}_{zz} This function corresponds to equations 108--110, 117/118, 122; 89--94, A18--A23, B13--B15; 97--10...
f13205:m1
def reflections(depth, e_zH, Gam, lrec, lsrc, use_ne_eval):
<EOL>for plus in [True, False]:<EOL><INDENT>if plus:<EOL><INDENT>pm = <NUM_LIT:1><EOL>layer_count = np.arange(depth.size-<NUM_LIT:2>, min(lrec, lsrc)-<NUM_LIT:1>, -<NUM_LIT:1>)<EOL>izout = abs(lsrc-lrec)<EOL>minmax = max(lrec, lsrc)<EOL><DEDENT>else:<EOL><INDENT>pm = -<NUM_LIT:1><EOL>layer_count = np.arange(<NUM_LIT:1>...
r"""Calculate Rp, Rm. .. math:: R^\pm_n, \bar{R}^\pm_n This function corresponds to equations 64/65 and A-11/A-12 in [HuTS15]_, and loosely to the corresponding files ``Rmin.F90`` and ``Rplus.F90``. This function is called from the function :mod:`kernel.greenfct`.
f13205:m2
def fields(depth, Rp, Rm, Gam, lrec, lsrc, zsrc, ab, TM, use_ne_eval):
<EOL>nlsr = abs(lsrc-lrec)+<NUM_LIT:1> <EOL>rsrcl = <NUM_LIT:0> <EOL>izrange = range(<NUM_LIT:2>, nlsr)<EOL>isr = lsrc<EOL>last = depth.size-<NUM_LIT:1><EOL>first_layer = lsrc == <NUM_LIT:0><EOL>last_layer = lsrc == depth.size-<NUM_LIT:1><EOL>if lsrc != depth.size-<NUM_LIT:1>:<EOL><INDENT>ds = depth[lsrc+<NUM_LIT:1>]...
r"""Calculate Pu+, Pu-, Pd+, Pd-. .. math:: P^{u\pm}_s, P^{d\pm}_s, \bar{P}^{u\pm}_s, \bar{P}^{d\pm}_s; P^{u\pm}_{s-1}, P^{u\pm}_n, \bar{P}^{u\pm}_{s-1}, \bar{P}^{u\pm}_n; P^{d\pm}_{s+1}, P^{d\pm}_n, \bar{P}^{d\pm}_{s+1}, \bar{P}^{d\pm}_n This function corresponds to equations 81/82, 95/96...
f13205:m3
def angle_factor(angle, ab, msrc, mrec):
<EOL>if ab in [<NUM_LIT>, ]:<EOL><INDENT>return np.ones(angle.size)<EOL><DEDENT>eval_angle = angle.copy()<EOL>if mrec and not msrc:<EOL><INDENT>eval_angle += np.pi<EOL><DEDENT>if ab in [<NUM_LIT:11>, <NUM_LIT>, <NUM_LIT:15>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>]:<EOL><INDENT>fct = np.cos<EOL>test_ang_1...
r"""Return the angle-dependent factor. The whole calculation in the wavenumber domain is only a function of the distance between the source and the receiver, it is independent of the angel. The angle-dependency is this factor, which can be applied to the corresponding parts in the wavenumber or in the ...
f13205:m4
def fullspace(off, angle, zsrc, zrec, etaH, etaV, zetaH, zetaV, ab, msrc,<EOL>mrec):
xco = np.cos(angle)*off<EOL>yco = np.sin(angle)*off<EOL>if mrec:<EOL><INDENT>if msrc: <EOL><INDENT>etaH, zetaH = -zetaH, -etaH<EOL>etaV, zetaV = -zetaV, -etaV<EOL><DEDENT>else: <EOL><INDENT>xco *= -<NUM_LIT:1><EOL>yco *= -<NUM_LIT:1><EOL>zsrc, zrec = zrec, zsrc<EOL><DEDENT><DEDENT>if ab not in [<NUM_LIT:16>, <NUM_LIT...
r"""Analytical full-space solutions in the frequency domain. .. math:: \hat{G}^{ee}_{\alpha\beta}, \hat{G}^{ee}_{3\alpha}, \hat{G}^{ee}_{33}, \hat{G}^{em}_{\alpha\beta}, \hat{G}^{em}_{\alpha 3} This function corresponds to equations 45--50 in [HuTS15]_, and loosely to the corre...
f13205:m5
def halfspace(off, angle, zsrc, zrec, etaH, etaV, freqtime, ab, signal,<EOL>solution='<STR_LIT>'):
xco = np.cos(angle)*off<EOL>yco = np.sin(angle)*off<EOL>res = np.real(<NUM_LIT:1>/etaH[<NUM_LIT:0>, <NUM_LIT:0>])<EOL>aniso = <NUM_LIT:1>/np.sqrt(np.real(etaV[<NUM_LIT:0>, <NUM_LIT:0>])*res)<EOL>if signal is None:<EOL><INDENT>freq = freqtime<EOL>dtype = complex<EOL><DEDENT>else:<EOL><INDENT>time = freqtime<EOL>if signa...
r"""Return frequency- or time-space domain VTI half-space solution. Calculates the frequency- or time-space domain electromagnetic response for a half-space below air using the diffusive approximation, as given in [SlHM10]_, where the electric source is located at [0, 0, zsrc], and the electric receive...
f13205:m6
def check_ab(ab, verb):
<EOL>try:<EOL><INDENT>ab = int(ab)<EOL><DEDENT>except VariableCatch:<EOL><INDENT>print('<STR_LIT>')<EOL>raise<EOL><DEDENT>pab = [<NUM_LIT:11>, <NUM_LIT:12>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT:15>, <NUM_LIT:16>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>,<EOL><NUM_LIT>, <NUM_LIT:32>, <NUM_LIT>, <NUM_LI...
r"""Check source-receiver configuration. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ab : int Source-receiver configuration. verb : {0, ...
f13207:m0
def check_bipole(inp, name):
def chck_dipole(inp, name):<EOL><INDENT>r"""<STR_LIT>"""<EOL>inp[<NUM_LIT:0>] = _check_var(inp[<NUM_LIT:0>], float, <NUM_LIT:1>, name+'<STR_LIT>')<EOL>inp[<NUM_LIT:1>] = _check_var(inp[<NUM_LIT:1>], float, <NUM_LIT:1>, name+'<STR_LIT>', inp[<NUM_LIT:0>].shape)<EOL>inp[<NUM_LIT:2>] = _check_var(inp[<NUM_LIT:2>], float, ...
r"""Check di-/bipole parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- inp : list of floats or arrays Coordinates of inp (m): ...
f13207:m1
def check_dipole(inp, name, verb):
<EOL>_check_shape(np.squeeze(inp), name, (<NUM_LIT:3>,))<EOL>inp[<NUM_LIT:0>] = _check_var(inp[<NUM_LIT:0>], float, <NUM_LIT:1>, name+'<STR_LIT>')<EOL>inp[<NUM_LIT:1>] = _check_var(inp[<NUM_LIT:1>], float, <NUM_LIT:1>, name+'<STR_LIT>', inp[<NUM_LIT:0>].shape)<EOL>inp[<NUM_LIT:2>] = _check_var(inp[<NUM_LIT:2>], float, ...
r"""Check dipole parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- inp : list of floats or arrays Pole coordinates (m): [pole-x, pole-...
f13207:m2
def check_frequency(freq, res, aniso, epermH, epermV, mpermH, mpermV, verb):
global _min_freq<EOL>if isinstance(res, dict):<EOL><INDENT>res = res['<STR_LIT>']<EOL><DEDENT>freq = _check_var(freq, float, <NUM_LIT:1>, '<STR_LIT>')<EOL>freq = _check_min(freq, _min_freq, '<STR_LIT>', '<STR_LIT>', verb)<EOL>if verb > <NUM_LIT:2>:<EOL><INDENT>_prnt_min_max_val(freq, "<STR_LIT>", verb)<EOL><DEDENT>c = ...
r"""Calculate frequency-dependent parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- freq : array_like Frequencies f (Hz). res : a...
f13207:m3
def check_hankel(ht, htarg, verb):
<EOL>ht = ht.lower()<EOL>if ht == '<STR_LIT>': <EOL><INDENT>htarg = _check_targ(htarg, ['<STR_LIT>', '<STR_LIT>'])<EOL>try:<EOL><INDENT>fhtfilt = htarg['<STR_LIT>']<EOL>if not hasattr(fhtfilt, '<STR_LIT>'):<EOL><INDENT>fhtfilt = getattr(filters, fhtfilt)()<EOL><DEDENT><DEDENT>except VariableCatch:<EOL><INDENT>fhtfil...
r"""Check Hankel transform parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ht : {'fht', 'qwe', 'quad'} Flag to choose the Hankel tra...
f13207:m4
def check_model(depth, res, aniso, epermH, epermV, mpermH, mpermV, xdirect,<EOL>verb):
global _min_res<EOL>if depth is None:<EOL><INDENT>depth = []<EOL><DEDENT>depth = _check_var(depth, float, <NUM_LIT:1>, '<STR_LIT>')<EOL>if depth.size == <NUM_LIT:0>:<EOL><INDENT>depth = np.array([-np.infty, ])<EOL><DEDENT>elif depth[<NUM_LIT:0>] != -np.infty:<EOL><INDENT>depth = np.insert(depth, <NUM_LIT:0>, -np.infty)...
r"""Check the model: depth and corresponding layer parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- depth : list Absolute layer inter...
f13207:m5
def check_opt(opt, loop, ht, htarg, verb):
<EOL>use_ne_eval = False<EOL>if opt == '<STR_LIT>':<EOL><INDENT>if numexpr:<EOL><INDENT>use_ne_eval = numexpr.evaluate<EOL><DEDENT>elif verb > <NUM_LIT:0>:<EOL><INDENT>print(numexpr_msg)<EOL><DEDENT><DEDENT>lagged_splined_fht = False<EOL>if ht == '<STR_LIT>':<EOL><INDENT>if htarg[<NUM_LIT:1>] != <NUM_LIT:0>:<EOL><INDEN...
r"""Check optimization parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- opt : {None, 'parallel'} Optimization flag; use ``numexpr`` o...
f13207:m6
def check_time(time, signal, ft, ftarg, verb):
<EOL>time = check_time_only(time, signal, verb)<EOL>ft = ft.lower()<EOL>if ft in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']: <EOL><INDENT>if ft == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>ft = ftarg[<NUM_LIT:2>]<EOL><DEDENT>except VariableCatch:<EOL><INDENT>ft = '<STR_LIT>'<EOL><DEDENT><DEDENT>if signal > <NUM_LIT:0>:<E...
r"""Check time domain specific input parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- time : array_like Times t (s). signal : {N...
f13207:m7
def check_time_only(time, signal, verb):
global _min_time<EOL>if int(signal) not in [-<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1>]:<EOL><INDENT>print("<STR_LIT>" +<EOL>"<STR_LIT>"+str(signal))<EOL>raise ValueError('<STR_LIT>')<EOL><DEDENT>time = _check_var(time, float, <NUM_LIT:1>, '<STR_LIT:time>')<EOL>time = _check_min(time, _min_time, '<STR_LIT>', '<STR_LIT:s>',...
r"""Check time and signal parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- time : array_like Times t (s). signal : {None, 0, 1, ...
f13207:m8
def check_solution(solution, signal, ab, msrc, mrec):
<EOL>if solution not in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>print("<STR_LIT>" +<EOL>"<STR_LIT>" + solution)<EOL>raise ValueError('<STR_LIT>')<EOL><DEDENT>if solution[<NUM_LIT:0>] == '<STR_LIT:d>' and (msrc or mrec):<EOL><INDENT>print('<STR_LIT>' +<EOL>'<STR_LIT>' +<EOL>str(ab)...
r"""Check required solution with parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- solution : str String to define analytical solution....
f13207:m9
def get_abs(msrc, mrec, srcazm, srcdip, recazm, recdip, verb):
<EOL>ab_calc = np.array([[<NUM_LIT:11>, <NUM_LIT:12>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT:32>, <NUM_LIT>]])<EOL>if msrc:<EOL><INDENT>ab_calc += <NUM_LIT:3><EOL><DEDENT>if mrec:<EOL><INDENT>ab_calc += <NUM_LIT:30><EOL>if msrc:<EOL><INDENT>ab_calc -= <NUM_LIT> <EOL><DEDENT>else:<EOL><INDE...
r"""Get required ab's for given angles. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- msrc, mrec : bool True if src/rec is magnetic, else Fals...
f13207:m10
def get_geo_fact(ab, srcazm, srcdip, recazm, recdip, msrc, mrec):
global _min_angle<EOL>fis = ab % <NUM_LIT:10><EOL>fir = ab // <NUM_LIT:10><EOL>if mrec and not msrc:<EOL><INDENT>fis, fir = fir, fis<EOL><DEDENT>def gfact(bp, azm, dip):<EOL><INDENT>r"""<STR_LIT>"""<EOL>if bp in [<NUM_LIT:1>, <NUM_LIT:4>]: <EOL><INDENT>return np.cos(azm)*np.cos(dip)<EOL><DEDENT>elif bp in [<NUM_LIT:...
r"""Get required geometrical scaling factor for given angles. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- ab : int Source-receiver configura...
f13207:m11
def get_layer_nr(inp, depth):
zinp = inp[<NUM_LIT:2>]<EOL>pdepth = np.concatenate((depth[<NUM_LIT:1>:], np.array([np.infty])))<EOL>b_zinp = np.atleast_1d(zinp)[:, None]<EOL>linp = np.where((depth[None, :] < b_zinp)*(pdepth[None, :] >= b_zinp))[<NUM_LIT:1>]<EOL>return np.squeeze(linp), zinp<EOL>
r"""Get number of layer in which inp resides. Note: If zinp is on a layer interface, the layer above the interface is chosen. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. ...
f13207:m12
def get_off_ang(src, rec, nsrc, nrec, verb):
global _min_off<EOL>off = np.empty((nrec*nsrc,))<EOL>angle = np.empty((nrec*nsrc,))<EOL>for i in range(nsrc):<EOL><INDENT>xco = rec[<NUM_LIT:0>] - src[<NUM_LIT:0>][i] <EOL>yco = rec[<NUM_LIT:1>] - src[<NUM_LIT:1>][i] <EOL>off[i*nrec:(i+<NUM_LIT:1>)*nrec] = np.sqrt(xco*xco + yco*yco) <EOL>angle[i*nrec:(i+<NUM_LIT:1>)...
r"""Get depths, offsets, angles, hence spatial input parameters. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- src, rec : list of floats or arrays ...
f13207:m13
def get_azm_dip(inp, iz, ninpz, intpts, isdipole, strength, name, verb):
global _min_off<EOL>if ninpz == <NUM_LIT:1>: <EOL><INDENT>tinp = inp<EOL><DEDENT>else: <EOL><INDENT>if isdipole:<EOL><INDENT>tinp = [np.atleast_1d(inp[<NUM_LIT:0>][iz]), np.atleast_1d(inp[<NUM_LIT:1>][iz]),<EOL>np.atleast_1d(inp[<NUM_LIT:2>][iz]), np.atleast_1d(inp[<NUM_LIT:3>]),<EOL>np.atleast_1d(inp[<NUM_LIT:4>])]<...
r"""Get angles, interpolation weights and normalization weights. This check-function is called from one of the modelling routines in :mod:`model`. Consult these modelling routines for a detailed description of the input parameters. Parameters ---------- inp : list of floats or arrays ...
f13207:m14
def printstartfinish(verb, inp=None, kcount=None):
if inp:<EOL><INDENT>if verb > <NUM_LIT:1>:<EOL><INDENT>ttxt = str(timedelta(seconds=default_timer() - inp))<EOL>ktxt = '<STR_LIT:U+0020>'<EOL>if kcount:<EOL><INDENT>ktxt += str(kcount) + '<STR_LIT>'<EOL><DEDENT>print('<STR_LIT>' + ttxt + '<STR_LIT>' + ktxt + '<STR_LIT:\n>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>t0 = de...
r"""Print start and finish with time measure and kernel count.
f13207:m15
def conv_warning(conv, targ, name, verb):
if verb > <NUM_LIT:0> and not conv:<EOL><INDENT>print('<STR_LIT>' + name +<EOL>'<STR_LIT>' +<EOL>'<STR_LIT>')<EOL><DEDENT>
r"""Print error if QWE/QUAD did not converge at least once.
f13207:m16
def set_minimum(min_freq=None, min_time=None, min_off=None, min_res=None,<EOL>min_angle=None):
global _min_freq, _min_time, _min_off, _min_res, _min_angle<EOL>if min_freq is not None:<EOL><INDENT>_min_freq = min_freq<EOL><DEDENT>if min_time is not None:<EOL><INDENT>_min_time = min_time<EOL><DEDENT>if min_off is not None:<EOL><INDENT>_min_off = min_off<EOL><DEDENT>if min_res is not None:<EOL><INDENT>_min_res = mi...
r""" Set minimum values of parameters. The given parameters are set to its minimum value if they are smaller. Parameters ---------- min_freq : float, optional Minimum frequency [Hz] (default 1e-20 Hz). min_time : float, optional Minimum time [s] (default 1e-20 s). min_off :...
f13207:m17
def get_minimum():
d = dict(min_freq=_min_freq,<EOL>min_time=_min_time,<EOL>min_off=_min_off,<EOL>min_res=_min_res,<EOL>min_angle=_min_angle)<EOL>return d<EOL>
r""" Return the current minimum values. Returns ------- min_vals : dict Dictionary of current minimum values with keys - min_freq : float - min_time : float - min_off : float - min_res : float - min_angle : float For a full description...
f13207:m18
def _check_shape(var, name, shape, shape2=None):
varshape = np.shape(var)<EOL>if shape != varshape:<EOL><INDENT>if shape2:<EOL><INDENT>if shape2 != varshape:<EOL><INDENT>print('<STR_LIT>' + name + '<STR_LIT>' +<EOL>'<STR_LIT>' + str(varshape) + '<STR_LIT>' + str(shape) +<EOL>'<STR_LIT>' + str(shape2) + '<STR_LIT:.>')<EOL>raise ValueError(name)<EOL><DEDENT><DEDENT>els...
r"""Check that <var> has shape <shape>; if false raise ValueError(name)
f13207:m19
def _check_var(var, dtype, ndmin, name, shape=None, shape2=None):
if var is None:<EOL><INDENT>raise ValueError<EOL><DEDENT>var = np.array(var, dtype=dtype, copy=True, ndmin=ndmin)<EOL>if shape:<EOL><INDENT>_check_shape(var, name, shape, shape2)<EOL><DEDENT>return var<EOL>
r"""Return variable as array of dtype, ndmin; shape-checked.
f13207:m20
def _strvar(a, prec='<STR_LIT>'):
return '<STR_LIT:U+0020>'.join([prec.format(i) for i in np.atleast_1d(a)])<EOL>
r"""Return variable as a string to print, with given precision.
f13207:m21
def _prnt_min_max_val(var, text, verb):
if var.size > <NUM_LIT:3>:<EOL><INDENT>print(text, _strvar(var.min()), "<STR_LIT:->", _strvar(var.max()),<EOL>"<STR_LIT::>", _strvar(var.size), "<STR_LIT>")<EOL>if verb > <NUM_LIT:3>:<EOL><INDENT>print("<STR_LIT>", _strvar(var))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print(text, _strvar(np.atleast_1d(var)))<EOL><DEDENT>
r"""Print variable; if more than three, just min/max, unless verb > 3.
f13207:m22
def _check_min(par, minval, name, unit, verb):
scalar = False<EOL>if par.shape == ():<EOL><INDENT>scalar = True<EOL>par = np.atleast_1d(par)<EOL><DEDENT>if minval is not None:<EOL><INDENT>ipar = np.where(par < minval)<EOL>par[ipar] = minval<EOL>if verb > <NUM_LIT:0> and np.size(ipar) != <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>' + name + '<STR_LIT>' + str(minval) +...
r"""Check minimum value of parameter.
f13207:m23
def _check_targ(targ, keys):
if not targ: <EOL><INDENT>targ = {}<EOL><DEDENT>elif not isinstance(targ, (list, tuple, dict)): <EOL><INDENT>targ = [targ, ]<EOL><DEDENT>if isinstance(targ, (list, tuple)): <EOL><INDENT>targ = {keys[i]: targ[i] for i in range(min(len(targ), len(keys)))}<EOL><DEDENT>return targ<EOL>
r"""Check format of htarg/ftarg and return dict.
f13207:m24
def spline_backwards_hankel(ht, htarg, opt):
<EOL>ht = ht.lower()<EOL>if ht in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>if ht == '<STR_LIT>':<EOL><INDENT>htarg = _check_targ(htarg, ['<STR_LIT>', '<STR_LIT>'])<EOL><DEDENT>elif ht in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>htarg = _check_targ(htarg, ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<E...
r"""Check opt if deprecated 'spline' is used. Returns corrected htarg, opt. r
f13207:m25
def __new__(cls, realpart, imagpart=None):
<EOL>if np.any(imagpart):<EOL><INDENT>obj = np.real(realpart) + <NUM_LIT>*np.real(imagpart)<EOL><DEDENT>else:<EOL><INDENT>obj = np.asarray(realpart, dtype=complex)<EOL><DEDENT>obj = np.atleast_1d(obj).view(cls)<EOL>obj.amp = np.abs(obj)<EOL>obj.pha = np.rad2deg(np.unwrap(np.angle(obj.real + <NUM_LIT>*obj.imag)))<EOL>re...
r"""Create a new EMArray.
f13207:c0:m0
def design(n, spacing, shift, fI, fC=False, r=None, r_def=(<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:2>), reim=None,<EOL>cvar='<STR_LIT>', error=<NUM_LIT>, name=None, full_output=False, finish=False,<EOL>save=True, path='<STR_LIT>', verb=<NUM_LIT:2>, plot=<NUM_LIT:1>):
<EOL>t0 = printstartfinish(verb)<EOL>if plot > <NUM_LIT:0> and not plt:<EOL><INDENT>plot = <NUM_LIT:0><EOL>if verb > <NUM_LIT:0>:<EOL><INDENT>print(plt_msg)<EOL><DEDENT><DEDENT>def check_f(f):<EOL><INDENT>if hasattr(f, '<STR_LIT:name>'): <EOL><INDENT>f = [f, ]<EOL><DEDENT>else: <EOL><INDENT>f = list(f)<EOL><DEDENT>re...
r"""Digital linear filter (DLF) design This routine can be used to design digital linear filters for the Hankel or Fourier transform, or for any linear transform ([Ghos70]_). For this included or provided theoretical transform pairs can be used. Alternatively, one can use the EM modeller empymod to use...
f13208:m0
def save_filter(name, filt, full=None, path='<STR_LIT>'):
<EOL>filt.tofile(path)<EOL>if full:<EOL><INDENT>path = os.path.abspath(path)<EOL>if len(name.split('<STR_LIT:.>')) == <NUM_LIT:2>:<EOL><INDENT>suffix = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>suffix = '<STR_LIT>'<EOL><DEDENT>fullfile = os.path.join(path, name.split('<STR_LIT:.>')[<NUM_LIT:0>]+'<STR_LIT>' + suffix)<EO...
r"""Save DLF-filter and inversion output to plain text files.
f13208:m1
def load_filter(name, full=False, path='<STR_LIT>'):
<EOL>filt = DigitalFilter(name.split('<STR_LIT:.>')[<NUM_LIT:0>])<EOL>filt.fromfile(path)<EOL>if full:<EOL><INDENT>try:<EOL><INDENT>path = os.path.abspath(path)<EOL>if len(name.split('<STR_LIT:.>')) == <NUM_LIT:2>:<EOL><INDENT>suffix = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>suffix = '<STR_LIT>'<EOL><DEDENT>fullfile ...
r"""Load saved DLF-filter and inversion output from text files.
f13208:m2
def plot_result(filt, full, prntres=True):
<EOL>if not plt:<EOL><INDENT>print(plt_msg)<EOL>return<EOL><DEDENT>if prntres:<EOL><INDENT>print_result(filt, full)<EOL><DEDENT>spacing = full[<NUM_LIT:2>][<NUM_LIT:0>, :, <NUM_LIT:0>]<EOL>shift = full[<NUM_LIT:2>][<NUM_LIT:1>, <NUM_LIT:0>, :]<EOL>minfield = np.squeeze(full[<NUM_LIT:3>])<EOL>plt.figure("<STR_LIT>", fig...
r"""QC the inversion result. Parameters ---------- - filt, full as returned from fdesign.design with full_output=True - If prntres is True, it calls fdesign.print_result as well. r
f13208:m3