-
Hi Do anyone know if there is a possibility to read res1d files from the LTS simulation. The current Res1D(filename).read() does only work for "normal" simulation results. Kind regards |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I would appreciate this as well. Some LTS-results can be extracted using the exampe below to extract maximum water levels for a node, but i cannot extract values from structures like weirs and pumps. The reason for this is that the time stamp for the data is all 1-1-100 00:00, and this is an unsupported time. When using the query below the time stamp index is omitted. Values = to_numpy(res1d.query.GetNodeValues(‘Node_57’, 'WaterLevelMaximum')) |
Beta Was this translation helpful? Give feedback.
-
Hi, currently it is not possible to read LTS event statistics result files with mikeio1d. import mikeio1d
from mikeio1d.res1d import Res1D, QueryDataNode
from mikeio1d.dotnet import from_dotnet_datetime
import datetime
import pandas as pd
class MyLongTermStatisticsRes1D(Res1D):
@property
def time_index(self):
""" pandas.DatetimeIndex of the time index. """
if self._time_index is not None:
return self._time_index
number_of_event_entries = len(self.data.TimesList)
event_index = [i for i in range(number_of_event_entries)]
self._time_index = pd.Index(event_index)
return self._time_index
# ----------- Read extreme statistics -----------
# Read in an LTS file
filepath = "LTSEventStatistics.res1d"
res1d = MyLongTermStatisticsRes1D(filepath)
# Create a maximum water level query for a particular node
node_id = "B4.1485"
water_level_maximum = QueryDataNode("WaterLevelMaximum", node_id)
water_level_maximum_time = QueryDataNode("WaterLevelMaximumTime", node_id)
df = res1d.read([water_level_maximum, water_level_maximum_time])
# Convert the times of events from seconds after reporting start time to readable date time
simulation_start = from_dotnet_datetime(res1d.data.StartTime)
seconds_after_simulation_start_array = df['WaterLevelMaximumTime:B4.1485'].to_numpy()
times = [simulation_start + datetime.timedelta(seconds=sec) for sec in seconds_after_simulation_start_array]
df['WaterLevelMaximumTime:B4.1485'] = times
print(df)
# ----------- Read chronological statistics -----------
filepath = "LTSMonthlyStatistics.res1d"
res1d = Res1D(filepath)
df = res1d.read()
print(df) I hope it helps. When I will find the time, I will update mikeio1d with this functionality. |
Beta Was this translation helpful? Give feedback.
-
Hi, I also managed to figure out how to do it. My Python skills are novice compared to yours @gedaskir, but it works fine and maybe others can use it as well :) Sorry for the danish comments.
|
Beta Was this translation helpful? Give feedback.
-
@Prebbish Nice that you have figure out how to deal with LTS results. Now it is possible to read the LTS results directly using mikeio1d 0.2 as described in this notebook: |
Beta Was this translation helpful? Give feedback.
@Prebbish Nice that you have figure out how to deal with LTS results. Now it is possible to read the LTS results directly using mikeio1d 0.2 as described in this notebook:
https://github.com/DHI/mikeio1d/blob/main/notebooks/res1d_lts.ipynb