-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forcings Engine Data Provider Interface and Lumped Forcings Implementation #720
Conversation
d4bb312
to
329d314
Compare
09f7873
to
6f8c3f4
Compare
Co-authored-by: Phil Miller - NOAA <[email protected]>
…ariables Co-authored-by: Phil Miller - NOAA <[email protected]>
Co-authored-by: Phil Miller - NOAA <[email protected]>
Co-authored-by: Phil Miller - NOAA <[email protected]>
…Provider::at Co-authored-by: Phil Miller - NOAA <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this. It would probably be good to get a fresh review from someone else, since I've poked at so many bits of this along the way.
@donaldwj @hellkite500 Could one of you review this? I'm happy with it, but I've also had a lot of say in its progression, so I don't want to be the one to sign off on it. |
This PR adds a
ForcingsEngineDataProvider
base class andForcingsEngineLumpedDataProvider
implementation.Implementation Details
ForcingsEngineDataProvider
is a templated base class taking two types,DataType
andSelectionType
, and inherits fromDataProvider<DataType, SelectionType>
. The base class handles Python module instantiation and timing functions, and leaves value acquisition to derived classes.ForcingsEngineLumpedDataProvider
is a derived class ofForcingsEngineDataProvider<double, CatchmentAggrDataSelector>
representing the forcings engine in lumped catchment mode (i.e.GRID_TYPE
in the config file is set to "hydrofabric").Since the forcings engine provides values over an entire domain, the classes are designed in a flyweight-like manner, where construction and instance referencing are through static maps for each templated base class of
ForcingsEngineDataProvider
, i.e. each derived class instance is stored in a map of its base type.Derived classes should implement a static construction function that uses the protected function
ForcingsEngineDataProvider::set_instance
, which moves aunique_ptr
of the base class into the static map. Then, to get an instance, callers should either use the return from the derived function (i.e.ForcingsEngineLumpedDataProvider::lumped_instance
), or get an existing instance usingForcingsEngineDataProvider<DataType, SelectionType>::instance
. Ownership and lifetime management are held by the static maps, so these functions return raw pointers (that do not imply any ownership).Additions
ForcingsEngineDataProvider
ForcingsEngineLumpedDataProvider
, and a corresponding test fixtureForcingsEngineLumpedDataProviderTest
.assert_forcings_engine_requirements
, which checks that the forcings engine python module is installed, and checks for the$WGRIB2
environment variable.Changes
NullForcingsEngine
implementation into source file so that theNGen::forcings
CMake target always has a source.Notes
WGRIB2
environment variable must be set to the path of the wgrib2 executable. If/when pywgrib2 is integrated, this will not be a requirement.To-Do
Checklist
Target Environment support