Basic question about the opendap plugin #243
-
Hi, I'm just getting started with xpublish. I have created and published a data set successfully which is to say I can read the data set with xarray using xarray zarr. E.g.
All good so far. I have installed the opendap plugin so I expected to be able to also access the data set via opendap. However, I'm not entirely sure of the correct URL. When I try http://cefi1.pmel.noaa.gov:8970/datasets/B10K-K20_CORECFS_Level1_collection/opendap.das in my browser, I get Internal server error in the browser, and this in the logs.
When I look at the loop which is doing the data_grid = dap_grid(ds[var], dims), it's in a loop that looks like:
When in turn does the access to da.encoding["dtype"] Of course, if I just open the data set and do the same thing it works fine:
Which make me feel like maybe I just don't quite understand the right URL to use to tell xpublish to open the data set with opendap since I can do what the opendap plugin wants to do when I open the data set myself. I'm sorry that the data set is behind our fire wall, but hopefully somebody can answer this basic question without access. If not, I'll try to figure out a way to give access. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
Without seeing how you are populating your dataset before serving it, this is just a guess, but I would think the opendap router should be robust to missing encoding. I would probably want to see something like: if "dtype" in da.encoding:
data = da.astype(da.encoding["dtype"]).data
else:
data = da.data (honestly, I'm not sure we should be type-casting this variable at all) |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response. I'm not well versed in the details of how xpublish works, but I made a change along the lines you suggested.
Now, the .das returns successfully in the browser. When I open the dataset,
There is an error from the DAP library: syntax error, unexpected WORD_WORD, expecting ';' or ',' But, I can access a data point in the xarray just fine.
The times do not get translated from Doubles to datetime even though I asked. I'm not sure who's job it is (xarray or the plugin) to translate the times, but maybe that's why the cast is in place. |
Beta Was this translation helpful? Give feedback.
-
Sorry you hit a bug with OpenDAP. I think you are accessing things the right way, so the issue is probably on the libraries end. The OpenDAP plugin is largely something that I hacked together in an evening, and since it worked suprisingly well, I threw it out into the world so that it could encounter more data, and find things that broke it. I think this is due to a change in more recent versions of Xarray in how encoding is handled. I believe that the encoding dict is reset for more variables when loading data in, or on various transformations, but I'm not finding anything in a quick search of what's new for recent releases. Are you using different versions of Xarray between the environment where Xpublish is running, and when you loaded it in locally? We're probably not getting the Is there any chance that you could carve off a small chunk of your dataset that you could share and we could test against? It would also be helpful to get a |
Beta Was this translation helpful? Give feedback.
-
No worries. Happy to help to make improvements and debug. I am using these on the server:
I am using these on the client:
I will get to work on a small sample data set. The full lists are attached. |
Beta Was this translation helpful? Give feedback.
-
Again thanks for looking at this. Here is a small self-contained example which illustrates all the steps I took to serve the data via xpublish and the xpublish-opendap. https://github.com/noaaroland/xpublish_example/tree/main. Edit: syntax |
Beta Was this translation helpful? Give feedback.
-
Hi @noaaroland , while I haven't gotten time to dig in to your example, @xaviernogueira made a PR that I think will address the underlying issue, and I just released v0.1.2 for xpublish-opendap with those fixes (PyPI done, Conda-Forge in progress). Any chance you could test and see if that did the trick? |
Beta Was this translation helpful? Give feedback.
-
I'm having a look at it now.... Thanks for the update. |
Beta Was this translation helpful? Give feedback.
I put in a pull request to fix some issues I had with attributes in the two examples I've tried.
It's appropriate to close this, however, there is a more fundamental problem with the OPeNDAP objects that get built for one of my test data sets which became apparent once I got past the issue with the attributes. This concerns how the OPeNDAP objects for a data variable with 2D coordinates gets constructed. I will start a new conversation for that issue.