Closed hansbrenna closed 2 years ago
Good point. One workaround in such cases could be to call the method differently, by parsing via dict directly (which you would possibly also do in similar functionality in other libraries, e.g. xarray):
import pyaerocom as pya
reader= pya.io.ReadUngridded()
eea=reader.read('GHOST.EEA.daily','concpm25',)
eea.filter_by_meta(**{'NOAA-DMSP-OLS_v4_average_nighttime_stable_lights_25km':[1,28]})
@hansbrenna Have you tested if this works when running it through the web-tools (i.e. specify as dict obs_filters)?
Interesting that that works. I thought it would not work, but I was probably having problems with issue #118 and not this when I filtering Joly-Peuch did not work in the web processing.
I'll test it when I have time using "NOAA-DMSP-OLS_v4_average_nighttime_stable_lights_25km".
Yeah, that is a python peculiarity / feature I guess. But you can always parse kwargs either via expressions (i.e. callable(bla='Blub', blub=42)
or as dictionaries callable({'bla':'Blub', 'blub':42})
. Let me know if it works through the highlevel routines!
Under the hood, *kwargs are always* parsed as a dictionary and can be used as such within the function body.
closed due to age
Any metadata variable key containing the character "-" is unusable for filtering on metadata using UngriddedData.filter_by_meta() because any metadata key has to be a valid python keyword and not an expression.
We should consider fixing this either by making sure characters like "-" are never used in metadata keys, or changing how filter_by_meta() workd.
Example code that fails: