-
Notifications
You must be signed in to change notification settings - Fork 795
Description
Describe the current behavior
Currently, the installed netCDF4 in colab cannot read remote data via opendap (see end of section here: https://unidata.github.io/netcdf4-python/#creatingopeningclosing-a-netcdf-file).
Describe the expected behavior
In the future, netCDf4 should be able to read remote data files like below. Alternatively, downgrading to netCDf4==1.5.8 from PyPI does the trick. Or from the same link above:
Remote OPeNDAP-hosted datasets can be accessed for reading over http if a URL is provided to the Dataset constructor instead of a filename. However, this requires that the netCDF library be built with OPenDAP support, via the --enable-dap configure option (added in version 4.0.1).
What web browser you are using
Safari.
Additional context
See code for a repro.
--
repro code:
BUG (current)
import netCDF4
print("current buggy version: ", netCDF4.__version__)
try:
nc = netCDF4.Dataset(
"https://psl.noaa.gov/thredds/dodsC/Datasets/" +
"ncep.reanalysis2" +
"/pressure/air.2020.nc"
)
print(nc)
except Exception as err:
print(err)
current buggy version: 1.6.0
[Errno -68] NetCDF: I/O failure: b'https://psl.noaa.gov/thredds/dodsC/Datasets/ncep.reanalysis2/pressure/air.2020.nc'
FIX (wanted!)
!pip install netCDF4==1.5.8 -qqq
# restart kernel and try again with 1.5.8
import netCDF4
print("one good version from PyPI: ", netCDF4.__version__)
try:
nc = netCDF4.Dataset(
"https://psl.noaa.gov/thredds/dodsC/Datasets/" +
"ncep.reanalysis2" +
"/pressure/air.2020.nc"
)
print(nc)
except Exception as err:
print(err)
one good version from PyPI: 1.5.8
<class 'netCDF4._netCDF4.Dataset'>
root group (NETCDF3_CLASSIC data model, file format DAP2):
Conventions: CF-1.0
title: 4x Daily NCEP/DOE Reanalysis 2
comments: Data is from
NCEP/DOE AMIP-II Reanalysis (Reanalysis-2)
(4x/day). It consists of most variables interpolated to
pressure surfaces from model (sigma) surfaces.
platform: Model
source: NCEP/DOE AMIP-II Reanalysis (Reanalysis-2) Model
institution: National Centers for Environmental Prediction
dataset_title: NCEP-DOE AMIP-II Reanalysis
References: https://www.psl.noaa.gov/data/gridded/data.ncep.reanalysis2.html
source_url: http://www.cpc.ncep.noaa.gov/products/wesley/reanalysis2/
history: created 2020/02 by NOAA/ESRL/PSD
Converted to chunked, deflated non-packed NetCDF4 2020/05
DODS_EXTRA.Unlimited_Dimension: time
dimensions(sizes): time(1464), lat(73), level(17), lon(144)
variables(dimensions): float32 level(level), float32 lat(lat), float32 lon(lon), float64 time(time), float32 air(time, level, lat, lon)
groups: