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

IRI data library opendap error from 1.4 to 1.5 #1041

Closed
mktippett opened this issue Sep 3, 2020 · 7 comments
Closed

IRI data library opendap error from 1.4 to 1.5 #1041

mktippett opened this issue Sep 3, 2020 · 7 comments

Comments

@mktippett
Copy link

In version 1.5.4

import netCDF4
soi_url_does_NOT_work = 'http://iridl.ldeo.columbia.edu/SOURCES/.Indices/.soi/.c8110/.anomaly/T/%28Jan%201979%29/VALUE/dods'
netCDF4.Dataset(soi_url_does_NOT_work)

fails and gives the error:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-1-cb085b0e14b9> in <module>
      1 import netCDF4
      2 soi_url_does_NOT_work = 'http://iridl.ldeo.columbia.edu/SOURCES/.Indices/.soi/.c8110/.anomaly/T/%28Jan%201979%29/VALUE/dods'
----> 3 netCDF4.Dataset(soi_url_does_NOT_work)

netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Dataset.__init__()

netCDF4/_netCDF4.pyx in netCDF4._netCDF4._ensure_nc_success()

OSError: [Errno -90] NetCDF: file not found: b'http://iridl.ldeo.columbia.edu/SOURCES/.Indices/.soi/.c8110/.anomaly/T/%28Jan%201979%29/VALUE/dods'

In version 1.4.2 it does not.

<class 'netCDF4._netCDF4.Dataset'>
root group (NETCDF3_CLASSIC data model, file format DAP2):
    Conventions: IRIDL
    dimensions(sizes): T(1)
    variables(dimensions): >f4 T(T), >f4 anomaly(T)
    groups:
@jswhit
Copy link
Collaborator

jswhit commented Sep 5, 2020

Nothing has changed in the python interface that would affect this. You probably have linked a different version of netcdf-c. Can you print netCDF4.__netcdf4libversion__ to check this?

@mktippett
Copy link
Author

netCDF4.__netcdf4libversion__ is 4.6.2 in the working installation and 4.7.4 in the not working installation.

I should tell my admin who is installing jupyterhub to use libnetcdf=4.6.2 in the yml file? Or something else? (I am very new to this.)

@jswhit
Copy link
Collaborator

jswhit commented Sep 5, 2020

Here's what ncdump tells me:

jeff-whitakers-imac-9:~/python/netcdf4-python.git] jsw% ncdump -h http://iridl.ldeo.columbia.edu/SOURCES/.Indices/.soi/.c8110/.anomaly/T/%28Jan%201979%29/VALUE/dods
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: <html^><title>Error 404 Not Found</title>

Error 404: Page Not Found

Error line: 80 anhtmlserverefize 64000000 defre

Error on line 0 of stdin: interpreter thinks " .from" not defined

Show Current Objects
  1. Ingrid:
  2. HTMLwords
  3. Indices soi c8110 anomaly[ T |]
  4. grid: /T (months since 1960-01-01) ordered (Jan 1951) to (Aug 2020) by 1.0 N= 836 pts :grid
  5. grid: /T (months since 1960-01-01) ordered (Jan 1951) to (Aug 2020) by 1.0 N= 836 pts :grid
<textarea name="command" rows="6" cols="50" wrap="soft"> SOURCES .Indices .soi .c8110 .anomaly T %28Jan%201979%29 VALUE</textarea>
1000
ncdump: http://iridl.ldeo.columbia.edu/SOURCES/.Indices/.soi/.c8110/.anomaly/T/%28Jan%201979%29/VALUE/dods: http://iridl.ldeo.columbia.edu/SOURCES/.Indices/.soi/.c8110/.anomaly/T/%28Jan%201979%29/VALUE/dods: NetCDF: file not found

Looks like a server-side issue to me, or an incorrect URL.

@mktippett
Copy link
Author

I get

