Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Sep 3, 2020
1 parent 898e25a commit dbfdc1b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion climetlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from climetlab.datasets import Dataset
# import logging

__version__ = "0.0.84"
__version__ = "0.0.85"

# if ipython_active:
# logging.
Expand Down
15 changes: 11 additions & 4 deletions climetlab/core/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
YAML_FILES = None


def _guess(data):
def _guess(data, path):
if "dataset" in data:
return "datasets"

Expand All @@ -29,7 +29,7 @@ def _guess(data):
if "msymb" in data["magics"]:
return "styles"

if "mcount" in data["magics"]:
if "mcont" in data["magics"]:
return "styles"

if "mcoast" in data["magics"]:
Expand All @@ -38,6 +38,7 @@ def _guess(data):
if "mmap" in data["magics"]:
return "projections"

LOG.warning("Cannot guess collection for %s", path)
return "unknown"


Expand Down Expand Up @@ -76,7 +77,7 @@ def _load_yaml_files():
with open(path) as f:
data = yaml.load(f.read(), Loader=yaml.SafeLoader)
name, _ = os.path.splitext(os.path.basename(path))
kind = _guess(data)
kind = _guess(data, path)
collection = YAML_FILES[kind]
if name in collection:
LOG.warning(
Expand All @@ -96,7 +97,13 @@ def _load_yaml_files():


def get_data_entry(kind, name):
return _load_yaml_files()[kind][name]
files = _load_yaml_files()
if kind not in files:
raise Exception("No collection named '%s'" % (kind,))
if name not in files[kind]:
raise Exception("No object '%s' in collection named '%s'" % (name, kind,))

return files[kind][name]


def data_entries(kind=None):
Expand Down
2 changes: 1 addition & 1 deletion climetlab/core/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _identity(x, **kwargs):
if ipython_active:
from IPython.display import display, Image, SVG, HTML, Markdown

enable_ipython_login()
# enable_ipython_login()
else:
Image = _identity
SVG = _identity
Expand Down
12 changes: 12 additions & 0 deletions climetlab/core/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
import json


# import xarray as xr


# @xr.register_dataset_accessor("climetlab")
# class CliMetLabAccessor:
# def __init__(self, xarray_obj):
# self._obj = xarray_obj
# print("CliMetLabAccessor")
# def foo(self, v):
# print("foo", v)


class Annotation:
def __init__(self, **kwargs):
self._kwargs = kwargs
Expand Down
5 changes: 3 additions & 2 deletions climetlab/datasets/meteonet/dataset.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
home_page: https://meteofrance.github.io/meteonet/
licence: https://meteonet.umr-cnrm.fr/dataset/LICENCE.md
dataset:
home_page: https://meteofrance.github.io/meteonet/
licence: https://meteonet.umr-cnrm.fr/dataset/LICENCE.md
2 changes: 2 additions & 0 deletions climetlab/helpers/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
class XArrayHelper:
def __init__(self, data):

data.climetlab.foo(42)

self.data = data
for name, var in data.data_vars.items():
self.name = name
Expand Down
2 changes: 2 additions & 0 deletions docs/firststeps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ on plotting below).
Datasets
^^^^^^^^

Datasets are a higher-level concept compared to data sources.

The following Python code:


Expand Down

0 comments on commit dbfdc1b

Please sign in to comment.