2.14.4.5. pycsamt.emtools.lcurve#
Functions
|
Build an |
|
Build an |
|
Build an |
|
|
|
Classes
|
Misfit/roughness/lambda sweep extracted from a real inversion log. |
- pycsamt.emtools.lcurve.lcurve_table(misfit, rough, lam=None, *, sort='auto', method='curvature', smooth=3, skip=1, return_dict=False)[source]
- class pycsamt.emtools.lcurve.LCurveData(misfit, rough, lam, iterations, backend, source)[source]
Bases:
objectMisfit/roughness/lambda sweep extracted from a real inversion log.
misfit[i],rough[i],lam[i], anditerations[i]all describe the same iteration, so the arrays can be passed straight intolcurve_table()orplot_lcurve()– which is exactly whattable()andplot()do.- Parameters:
- misfit: ndarray
- rough: ndarray
- lam: ndarray
- iterations: ndarray
- backend: str
- source: Path
- pycsamt.emtools.lcurve.lcurve_from_occam2d(path, **kwargs)[source]
Build an
LCurveDatasweep from an Occam2D convergence log.Reads the per-iteration
LogFile.logfilewritten by the Occam2D Fortran binary withpycsamt.models.occam2d.log.OccamLog, which already parses accepted RMS misfit, roughness, and Lagrange multiplier for every completed iteration. Rows with a non-finite or non-positive misfit or roughness (for example a final iteration that stopped on “Convergence problems” before writingROUGHNESS IS) are dropped, sincelcurve_table()requires strictly positive values for its log-log scoring.- Parameters:
path (path-like) – Path to an Occam2D log file, typically
LogFile.logfile.**kwargs – Forwarded to
OccamLog.read(for exampleverbose).
- Returns:
roughholds Occam’s reportedROUGHNESS ISvalues,misfitthe accepted RMS, andlamthe accepted Lagrange multiplier (linear scale, not log10).- Return type:
Examples
>>> from pycsamt.emtools.lcurve import lcurve_from_occam2d >>> sweep = lcurve_from_occam2d("data/occam2D/LogFile.logfile") >>> sweep.backend 'occam2d' >>> ax = sweep.plot()
- pycsamt.emtools.lcurve.lcurve_from_modem(path, **kwargs)[source]
Build an
LCurveDatasweep from a ModEM NLCG log.Reads the per-iteration
Completed NLCG iterationblocks written by ModEM withpycsamt.models.modem.log.ModEmLog. ModEM reports the model-regularization term directly asm2rather than a roughness norm, soroughhere ism2– the same quantity \(\lambda\,\Phi_m(m)\) trades off against data misfit in ModEM’s objective function, and it plays the identical x-axis role on an L-curve.- Parameters:
path (path-like) – Path to a ModEM log file, typically
Modular_NLCG.log.**kwargs – Forwarded to
ModEmLog.read(for exampleverbose).
- Returns:
roughholds ModEM’sm2model-norm term,misfitthe reportedrms, andlamthe damping parameterlambda.- Return type:
Examples
>>> from pycsamt.emtools.lcurve import lcurve_from_modem >>> sweep = lcurve_from_modem( ... "data/modem/willy_27freq_watex_line02_sample/Modular_NLCG.log" ... ) >>> sweep.backend 'modem' >>> ax = sweep.plot()
- pycsamt.emtools.lcurve.lcurve_from_mare2dem(path, **kwargs)[source]
Build an
LCurveDatasweep from a MARE2DEM convergence log.Reads the per-iteration
** Iteration N **blocks written by MARE2DEM withpycsamt.models.mare2dem.log.Mare2DEMLog, which already parsesModel Misfit,Roughness, andOptimal Mufor every completed iteration. MARE2DEM reportsOptimal Muas \(\log_{10}\mu\), so it is converted back to linear scale here to match the convention used by the other two adapters.- Parameters:
path (path-like) – Path to a MARE2DEM log file, typically
*.logfile.**kwargs – Accepted for interface symmetry with the other adapters;
Mare2DEMLogtakes no extra keyword arguments.
- Returns:
roughholds MARE2DEM’s reported roughness,misfitthe model misfit, andlamthe optimal mu converted to linear scale (10 ** log10_mu).- Return type:
Examples
>>> from pycsamt.emtools.lcurve import lcurve_from_mare2dem >>> sweep = lcurve_from_mare2dem( ... "data/mare2dem/demo_mt_inversion/demo.logfile" ... ) >>> sweep.backend 'mare2dem' >>> ax = sweep.plot()
- pycsamt.emtools.lcurve.plot_lcurve(misfit, rough, lam=None, *, labels=None, colors=None, cmap='viridis', marker='o', ms=3.0, lw=1.4, alpha=0.9, show_points=True, show_path=True, arrow_every=0, method='curvature', smooth=3, skip=1, show_corner=True, corner_style=None, show_inset=True, inset_loc=(0.62, 0.12, 0.32, 0.32), label_every=0, label_prefix='', label_fontsize=7.0, target_misfit=None, target_label='target misfit', figsize=(6.0, 4.6), ax=None)[source]
- Parameters:
cmap (str)
marker (str)
ms (float)
lw (float)
alpha (float)
show_points (bool)
show_path (bool)
arrow_every (int)
method (str)
smooth (int)
skip (int)
show_corner (bool)
show_inset (bool)
label_every (int)
label_prefix (str)
label_fontsize (float)
target_misfit (float | None)
target_label (str)
ax (Axes | None)