Skip to content

Commit

Permalink
schism: Add parse_station_in()
Browse files Browse the repository at this point in the history
  • Loading branch information
pmav99 committed May 2, 2024
1 parent f74b63d commit 234d9f5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pyposeidon/schism.py
Original file line number Diff line number Diff line change
Expand Up @@ -1984,3 +1984,8 @@ def parse_staout(path: os.PathLike[str] | str, start: pd.Timestamp = pd.NaT):
index = index.rename("time")
df = df.set_index(index)
return df


def parse_station_in(path: os.PathLike[str] | str = "station.in") -> pd.DataFrame:
df = pd.read_csv(path, skiprows=2, header=None, names=["lon", "lat", "layer"], sep="\s+")
return df
3 changes: 3 additions & 0 deletions tests/data/station.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1 0 0 0 0 0 0 0 0
1
1 -21.9435235194 64.1473641012 0
12 changes: 12 additions & 0 deletions tests/test_schism.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,15 @@ def test_parse_staout_with_start_date():
assert isinstance(df.index, pd.DatetimeIndex)
assert df.index.name == "time"
assert df.index[0] == pd.Timestamp("2017-10-01T00:02:30") # that's 150 seconds after midnight


def test_parse_station_in():
path = DATA_DIR / "station.in"
df = pyposeidon.schism.parse_station_in(path)
assert isinstance(df, pd.DataFrame)
assert len(df) == 1
assert len(df.columns) == 3
assert df.columns.equals(pd.Index(["lon", "lat", "layer"]))
assert df.iloc[0].lon == -21.9435235194
assert df.iloc[0].lat == 64.1473641012
assert df.iloc[0].layer == 0

0 comments on commit 234d9f5

Please sign in to comment.