Data Structures¶
Classes¶
Hydrophone¶
The Hydrophone represents an acoustic recorder and its properties and functions to read its output data.
Each object needs to have at least the same functions than the class Hydrophone. Some can add additional functions.
-
class
pyhydrophone.hydrophone.Hydrophone(name, model, serial_number, sensitivity, preamp_gain, Vpp, string_format, calibration_file=None, **kwargs)[source]¶ Base class Hydrophone initialization
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder
- sensitivityfloat
Sensitivity of the acoustic recorder in db
- preamp_gainfloat
Gain of the preamplifier in dB
- Vppfloat
Voltage peak to peak in volts
- string_formatstring
Format of the datetime string present in the filename
- calibration_filestring or Path
File where the frequency dependent sensitivity values for the calibration are
-
calibrate(file_path)[source]¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)[source]¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
end_to_end_calibration(p_ref=1.0)[source]¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)[source]¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=',', freq_col_id=0, val_col_id=1, start_data_id=0)[source]¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(date_string)[source]¶ Read the name of the file and according to the hydrophone protocol get the date
Parameters: - date_stringstring
Datetime in string format
-
get_new_name(filename, new_date)[source]¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
-
update_calibration(calibration_signal, p_ref=1.0)[source]¶ Updates ONLY the parameter preamp_gain of the hydrophone with a correction factor to match expected calibration.
Parameters: - calibration_signal: np.array
signal to calibrate from (already cut to ONLY calibration)
- p_ref: float
Reference pressure to compute db from
Returns: - Updates the parameter preamp_gain
AMAR¶
-
class
pyhydrophone.amar.AmarG3(name, model, serial_number, sensitivity, preamp_gain, Vpp, string_format='%Y%m%dT%H%M%S', calibration_file=None, **kwargs)[source]¶ Init an instance of AMARG3
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder
- sensitivityfloat
Sensitivity of the acoustic recorder in db
- preamp_gainfloat
Gain of the preamplifier in dB
- Vppfloat
Voltage peak to peak in volts
- string_formatstring
Format of the datetime string present in the filename
- calibration_filestring or Path
File where the frequency dependent sensitivity values for the calibration are
-
calibrate(file_path)¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
end_to_end_calibration(p_ref=1.0)¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=',', freq_col_id=0, val_col_id=1, start_data_id=0)¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(file_name)[source]¶ Get the data and time of recording from the name of the file
Parameters: - file_namestring
File name (not path) of the file
-
get_new_name(filename, new_date)[source]¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
-
update_calibration(calibration_signal, p_ref=1.0)¶ Updates ONLY the parameter preamp_gain of the hydrophone with a correction factor to match expected calibration.
Parameters: - calibration_signal: np.array
signal to calibrate from (already cut to ONLY calibration)
- p_ref: float
Reference pressure to compute db from
Returns: - Updates the parameter preamp_gain
-
class
pyhydrophone.amar.AmarG3MEMS(name, model, serial_number, hydroph_sensitivity, preamp_gain, mems_sensitivity, Vpp)[source]¶ Add the MEMS specs
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder
- hydroph_sensitivityfloat
Sensitivity of the acoustic recorder in db
- preamp_gainfloat
Gain of the preamplifier in dB
- mems_sensitivityfloat
Sensitivity of the accelerometer
- Vppfloat
Voltage peak to peak in volts
-
calibrate(file_path)¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
end_to_end_calibration(p_ref=1.0)¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=',', freq_col_id=0, val_col_id=1, start_data_id=0)¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(file_name)¶ Get the data and time of recording from the name of the file
Parameters: - file_namestring
File name (not path) of the file
-
get_new_name(filename, new_date)¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
-
update_calibration(calibration_signal, p_ref=1.0)¶ Updates ONLY the parameter preamp_gain of the hydrophone with a correction factor to match expected calibration.
Parameters: - calibration_signal: np.array
signal to calibrate from (already cut to ONLY calibration)
- p_ref: float
Reference pressure to compute db from
Returns: - Updates the parameter preamp_gain
B&K¶
-
class
pyhydrophone.bruelkjaer.BruelKjaer(name, model, serial_number, preamp_gain, Vpp=2.0, string_format='%y%m%d%H%M%S', type_signal='ref', max_calibration_time=120.0, calibration_file=None, **kwargs)[source]¶ Init an instance of B&K Nexus. Check well the Vpp in case you don’t have a reference signal! Specially of the recorder used.
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder
- preamp_gain: float
Amplification selected in the Nexus in db 10*log10((V/uPa)^2)
- Vpp: float
Volts peak to peak
- string_format: string
Format of the datetime string present in the filename
- type_signalstr
Can be ‘ref’ or ‘test’
- calibration_filestring or Path
File where the frequency dependent sensitivity values for the calibration are
-
calibrate(file_path)[source]¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
end_to_end_calibration(p_ref=1.0)¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=',', freq_col_id=0, val_col_id=1, start_data_id=0)¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(file_name)[source]¶ Get the data and time of recording from the name of the file
Parameters: - file_namestring
File name (not path) of the file
-
get_new_name(filename, new_date)[source]¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
EARS¶
-
class
pyhydrophone.ears.EARs(name, model, serial_number, sensitivity, preamp_gain, Vpp, string_format='%Y%m%d_%H%M%S', calibration_file=None, **kwargs)[source]¶ Init an instance of EARs
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder
- sensitivityfloat
Sensitivity of the acoustic recorder in db
- preamp_gainfloat
Gain of the preamplifier in dB
- Vppfloat
Voltage peak to peak in volts
- string_formatstring
Format of the datetime string present in the filename
- calibration_filestring or Path
File where the frequency dependent sensitivity values for the calibration are
-
calibrate(file_path)¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
end_to_end_calibration(p_ref=1.0)¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=',', freq_col_id=0, val_col_id=1, start_data_id=0)¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(file_name)[source]¶ Get the data and time of recording from the name of the file
Parameters: - file_namestring
File name (not path) of the file
-
get_new_name(filename, new_date)[source]¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
-
update_calibration(calibration_signal, p_ref=1.0)¶ Updates ONLY the parameter preamp_gain of the hydrophone with a correction factor to match expected calibration.
Parameters: - calibration_signal: np.array
signal to calibrate from (already cut to ONLY calibration)
- p_ref: float
Reference pressure to compute db from
Returns: - Updates the parameter preamp_gain
MTE¶
-
class
pyhydrophone.mte.MTE(name, model, serial_number, sensitivity, preamp_gain, Vpp, string_format='%y%m%d_%H%M%S', calibration_file=None, **kwargs)[source]¶ Init an instance of Aural
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder
- sensitivityfloat
Sensitivity of the acoustic recorder in db
- preamp_gainfloat
Gain of the preamplifier in dB
- Vppfloat
Voltage peak to peak in volts
- string_formatstring
Format of the datetime string present in the filename
- calibration_filestring or Path
File where the frequency dependent sensitivity values for the calibration are
-
calibrate(file_path)¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
end_to_end_calibration(p_ref=1.0)¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=',', freq_col_id=0, val_col_id=1, start_data_id=0)¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(file_name)[source]¶ Get the data and time of recording from the name of the file
Parameters: - file_namestring
File name (not path) of the file
-
get_new_name(filename, new_date)[source]¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
-
update_calibration(calibration_signal, p_ref=1.0)¶ Updates ONLY the parameter preamp_gain of the hydrophone with a correction factor to match expected calibration.
Parameters: - calibration_signal: np.array
signal to calibrate from (already cut to ONLY calibration)
- p_ref: float
Reference pressure to compute db from
Returns: - Updates the parameter preamp_gain
RTSYS¶
-
class
pyhydrophone.rtsys.RTSys(name, model, serial_number, sensitivity, preamp_gain, Vpp, mode, channel='A', string_format='%Y-%m-%d_%H-%M-%S', calibration_file=None)[source]¶ Init an instance of RTSys
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder
- sensitivityfloat
Sensitivity of the acoustic recorder in db
- preamp_gainfloat
Gain of the preamplifier in dB
- Vppfloat
Voltage peak to peak in volts
- mode: string
Can be ‘lowpower’ or ‘broadband’
- channel: string
Channel to process, ‘A’, ‘B’, ‘C’ or ‘D’
- string_formatstring
Format of the datetime string present in the filename
- calibration_filestring or Path
File where the frequency dependent sensitivity values for the calibration are
-
calibrate(file_path, zip_mode=False)[source]¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
compute_consumption(board_file_path)[source]¶ Calculate the total energy consumption of the file
Parameters: - board_file_pathstr or Path
Returns: - Total consumption in the file
-
compute_consumption_total_mission(mission_folder_path)[source]¶ Calculate the total energy consumption of the file
Parameters: - mission_folder_pathstr or Path
Returns: - Total consumption in the mission
-
end_to_end_calibration(p_ref=1.0)¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=';', freq_col_id=0, val_col_id=1, start_data_id=0)[source]¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(file_name)[source]¶ Get the data and time of recording from the name of the file
Parameters: - file_namestring
File name (not path) of the file
-
get_new_name(filename, new_date)[source]¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
-
plot_consumption(board_file_path)[source]¶ Plot the consumption evolution from the board_file_path
Parameters: - board_file_pathstr or Path
-
static
read_header(file_path, zip_mode=False)[source]¶ Return the parameters of the .wav file’s header as a dictionary
Parameters: - file_path: Path or string
Path to the .wav file to read the header from
Returns: - extra_header: dictionary with all the parameters of the configuration provided by RTSys
-
update_calibration(calibration_signal, p_ref=1.0)¶ Updates ONLY the parameter preamp_gain of the hydrophone with a correction factor to match expected calibration.
Parameters: - calibration_signal: np.array
signal to calibrate from (already cut to ONLY calibration)
- p_ref: float
Reference pressure to compute db from
Returns: - Updates the parameter preamp_gain
-
update_metadata(file_path, zip_mode=False)[source]¶ Creates a new RTSys object from an already existing one but updating the metadata from the file header. The “mode” parameter stays the same.
Parameters: - file_path: str or Path
path to the wav file recorded with RTSys with a correc header
- zip_mode: bool
True if file is zipped, otherwise false
SoundTrap¶
-
class
pyhydrophone.soundtrap.SoundTrap(name, model, serial_number, sensitivity=None, gain_type='High', string_format='%y%m%d%H%M%S', calibration_file=None, **kwargs)[source]¶ Initialize a SoundTrap instance
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder. It has to match the one in the calibration file
- sensitivityfloat
Sensitivity of the acoustic recorder in db. If None the one from the calibration file will be read
- gain_typestr
‘High’ or ‘Low’, depending on the settings of the recorder
- string_formatstring
Format of the datetime string present in the filename
- calibration_filestring or Path
File where the frequency dependent sensitivity values for the calibration are
-
calibrate(file_path)¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
end_to_end_calibration(p_ref=1.0)¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=',', freq_col_id=0, val_col_id=1, start_data_id=0)¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(file_name)[source]¶ Get the data and time of recording from the name of the file Will convert the local in UTC. It assumes the localtime is the one from the computer
Parameters: - file_namestring
File name (not path) of the file
-
get_new_name(filename, new_date)[source]¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
-
static
get_xml_utc_datetime(file_path)[source]¶ Get the UTC datetime from the xml file
Parameters: - file_pathstr or Path
-
static
read_file_specs(xmlfile_path, last_gain, date_format='%Y-%m-%dT%H:%M:%S')[source]¶ Read the specs of the recording from the XML file and save them to the object
Parameters: - xmlfile_pathstring or path
Path to the xml file
- last_gainstr
Last gain type. ‘High’ or ‘Low’, depending on the settings of the recorder
- date_formatstring
Format of the datetime in the .log.xml file
-
update_calibration(calibration_signal, p_ref=1.0)¶ Updates ONLY the parameter preamp_gain of the hydrophone with a correction factor to match expected calibration.
Parameters: - calibration_signal: np.array
signal to calibrate from (already cut to ONLY calibration)
- p_ref: float
Reference pressure to compute db from
Returns: - Updates the parameter preamp_gain
-
class
pyhydrophone.soundtrap.SoundTrapHF(name, model, serial_number, sensitivity=None, gain_type='High', string_format='%y%m%d%H%M%S')[source]¶ Init a SoundTrap HF reader
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder. It has to match the one in the calibration file
- sensitivityfloat
Sensitivity of the acoustic recorder in db. If None the one from the calibration file will be read
- gain_typestr
‘High’ or ‘Low’, depending on the settings of the recorder
- string_formatstring
Format of the datetime string present in the filename
-
calibrate(file_path)¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
end_to_end_calibration(p_ref=1.0)¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=',', freq_col_id=0, val_col_id=1, start_data_id=0)¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(file_name)¶ Get the data and time of recording from the name of the file Will convert the local in UTC. It assumes the localtime is the one from the computer
Parameters: - file_namestring
File name (not path) of the file
-
get_new_name(filename, new_date)¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
-
static
get_xml_utc_datetime(file_path)¶ Get the UTC datetime from the xml file
Parameters: - file_pathstr or Path
-
read_HFclicks_file(wavfile_path, zip_mode=False)[source]¶ Read all the clicks stored in a folder with soundtrap files
Parameters: - wavfile_path: str
Wav file path
- zip_modeboolean
Set to True if the folders are zipped
Returns: - A DataFrame with all the clicks and a fs metadata parameter with the sampling rate
-
read_HFfolder(main_folder_path, zip_mode=False, include_dirs=False)[source]¶ Read all the clicks in all the folders. If zip_mode is True and include_dirs is True, only the INSIDE folders can be zipped inside a non-zipped folder. If only one zip folder is to be analyzed, then set include_dirs to False.
Parameters: - main_folder_path: str or Path
Folder containing all the files and/or subfolders to be extracted
- zip_modeboole
Set to True if the folders are zipped
- include_dirsbool
Set to True if folder needs to be analyzed recursively
Returns: - A DataFrame with all the clicks of all the folders and a fs metadata parameter with the sampling rate
-
static
read_HFparams(xml_path)[source]¶ Return the length of the clips and the time in between
Parameters: - xml_pathstring or Path
Path to the .log.xml file
Returns: - Clip length in samples (int)
-
static
read_file_specs(xmlfile_path, last_gain, date_format='%Y-%m-%dT%H:%M:%S')¶ Read the specs of the recording from the XML file and save them to the object
Parameters: - xmlfile_pathstring or path
Path to the xml file
- last_gainstr
Last gain type. ‘High’ or ‘Low’, depending on the settings of the recorder
- date_formatstring
Format of the datetime in the .log.xml file
-
test_calibration(signal)¶ Test the calibration of the soundtrap
-
update_calibration(calibration_signal, p_ref=1.0)¶ Updates ONLY the parameter preamp_gain of the hydrophone with a correction factor to match expected calibration.
Parameters: - calibration_signal: np.array
signal to calibrate from (already cut to ONLY calibration)
- p_ref: float
Reference pressure to compute db from
Returns: - Updates the parameter preamp_gain
uPAM¶
-
class
pyhydrophone.upam.uPam(name, model, serial_number, sensitivity, preamp_gain, Vpp, string_format='%Y%m%d_%H%M%S_%f', calibration_file=None, **kwargs)[source]¶ Init an instance of Seiche
Parameters: - name: str
Name of the acoustic recorder
- model: str or int
Model of the acoustic recorder
- serial_numberstr or int
Serial number of the acoustic recorder
- sensitivityfloat
Sensitivity of the acoustic recorder in db
- preamp_gainfloat
Gain of the preamplifier in dB
- Vppfloat
Voltage peak to peak in volts
- string_formatstring
Format of the datetime string present in the filename
-
calibrate(file_path)¶ Find the beginning and ending sample of the calibration tone Returns start and end points, in seconds
Parameters: - file_pathstring or Path
File where to look for the calibration (at the beginning of the file)
Returns: - end sample of the calibration (int)
-
change_calibration_system(cal_freq, cal_val)¶ Change the parameters of the calibration system (piston phone)
Parameters: - cal_freq: float
Calibration frequency in Hz
- cal_val: float
Expected value in db
-
end_to_end_calibration(p_ref=1.0)¶ Returns the end to end calibration of the system, so it can be directly used on a wav file to obtain uPa
Parameters: - p_ref
Returns: - End to end calibration in db
-
freq_cal_inc(frequencies, p_ref=1.0)¶ Returns a dataframe with the frequency dependent values to increment from the selected frequencies you give from the data you want to increment
Parameters: - frequencies1d array
Frequencies from the data you want to increment with frequency dependent calibration
- p_ref: float
Reference pressure to compute db from
Returns: - df_freq_incpandas Dataframe
Frequency dependent values to increment in your data
-
get_freq_cal(val='sensitivity', sep=',', freq_col_id=0, val_col_id=1, start_data_id=0)¶ Compute a dataframe with all the frequency dependent sensitivity values from the calibration file
Parameters: - valstr
Can be ‘sensitivity’ or ‘end_to_end’ depending on what are the values in the calibration file
- sepstr
Separator between the different columns in csv or txt files
- freq_col_idint
Id of the frequency column in the file (starts with 0)
- val_col_idint
Id of the values column in the file (starts with 0)
- start_data_idint
Id of the first line with data (without title) in the file (starts with 0)
-
get_name_datetime(file_name)[source]¶ Get the data and time of recording from the name of the file
Parameters: - file_namestring
File name (not path) of the file
-
get_new_name(filename, new_date)[source]¶ Replace the datetime with the appropriate one
Parameters: - filenamestring
File name (not path) of the file
- new_datedatetime object
New datetime to be replaced in the filename
-
update_calibration(calibration_signal, p_ref=1.0)¶ Updates ONLY the parameter preamp_gain of the hydrophone with a correction factor to match expected calibration.
Parameters: - calibration_signal: np.array
signal to calibrate from (already cut to ONLY calibration)
- p_ref: float
Reference pressure to compute db from
Returns: - Updates the parameter preamp_gain