Skip to content

Commit

Permalink
Add type hints to the Channel class
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Mar 27, 2024
1 parent 97b0180 commit 36486e7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 37 deletions.
64 changes: 34 additions & 30 deletions HinetPy/channel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
import math

Expand All @@ -9,49 +11,51 @@

class Channel:
"""
Class for channel information.
Channel information for a single channel.
The information can be used to generate SAC polezero files.
"""

def __init__( # noqa: PLR0913
self,
id=None, # noqa: A002
name=None,
component=None,
latitude=None,
longitude=None,
unit=None,
gain=None,
damping=None,
period=None,
preamplification=None,
lsb_value=None,
id: str, # noqa: A002
name: str,
component: str,
latitude: float | str,
longitude: float | str,
unit: str,
gain: float | str,
damping: float | str,
period: float | str,
preamplification: float | str,
lsb_value: float | str,
):
"""
Initialize a channel.
Parameters
----------
id: str
id
Channel ID.
name: str
name
Station Name.
component: str
component
Channel component name (e.g., ``U``, ``N`` or ``E``).
latitude: float
latitude
Station latitude.
longitude: float
longitude
Station longitude.
unit: str
unit
Unit of data (e.g., ``m``, ``m/s``, ``m/s/s``, ``rad``).
gain: float
gain
Sensor sensitivity.
damping: float
damping
Damping constant of the sensor.
period: float
period
Natural period of the seismometer.
preamplification:
preamplification
Preamplification value.
lsb_value:
lsb_value
LSB value.
Notes
Expand All @@ -62,14 +66,14 @@ def __init__( # noqa: PLR0913
self.id = id
self.name = name
self.component = component
self.latitude = latitude
self.longitude = longitude
self.latitude = float(latitude)
self.longitude = float(longitude)
self.unit = unit
self.gain = gain
self.damping = damping
self.period = period
self.preamplification = preamplification
self.lsb_value = lsb_value
self.gain = float(gain)
self.damping = float(damping)
self.period = float(period)
self.preamplification = float(preamplification)
self.lsb_value = float(lsb_value)

def write_sacpz(self, pzfile, keep_sensitivity=False):
"""
Expand Down
14 changes: 7 additions & 7 deletions HinetPy/win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ def read_ctable(ctable):
id=items[0],
name=items[3],
component=items[4],
latitude=float(items[13]),
longitude=float(items[14]),
latitude=items[13],
longitude=items[14],
unit=items[8],
gain=float(items[7]),
damping=float(items[10]),
period=float(items[9]),
preamplification=float(items[11]),
lsb_value=float(items[12]),
gain=items[7],
damping=items[10],
period=items[9],
preamplification=items[11],
lsb_value=items[12],
)
)
except ValueError as err:
Expand Down

0 comments on commit 36486e7

Please sign in to comment.