sitem1d package

Submodules

Module contents

class sitem1d.ChannelData(inphase: float | ndarray, quadrature: float | ndarray, unit: str | None = None, label: str | None = None)

Bases: object

Simple object for complex data with option to compute inphase & quadrature from amplitude & phase and vice versa.

_set(z: ndarray) None

Seth the complex channel data.

Parameters:

z

Returns:

property amplitude: ndarray
static ap2iq(amp: ndarray, phase: ndarray, degree: bool = True) Tuple[ndarray, ndarray]

Compute inphase, quadrature from amplitude & phase

Parameters:
  • amp – amplitude value

  • phase – phase value

  • degree – flag if phase is in degree or radian

Returns:

inphase and quadrature values

Raise:

None

clone() ChannelData

Return a clone of this instance :return:

classmethod from_complex(channel_data: ndarray | complex, **kwargs) ChannelData

Init the channel data instance with a complex data

Parameters:
  • channel_data

  • kwargs

Returns:

property inphase: ndarray
property iq: ndarray
static iq2ap(inphase: ndarray, quadrature: ndarray, degree: bool = True) Tuple[ndarray, ndarray]

Compute amplitude and phase from inphase and quadrature

Parameters:
  • inphase

  • quadrature

  • degree

Returns:

property label: str
property n_records: int
property phase: ndarray
property phase_radian: ndarray
property quadrature: ndarray
property unit: str
property z: ndarray
class sitem1d.ChannelDefinition(frequency_hz: float, rxtx_separation_m: float, rxtx_mode: str, bxtx_separation_m: float | None = None)

Bases: object

Definition of a channel of an EM sensor limited to the information required for the forward model.

If the (optional) rxbx coil spacing is provided, the forward model will automatically include the bucking bias computation

property attribute_dict: dict

Returns a dictionary representation

Returns:

property bxtx_separation_m: float | None
property frequency_hz: float
property has_bx: bool
property id: str
property property_list
property rxtx_mode: str
property rxtx_mode_flag: int
property rxtx_mode_flag_dict: dict
property rxtx_separation_m: float
class sitem1d.EMChannel(channel_data: ChannelData, channel_def: ChannelDefinition, sample_id: str | int | List | ndarray | None = None, segment_id: str | int | List | ndarray | None = None)

Bases: object

Container for full channel data: Hs/Hp for one frequency with metadata

_valid_rxtx_modes = ['hcp', 'vcp']
_valid_source_types = ['sensor_ppm']
_valid_source_units = ['ppm']
append(other: EMChannel) None

Merge two EMChannel objects

Parameters:

other

Returns:

property bxtx_separation_m: float
property frequency_hz: float
property id: str
property iq: ChannelData
property iq_source: ChannelData
property n_records: int
property rxtx_mode: str
property rxtx_separation_m: float
property sample_id: ndarray
property segment_id: ndarray
set_calibration(cal: Any) None
set_idx_subset(idx_subset: List | ndarray) None
property valid_source_types: List[str]
property valid_source_units: List[str]
class sitem1d.EMChannelCollection(channels: List[EMChannel] | None = None)

Bases: object

A list of channels

add_channel(channel: EMChannel) None

Add a channel to the sensor channel collection

Parameters:

channel – EMChannel instance

Returns:

None

apply_calibration(calobj)

Change the ppm values with a calibration object

Parameters:

calobj

Returns:

property channel_ids: List[str]
property channels: List[EMChannel]
clone() EMChannelCollection
property data_group_id: str
get_channel(channel_id: str) EMChannel | None
Parameters:

channel_id

Returns:

get_netcdf_variables(frequency_dimension_name: str = 'frequency', time_dimension_name: str = 'time') Dict

Return a dictionary of netCDF variables.

Parameters:
  • frequency_dimension_name

  • time_dimension_name

Returns:

property n_channels: int
property n_records: int
property segment_id: ndarray
set_idx_subset(idx_subset: List | ndarray) None
update_channel(channel_data: EMChannel) None

Update an existing channel

Parameters:

channel_data

Returns:

None

class sitem1d.EMSensorData(sensor_def: EMSensorDefinition, channels: EMChannelCollection, position: EMSensorPosition, auxdata: EMSensorAuxdata | None = None, observation_id: ndarray | None = None, metadata: EMSensorMetadata | None = None, source_file: str | None = None)

Bases: object

Container for a full EM sensor data container.

calibrate(calibrate_object) None

Apply a calibration to each channel.

Parameters:

calibrate_object

Returns:

clone()
property dataset_id: str

Return a filename-proof unique dataset id

Returns:

property has_auxdata
iter_channels() Iterator[EMChannel]

Creates an iterator for the individual channels

Returns:

property n_records
register_auxdata(value, name)

Add a variable to the auxiliary data collection

Parameters:
  • value

  • name

Returns:

to_netcdf(output_directory: str | Path, filename: str | None = None) None

Write the content of the class to a netCDF file

Parameters:
  • output_directory

  • filename

Returns:

update_geospatial_time_metadata() None

Update the metadat container with the data container

Returns:

class sitem1d.EMSensorDataCollection(data_sets: List[EMSensorData] | None = None, metadata: EMSensorMetadata | None = None)

Bases: object

A collection of EM sensor data sets, e.g. a list of files merged into a single data container, but with traceable origin.

_validate()

Runs consistency checks of the gem2 datasets in the collection. Raises ValueError for any inconsistencies found

Returns:

add(dataset: EMSensorData) None

Add a dataset to the catalog

Parameters:

dataset

Returns:

get_merged_data() EMSensorData

Collapse the EM sensor data collection into a single EMSensorData instance. :return:

property n_datasets
to_merged_netcdf(output_directory: str | Path) None

Merge the data from the collection and write a single netCDF

Parameters:

output_directory

Returns:

class sitem1d.EMSensorDefinition(channel_defs: List[ChannelDefinition], type_id: str | None = None, device_id: str | None = None, longname: str | None = None, manufacturer: str | None = None, owner: str | None = None, contact: str | None = None, configuration_id: str | None = None, cfg_file=None)

Bases: object

Container for Sensor Metadata

property attribute_dict

Return a dictionary representation of the sensor definition

Returns:

property cfg_file
property channel_ids
property configuration_id
property contact
property data_group_id: str
property device_id
property frequencies
classmethod from_yaml(yaml_file)

Set the sensor definition from yaml config file :return:

get_channel(channel_id, raise_on_error=False)

Return a channel by its id

Parameters:
  • channel_id

  • raise_on_error

Returns:

get_channel_attributes(frequency_hz)

Returns channels attributes (coils spacing etc) for a given frequency)

Parameters:

frequency_hz

Returns:

get_channel_by_frequency(frequency=None, raise_on_error=False)
Parameters:
  • frequency

  • raise_on_error

Returns:

get_channel_idx(channel_id: str) int | None

Return the index of a channel id in the list of channels. Return None if channel id not in the sensor definition. :param channel_id: :return:

get_netcdf_variables(dimension_name: str = 'frequency') Dict

Return a dictionary of netCDF variables

Returns:

property longname
property manufacturer
property num_channels: int
property owner
property type_id
class sitem1d.EMSensorMetadata(metadata_dict: dict | None = None, include_empty: bool | None = None)

Bases: object

append(key: str, value: str, separator: str = ';') None

Append an attribute by an additional value. If the attribute does not exist it will be created. Appending only works with str, a ValueError will be raised for the wrong data type.

Parameters:
  • key

  • value

  • separator

Returns:

property attr: OrderedDict
clone() EMSensorMetadata

Return a copy of this instance :return:

property default_attr_list: List[str]

The list of default attributes is taken from the Attribute Convention for Data Discovery (ACDD): https://wiki.esipfed.org/Attribute_Convention_for_Data_Discovery_1-3#Global_Attributes It includes the highly recommended and a subset of the recommended and suggested attributes. The only addition is the tracking_id attribute

Returns:

get(key: str, missing_value: None | str | float | int = None) None | str | float | int

Get an attribute

Parameters:
  • key

  • missing_value

Returns:

static get_datetime_string(datetime_like: datetime) str
property is_empty: bool
set(key: str, value: str | float | int, key_must_exist: bool = False) None

Sets an attribute with an optional check that the attribute needs to exist.

Parameters:
  • key – Key of the attribute dictionary

  • value – Value to be set

  • key_must_exist – if true, a KeyError will be raised if attribute does not exist

Returns:

update_geospatial_bounds(lons: ndarray, lats: ndarray) None

Set the geopgraphical bounds from longitude and latitude arrays

Parameters:
  • lons

  • lats

Returns:

update_time_bounds(times: ndarray) None

Set the time coverage start and end attributes from arrays of datetimes

Parameters:

times

Returns:

class sitem1d.EMSensorPosition(time=None, longitude=None, latitude=None, altitude=None, sensor_height=None, pitch=None, roll=None, true_heading=None)

Bases: object

Container for the geographic location and height above surface of the sensor. Also includes sensor time and options for x, y coordinate systems #TODO: Candidate for data class

property calendar: str
property data_group_id: str
get_netcdf_variables(dimension_name: str = 'time') Dict

Return a list of netCDF variables from this class

Parameters:

dimension_name

Returns:

property n_records: int
set_idx_subset(idx_subset)
property time_coverage_end: datetime
property time_coverage_start: datetime
property time_units: str
update(time=None, longitude=None, latitude=None, sensor_height=None)

#TODO: This is clunky and error prone Set the primary information after initialization

Parameters:
  • time – (datetime) sensor time (assumed to be UTC)

  • longitude – (float) longitudes in degrees east

  • latitude – (float) latitudes in degrees north

  • sensor_height – (float) height of sensor above surface in meter

Returns:

None

update_sensor_height(sensor_height)

Update the sensor height

Parameters:

sensor_height – Can be float or array (unit in meter)

Returns: