Skip to content

Commit

Permalink
Deal with schism bug in station output
Browse files Browse the repository at this point in the history
Manually set the time index of staout files
Fix #174
  • Loading branch information
brey committed Jan 21, 2024
1 parent 730d342 commit cf32241
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pyposeidon/schism.py
Original file line number Diff line number Diff line change
Expand Up @@ -1903,14 +1903,22 @@ def get_station_sim_data(self, **kwargs):

skiprows = kwargs.get("station_skiprows", 0)

try:
dt = self.parameters["dt"]
except:
dt = self.params["core"]["dt"]

dfs = []
for idx in vals.index:
obs = np.loadtxt(sfiles[idx], skiprows=skiprows)
df = pd.DataFrame(obs)
df = df.set_index(0)
df.index.name = "time"
df.columns.name = vals.loc[idx, "variable"]
df.index = pd.to_datetime(dstamp) + pd.to_timedelta(df.index, unit="S")
# deal with schism bug
ns = np.arange(1, df.shape[0] + 1)
df.index = pd.to_datetime(dstamp) + pd.to_timedelta(ns * dt, unit="S")
# df.index = pd.to_datetime(dstamp) + pd.to_timedelta(df.index, unit="S")
pindex = pd.MultiIndex.from_product([df.T.columns, df.T.index])

r = pd.DataFrame(df.values.flatten(), index=pindex, columns=[vals.loc[idx, "variable"]])
Expand Down

0 comments on commit cf32241

Please sign in to comment.