@@ -144,6 +144,18 @@ def _read_profile(self, profile_key: str, index: int) -> Curve:
144144 ),
145145 )
146146
147+ def _read_profile_time_set (self , profile_key : str ) -> Array :
148+ """
149+ Create a profile's timeset from the results.
150+ """
151+ metadata = self .metadata
152+ profile_metadata = metadata .profiles [profile_key ]
153+ profile_time_set_key = profile_metadata ["time_set_key" ]
154+ time_set_key = ("profile_id" , profile_time_set_key )
155+ time_sets = read_time_sets (metadata , [time_set_key ])
156+ time_set = time_sets [time_set_key ]
157+ return Array (values = time_set , unit = metadata .time_sets_unit , category = "time" )
158+
147159 def get_positional_trend_curve (
148160 self ,
149161 property_name : str ,
@@ -170,7 +182,10 @@ def get_positional_trend_curve(
170182 return self ._read_trend (trend_key )
171183
172184 msg = [
173- f"Can not locate '{ property_name } ' trend for element '{ element_name } ' at position '{ position_m } '.\n Found positional trends:" ,
185+ (
186+ f"Can not locate '{ property_name } ' trend for element '{ element_name } '"
187+ f" at position '{ position_m } '.\n Found positional trends:"
188+ ),
174189 * map (str , self .list_positional_trends ()),
175190 ]
176191 raise RuntimeError ("\n - " .join (msg ))
@@ -189,7 +204,10 @@ def get_overall_trend_curve(self, property_name: str, element_name: str) -> Curv
189204 return self ._read_trend (trend_key )
190205
191206 msg = [
192- f"Can not locate overall '{ property_name } ' trend for element '{ element_name } '.\n Found overall trends:" ,
207+ (
208+ f"Can not locate overall '{ property_name } ' trend for element"
209+ f" '{ element_name } '.\n Found overall trends:"
210+ ),
193211 * map (str , self .list_overall_trends ()),
194212 ]
195213 raise RuntimeError ("\n - " .join (msg ))
@@ -254,25 +272,43 @@ def list_global_trends(self) -> Sequence[GlobalTrendMetadata]:
254272 if (trend_metadata ["network_element_name" ] is None )
255273 ]
256274
257- def get_profile_curve (
258- self , property_name : str , element_name : str , index : int
259- ) -> Curve :
275+ def _get_profile_key (self , property_name : str , element_name : str ) -> str :
260276 """
261- Return a profile curve at a given time step index.
277+ Return the profile key (used to access the profile data in low level) for the
278+ given property and element.
262279 """
263280 metadata = self .metadata
264281 for profile_key , profile_metadata in metadata .profiles .items ():
265282 if (profile_metadata ["property_id" ] == property_name ) and (
266283 profile_metadata ["network_element_name" ] == element_name
267284 ):
268- return self . _read_profile ( profile_key , index )
285+ return profile_key
269286
270287 msg = [
271- f"Can not locate '{ property_name } ' profile for element '{ element_name } '.\n Found profiles:" ,
288+ (
289+ f"Can not locate '{ property_name } ' profile for element '{ element_name } '."
290+ f"\n Found profiles:"
291+ ),
272292 * map (str , self .list_profiles ()),
273293 ]
274294 raise RuntimeError ("\n - " .join (msg ))
275295
296+ def get_profile_curve (
297+ self , property_name : str , element_name : str , index : int
298+ ) -> Curve :
299+ """
300+ Return a profile curve at a given time step index.
301+ """
302+ profile_key = self ._get_profile_key (property_name , element_name )
303+ return self ._read_profile (profile_key , index )
304+
305+ def get_profile_time_set (self , property_name : str , element_name : str ) -> Array :
306+ """
307+ Return the timeset for a given profile.
308+ """
309+ profile_key = self ._get_profile_key (property_name , element_name )
310+ return self ._read_profile_time_set (profile_key )
311+
276312 def list_profiles (self ) -> Sequence [ProfileMetadata ]:
277313 """
278314 List the collected profiles (and how many timesteps are present).
0 commit comments