-
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
Gridded Data Selectors #799
Comments
Some notes: Initial DesignCurrently, I'm envisioning a gridded data selector as a struct holding cell indices, where struct Cell {
std::uint64_t x, y, z;
double value;
}; // 32 bytes Then, for selection, we'd just need a struct Extent {
double xmin, xmax, ymin, ymax;
};
struct GridSpecification {
//! Total number of rows (aka y)
std::uint64_t rows;
//! Total number of columns (aka x)
std::uint64_t columns;
//! Extent of the grid region (aka min-max corner points)
Extent extent;
}; Using a struct SelectorConfig {
//! Initial time for query.
//! @todo Refactor to use std::chrono
time_t init_time;
//! Duration for query, in seconds.
//! @todo Refactor to use std::chrono
long duration_seconds;
//! Variable to return from query.
std::string variable_name;
//! Units for output variable.
std::string variable_units;
};
struct GridDataSelector;
GridDataSelector::GridDataSelector(
SelectorConfig config,
const GridSpecification& grid,
boost::span<const geojson::coordinate_t> points
); Where the implementation simply encodes the point coordinates against the grid specification. I'll probably assume planar coordinates, as that simplifies the implementation and the numerical error will most likely be negligible. Encoding CoordinatesCoordinates can be encoded to a grid axis by taking the size of that axis ( std::uint64_t coordinate_to_axis_index(
double position,
double min,
double max,
std::uint64_t upper_bound
) {
const double diff = static_cast<double>(upper_bound) / (max - min);
// Coordinate position is within or on the grid axis bounds
if (position >= min && position <= max) {
return std::floor((position - min) * diff);
}
// Coordinate position is out of bounds, so
// return a sentinel or throw an exception
return static_cast<std::uint64_t>(-1);
} ProvidersUnlike the current data providers, a gridded data provider may look like: class SomeGridDataProvider : public data_access::DataProvider<Cell, GridDataSelector>
{ ... }; The main difference is in the base class. This will imply the return value SomeGridDataProvider::get_values(...) -> std::vector<Cell> So, a |
Just to make sure I don't confuse things with irrelevant comments, this issue's notes are all aimed at models like Noah-OWP-Modular, which will run over (a masked subset of) a regular grid, right? Unstructured mesh nodes/elements will be addressed separately? |
@PhilMiller For the first pass of gridded data selectors, yes, I'm just tackling (uniform) structured grids. |
Following the intergration of the Gridded Forcing Engine (#705), implement gridded data selectors for DataProviders to allow connecting gridded formulations to gridded input data.
The text was updated successfully, but these errors were encountered: