intake / intake-esm

An intake plugin for parsing an Earth System Model (ESM) catalog and loading assets into xarray datasets.
https://intake-esm.readthedocs.io
Apache License 2.0
138 stars 47 forks source link

Unable to get aggregation_control.groupby_attrs a #665

Open aradhakrishnanGFDL opened 6 months ago

aradhakrishnanGFDL commented 6 months ago

Description

Following [intake-esm doc](https://intake-esm.readthedocs.io/en/stable/how-to/understand-keys-and-how-to-change-them.html) to print aggregation columns and get more info on the keys
 1) catalog.esmcat.aggregation_control.groupby_attrs and 2) keys_info(), but running into errors. User error not ruled out, please point me in the right direction. 

Background being - I want to get the aggregate columns (and vocabulary url!) from the json and see if we can validate and provide additional info to users regarding the catalog correctness and expected structure before it is used in the analysis. 

What I Did

cat = intake.open_esm_datastore(col)

>>> cat.keys_info()
Traceback (most recent call last):
  File "/nbhome/Aparna.Radhakrishnan/conda/envs/intake/lib/python3.7/site-packages/intake_esm/core.py", line 239, in __getitem__
    return self._entries[key]
KeyError: 'keys_info'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nbhome/Aparna.Radhakrishnan/conda/envs/intake/lib/python3.7/site-packages/intake/catalog/base.py", line 339, in __getattr__
    return self[item]  # triggers reload_on_change
  File "/nbhome/Aparna.Radhakrishnan/conda/envs/intake/lib/python3.7/site-packages/intake_esm/core.py", line 246, in __getitem__
    raise KeyError(key)
KeyError: 'keys_info'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nbhome/Aparna.Radhakrishnan/conda/envs/intake/lib/python3.7/site-packages/intake/catalog/base.py", line 341, in __getattr__
    raise AttributeError(item)
AttributeError: keys_info
cat.esmcat.aggregation_control.groupby_attrs
AttributeError: esmcat
>>> type(cat)
<class 'intake_esm.core.esm_datastore'>
>>> catalog.esmcat.aggregation_control.groupby_attrs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'catalog' is not defined
>>> cat.esmcat.aggregation_control.groupby_attrs
Traceback (most recent call last):
  File "/nbhome/Aparna.Radhakrishnan/conda/envs/intake/lib/python3.7/site-packages/intake_esm/core.py", line 239, in __getitem__
    return self._entries[key]
KeyError: 'esmcat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nbhome/Aparna.Radhakrishnan/conda/envs/intake/lib/python3.7/site-packages/intake/catalog/base.py", line 339, in __getattr__
    return self[item]  # triggers reload_on_change
  File "/nbhome/Aparna.Radhakrishnan/conda/envs/intake/lib/python3.7/site-packages/intake_esm/core.py", line 246, in __getitem__
    raise KeyError(key)
KeyError: 'esmcat'

Version information: output of intake_esm.show_versions()

The files in csv are NetCDF files that are internal to GFDL. This is a template of what was used https://github.com/aradhakrishnanGFDL/CatalogBuilder/blob/main/cats/gfdl_test1.json and https://github.com/aradhakrishnanGFDL/CatalogBuilder/blob/main/cats/gfdl_test1.csv intake_esm.__version__ '2020.6.11'