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

Fix SwathDefinition html representation error when lons/lats 1D #610

Merged
merged 6 commits into from
Jul 29, 2024

Conversation

BENR0
Copy link
Contributor

@BENR0 BENR0 commented Jul 25, 2024

This is a quick fix for #609. It just sets things like resolution and width/height to Na in the case of 1D lat/lon arrays so the html representation does not break.
It also does some quick fixing of formatting issues I noticed.

Copy link

codecov bot commented Jul 25, 2024

Codecov Report

Attention: Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 93.96%. Comparing base (f3acfb4) to head (9c07da9).
Report is 20 commits behind head on main.

Files Patch % Lines
pyresample/_formatting_html.py 81.25% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #610      +/-   ##
==========================================
- Coverage   93.98%   93.96%   -0.03%     
==========================================
  Files          86       86              
  Lines       13775    13786      +11     
==========================================
+ Hits        12947    12954       +7     
- Misses        828      832       +4     
Flag Coverage Δ
unittests 93.96% <81.25%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

coveralls commented Jul 25, 2024

Coverage Status

coverage: 93.665% (-0.03%) from 93.692%
when pulling 9c07da9 on BENR0:fix_html_repr_swathdefinition
into 60629b7 on pytroll:main.

Comment on lines 249 to 250
resolution_str = "{resolution}/{resolution}".format(resolution="Na")
height, width = "Na", "Na"
Copy link
Member

Choose a reason for hiding this comment

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

How about all caps:

Suggested change
resolution_str = "{resolution}/{resolution}".format(resolution="Na")
height, width = "Na", "Na"
resolution_str = "{resolution}/{resolution}".format(resolution="N/A")
height, width = "N/A", "N/A"

Or maybe "NA"? For the resolution string, why not just hardcode "NA/NA" instead of formatting? Otherwise, should resolution use a different separator than /? Maybe x?

Not sure why I didn't ask this before, but what is 40075000?

Copy link
Contributor Author

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.

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):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if isinstance(area.lons, np.ndarray) & isinstance(area.lats, np.ndarray):
if isinstance(area.lons, np.ndarray) and isinstance(area.lats, np.ndarray):

@djhoese djhoese changed the title fix: SwathDefinition html representation error when lons/lats 1D Fix SwathDefinition html representation error when lons/lats 1D Jul 27, 2024
@djhoese djhoese added the bug label Jul 27, 2024
@djhoese djhoese self-assigned this Jul 27, 2024
@djhoese
Copy link
Member

djhoese commented Jul 28, 2024

Looks like the unstable environment are failing for some related things, but not only related things. I wonder if this is something we could/should fix in this PR:

 FAILED pyresample/test/test_formatting.py::test_plot_area_def_w_swath_def[LegacySwathDefinition] - TypeError: ufunc 'create_collection' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED pyresample/test/test_formatting.py::test_plot_area_def_w_swath_def[SwathDefinition] - TypeError: ufunc 'create_collection' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED pyresample/test/test_formatting.py::test_area_def_cartopy_installed - TypeError: ufunc 'create_collection' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED pyresample/test/test_formatting.py::test_area_repr_w_static_files - TypeError: ufunc 'create_collection' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED pyresample/test/test_formatting.py::test_area_repr_wo_static_files - TypeError: ufunc 'create_collection' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED pyresample/test/test_sgeom/test_point.py::TestSMultiPoint::test_to_shapely - TypeError: ufunc 'create_collection' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

@djhoese
Copy link
Member

djhoese commented Jul 29, 2024

Bug report for the failures: shapely/shapely#2098

Let's merge this since these failures are not your fault and are in the unstable environment.

@djhoese djhoese merged commit c957997 into pytroll:main Jul 29, 2024
22 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in SwathDefinition html representation if lon/lat arrays are dask arrays
3 participants