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 opening tiff and fits files #162

Merged
merged 18 commits into from
Jun 28, 2024
Merged

Fix opening tiff and fits files #162

merged 18 commits into from
Jun 28, 2024

Conversation

TomNicholas
Copy link
Member

@TomNicholas TomNicholas commented Jun 25, 2024

@scottyhq this is the minimum needed for #160

  • Closes KeyError: 'refs' opening TIFF file #160
  • Tests added
  • Tests passing
  • Full type hint coverage
  • Changes are documented in docs/releases.rst
  • New functions/methods are listed in api.rst
  • New functionality has documentation

@TomNicholas
Copy link
Member Author

I found that passing a local filepath with no / anywhere exposes a bug in fsspec. I tried this out successfully on the same file you pointed me to @scottyhq but downloaded locally, and referred to as open_virtual_dataset("./lcmap_tiny_cog_2020.tif", filetype='tiff', indexes={}). I haven't tried it on the fits file yet (as I'm on a a train with spotty signal 😁)

@TomNicholas TomNicholas added the references generation Reading byte ranges from archival files label Jun 27, 2024
@TomNicholas TomNicholas changed the title Fix open tiff Fix opening tiff and fits files Jun 27, 2024
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.43%. Comparing base (cc97112) to head (cb3f969).
Report is 28 commits behind head on main.

Current head cb3f969 differs from pull request most recent head c705ce8

Please upload reports for the commit c705ce8 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #162      +/-   ##
==========================================
+ Coverage   91.38%   92.43%   +1.05%     
==========================================
  Files          20       20              
  Lines        1300     1521     +221     
==========================================
+ Hits         1188     1406     +218     
- Misses        112      115       +3     
Flag Coverage Δ
unittests 92.43% <100.00%> (+1.05%) ⬆️

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.

Comment on lines 311 to +315
@network
class TestReadFromURL:
def test_read_from_url(self):
examples = {
"grib": "https://github.com/pydata/xarray-data/raw/master/era5-2mt-2019-03-uk.grib",
"netcdf3": "https://github.com/pydata/xarray-data/raw/master/air_temperature.nc",
"netcdf4": "https://github.com/pydata/xarray-data/raw/master/ROMS_example.nc",
"hdf4": "https://github.com/corteva/rioxarray/raw/master/test/test_data/input/MOD09GA.A2008296.h14v17.006.2015181011753.hdf",
@pytest.mark.parametrize(
"filetype, url",
[
Copy link
Member Author

Choose a reason for hiding this comment

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

@scottyhq this has become a pretty powerful test!

Comment on lines +341 to +347
pytest.param(
"fits",
"https://fits.gsfc.nasa.gov/samples/WFPC2u5780205r_c0fx.fits",
marks=pytest.mark.skipif(
not has_astropy, reason="package astropy is not available"
),
),
Copy link
Member Author

Choose a reason for hiding this comment

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

We could potentially do this same skipif thing for dependencies required to read the other filetypes too.

@TomNicholas TomNicholas merged commit 76fbb9c into main Jun 28, 2024
1 check passed
@TomNicholas TomNicholas deleted the fix_open_tiff branch June 28, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
references generation Reading byte ranges from archival files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KeyError: 'refs' opening TIFF file
1 participant