pycsamt.site.recompute#

Functions

recompute_edi(edi, *[, rotate_angle, ...])

Recompute one EDI object.

recompute_edis(source, **kwargs)

Convenience function for EDIRecomputer.

Classes

EDIRecomputeRecord(source, output, line, ...)

Per-station outcome for an EDI recomputation workflow.

EDIRecomputeResult(sites, records[, ...])

Result returned by EDIRecomputer.

EDIRecomputer([output_root, output_name, ...])

Recompute and rewrite EDI files using pyCSAMT conventions.

class pycsamt.site.recompute.EDIRecomputeRecord(source, output, line, station, status, message='')[source]#

Bases: object

Per-station outcome for an EDI recomputation workflow.

Variables:
  • source (pathlib.Path or None) – Source EDI path when known.

  • output (pathlib.Path or None) – Written EDI path when write=True and the station was written successfully.

  • line (str or None) – Line/group name inferred from the source directory.

  • station (str) – Station name after recomputation and optional renaming.

  • status (str) – "ok" for success or "failed" when processing continued after an error.

  • message (str, default "") – Optional diagnostic message.

Parameters:
  • source (Path | None)

  • output (Path | None)

  • line (str | None)

  • station (str)

  • status (str)

  • message (str)

source: Path | None#
output: Path | None#
line: str | None#
station: str#
status: str#
message: str = ''#
class pycsamt.site.recompute.EDIRecomputeResult(sites, records, output_root=None, items=<factory>)[source]#

Bases: object

Result returned by EDIRecomputer.

Variables:
Parameters:
sites: Sites#
records: list[EDIRecomputeRecord]#
output_root: Path | None = None#
items: list[EDIFile]#
property edis: list[EDIFile][source]#

Return recomputed raw EDI objects.

property paths: list[Path][source]#

Return successfully written output paths.

property failed: list[EDIRecomputeRecord][source]#

Return failed records.

to_manifest(path)[source]#

Write the records to a CSV manifest.

Parameters:

path (str | Path)

Return type:

Path

class pycsamt.site.recompute.EDIRecomputer(output_root=None, output_name='recomputed_edis', preserve_line_dirs=True, template='{station}.edi', overwrite=False, write=True, manifest_csv=True, rotate_angle=None, rotate_components=<factory>, fmin=None, fmax=None, keep_freq=None, fill_missing_values=None, recompute_resphase=True, rename_policy=None, datatype=None, synthesize_spectra=False, recursive=True, strict=False, on_dup='replace', copy=True, progress=False, verbose=0, progress_callback=None)[source]#

Bases: object

Recompute and rewrite EDI files using pyCSAMT conventions.

This class is a workflow layer over the lower-level site helpers. It accepts EDI objects, EDI collections, files, line folders, or survey folders, applies a sequence of optional normalizations, and can write pyCSAMT-generated EDI files to a new output tree.

Parameters:
  • output_root (str or pathlib.Path, optional) – Root directory for recomputed EDI files. If omitted, a recomputed_edis directory is created next to a selected line folder, or inside a selected survey folder.

  • output_name (str, default "recomputed_edis") – Directory name used when output_root is not provided.

  • preserve_line_dirs (bool, default True) – If True, write each inferred line into its own subdirectory under output_root. If False, write all recomputed EDI files directly under output_root.

  • template (str, default "{station}.edi") – Filename template. Available keys are station, index, line, and source_stem.

  • overwrite (bool, default False) – Allow replacing existing output files.

  • write (bool, default True) – If False, only return recomputed in-memory objects.

  • manifest_csv (bool or str or pathlib.Path, default True) – Write a CSV manifest. True writes <output_root>/manifest.csv. A path writes there.

  • rotate_angle (float, optional) – Rotation angle in degrees. If omitted, no rotation is applied.

  • rotate_components (iterable of str, default ("Z", "Tip")) – Components to rotate. Accepts values such as "Z", "impedance", "Tip", and "tipper".

  • fmin (float, optional) – Frequency range to keep before recomputation.

  • fmax (float, optional) – Frequency range to keep before recomputation.

  • keep_freq (iterable of int, optional) – Explicit frequency indices or mask passed to pycsamt.site.edit.select_freq().

  • fill_missing_values ({"zero", "nan"}, optional) – Missing-value policy passed to pycsamt.site.edit.fill_missing().

  • recompute_resphase (bool, default True) – Recompute apparent resistivity and phase from impedance.

  • rename_policy (callable, optional) – Function mapping the current station name to a new name.

  • datatype (str, optional) – EDI writer datatype override, for example "mt" or "emap".

  • synthesize_spectra (bool, default False) – Ask the pyCSAMT EDI writer to synthesize spectra when possible and missing.

  • recursive (bool, default True) – Recurse while discovering EDI files inside line folders.

  • strict (bool, default False) – Raise on read/process/write errors instead of recording failed manifest rows.

  • on_dup ({"replace", "keep"}, default "replace") – Duplicate station policy during loading.

  • copy (bool, default True) – Recompute copies of loaded EDI objects. Keep this enabled when the original objects should remain unchanged.

  • progress (bool or {"auto"}, default False) – Show progress while recomputing.

  • verbose (int, default 0) – Verbosity for loading, processing, and writing.

  • progress_callback (Callable[[int, int, str, str, str], None] | None)

output_root: str | Path | None = None#
output_name: str = 'recomputed_edis'#
preserve_line_dirs: bool = True#
template: str = '{station}.edi'#
overwrite: bool = False#
write: bool = True#
manifest_csv: bool | str | Path = True#
rotate_angle: float | None = None#
rotate_components: Iterable[str]#
fmin: float | None = None#
fmax: float | None = None#
keep_freq: Iterable[int] | None = None#
fill_missing_values: str | None = None#
recompute_resphase: bool = True#
rename_policy: Callable[[str], str] | None = None#
datatype: str | None = None#
synthesize_spectra: bool = False#
recursive: bool = True#
strict: bool = False#
on_dup: str = 'replace'#
copy: bool = True#
progress: bool | str = False#
verbose: int = 0#
progress_callback: Callable[[int, int, str, str, str], None] | None = None#
run(source)[source]#

Run the recomputation workflow.

Parameters:

source (Any)

Return type:

EDIRecomputeResult

recompute_one(edi)[source]#

Recompute one EDI object and return the result.

Parameters:

edi (Any)

Return type:

EDIFile

pycsamt.site.recompute.recompute_edi(edi, *, rotate_angle=None, rotate_components=('Z', 'Tip'), fmin=None, fmax=None, keep_freq=None, fill_missing_values=None, recompute_resphase=True, rename_policy=None, copy=True)[source]#

Recompute one EDI object.

The operation is copy-returning by default. It can rotate transfer functions, subset frequencies, fill missing values, recompute apparent resistivity/phase, and rename station ids.

Parameters:
Return type:

EDIFile

pycsamt.site.recompute.recompute_edis(source, **kwargs)[source]#

Convenience function for EDIRecomputer.

Examples

>>> result = recompute_edis("WILLY_DATA", rotate_angle=30.0)
>>> result.paths
[...]
Parameters:
Return type:

EDIRecomputeResult