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

Adding stereographic subset #263

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

Adding stereographic subset #263

wants to merge 17 commits into from

Conversation

uriii3
Copy link
Collaborator

@uriii3 uriii3 commented Jan 9, 2025

Let's try to add a way to do subset also for datasets which have stereographic (in general, original) projections.

To do:

  • How do we want to differentiate between x/y and Lon/lat?
  • make the variables work
  • make the subset available
  • make the coordinates selection method available
  • make some tests
  • make sure it doesn't break other stuff
  • Make sure the choosing of Arco series is good also with these coordinates
  • Make sure that arguments -x and -y also work for originalGrid Datasets
  • Internally, make them work within the same variable
  • Add check out of bounds for those variables too

📚 Documentation preview 📚: https://copernicusmarine--263.org.readthedocs.build/en/263/

@uriii3 uriii3 force-pushed the stereographic-subset branch from e72b349 to c089ad9 Compare January 20, 2025 09:40
@renaudjester renaudjester self-requested a review January 20, 2025 11:07
@uriii3 uriii3 force-pushed the stereographic-subset branch from c6c9768 to 18980f6 Compare February 12, 2025 11:10
Copy link
Collaborator

@renaudjester renaudjester left a comment

Choose a reason for hiding this comment

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

In the code maybe I would get rid the words latitude and longitude altogether (except for input, "latlon" to know the type of grid, and the longitude modulus)

Comment on lines +110 to +111
Exception raised when using longitude and latitude subset is not available
for original grid datasets.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Implicitely this says that for some originalGrid dataset longitude and latitude is available sometimes

Comment on lines +124 to +130
class XYNotAvailableInNonOriginalGridDatasets(Exception):
"""
Exception raised when using x and y subset is not available for non-original grid
datasets.
Please make sure the dataset part is 'originalGrid' when using x and y subset.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

I hate it haha:
Isn't it weird that when the user wants stereographic data it has to make two actions: change the way to define the bounding box and also choose the part? since those two actions are necessary and if you miss one it throws an error

@@ -148,23 +148,29 @@ def _get_best_arco_service_type(
dataset_subset: DatasetTimeAndSpaceSubset,
dataset_url: str,
username: Optional[str],
dataset_version_part_name: str,
Copy link
Collaborator

Choose a reason for hiding this comment

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

part_name enough maybe?

Comment on lines +207 to +211
if (
"x" not in coordinates_name_and_axis.keys()
): # assume they will come together
coordinates_name_and_axis["y"] = "not_defined"
coordinates_name_and_axis["x"] = "not_defined"
Copy link
Collaborator

Choose a reason for hiding this comment

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

quite confusing tbh

geographical_parameters = GeographicalParameters(
latitude_parameters=LatitudeParameters(
minimum_latitude=subset_request.minimum_latitude,
maximum_latitude=subset_request.maximum_latitude,
name=coordinates_name_and_axis["y"],
axis=1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it an int? I feel like from before it was named x,y,z,t maybe clearer to keep it this way?

Comment on lines +18 to +26
axis: int = 0


@dataclass
class LongitudeParameters:
minimum_longitude: Optional[float] = None
maximum_longitude: Optional[float] = None
name: str = "longitude"
axis: int = 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

The numbers don't seem to match with the download_arco_series.py file: 1 and 2 vs 0 and 1

@@ -151,56 +152,56 @@ def _nearest_selection(

def _dataset_custom_sel(
dataset: xarray.Dataset,
coord_type: Literal["latitude", "longitude", "depth", "time"],
coord_type: str,
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe it's not a coord_type but a coordinate_name or coordinate_label now

return dataset


def _x_subset(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there should be a way to mix _x_subset, _y_subset and longitude_subset, latitude_subset even for the longitude it's a bit more complicated

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.

2 participants