ncdump -h http://iridl.ldeo.columbia.edu/SOURCES/.Indices/.soi/.c8110/.anomaly/T/%28Jan%201979%29/VALUE/dods
netcdf dods {
dimensions:
	T = 1 ;
variables:
	float T(T) ;
		T:standard_name = "time" ;
		T:pointwidth = 1.f ;
		T:expires = 1601942400 ;
		T:calendar = "360" ;
		T:gridtype = 0 ;
		T:units = "months since 1960-01-01" ;
	float anomaly(T) ;
		anomaly:file_missing_value = -999.9f ;
		anomaly:standard_name = "air_pressure_anomaly" ;
		anomaly:history = "Indices Tahiti slp c8110 standardized\n",
			"Indices Tahiti slp c8110 anomaly\n",
			"Averaged over T2[1981, 2010] minimum 0.0% data present\n",
			"sqrt [   total ( { Indices Tahiti slp c8110 anomaly } squared )   / 360. ]\n",
			"  total [ ( Indices Tahiti slp c8110 anomaly ) squared ]   / 360.\n",
			"Averaged over T2[1981, 2010] minimum 0.0% data present\n",
			"Averaged over T[Jan 1981, Dec 2010] minimum 0.0% data present\n",
			"Indices Darwin slp c8110 standardized\n",
			"Indices Darwin slp c8110 anomaly\n",
			"Averaged over T2[1981, 2010] minimum 0.0% data present\n",
			"sqrt [   total ( { Indices Darwin slp c8110 anomaly } squared )   / 360. ]\n",
			"  total [ ( Indices Darwin slp c8110 anomaly ) squared ]   / 360.\n",
			"Averaged over T2[1981, 2010] minimum 0.0% data present\n",
			"Averaged over T[Jan 1981, Dec 2010] minimum 0.0% data present" ;
		anomaly:units = "unitless" ;
		anomaly:expires = 1601942400 ;
		anomaly:long_name = "sea level pressure anomaly" ;
		anomaly:missing_value = -999.9f ;

// global attributes:
		:Conventions = "IRIDL" ;
}

Of course, my ncdump is ancient.

netcdf library version 4.3.3.1 of Feb 22 2016 16:36:46 $

@jswhit
Copy link
Collaborator

jswhit commented Sep 5, 2020

I would suggest asking on the netcdf-c [issue tracker] (https://github.com/Unidata/netcdf-c/issues) why ncdump works for this URL for older versions of the netcdf-c, but not for 4.7.x.

@mktippett
Copy link
Author

Thanks I will do that! (I am assuming that I should close this issue since it is a netcdf-c issue?)

@DennisHeimbigner
Copy link
Collaborator

See here:
Unidata/netcdf-c#1832 (comment)

DennisHeimbigner added a commit to DennisHeimbigner/netcdf-c that referenced this issue Sep 8, 2020
re: Github issue Unidata#1832
and Github issue Unidata/netcdf4-python#1041

Handling of URL escape sequences for some servers
(e.g. http://iridl.ldeo.columbia.edu) appears to be somewhat
non-standard.
In particular, certain characters need escaping that other servers
do not. Fortunately, the changes should also work existing other servers.
DennisHeimbigner added a commit to DennisHeimbigner/netcdf-c that referenced this issue Nov 5, 2020
re:  Unidata#1876
and: Unidata#1835
and: Unidata/netcdf4-python#1041

The change in PR 1835 was correct with respect to using %20 instead of '+'
for encoding blanks. However, it was a mistake to assume everything was
unencoded and then to do encoding ourselves. The problem is that
different servers do different things, with Columbia being an outlier.

So, I have added a set of client controls that can at least give
the caller some control over this. The caller can append
the following fragment to his URL to control what gets encoded before
sending it to the server. The syntax is as follows:
````
https://<host>/<path>/<query>#encode=path|query|all|none
````

The possible values:
* path  -- URL encode (i.e. %xx encode) as needed in the path part of the URL.
* query -- URL encode as needed in the query part of the URL.
* all   -- equivalent to ````#encode=path,query````.
* none  -- do not url encode any part of the URL sent to the server; not strictly necessary, so mostly for completeness.

Note that if "encode=" is used, then before it is processed, all encoding
is turned of so that ````#encode=path```` will only encode the path
and not the query.

The default is ````#encode=query````, so the path is left untouched,
but the query is always encoded.

Internally, this required changes to pass the encode flags down into
the OC2 library.

Misc. Unrelated Changes:
* Shut up those irritating warning from putget.m4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants