I'm trying to extract a timeseries for a single point from one of the EFAS datasets. I can retrieve the data from the catalogue:
print(data)
which gives the following output:
<xarray.DataArray 'snow_amount' (time: 152, y: 950, x: 1000)> dask.array<shape=(152, 950, 1000), dtype=float32, chunksize=(48, 950, 1000)> Coordinates: * y (y) float32 752500.0 757500.0 762500.0 ... 5492500.0 5497500.0 * x (x) float32 2502500.0 2507500.0 ... 7492500.0 7497500.0 * time (time) datetime64[ns] 2012-01-01T06:00:00 ... 2012-05-31T06:00:00 leadtime timedelta64[ns] ... surface int64 ... lat (y, x) float64 dask.array<shape=(950, 1000), chunksize=(950, 1000)> lon (y, x) float64 dask.array<shape=(950, 1000), chunksize=(950, 1000)> valid_time (time) datetime64[ns] dask.array<shape=(152,), chunksize=(48,)> Attributes: long_name: Snow Amount units: kg m^-2 grid_mapping: lambert_azimuthal_equal_area standard_name: surface_snow_amount cell_methods: area: mean where land time: mean cell_measures: area: areacella comment: where land over land, this is computed as the m... type: real Conventions: CF-1.7 institution: European Centre for Medium-Range Weather Forecasts history: 2019-10-17T08:37:36 GRIB to CDM+CF via cfgrib-0... grid_mapping_short_name: laean source: EFAS
However, following the extract time series example, this:
data_sel = ct.geo.extract_point(data, lon=lon, lat=lat)
gives me an error:
Traceback (most recent call last): File "/opt/cdstoolbox/cdscompute/cdscompute/cdshandlers/services/handler.py", line 49, in handle_request result = cached(context.method, proc, context, *context.args, **context.kwargs)
(...)File "/usr/local/lib/python3.6/site-packages/xarray/core/indexing.py", line 207, in get_dim_indexers % invalid) ValueError: dimensions or multi-index levels ['lon', 'lat'] do not exist
This is, of course, not particularly helpful. Googling this as an xarray error message suggests that the problem could be that the lon/lat coordinates are in fact 2-dimensional, but I'm stumped as to what the solution then would be. I tried several examples of indexing xarray DataArrays but none of them seem to work as expected. The cube.select function gives me the same error message as above. The function geo.make_regular seemed promising, but throws up a key error on 'laean'.
How can I perform this basic task, which is to select the data for a single point based on it's lat/lon value?
Many thanks in advance for any pointers!