COSIMA / cosima-cookbook

Framework for indexing and querying ocean-sea ice model output.
https://cosima-recipes.readthedocs.io/en/latest/
Apache License 2.0
58 stars 25 forks source link

Add data exploration GUI #200

Closed aidanheerdegen closed 4 years ago

aidanheerdegen commented 4 years ago

ipywidgets for data exploration

Closes #199

aidanheerdegen commented 4 years ago

To have a play with the default DB:

from cosima_cookbook import explore
dbx = explore.DatabaseExplorer()
dbx

You can pass a session to DatabaseExplorer if you want to test other databases.

navidcy commented 4 years ago

This is great!!

OK, I loaded pbot_t for example but then how can I plot something? Or use this loaded data array?

It says The loaded DataArray is accessible as the data attribute of the ExperimentExplorer object but when I call

dbx.data

I get

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-13-e641cb6988d1> in <module>
----> 1 dbx.data

AttributeError: 'DatabaseExplorer' object has no attribute 'data'
navidcy commented 4 years ago

Btw, this PR definitely it should be definitely accompanied by a Data Exploration Tutorial in cosima-recipes

aidanheerdegen commented 4 years ago

The child ExperimentExplorer object of the DatabaseExplorer is accessible as the .ee attribute. So in this case the data is accessible as dbx.ee.data.

It needs documentation for sure, and yes a tutorial would be on the To-Do list.

There is a plan to have a VariableExplorer which wraps hvplot, but that might have to wait.

aidanheerdegen commented 4 years ago

Turns out the issue with widgets popping up where they shouldn't is because I am storing them in a dict.

https://github.com/jupyter-widgets/ipywidgets/issues/2944

Python is weird sometimes.

aidanheerdegen commented 4 years ago

Ok, random widgets turning up in weird places is now fixed.

aidanheerdegen commented 4 years ago

I would like to get this out so people can use it. It would be nice to have more elegant SQL queries to replace the DatabaseExplorer functionality but I think it would take me too long to figure it out. If you're interested I'm happy to take suggestions @angus-g, or we can go with this and improve it later when more experiments are added the DB and it the length of time to loop over all the experiments becomes too large.

angus-g commented 4 years ago

I'll have a quick play with getting the kind of data we want accessible at the ORM level, but I agree that it's better to have something usable rather than fuss over perfection!

angus-g commented 4 years ago

I have some ideas of how to change things, but I'm going to merge this first. If they come to fruition, they can come in through a new PR.