Skip to content

Feature/scenarios dims order#219

Merged
FBumann merged 11 commits intofeature/scenariosfrom
feature/scenarios-dims-order
Apr 5, 2025
Merged

Feature/scenarios dims order#219
FBumann merged 11 commits intofeature/scenariosfrom
feature/scenarios-dims-order

Conversation

@FBumann
Copy link
Member

@FBumann FBumann commented Apr 5, 2025

No description provided.

@FBumann
Copy link
Member Author

FBumann commented Apr 5, 2025

Change the order of dimensions

  • time is always the first dimension.
    This seems more intuitive and brings more consistency

Furthermore, converting a solution to a Dataframe with array.DataArray.to_pandas()results in:

  • a pd.Series if no Scenario is Present
  • a pd.DataFrame with the scenario as the columns.
In[4]: 
calculation.results.solution['CHP(Q_th)|flow_rate'].to_pandas()
Out[4]: 
scenario             Base Case  High Demand
time                                       
2020-01-01 00:00:00  25.000000    25.000000
2020-01-01 01:00:00  21.666667    21.666667
2020-01-01 02:00:00  75.000000    75.000000
2020-01-01 03:00:00  75.000000    75.000000
2020-01-01 04:00:00  75.000000    75.000000
2020-01-01 05:00:00  15.000000    15.000000
2020-01-01 06:00:00  15.000000    15.000000
2020-01-01 07:00:00  15.000000    15.000000
2020-01-01 08:00:00  15.000000    15.000000
2020-01-01 09:00:00        NaN          NaN

When initiating data from numpy, this needs to be done as follows:

For Data for each timestep and scenario, a 2D array is needed. But :

heat_demand_per_h = array([
       [ 30,  30],
       [  0,   0],
       [ 90, 100],
       [110, 118],
       [110, 125],
       [ 20,  20],
       [ 20,  20],
       [ 20,  20],
       [ 20,  20]
])

# Or for convenience:
heat_demand_per_h = np.array([[30, 0, 90, 110, 110, 20, 20, 20, 20], 
                                                         [30, 0, 100, 118, 125, 20, 20, 20, 20]]).T

For Data for each timestep, a 1D array is enough:

  heat_demand_per_h = np.array([30, 0, 90, 110, 110, 20, 20, 20, 20])

As for data per scenario

 heat_demand_per_h = np.array([20, 30])

@FBumann FBumann merged commit 28a46dc into feature/scenarios Apr 5, 2025
@FBumann FBumann deleted the feature/scenarios-dims-order branch April 11, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant