-
Notifications
You must be signed in to change notification settings - Fork 179
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
WIP: use netcdf/cf inspired model for tracking CRS information #899
Conversation
flake8 complains about starting variable with a Capital letter, for some math code using variables like X, Y, XX, XY makes perfect sense. since flake8 does not support per file configuration we just allow a whitelist of such variables
Previously all code assumed that grid_mapping variable is to be called "crs". With this change making this less hard-coded, it's still not fully configurable though. The goal is to rename crs -> spatial_ref eventually.
This is related to #837
Codecov Report
@@ Coverage Diff @@
## develop #899 +/- ##
========================================
Coverage 92.70% 92.70%
========================================
Files 95 95
Lines 9283 9283
========================================
Hits 8606 8606
Misses 677 677 Continue to review full report at Codecov.
|
test_netcdfwriter. we want to rename this variable, pull it in from netcdf driver lib instead of assuming it is 'crs'
- expect error when output file exists - verify that grid_mapping variable is a coordinate and not data var
Store grid_mapping information in a variable named spatial_ref (was crs). This is because `crs` clashes with `crs` attribute, commonly set on a Dataset.
`.geobox` property is dynamic and is only available when crs is available, so `dataset.geobox.crs` can never be `None`, since `dataset.geobox` is either None or a fully qualified `GeoBox` with some non-None `.crs`.
data_resolution_and_offset accept optional fallback_resolution parameter, this is only used for single element axis.
flake8, we have way too much code that doesn't have spaces around arithmetic operators, also it's used for paths and `"some_dir"/"file.txt"`, looks more like a path than `"some_dir" / "file.txt"`
Mapping from pixel space to X/Y space is defined regardless of CRS
Planning to add parameters to it, like whether to include CRS coordinates in the output or not
Optionally return netcdf/cf style spatial_ref coordinate from xr_coords
Structure of "odc style xr dataset" is changing, this will ensure sample dataset is representative of the current state.
This had impact on netcdf writing, for now we just skip dimensionless coordinates, but really we need to handle it properly.
needed for CF convention.
It's not longer just `crs` key in attrs
9c48740
to
d16d86d
Compare
Order of resolution is something like: - x.coords[x.grid_mapping].spatial_ref - x.coords[<looks like crs coord>].spatial_ref - x.{x,y,latitude,longitude}.attrs['crs'] - x.attrs['crs']
d16d86d
to
6f94f22
Compare
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 am OK with this. 👍
Reason for this pull request
To address issue #837. Rather than rely on xarray attributes that are easily lost use non-dimensional coordinate to capture CRS WKT information.
Proposed changes
crs->spatial_ref
to not clash with crs attributedc.load
to create xarrays with appropriate structure.geobox
code to understand data from 2,3.geobox
property #837docs/about/whats_new.rst
for all changes