-
Notifications
You must be signed in to change notification settings - Fork 94
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
Fix SwathDefinition html representation error when lons/lats 1D #610
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eff0f41
fix: SwathDefinition error when lons/lats 1D
92fb36d
fix: formatting of attributes
fd030a2
fix: wrapping of properties section
d53bb2f
refactor: resolution units
9a19209
refactor: resolution string
BENR0 9c07da9
Update pyresample/_formatting_html.py
djhoese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -244,25 +244,30 @@ | |||||
- Improve resolution estimation from lat/lon arrays. Maybe use CoordinateDefinition.geocentric_resolution? | ||||||
|
||||||
""" | ||||||
if isinstance(area.lons, np.ndarray) & isinstance(area.lats, np.ndarray): | ||||||
# Calculate and estimated resolution from lats/lons in meter | ||||||
area_name = "Arbitrary Swath" | ||||||
resolution_y = np.mean(area.lats[0:-1, :] - area.lats[1::, :]) | ||||||
resolution_x = np.mean(area.lons[:, 1::] - area.lons[:, 0:-1]) | ||||||
resolution = np.mean(np.array([resolution_x, resolution_y])) | ||||||
resolution = np.round(40075000 * resolution / 360, 1) | ||||||
resolution_str = f"{resolution}/{resolution}" | ||||||
if np.ndim(area.lons) == 1: | ||||||
area_name = "1D Swath" | ||||||
resolution_str = "{resolution}/{resolution}".format(resolution="Na") | ||||||
height, width = "Na", "Na" | ||||||
area_units = "m" | ||||||
else: | ||||||
lon_attrs = area.lons.attrs | ||||||
lat_attrs = area.lats.attrs | ||||||
if isinstance(area.lons, np.ndarray) & isinstance(area.lats, np.ndarray): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
# Calculate and estimated resolution from lats/lons in meter | ||||||
area_name = "Arbitrary Swath" | ||||||
resolution_y = np.mean(area.lats[0:-1, :] - area.lats[1::, :]) | ||||||
resolution_x = np.mean(area.lons[:, 1::] - area.lons[:, 0:-1]) | ||||||
resolution = np.mean(np.array([resolution_x, resolution_y])) | ||||||
resolution = np.round(40075000 * resolution / 360, 1) | ||||||
resolution_str = f"{resolution}/{resolution}" | ||||||
else: | ||||||
lon_attrs = area.lons.attrs | ||||||
lat_attrs = area.lats.attrs | ||||||
|
||||||
# use resolution from lat/lons dataarray attributes -> are these always set? -> Maybe try/except? | ||||||
area_name = f"{lon_attrs.get('sensor')} Swath" | ||||||
resolution_str = "/".join([str(round(x.get("resolution"), 1)) for x in [lat_attrs, lon_attrs]]) | ||||||
|
||||||
# use resolution from lat/lons dataarray attributes -> are these always set? -> Maybe try/except? | ||||||
area_name = f"{lon_attrs.get('sensor')} swath" | ||||||
resolution_str = "/".join([str(round(x.get("resolution"), 1)) for x in [lat_attrs, lon_attrs]]) | ||||||
area_units = "m" | ||||||
|
||||||
height, width = area.lons.shape | ||||||
height, width = area.lons.shape | ||||||
|
||||||
attrs_icon = _icon("icon-file-text2") | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How about all caps:
Or maybe "NA"? For the resolution string, why not just hardcode "NA/NA" instead of formatting? Otherwise, should resolution use a different separator than
/
? Maybex
?Not sure why I didn't ask this before, but what is 40075000?
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.
Yeah you are right, I will just hard code it. I just took the code from the other cases but does not make sense here. Good idea with the "x" instead of "/" definitely makes more sense.
Well as mentioned somewhere before the resolution calculation in case of the attributes not having resolution set is just a rough estimate and therefore the circumference of the earth (40075000) is just hard coded.