API reference
Contents
API reference#
API components that most users will interact with.
Attention
In echopype versions prior to 0.5.0, the API in this page focused
on the convert
and process
subpackages. See the
0.4.1 API page
if you’re using a previous release. That workflow is being deprecated.
Content
EchoData class#
EchoData is an object that handles interfacing raw converted data. It is used for calibration and other processing.
Classes#
|
Echo data model class for handling raw converted data, including multiple files associated with the same data set. |
Open raw and converted files#
- echopype.open_raw(raw_file: Optional[PathHint] = None, sonar_model: Optional[SonarModelsHint] = None, xml_path: Optional[PathHint] = None, convert_params: Optional[Dict[str, str]] = None, storage_options: Optional[Dict[str, str]] = None) Optional[echopype.echodata.echodata.EchoData] #
Create an EchoData object containing parsed data from a single raw data file.
The EchoData object can be used for adding metadata and ancillary data as well as to serialize the parsed data to zarr or netcdf.
- Parameters
- raw_filestr
path to raw data file
- sonar_modelstr
model of the sonar instrument
EK60
: Kongsberg Simrad EK60 echosounderES70
: Kongsberg Simrad ES70 echosounderEK80
: Kongsberg Simrad EK80 echosounderEA640
: Kongsberg EA640 echosounderAZFP
: ASL Environmental Sciences AZFP echosounderAD2CP
: Nortek Signature series ADCP (tested with Signature 500 and Signature 1000)
- xml_pathstr
path to XML config file used by AZFP
- convert_paramsdict
parameters (metadata) that may not exist in the raw file and need to be added to the converted file
- storage_optionsdict
options for cloud storage
- Returns
- EchoData object
- echopype.open_converted(converted_raw_path: PathHint, storage_options: Dict[str, str] = None, **kwargs)#
Create an EchoData object from a single converted netcdf or zarr file.
- Parameters
- converted_raw_pathstr
path to converted data file
- storage_optionsdict
options for cloud storage
- kwargsdict
optional keyword arguments to be passed into xr.open_dataset
- Returns
- EchoData object
Combine EchoData objects#
- echopype.combine_echodata(echodatas: List[echopype.echodata.echodata.EchoData], combine_attrs='override') echopype.echodata.echodata.EchoData #
Combines multiple EchoData objects into a single EchoData object.
- Parameters
- echodatas: List[EchoData]
The list of EchoData objects to be combined.
- combine_attrs: { “override”, “drop”, “identical”, “no_conflicts”, “overwrite_conflicts” }
String indicating how to combine attrs of the EchoData objects being merged. This parameter matches the identically named xarray parameter (see https://xarray.pydata.org/en/latest/generated/xarray.combine_nested.html) with the exception of the “overwrite_conflicts” value.
“override”: Default. skip comparing and copy attrs from the first EchoData object to the result.
“drop”: empty attrs on returned EchoData object.
“identical”: all attrs must be the same on every object.
“no_conflicts”: attrs from all objects are combined, any that have the same name must also have the same value.
“overwrite_conflicts”: attrs from all EchoData objects are combined, attrs with conflicting keys will be overwritten by later EchoData objects.
- Returns
- EchoData
An EchoData object with all of the data from the input EchoData objects combined.
- Raises
- ValueError
If echodatas contains EchoData objects with different or None sonar_model values (i.e., all EchoData objects must have the same non-None sonar_model value).
- ValueError
If EchoData objects have conflicting source file names.
- Warns
- UserWarning
If the sonar_model of the input EchoData objects is “EK60” and any EchoData objects have non-monotonically increasing ping_time, time1 or time2 values, the corresponding values in the output EchoData object will be increased starting at the timestamp where the reversal occurs such that all values in the output are monotonically increasing. Additionally, the original ping_time, time1 or time2 values will be stored in the Provenance group, although this behavior may change in future versions.
Warning
Changes in parameters between EchoData objects are not currently checked; however, they may raise an error in future versions.
Notes
EchoData objects are combined by combining their groups individually.
Attributes from all groups before the combination will be stored in the provenance group, although this behavior may change in future versions.
The source_file and converted_raw_path attributes will be copied from the first EchoData object in the given list, but this may change in future versions.
Examples
>>> ed1 = echopype.open_converted("file1.nc") >>> ed2 = echopype.open_converted("file2.zarr") >>> combined = echopype.combine_echodata([ed1, ed2])
Data processing subpackages#
calibrate#
Functions#
|
Compute volume backscattering strength (Sv) from raw data. |
|
Compute target strength (TS) from raw data. |
preprocess#
Functions#
|
Compute Mean Volume Backscattering Strength (MVBS) based on intervals of range ( |
|
Compute Mean Volume Backscattering Strength (MVBS) based on intervals of |
|
Remove noise by using estimates of background noise from mean calibrated power of a collection of pings. |
Use frequency_nominal in place of channel as dataset dimension and coordinate. |
qc#
Functions#
|
Coerce a time coordinate to always flow forward. |
|
Test for occurrence of time reversal in specified datetime coordinate variable. |
Utilities#
Utilities for calculating seawater acoustic properties.
Functions#
|
Calculate sea water absorption in units [dB/m]. |
|
Calculate sound speed in [m/s]. |
Visualization subpackage#
Visualization module to quickly plot raw, Sv, and MVBS dataset.
NOTE: To use this subpackage. `Matplotlib` and `cmocean` package must be installed.
- echopype.visualize.create_echogram(data: Union[echopype.echodata.echodata.EchoData, xarray.core.dataset.Dataset], channel: Optional[Union[str, List[str]]] = None, frequency: Optional[Union[str, List[str]]] = None, get_range: Optional[bool] = None, range_kwargs: dict = {}, water_level: Optional[Union[int, float, xarray.core.dataarray.DataArray, bool]] = None, **kwargs) List[Union[xarray.plot.facetgrid.FacetGrid, matplotlib.collections.QuadMesh]] #
Create an Echogram from an EchoData object or Sv and MVBS Dataset.
- Parameters
- dataEchoData or xr.Dataset
Echodata or Xarray Dataset to be plotted
- channelstr or list of str, optional
The channel to be plotted. Otherwise all channels will be plotted.
- frequencyint, float, or list of float or ints, optional
The frequency to be plotted. If not specified, all frequency will be plotted.
- get_rangebool, optional
Flag as to whether range (
echo_range
) should be computed or not, by default it will just plot range_sample` as the yaxis.Note that for data that is “Sv” xarray dataset, get_range defaults to True.
- range_kwargsdict
Keyword arguments dictionary for computing range (
echo_range
). Keys are env_params, waveform_mode, and encode_mode.- water_levelint, float, xr.DataArray, or bool, optional
Water level data array for platform water level correction. Note that auto addition of water level can be performed when data is an EchoData object by setting this argument to True. Currently because the water level information is not available as part of the Sv dataset, a warning is issued when water_level=True in this case and no correction is performed. This behavior will change in the future when the default content of Sv dataset is updated to include this information.
- **kwargs: optional
Additional keyword arguments for xarray plot pcolormesh.
Notes
The EK80 echosounder can be configured to transmit either broadband (
waveform_mode="BB"
) or narrowband (waveform_mode="CW"
) signals. When transmitting in broadband mode, the returned echoes are encoded as complex samples (encode_mode="complex"
). When transmitting in narrowband mode, the returned echoes can be encoded either as complex samples (encode_mode="complex"
) or as power/angle combinations (encode_mode="power"
) in a format similar to those recorded by EK60 echosounders.