-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from scottyhq/http-netcdf
Add logic for remote or local files in NetCDFSource
- Loading branch information
Showing
10 changed files
with
326 additions
and
16 deletions.
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: test_env | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python=3.9 | ||
- aiohttp | ||
- boto3 | ||
- flask | ||
- h5netcdf | ||
- intake | ||
- netcdf4 | ||
- pip | ||
- pydap | ||
- pytest | ||
- rasterio | ||
- s3fs | ||
- scikit-image | ||
- xarray | ||
- zarr | ||
- pip: | ||
- rangehttpserver | ||
- moto[s3] |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Tests that read public data over the internet | ||
import intake | ||
import pytest | ||
import xarray as xr | ||
import s3fs | ||
import gcsfs | ||
|
||
# RasterIOSource | ||
def test_open_rasterio_http(): | ||
prefix = 'https://landsat-pds.s3.us-west-2.amazonaws.com/L8/139/045' | ||
image = 'LC81390452014295LGN00/LC81390452014295LGN00_B1.TIF' | ||
url = f'{prefix}/{image}' | ||
source = intake.open_rasterio(url, | ||
chunks=dict(band=1)) | ||
ds = source.to_dask() | ||
assert isinstance(ds, xr.core.dataarray.DataArray) | ||
|
||
|
||
def test_open_rasterio_s3(): | ||
bucket = 's3://landsat-pds' | ||
key = 'L8/139/045/LC81390452014295LGN00/LC81390452014295LGN00_B1.TIF' | ||
url = f'{bucket}/{key}' | ||
source = intake.open_rasterio(url, | ||
chunks=dict(band=1), | ||
storage_options = dict(anon=True)) | ||
ds = source.to_dask() | ||
assert isinstance(ds, xr.core.dataarray.DataArray) | ||
|
||
|
||
# NETCDFSource | ||
def test_open_netcdf_gs(): | ||
bucket = 'gs://ldeo-glaciology' | ||
key = 'bedmachine/BedMachineAntarctica_2019-11-05_v01.nc' | ||
url = f'{bucket}/{key}' | ||
source = intake.open_netcdf(url, | ||
chunks=3000, | ||
xarray_kwargs=dict(engine='h5netcdf'), | ||
) | ||
ds = source.to_dask() | ||
assert isinstance(ds._file_obj, xr.backends.h5netcdf_.H5NetCDFStore) | ||
assert isinstance(ds, xr.core.dataarray.Dataset) | ||
|
||
def test_open_netcdf_s3(): | ||
bucket = 's3://its-live-data.jpl.nasa.gov' | ||
key = 'icesat2/alt06/rel003/ATL06_20181230162257_00340206_003_01.h5' | ||
url = f'{bucket}/{key}' | ||
source = intake.open_netcdf(url, | ||
xarray_kwargs=dict(group='gt1l/land_ice_segments', engine='h5netcdf'), | ||
storage_options=dict(anon=True), | ||
) | ||
ds = source.to_dask() | ||
assert isinstance(ds._file_obj, xr.backends.h5netcdf_.H5NetCDFStore) | ||
assert isinstance(ds, xr.core.dataarray.Dataset) | ||
|
||
|
||
def test_open_netcdf_s3_simplecache(): | ||
bucket = 's3://its-live-data.jpl.nasa.gov' | ||
key = 'icesat2/alt06/rel003/ATL06_20181230162257_00340206_003_01.h5' | ||
url = f'simplecache::{bucket}/{key}' | ||
source = intake.open_netcdf(url, | ||
xarray_kwargs=dict(group='gt1l/land_ice_segments', engine='h5netcdf'), | ||
storage_options=dict(s3={'anon': True}), | ||
) | ||
ds = source.to_dask() | ||
assert isinstance(ds._file_obj, xr.backends.h5netcdf_.H5NetCDFStore) | ||
assert isinstance(ds, xr.core.dataarray.Dataset) |
Oops, something went wrong.