Skip to content

[Feature] If time-index is shorter than given time-series don't error (Time Windows) #36

@dylanjm

Description

@dylanjm

Motivation

Currently, we raise a ValueError if the time-index doesn't match the time-series profiles given by the user. I think there needs to be some flexibility. I think we may have talked about this in a design meeting @caleb-sitton-inl and @GabrielSoto-INL about handling this different ways. We can use this issue to track windowing.

For example, today I was writing a dove script that loaded up a full 8760. I used that as my max_capacity_profiles and was initially dispatching on the full-year. Then I wanted to take a look at a 120 hour time window. I went and changed the time_index parameter on my system and got an error. It would be nice to quickly change time-horizon without having to filter my data down.

Design

I modified the verify_time_series method. Not sure if this is the best way to handle it, but it gets the job done:

diff --git a/src/dove/core/system.py b/src/dove/core/system.py
index b511ed5..59a9bb5 100644
--- a/src/dove/core/system.py
+++ b/src/dove/core/system.py
@@ -160,10 +160,13 @@ class System:
         # Check that time index length matches component capacity profiles
         for comp in self.components:
             if len(comp.max_capacity_profile) != len(self.time_index):
-                raise ValueError(
-                    f"Component '{comp.name}' has a capacity profile length "
-                    "that does not match the time index length!"
-                )
+                if len(comp.max_capacity_profile) > len(self.time_index):
+                    comp.max_capacity_profile = comp.max_capacity_profile[self.time_index]
+                else:
+                    raise ValueError(
+                        f"Component '{comp.name}' has a capacity profile length "
+                        "that does not match the time index length!"
+                    )

Impact

Quicker exploration of different dispatch windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions