ecmwf / earthkit-maps

Geospatial visulation tools and templates
Apache License 2.0
9 stars 4 forks source link

BOM Style tcwv #40

Open HCookie opened 9 months ago

HCookie commented 9 months ago

What happened?

Due to the recent changes, the tcwv style within the Bureau schema, is broken. It prevents any loading of data otherwise not assigned a style.

It was originally intended to be an alias for precipitable water, but that functionality seems no longer available.

What are the steps to reproduce the bug?

With any data except those with a defined style, create a chart using the bom schema.

earthkit.maps.schema.use('bom')

Version

0.0.13

Platform (OS and architecture)

Linux

Relevant log output

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[22], line 3
      1 chart = earthkit.maps.Chart(domain = 'Oceania')
----> 2 chart.plot(ds['msl'].isel(time = 0))

File /earthkit-maps/earthkit/maps/charts/__init__.py:327, in Chart.plot(self, data, *args, **kwargs)
    323     raise NotImplementedError(
    324         "Plotting pandas DataFrames and Series is an upcoming feature"
    325     )
    326 else:
--> 327     return self._plot_gridded_scalar(data, *args, **kwargs)

File /earthkit-maps/earthkit/maps/charts/__init__.py:290, in Chart._expand_rows_cols.<locals>.wrapper(self, data, *args, **kwargs)
    288     else:
    289         subplot = self.subplots[i]
--> 290     layer = getattr(subplot, method.__name__)(field, *args, **kwargs)
    291     layers.append(layer)
    293 return LayerGroup(layers)

File /earthkit-maps/earthkit/maps/charts/subplots.py:149, in Subplot.plot_gridded_scalar.<locals>.wrapper(self, data, transform_first, style, *args, **kwargs)
    142 if transform_first is None:
    143     transform_first = self._can_transform_first(method)
    145 mappable = method(
    146     self,
    147     input_data.x,
    148     input_data.y,
--> 149     input_data.values,
    150     style=input_data.style,
    151     transform=input_data.transform,
    152     transform_first=transform_first,
    153     **kwargs,
    154 )
    156 layer = Layer(data, mappable, self, style=input_data.style)
    157 self.layers.append(layer)

File /earthkit-maps/earthkit/maps/inputs.py:100, in Input.values(self)
     98 @property
     99 def values(self):
--> 100     return self.style.convert_units(
    101         self._values,
    102         self.source_units,
    103         self.short_name,
    104     )

File /earthkit-maps/earthkit/maps/inputs.py:95, in Input.style(self)
     93     if not schema.use_preferred_styles:
     94         style_units = self._kwargs.pop("units", None) or self.source_units
---> 95     self._style = styles.auto.guess_style(self.data, units=style_units)
     96 return self._style

File /earthkit-maps/earthkit/maps/styles/auto.py:38, in guess_style(data, units)
     35 with open(fname, "r") as f:
     36     config = yaml.load(f, Loader=yaml.SafeLoader)
---> 38 for criteria in config["criteria"]:
     39     for key, value in criteria.items():
     40         if data.metadata(key, default=None) != value:

KeyError: 'criteria'


### Accompanying data

_No response_

### Organisation

Australian Bureau of Meteorology
HCookie commented 9 months ago

Resolution

To immediately resolve this and allow usage, the tcwv style must be removed.

Long term, a alias style could be added, or tcwv criteria incorporated into the precip water