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

CRS bug fix with temporary subset_geom clipping object, original get_target_crs function #125

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/api_core/data_request.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

The change here overlaps with the #126 PR to which I committed a further edit.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def __init__(
months: Months to include in the request.
days: Days to include in the request.
hours: Hours to include in the request.
grain_method:
grain_method: Determines what temporal grains (ie annual, monthly, daily)
the user will accept if the grain the user requests is not
implemented for a requested dataset. Options include, "strict",
"skip", "any", "coarser", and "finer".
subset_geom: A SubsetGeom representing the clipping region or points to
use or None.
target_crs: A CRS instance.
Expand Down
5 changes: 3 additions & 2 deletions src/api_core/data_request_handler.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember talking about this change, but I don't remember enough to feel confident this is the entire solution we wanted. Plus, we talked more recently about target CRS versus user-provided CRS, so does that affect this change here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The actual CRS bug was fixed previously in this commit: 3dc613b. The CRS related-change here improves upon that fix by creating a temporary geometry instead of modifying the request object's geometry to prevent downstream issues. Switching to using separate target_crs and user_geom_crs parameters will be a rather time consuming overhaul of the code, so I propose we fix this small issue now, and fix the larger issue of separating target_crs into two different parameters once we have the capacity to take that on.

Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,15 @@ def _getRasterLayer(
match_data_array=target_data,
resampling=Resampling[ri_method]
)
temp_geom = request.subset_geom
# If raster reprojection is not needed, then reproject subset_geom
# to match the crs of the data
else:
request.subset_geom = request.subset_geom.reproject(
temp_geom = request.subset_geom.reproject(
data.rio.crs)

# Clip to the non-modified requested geometry
data = data.rio.clip([request.subset_geom.json], all_touched = True)
data = data.rio.clip([temp_geom.json], all_touched = True)

# Assign time coordinate to request date.
# Overwrite native time format if present.
Expand Down
2 changes: 0 additions & 2 deletions src/api_core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,3 @@ def get_target_crs(input_crs_str, resolution, user_geom):

return target_crs



Loading