ctdam.parser.parameter module¶
- class ctdam.parser.parameter.Parameters(data, metadata, only_header=False, bad_flag=-9.99e-29)[source]¶
Bases:
UserDictA collection of all the parameters in a CnvFile.
Allows for clean handling of parameter data and their metadata.
- Parameters:
data (
list) – The raw data as extracted by DataFilemetadata (
list) – The raw metadata as extracted by DataFileonly_header (
bool) – Whether to only work with metadata (Default=False)bad_flag (
float) – The value to consider as bad (Default=-9.990e-29)
- set_sample_rate(rate, unit)[source]¶
Setter for sample rate of binned data.
- Parameters:
rate (
float) – The sample rate to set tounit (
str) – The unit of the sample rate
- get_sample_rate(raw_interval_info='')[source]¶
Getter of the sample rate.
Determines whether data is binned.
- Parameters:
raw_interval_info (
str) – The .cnv metadata (Default value = “”)- Return type:
float
- create_full_ndarray(data_table=[])[source]¶
Parser for .cnv data table data.
- Parameters:
data_table (
list) – The data to work with (Default value = [])- Return type:
ndarray
- sort_parameters(top=['depSM', 'prDM', 't090C', 't190C', 'sal00', 'sal11', 'sbox0Mm/Kg', 'sbox1Mm/Kg', 'flECO-AFL', 'turbWETntu0', 'par', 'spar'], bottom=['gsw_densityA0', 'gsw_densityA1', 'gsw_saA0', 'gsw_saA1', 'gsw_ctA0', 'gsw_ctA1', 'sbeox0ML/L', 'sbeox1ML/L', 'c0mS/cm', 'c1mS/cm', 'latitude', 'longitude', 'flag'])[source]¶
Allows sorting of parameter instances for output reasons.
- Parameters:
top (
list) – The parameters to fix to the topbottom (
list) – The parameters to fix to the bottom
- Return type:
dict
- create_parameter_instances(array_data, metadata)[source]¶
Differentiates the individual parameter columns into separate parameter instances.
- Parameters:
array_data (
ndarray) – The parsed CTD data arraymetadata (
dict[str,dict]) – The structured metadata dictionary (Default value = {})
- Return type:
dict[str,Parameter]
- add_parameter(parameter, position='')[source]¶
Adds one parameter instance to the collection.
- Parameters:
parameter (
Parameter) – The new parameter instanceposition (
str) – The parameter to insert the new one after (Default value = “”)
- create_parameter(data, metadata={}, name='', position='')[source]¶
Creates a new parameter instance with the given data and metadata.
The input data is either a numpy array or a single value. The single value will be broadcasted to the shape of the data table. A use-case would be the addition of an ‘event’ or ‘cast’ column.
- Parameters:
data (
ndarray|int|float|str|None) – Data to use as array or a value to expand to an arraymetadata (
dict) – Metadata for the new parameter (Default value = {})name (
str) – Name to use for missing metadata values (Default value = “”)position (
str) – The parameter position to add the new one after (Default value = “”)
- Return type:
- add_default_metadata(name, metadata={}, list_of_keys=['shortname', 'longinfo', 'name', 'metainfo', 'unit'])[source]¶
Fills up missing metadata points with a default value.
- Parameters:
name (
str) – The value to use as defaultmetadata (
dict) – The present metadata (Default value = {})list_of_keys (
list) – The expected metadata keys
- Return type:
dict
- get_pandas_dataframe()[source]¶
Returns a pandas DataFrame of the current parameter data.
- Return type:
DataFrame
- class ctdam.parser.parameter.Parameter(data, metadata, bad_flag=-9.99e-29)[source]¶
Bases:
objectA representation of one parameter in CTD data.
Consists of the data and metadata.
- Parameters:
data (
ndarray) – The data arraymetadata (
dict) – The metadata informationbad_flag (
float) – The value to consider as bad (Default=-9.990e-29)
- get_pandas_series()[source]¶
Returns a pandas Series of the current parameter data.
- Return type:
Series