diff --git a/aimbat/lib/data.py b/aimbat/lib/data.py index cef762c..bcfc302 100644 --- a/aimbat/lib/data.py +++ b/aimbat/lib/data.py @@ -34,6 +34,8 @@ def _create_station( select(AimbatStation) .where(AimbatStation.name == new_aimbat_station.name) .where(AimbatStation.network == new_aimbat_station.network) + .where(AimbatStation.channel == new_aimbat_station.channel) + .where(AimbatStation.location == new_aimbat_station.location) ) aimbat_station = session.exec(select_aimbat_station).one_or_none() @@ -106,7 +108,6 @@ def add_files_to_project( """Add files to the AIMBAT database. Parameters: - session: Database session. datasources: List of data sources to add. datatype: Type of data. disable_progress_bar: Do not display progress bar. diff --git a/aimbat/lib/io/_sac.py b/aimbat/lib/io/_sac.py index 5f156c1..9fcd836 100644 --- a/aimbat/lib/io/_sac.py +++ b/aimbat/lib/io/_sac.py @@ -60,8 +60,8 @@ def create_station_from_sacfile(sacfile: str | PathLike) -> AimbatStation: logger.debug(f"Reading station data from {sacfile}.") - event = SAC.from_file(sacfile).station - aimbat_station = AimbatStation.model_validate(event) + station = SAC.from_file(sacfile).station + aimbat_station = AimbatStation.model_validate(station) return aimbat_station diff --git a/aimbat/lib/models.py b/aimbat/lib/models.py index c2b05f8..14569b2 100644 --- a/aimbat/lib/models.py +++ b/aimbat/lib/models.py @@ -55,7 +55,7 @@ class AimbatEvent(SQLModel, table=True): active: bool | None = Field(default=None, unique=True) "Indicates if an event is the active event." - time: datetime = Field(unique=True, sa_type=_DateTimeUTC) + time: datetime = Field(unique=True, sa_type=_DateTimeUTC, allow_mutation=False) "Event time." latitude: float @@ -149,15 +149,21 @@ class AimbatStation(SQLModel, table=True): name: str = Field(allow_mutation=False) "Station name." + network: str = Field(allow_mutation=False) + "Network name." + + location: str = Field(allow_mutation=False) + "Location ID." + + channel: str = Field(allow_mutation=False) + "Channel code." + latitude: float "Station latitude" longitude: float "Station longitude" - network: str | None = Field(default=None, allow_mutation=False) - "Network name." - elevation: float | None = None "Station elevation." diff --git a/aimbat/lib/station.py b/aimbat/lib/station.py index 0095e59..33e5474 100644 --- a/aimbat/lib/station.py +++ b/aimbat/lib/station.py @@ -110,6 +110,8 @@ def print_station_table(short: bool, all_events: bool = False) -> None: table.add_column( "Name & Network", justify="center", style=TABLE_STYLING.mine, no_wrap=True ) + table.add_column("Channel", justify="center", style=TABLE_STYLING.mine) + table.add_column("Location", justify="center", style=TABLE_STYLING.mine) table.add_column("Latitude", justify="center", style=TABLE_STYLING.mine) table.add_column("Longitude", justify="center", style=TABLE_STYLING.mine) table.add_column("Elevation", justify="center", style=TABLE_STYLING.mine) @@ -128,6 +130,8 @@ def print_station_table(short: bool, all_events: bool = False) -> None: else str(aimbat_station.id) ), f"{aimbat_station.name} - {aimbat_station.network}", + f"{aimbat_station.channel}", + f"{aimbat_station.location}", ( f"{aimbat_station.latitude:.3f}" if short diff --git a/flake.lock b/flake.lock index 74b0821..d89e582 100644 --- a/flake.lock +++ b/flake.lock @@ -72,11 +72,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1758690382, - "narHash": "sha256-NY3kSorgqE5LMm1LqNwGne3ZLMF2/ILgLpFr1fS4X3o=", + "lastModified": 1759036355, + "narHash": "sha256-0m27AKv6ka+q270dw48KflE0LwQYrO7Fm4/2//KCVWg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e643668fd71b949c53f8626614b21ff71a07379d", + "rev": "e9f00bd893984bc8ce46c895c3bf7cac95331127", "type": "github" }, "original": { diff --git a/tests/lib/test_lib_common.py b/tests/lib/test_lib_common.py index 2de88e0..22c9e65 100644 --- a/tests/lib/test_lib_common.py +++ b/tests/lib/test_lib_common.py @@ -16,14 +16,20 @@ def session_with_stations( ) -> Iterator[Session]: station_1 = AimbatStation( id=UUID1, - name="test_station_1", + name="TEST1", + network="TE", + channel="BHZ", + location="", latitude=12, longitude=12, elevation=12, ) station_2 = AimbatStation( id=UUID2, - name="test_station_2", + name="TEST2", + network="TE", + channel="BHZ", + location="", latitude=12, longitude=12, elevation=12, diff --git a/uv.lock b/uv.lock index 0975fb3..5673266 100644 --- a/uv.lock +++ b/uv.lock @@ -230,15 +230,15 @@ wheels = [ [[package]] name = "beautifulsoup4" -version = "4.14.0" +version = "4.14.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "soupsieve" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/8a/bb/3387a5bf72121e1e2cd9223d20598c2fb599ef63517ff3e6ec526d8c4928/beautifulsoup4-4.14.0.tar.gz", hash = "sha256:e6150e53c8a52fd4f3b9b28839f8f0fb7c7f029d3c953a50b1762b0947c3cf85", size = 625697, upload-time = "2025-09-27T17:22:17.532Z" } +sdist = { url = "https://files.pythonhosted.org/packages/77/e9/df2358efd7659577435e2177bfa69cba6c33216681af51a707193dec162a/beautifulsoup4-4.14.2.tar.gz", hash = "sha256:2a98ab9f944a11acee9cc848508ec28d9228abfd522ef0fad6a02a72e0ded69e", size = 625822, upload-time = "2025-09-29T10:05:42.613Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/28/4f/3e23dfc8b4951103028d30f29e17aa703a87564abd71bc405964c36326dc/beautifulsoup4-4.14.0-py3-none-any.whl", hash = "sha256:aee96fbccdf2d2a8d1288b2afa51fc76bb60823b7881a50fb1ed5f711d1a7d73", size = 106466, upload-time = "2025-09-27T17:22:16.13Z" }, + { url = "https://files.pythonhosted.org/packages/94/fe/3aed5d0be4d404d12d36ab97e2f1791424d9ca39c2f754a6285d59a3b01d/beautifulsoup4-4.14.2-py3-none-any.whl", hash = "sha256:5ef6fa3a8cbece8488d66985560f97ed091e22bbc4e9c2338508a9d5de6d4515", size = 106392, upload-time = "2025-09-29T10:05:43.771Z" }, ] [[package]] @@ -785,7 +785,7 @@ wheels = [ [[package]] name = "ipython" -version = "9.5.0" +version = "9.6.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, @@ -799,9 +799,9 @@ dependencies = [ { name = "stack-data" }, { name = "traitlets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/6e/71/a86262bf5a68bf211bcc71fe302af7e05f18a2852fdc610a854d20d085e6/ipython-9.5.0.tar.gz", hash = "sha256:129c44b941fe6d9b82d36fc7a7c18127ddb1d6f02f78f867f402e2e3adde3113", size = 4389137, upload-time = "2025-08-29T12:15:21.519Z" } +sdist = { url = "https://files.pythonhosted.org/packages/2a/34/29b18c62e39ee2f7a6a3bba7efd952729d8aadd45ca17efc34453b717665/ipython-9.6.0.tar.gz", hash = "sha256:5603d6d5d356378be5043e69441a072b50a5b33b4503428c77b04cb8ce7bc731", size = 4396932, upload-time = "2025-09-29T10:55:53.948Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/08/2a/5628a99d04acb2d2f2e749cdf4ea571d2575e898df0528a090948018b726/ipython-9.5.0-py3-none-any.whl", hash = "sha256:88369ffa1d5817d609120daa523a6da06d02518e582347c29f8451732a9c5e72", size = 612426, upload-time = "2025-08-29T12:15:18.866Z" }, + { url = "https://files.pythonhosted.org/packages/48/c5/d5e07995077e48220269c28a221e168c91123ad5ceee44d548f54a057fc0/ipython-9.6.0-py3-none-any.whl", hash = "sha256:5f77efafc886d2f023442479b8149e7d86547ad0a979e9da9f045d252f648196", size = 616170, upload-time = "2025-09-29T10:55:47.676Z" }, ] [[package]] @@ -2158,7 +2158,7 @@ wheels = [ [[package]] name = "pysmo" version = "1.0.0.dev1" -source = { git = "https://github.com/pysmo/pysmo?rev=master#be0a78278f849f5120ac00de12e1ebd2316e399f" } +source = { git = "https://github.com/pysmo/pysmo?rev=master#6262a8ea4a465a5cd0346228e543055d123ddd8b" } dependencies = [ { name = "attrs" }, { name = "attrs-strict" },