multi-vector-simulator
multi-vector-simulator copied to clipboard
[Bug] Simulation result is not always JSON compatible
As I understand, the simulation results are supposed to be JSON compatible. However, in edge cases the results include Infinity, -Infinity and NaN. Those are by defintion not strict JSON compatible and results in an error in other languages like TypeScript/JavaScript when calling json.parse()
Example output for a simulation with PV, Inverter, Battery and demand:
{ ...
"energy_storage": [
{ ...
"timeseries_soc": {
"unit": "kWh",
"value": [-Infinity, -Infinity, NaN, ... ]
},
... }],
...}
Possible Solutions:
- Parsing Infinity, -Infinity and NaN as null which is supported by JSON -> Issue: loosing information because NaN is definitely not the same as Infinity, same with -Infinity vs Infinity
- Parsing them as strings like 'Infinity' , ' -Infinity' and 'NaN' -> Issue: Now the type of a timeseries is a bit muddled because it is a mix between numbers and strings in the array
- Parsing Infinity and -Infinity as 1e9999 and -1e9999 or another extremely high number and NaN as null (Best solution in my opinion)
- Letting the end user handle it but then please make a comment in the documentation