Closed FelixMau closed 1 year ago
When initializing classes with attributes that can be either a sequence or a scalar sequence() is being called from __init__
. This Process turns eventually given default values like the fixed_costs
within facades.Storage
from integer into _Sequence
that is emulating a list with "unknown length" as explained in this example:
>>> s = _Sequence(default=42)
>>> len(s)
0
>>> s[1]
42
The Sequence class cannot be saved within a regular Datapackage.
When unpacking the AdapterClass to a dict with as_dict
(to save it as an Pandas.DataFrame
) I suggest that we test if we have recieved a sequence and if yes writing the default value of the _Sequence to the dict.
As it is now a empty list is being returned and when deseralizing the Datapackage it is interpreted as full Sequence
leading to errors since the sequence is actually empty. I think we could also improve on the tabular deserialization
part and improve its stability by catching this error and take the default value if a faulty iterable
is passed. This might be helpful as well for upcomming implementations of periodically
changing scalars
.
Edit: Problem here might be that we do not know the full timeseries length (or amount of steps) yet when initializing the facades, correct?
I would like your feedback regarding the plans on scalars within multi period feature.
@FelixMau
Suggestion 1:
I agree with you, thank you for tackling this. We will probably have to rework this after the
deserialization
is solved, but we will do this in a separate issue.Suggestion 2:
Currently, the
empty list
is detected asempty list
which is fine, as we actually save it in the wrong way. So we have to think of a different way of passing a_Sequence
via the datapackage. Concerning theperiodic-scalar
, I would wait until this is/or if it is fixed on theoemof.solph
side, but I am keen enhancing_sequence
for this. It makes sense to think this together. But we probably have to take care of #116 before
I gave the plumbing a try, see here, do you think thats possible to implement from the adapter side? to somehow catch it if the parameter change per period and are then written as a dict
?
But lets tackle this is in a new Issue
Test improvements moved to #43 Developing Period merging and reading moved to #40
To be able to create an energy system from a data package, you must provide a
datapackage.json
It is necessary to write down
foreign_keys
whilstbuild_datapackage
to keep track oftimeseries
column names and resource names. (Closes #23 ) Note: There is already a method within DataPackage class prepared for this purposeThe data package must provide the following information:
[x] The path where the resource (and foreign resources) is located.
[x] Information on fields, including their types and metadata (defaults could be used)
[x] Foreign keys that provide additional information, such as bus data.
[x] "Foreign keys" pointing to time series data, (different from ordinary foreign keys.)
[x] Additionally, a dataset needs to be built to contain all the buses (whilst
build_datapackage
).To monitor and check whether code is working properly: