Regions2D

class echoregions.formats.Regions2D(input_file=None, parse=True, convert_time=False, convert_range_edges=True, offset=0, min_depth=None, max_depth=None, raw_range=None)

Bases: object

Attributes
input_file

String path to the EVR file

max_depth

Get the depth value that the 9999.99 edge will be set to

min_depth

Get the depth value that the -9999.99 edge will be set to

output_data

Dictionary containing region data and metadata for the EVR file

output_file

Path(s) to the list of files saved.

raw_range

Get the range vector that provides the min_depth and max_depth

region_ids

Get region ids available

Methods

close_region(points)

Closes a region by appending the first point to the end

convert_output([convert_time, …])

Convert x and y values of points from the EV format.

convert_points(points[, convert_time, …])

Convert x and y values of points from the EV format.

get_points_from_region(region[, file])

Get points from specified region from a JSON or CSV file or from the parsed data.

get_region_classifications([grouped])

Get the region classification for each region in the EVR file

get_region_ids()

Get the ids of all regions in the EVR file

mask_region(ds, region[, data_var, offset])

Mask an xarray dataset

parse_file([convert_time, …])

Parse the EVR file into Regions2D.output_data

plot_region(region[, offset])

Plot a region from output_data.

select_raw(files[, region_id, t1, t2])

Finds raw files in the time domain that encompasses region or list of regions

set_range_edge_from_raw(raw[, model])

Calculate the sonar range from a raw file using Echopype.

to_csv([save_path])

Convert an EVR file to a CSV file

to_dataframe(**kwargs)

Organize EVR data into a Pandas DataFrame.

to_json([save_path])

Convert EVR to a JSON file

Attributes Summary

max_depth

Get the depth value that the 9999.99 edge will be set to

min_depth

Get the depth value that the -9999.99 edge will be set to

output_data

Dictionary containing region data and metadata for the EVR file

output_file

Path(s) to the list of files saved.

Regions2D.plotter

raw_range

Get the range vector that provides the min_depth and max_depth

Regions2D.region_classifications

Regions2D.regions

Methods Summary

convert_output([convert_time, …])

Convert x and y values of points from the EV format.

convert_points(points[, convert_time, …])

Convert x and y values of points from the EV format.

get_points_from_region(region[, file])

Get points from specified region from a JSON or CSV file or from the parsed data.

get_region_classifications([grouped])

Get the region classification for each region in the EVR file

Regions2D.get_regions

parse_file([convert_time, …])

Parse the EVR file into Regions2D.output_data

plot_region(region[, offset])

Plot a region from output_data.

select_raw(files[, region_id, t1, t2])

Finds raw files in the time domain that encompasses region or list of regions

set_range_edge_from_raw(raw[, model])

Calculate the sonar range from a raw file using Echopype.

to_csv([save_path])

Convert an EVR file to a CSV file

to_json([save_path])

Convert EVR to a JSON file

Attributes Documentation

max_depth

Get the depth value that the 9999.99 edge will be set to

min_depth

Get the depth value that the -9999.99 edge will be set to

output_data

Dictionary containing region data and metadata for the EVR file

output_file

Path(s) to the list of files saved. String if a single file. LIst of strings if multiple.

raw_range

Get the range vector that provides the min_depth and max_depth

Methods Documentation

convert_output(convert_time=True, convert_range_edges=True)

Convert x and y values of points from the EV format. Modifies Regions2d.output_data. See convert_points for arguments.f

convert_points(points, convert_time=True, convert_range_edges=True, offset=0, unix=False)

Convert x and y values of points from the EV format. Returns a copy of points.

Parameters
pointslist, dict

Point in [x, y] format or list/dict of these

convert_timebool, default True

Convert EV time to datetime64.

convert_range_edgesbool, default True

Convert -9999.99 edges to real range values. Min and max ranges must be set manually or by calling set_range_edge_from_raw

offsetfloat, default 0

Depth offset in meters

unixbool, default False

Output the time in the unix time format

Returns
list or dict

single converted point or list/dict of converted points depending on input

get_points_from_region(region, file=None)

Get points from specified region from a JSON or CSV file or from the parsed data.

Parameters
regionint, str, or dict

ID of the region to extract points from or region dictionary

filestr

path to JSON or CSV file. Use parsed data if None

Returns
pointslist

list of x, y points

get_region_classifications(grouped=False)

Get the region classification for each region in the EVR file

Returns
regions classificationsdict

dict with keys as region id and values as the region classification

parse_file(convert_time=False, convert_range_edges=True, offset=0)

Parse the EVR file into Regions2D.output_data

Parameters
convert_timebool, default False
Convert times in the EV datetime format to numpy datetime64.

Numpy datetime64 objects cannot be saved to JSON.

convert_range_edgesbool, default True

Convert -9999.99 and -9999.99 depth edges to real values for EVR files. Set the values by assigning range values to min_depth and max_depth or by passing a file into set_range_edge_from_raw.

offsetfloat, default 0

Depth offset in meters

plot_region(region, offset=0)

Plot a region from output_data. Automatically convert time and range_edges.

regionstr

region_id to plot

offsetfloat

A depth offset in meters added to the range of the points used for masking

Returns
xnp.ndarray

x points used by the matplotlib plot function

ynp.ndarray

y points used by the matplotlib plot function

select_raw(files, region_id=None, t1=None, t2=None)

Finds raw files in the time domain that encompasses region or list of regions

Parameters
fileslist

raw filenames

region_idstr or list

region(s) to select raw files with If none, select all regions. Defaults to None

t1str, numpy datetime64

lower bound to select files from. either EV time string or datetime64 object

t2str, numpy datetime64

upper bound to select files from either EV time string or datetime64 object

Returns
rawstr, list

raw file as a string if a single raw file is selected. list of raw files if multiple are selected.

set_range_edge_from_raw(raw, model='EK60')

Calculate the sonar range from a raw file using Echopype. Used to replace EVR depth edges -9999.99 and 9999.99 with real values

Parameters
rawstr

Path to raw file

modelstr

The sonar model that created the raw file, defaults to EK60. See echopype for list of supported sonar models. Echoregions is only tested with EK60

to_csv(save_path=None, **kwargs)

Convert an EVR file to a CSV file

Parameters
save_pathstr

Path to save csv file to

convert_timebool, default False

Convert times in the EV datetime format to numpy datetime64.

kwargskeyword arguments

Additional arguments passed to Regions2D.parse_file

to_json(save_path=None, **kwargs)

Convert EVR to a JSON file

Parameters
save_pathstr

Path to save csv file to

prettybool, default False

Output more human readable JSON

kwargskeyword arguments

Additional arguments passed to Regions2D.parse_file