-
Notifications
You must be signed in to change notification settings - Fork 1
Update ngen to generate catchment output variables in a combined netCDF file (NGWPC-9011) #106
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
base: development
Are you sure you want to change the base?
Changes from 2 commits
7837b09
b44c038
6fcb180
4358f6a
3dcac1a
74a624a
53f7022
43fb963
fc5eec5
915c0c3
fff50aa
f4b8819
cf5e694
b82797b
971c830
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #include <netcdf> | ||
| #include <Formulation_Manager.hpp> | ||
| #include <Simulation_Time.hpp> | ||
| #include <Catchment_Formulation.hpp> | ||
|
|
||
| using namespace netCDF; | ||
|
|
||
| class NetCDFCreator | ||
| { | ||
| public: | ||
| NetCDFCreator(std::shared_ptr<realization::Formulation_Manager> manager, | ||
| const std::string& output_name, Simulation_Time const& sim_time); | ||
| NetCDFCreator() = delete; | ||
| ~NetCDFCreator(); | ||
|
|
||
| private: | ||
| std::shared_ptr<Simulation_Time> sim_time_; | ||
| NcDim timeDim; | ||
| NcDim catchmentsDim; | ||
| std::map<std::string, std::shared_ptr<realization::Catchment_Formulation>> formulations; | ||
|
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #include <NetCDFCreator.hpp> | ||
| #include <Catchment_Formulation.hpp> | ||
| #include <Logger.hpp> | ||
|
|
||
| using namespace netCDF; | ||
|
|
||
|
|
||
| NetCDFCreator::NetCDFCreator(std::shared_ptr<realization::Formulation_Manager> manager, | ||
| const std::string& output_name,Simulation_Time const& sim_time) | ||
| :catchmentNcFile_(manager->get_output_root() + output_name + ".nc",NcFile::replace) | ||
|
||
| ,sim_time_(std::make_shared<Simulation_Time>(sim_time)) | ||
| { | ||
| timeDim = catchmentNcFile_.addDim("time", NC_UNLIMITED); //unlimited dimension to append data efficiently without redefining the entire file structure | ||
| NcVar timeVar = catchmentNcFile_.addVar("time", NC_INT64, timeDim); | ||
| catchmentsDim = catchmentNcFile_.addDim("catchments", manager->get_size()); | ||
|
|
||
| int start_t = sim_time_->get_current_epoch_time(); | ||
| timeVar.putVar(&start_t); | ||
| for (int t_step = 0; t_step < sim_time_->get_total_output_times(); t_step++) { | ||
| int next_t = sim_time_->next_timestep_epoch_time(); | ||
| timeVar.putVar(&next_t); | ||
| } | ||
|
|
||
| formulations = std::map<std::string, std::shared_ptr<realization::Catchment_Formulation>>(manager->begin(), manager->end()); | ||
| for (auto const& catchment : formulations){ | ||
|
|
||
| } | ||
| } | ||
|
|
||
| NetCDFCreator::~NetCDFCreator() = default; | ||
Uh oh!
There was an error while loading. Please reload this page.