Skip to content
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

use gridmapping in gen and gen2 #495

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

TonioF
Copy link
Contributor

@TonioF TonioF commented Jul 30, 2021

Uses the newly introduced GridMapping in xcube gen and gen2. In particular, there is now a parameter 'crs' that can be passed to the gen cli. The class ReprojectionInfo has been removed.

Checklist:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/source/*
  • Changes documented in CHANGES.md
  • AppVeyor CI passes
  • Test coverage remains or increases (target 100%)

Remember to close associated issues after merge!

@TonioF TonioF self-assigned this Jul 30, 2021
…use-gridmapping

# Conflicts:
#	xcube/core/gen2/opener.py
Copy link
Contributor

@AliceBalfanz AliceBalfanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question at one code place, and also am missing an entry at least in the changelog (I am almost afraid to ask for an entry in the documentation :))

geo_coding = None
if crs is not None:
if spatial_res is None:
raise ValueError('If CRS is provided, '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why must the spatial resolution be provided when crs is given? What if a user includes the native CRS of the dataset and only uses the subsetting without resampling?

@codecov-commenter
Copy link

Codecov Report

Merging #495 (be292b3) into master (e56f64d) will decrease coverage by 0.03%.
The diff coverage is 74.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #495      +/-   ##
==========================================
- Coverage   91.54%   91.50%   -0.04%     
==========================================
  Files         292      292              
  Lines       26464    26401      -63     
==========================================
- Hits        24227    24159      -68     
- Misses       2237     2242       +5     
Impacted Files Coverage Δ
xcube/core/select.py 88.50% <28.57%> (-11.50%) ⬇️
xcube/core/gen/config.py 90.16% <66.66%> (-1.37%) ⬇️
test/cli/test_gen.py 100.00% <100.00%> (ø)
test/core/gen/test_config.py 96.84% <100.00%> (ø)
test/core/gen/test_iproc.py 100.00% <100.00%> (ø)
xcube/cli/gen.py 100.00% <100.00%> (ø)
xcube/core/gen/gen.py 85.46% <100.00%> (+0.12%) ⬆️
xcube/core/gen/iproc.py 87.27% <100.00%> (-0.23%) ⬇️
xcube/core/gridmapping/__init__.py 100.00% <100.00%> (ø)
xcube/core/gridmapping/base.py 97.08% <100.00%> (+0.01%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e56f64d...be292b3. Read the comment docs.


dataset = select_spatial_subset(dataset,
xy_bbox=bbox,
geo_coding=geo_coding)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

geo_coding is deprecated.

@@ -51,16 +55,43 @@ def select_subset(dataset: xr.Dataset,

:param dataset: The dataset.
:param var_names: Optional variable names.
:param crs: The dataset's CRS. If not set the dataset's current CRS will
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a dataset's current CRS?

:param time_range: Optional time range
:return: a subset of *dataset*, or unchanged *dataset*
if no keyword-arguments are used.
"""
if var_names is not None:
dataset = select_variables_subset(dataset, var_names=var_names)
if bbox is not None:
dataset = select_spatial_subset(dataset, xy_bbox=bbox)
geo_coding = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does all this code here and why is it not better located in select_spatial_subset.

y_res = spatial_res[1] if isinstance(spatial_res, tuple) \
else spatial_res
height = math.ceil((y_max - y_min) / y_res)
geo_coding = GridMapping.regular(size=(width, height),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, this looks wrong. You cannot assign an arbitrary CRS to a dataset that uses a different CRS. The GridMapping that must first be transformed from one CRS to the datasets CRS.

@@ -37,97 +37,6 @@
from xcube.util.plugin import get_extension_registry


class ReprojectionInfo:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes cube incompatible with iproc plugins for "xcube gen"

@@ -46,6 +46,8 @@
from .helpers import _to_affine
from .helpers import scale_xy_res_and_size

DEFAULT_CRS = 'EPSG:4326'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default of/for what? I don't think, such default exists. Or at least, we want to get rid of it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants