diff --git a/pyposeidon/schism.py b/pyposeidon/schism.py index 6ce34faa..bda59300 100644 --- a/pyposeidon/schism.py +++ b/pyposeidon/schism.py @@ -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 diff --git a/tests/test_schism.py b/tests/test_schism.py index d1449154..24796cca 100644 --- a/tests/test_schism.py +++ b/tests/test_schism.py @@ -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