Retrieving results for functional units has been problematic because Functional unit results don't fit neatly within the three main criteria (NetworkElement - which maps to catchment, RecordingElement and RecordingVariable).
Long story short - the typical behaviour is that you get N subcatchments M functional units M functional units.
So, in the example here, 10 catchments, 5 functional units leads to 10 x 5 x 5 = 250 time series being retrieved, rather than the expected 50.
This can partly be dealt with by using an appropriate column naming function (veneer.name_for_fu_and_sc) and then filtering the results, but its still annoying, slow and wastes memory.
In recent versions of Veneer, you can now request results for a specific Functional Unit. You need to call v.retrieve_multiple_time_series
multiple times, but you end up with just what you're after
In [54]:
import veneer
In [55]:
v = veneer.Veneer()
In [56]:
set(v.model.catchment.get_functional_unit_types())
Out[56]:
In [57]:
v.drop_all_runs()
In [58]:
v.configure_recording(enable=[{'RecordingVariable':'Total Flow'}])
In [59]:
v.run_model()
Out[59]:
In [60]:
res = v.retrieve_multiple_time_series(criteria={'RecordingVariable':'Total Flow'})
res[:10]
Out[60]:
In [61]:
len(res.columns)
Out[61]:
In [62]:
res.columns
Out[62]:
In [63]:
res = v.retrieve_multiple_time_series(criteria={'RecordingVariable':'Total Flow'},name_fn=veneer.name_for_fu_and_sc)
res[:10]
Out[63]:
In [64]:
res.columns
Out[64]:
Recent versions of Veneer support the FunctionalUnit
criteria. Note this is only available on retrieve_multiple_time_series
- not available on configure_recording
.
This version is bundled with Source 4.6 onwards and available in custom Veneer builds for earlier versions of Source
In [48]:
v.retrieve_multiple_time_series?
In [52]:
res = v.retrieve_multiple_time_series(criteria={'RecordingVariable':'Total Flow','FunctionalUnit':'GeneratedFunctionalUnit0'},
name_fn=veneer.name_for_fu_and_sc)
res[:10]
Out[52]:
In [53]:
res.columns
Out[53]:
In [ ]: