TargetSet

Definition of TargetSet class.

class TargetSet(targets: List[swprepost.modaltarget.ModalTarget])

Bases: object

Container for handling multiple inversion targets.

__init__(targets: List[swprepost.modaltarget.ModalTarget]) → None

Initialize a TargetSet object.

Parameters:targets (list) – List of ModalTargets that define TargetSet.
cut(pmin, pmax, domain='frequency')

Remove data outside of the specified range.

Parameters:
  • pmin, pmax (float) – New minimum and maximum parameter value in the specified domain, respectively.
  • domain ({‘frequency’, ‘wavelength’}, optional) – Domain along which to perform the cut.
Returns:

None – May update attributes frequency, velocity, and velstd.

easy_resample(pmin, pmax, pn, res_type='log', domain='wavelength', inplace=False)

Resample dispersion curve.

Resample dispersion curve over a specific range, using log or linear sampling in the frequency or wavelength domain.

Parameters:
  • pmin, pmax (float) – Minimum and maximum parameter value in the resampled dispersion data.
  • pn (int) – Number of points in the resampled dispersion data.
  • res_type ({‘log’, ‘linear’}, optional) – Resample using either logarithmic or linear sampling, default is logarithmic.
  • domain ({‘frequency’, ‘wavelength’}, optional) – Domain along which to perform the resampling.
  • inplace (bool) – Indicating whether the resampling should be done in place or if a new Target object should be returned.
Returns:

None or Target – If inplace=True returns None, and may update attributes frequency, velocity, and velstd. If inplace=False a new Target object is returned.

Raises:

NotImplementedError – If res_type and/or domain are not among the options specified.

classmethod from_file(fname, file_format=None, version='3.4.2')

Read TargetSet info from disk.

Parameters:
  • fname (str) – Name of file, a relative or full path may be provided.
  • file_format ({‘.target’}, optional) – Format of the file, default is None indicating extension of fname will be used.
Returns:

TargetSet – Created from information stored in the provided file.

Raises:

ValueError – If fname does not have an extension and format is None.

classmethod from_target(fname_prefix, version='3.4.2')

Create TargetSet from .target file.

Note this method is still largely experimental and may not work for all cases.

Parameters:
  • fname_prefix (str) – Name of target file to be opened excluding the .target suffix, may include the relative or full path.
  • version ({‘3.4.2’, ‘2.10.1’}, optional) – Version of Geopsy, default is version ‘3.4.2’.
Returns:

TargetSet – Instantiated TargetSet object.

Raises:

NotImplementedError – If version does not match the options provided.

Notes

In previous versions of swprepost (v1.0.0 and earlier) an attempt was made to support all versions of Dinver’s .target and .param formats. However, this has become untenable due to the number and frequency of breaking changes that occur to these formats. Therefore, in lieu of supporting all versions, swprepost will seek to support only those versions directly associated with the open-source high-performance computing application swbatch.

to_file(fname, file_format=None, version='3.4.2')

Write TargetSet info to disk.

Parameters:
  • fname (str) – Name of file, a relative or full path may be provided.
  • file_format ({‘.target’}, optional) – Format of the file, default is None indicating extension of fname will be used.
Returns:

None – Writes TargetSet object to disk.

Raises:

ValueError – If fname does not have an extension and file_format is None.

to_target(fname_prefix, version='3.4.2')

Write info to the .target file format used by Dinver.

Parameters:
  • fname_prefix (str) – Name of target file without the .target suffix, a relative or full path may be provided.
  • version ({‘3.4.2’, ‘2.10.1’}, optional) – Version of Geopsy, default is version ‘3.4.2’.
Returns:

None – Writes .target file to disk.

Notes

In previous versions of swprepost (v1.0.0 and earlier) an attempt was made to support all versions of Dinver’s .target and .param formats. However, this has become untenable due to the number and frequency of breaking changes that occur to these formats. Therefore, in lieu of supporting all versions, swprepost will seek to support only those versions directly associated with the open-source high-performance computing application swbatch.