Skip to content

Commit

Permalink
Merge pull request #1253 from OSOceanAcoustics/pre-commit-ci-update-c…
Browse files Browse the repository at this point in the history
…onfig

[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
leewujung authored Feb 2, 2024
2 parents b39c8c7 + 65626f5 commit 9f56124
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 49 deletions.
1 change: 1 addition & 0 deletions .ci_helpers/docker/setup-services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Script to help bring up docker services for testing.
"""

import argparse
import logging
import shutil
Expand Down
1 change: 1 addition & 0 deletions .ci_helpers/run-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Script to run tests in Github and locally.
"""

import argparse
import glob
import os
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ repos:
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8

Expand Down
6 changes: 3 additions & 3 deletions echopype/calibrate/cal_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,9 @@ def _get_fs():
elif p == "gain_correction":
# interpolate or pull from narrowband table
out_dict[p] = _get_interp_da(
da_param=None
if "gain" not in vend
else vend["gain"], # freq-dep values
da_param=(
None if "gain" not in vend else vend["gain"]
), # freq-dep values
freq_center=freq_center,
alternative=get_vend_cal_params_power(beam=beam, vend=vend, param=p),
)
Expand Down
1 change: 1 addition & 0 deletions echopype/commongrid/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions for enhancing the spatial and temporal coherence of data.
"""

import logging
from typing import Literal

Expand Down
1 change: 1 addition & 0 deletions echopype/consolidate/split_beam_angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Contains functions necessary to compute the split-beam (alongship/athwartship)
angles and add them to a Dataset.
"""

from typing import List, Tuple

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions echopype/convert/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Simrad EK80 echosounder ``.raw`` data
- ASL Environmental Sciences AZFP echosounder ``.01A`` data
"""

# flake8: noqa
from .parse_ad2cp import ParseAd2cp
from .parse_azfp import ParseAZFP
Expand Down
12 changes: 7 additions & 5 deletions echopype/convert/set_groups_ad2cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,14 @@ def _make_dataset(self, var_names: Dict[str, str]) -> xr.Dataset:
Union[Tuple[List[str], np.ndarray, Dict[str, str]], Tuple[Tuple[()], None]],
] = {
var_name: (
[dim.dimension_name() for dim in dims[field_name]],
combined_fields[field_name],
attrs.get(field_name, {}),
(
[dim.dimension_name() for dim in dims[field_name]],
combined_fields[field_name],
attrs.get(field_name, {}),
)
if field_exists[field_name]
else ((), None)
)
if field_exists[field_name]
else ((), None)
for field_name, var_name in var_names.items()
} # type: ignore
coords: Dict[str, np.ndarray] = dict()
Expand Down
1 change: 1 addition & 0 deletions echopype/convert/set_groups_azfp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Class to save unpacked echosounder data to appropriate groups in netcdf or zarr.
"""

from typing import List

import numpy as np
Expand Down
8 changes: 5 additions & 3 deletions echopype/convert/set_groups_ek80.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ def set_env(self) -> xr.Dataset:
),
"sound_velocity_profile_depth": (
["sound_velocity_profile_depth"],
self.parser_obj.environment["sound_velocity_profile"][::2]
if "sound_velocity_profile" in self.parser_obj.environment
else [],
(
self.parser_obj.environment["sound_velocity_profile"][::2]
if "sound_velocity_profile" in self.parser_obj.environment
else []
),
{
"standard_name": "depth",
"units": "m",
Expand Down
1 change: 1 addition & 0 deletions echopype/echodata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
EchoData is an object that handles interfacing raw converted data.
It is used for calibration and other processing.
"""

from . import convention
from .echodata import EchoData

Expand Down
16 changes: 10 additions & 6 deletions echopype/echodata/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,11 @@ def _combine(
{
"is_combined": is_combined,
"attrs_dict": _get_prov_attrs(ed["Provenance"], is_combined),
"echodata_filename": [str(s) for s in ed["Provenance"][ED_FILENAME].values]
if is_combined
else [echodata_filenames[idx]],
"echodata_filename": (
[str(s) for s in ed["Provenance"][ED_FILENAME].values]
if is_combined
else [echodata_filenames[idx]]
),
}
)
# Get single boolean value to see if there's any combined files
Expand All @@ -755,9 +757,11 @@ def _combine(

# select only the appropriate channels from each Dataset
ds_list = [
ds.sel(channel=ed_group_chan_sel[ed_group])
if ed_group_chan_sel[ed_group] is not None
else ds
(
ds.sel(channel=ed_group_chan_sel[ed_group])
if ed_group_chan_sel[ed_group] is not None
else ds
)
for ds in all_chan_ds_list
]

Expand Down
48 changes: 24 additions & 24 deletions echopype/echodata/sensor_ep_version_mapping/v05x_to_v06x.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,21 @@ def _change_beam_var_names(ed_obj, sensor):

if sensor in ["EK60", "EK80"]:
for beam_group in ed_obj._tree["Sonar"].children.values():
beam_group.ds.angle_sensitivity_alongship.attrs[
"long_name"
] = "alongship angle sensitivity of the transducer"
beam_group.ds.angle_sensitivity_alongship.attrs["long_name"] = (
"alongship angle sensitivity of the transducer"
)

beam_group.ds.angle_sensitivity_athwartship.attrs[
"long_name"
] = "athwartship angle sensitivity of the transducer"
beam_group.ds.angle_sensitivity_athwartship.attrs["long_name"] = (
"athwartship angle sensitivity of the transducer"
)

beam_group.ds.angle_offset_alongship.attrs[
"long_name"
] = "electrical alongship angle offset of the transducer"
beam_group.ds.angle_offset_alongship.attrs["long_name"] = (
"electrical alongship angle offset of the transducer"
)

beam_group.ds.angle_offset_athwartship.attrs[
"long_name"
] = "electrical athwartship angle offset of the transducer"
beam_group.ds.angle_offset_athwartship.attrs["long_name"] = (
"electrical athwartship angle offset of the transducer"
)


def _add_comment_to_beam_vars(ed_obj, sensor):
Expand Down Expand Up @@ -333,23 +333,23 @@ def _add_comment_to_beam_vars(ed_obj, sensor):
"angle corresponds to the major angle in SONAR-netCDF4 vers 2. "
)

beam_group.ds.angle_sensitivity_alongship.attrs[
"comment"
] = beam_group.ds.angle_offset_alongship.attrs["comment"]
beam_group.ds.angle_sensitivity_alongship.attrs["comment"] = (
beam_group.ds.angle_offset_alongship.attrs["comment"]
)

beam_group.ds.angle_sensitivity_athwartship.attrs[
"comment"
] = beam_group.ds.angle_offset_athwartship.attrs["comment"]
beam_group.ds.angle_sensitivity_athwartship.attrs["comment"] = (
beam_group.ds.angle_offset_athwartship.attrs["comment"]
)

if "angle_alongship" in beam_group.ds:
beam_group.ds.angle_alongship.attrs[
"comment"
] = beam_group.ds.angle_offset_alongship.attrs["comment"]
beam_group.ds.angle_alongship.attrs["comment"] = (
beam_group.ds.angle_offset_alongship.attrs["comment"]
)

if "angle_athwartship" in beam_group.ds:
beam_group.ds.angle_athwartship.attrs[
"comment"
] = beam_group.ds.angle_offset_athwartship.attrs["comment"]
beam_group.ds.angle_athwartship.attrs["comment"] = (
beam_group.ds.angle_offset_athwartship.attrs["comment"]
)


def _beam_groups_to_convention(ed_obj, set_grp_cls):
Expand Down
1 change: 1 addition & 0 deletions echopype/echodata/simrad.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Contains functions that are specific to Simrad echo sounders
"""

from typing import Optional, Tuple

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions echopype/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions to compute summary statistics from echo data.
"""

from .summary_statistics import abundance, aggregation, center_of_mass, dispersion, evenness

__all__ = [
Expand Down
1 change: 1 addition & 0 deletions echopype/utils/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Module containing various helper functions
for performing computations within echopype.
"""

from typing import Union

import dask.array
Expand Down
1 change: 1 addition & 0 deletions echopype/utils/io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
echopype utilities for file handling
"""

import os
import pathlib
import platform
Expand Down
8 changes: 2 additions & 6 deletions echopype/utils/uwa.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utilities for calculating seawater acoustic properties.
"""

import numpy as np


Expand Down Expand Up @@ -36,12 +37,7 @@ def calc_sound_speed(temperature=27, salinity=35, pressure=10, formula_source="M
temperature −2 to 30 °C, salinity 30 to 40 ppt, and depth 0 to 8000 m.
"""
if formula_source == "Mackenzie":
ss = (
1448.96
+ 4.591 * temperature
- 5.304e-2 * temperature**2
+ 2.374e-4 * temperature**3
)
ss = 1448.96 + 4.591 * temperature - 5.304e-2 * temperature**2 + 2.374e-4 * temperature**3
ss += 1.340 * (salinity - 35) + 1.630e-2 * pressure + 1.675e-7 * pressure**2
ss += -1.025e-2 * temperature * (salinity - 35) - 7.139e-13 * temperature * pressure**3
elif formula_source == "AZFP":
Expand Down

0 comments on commit 9f56124

Please sign in to comment.