openclimatefix / metoffice_ec2

Subset Met Office MOGREPS-UK and UKV on AWS EC2
MIT License
11 stars 2 forks source link

dimensions or multi-index levels ['height'] do not exist #44

Closed flowirtz closed 4 years ago

flowirtz commented 4 years ago
2020-06-18 13:39:13,637 - metoffice_ec2 - ERROR - dimensions or multi-index levels ['height'] do not exist
Traceback (most recent call last):
  File "scripts/ec2.py", line 132, in loop
    load_subset_and_save_data(mo_message, height_meters, s3)
  File "scripts/ec2.py", line 82, in load_subset_and_save_data
    dataset = subset.subset(dataset, height_meters, **DEFAULT_GEO_BOUNDARY)
  File "/usr/src/app/metoffice_ec2/subset.py", line 20, in subset
    dataset = dataset.sel(height=height_meters)
  File "/opt/conda/envs/metoffice_ec2/lib/python3.8/site-packages/xarray/core/dataset.py", line 2065, in sel
    pos_indexers, new_indexes = remap_label_indexers(
  File "/opt/conda/envs/metoffice_ec2/lib/python3.8/site-packages/xarray/core/coordinates.py", line 396, in remap_label_indexers
    pos_indexers, new_indexes = indexing.remap_label_indexers(
  File "/opt/conda/envs/metoffice_ec2/lib/python3.8/site-packages/xarray/core/indexing.py", line 254, in remap_label_indexers
    dim_indexers = get_dim_indexers(data_obj, indexers)
  File "/opt/conda/envs/metoffice_ec2/lib/python3.8/site-packages/xarray/core/indexing.py", line 220, in get_dim_indexers
    raise ValueError(f"dimensions or multi-index levels {invalid!r} do not exist")
flowirtz commented 4 years ago

I think I have it!!

https://github.com/openclimatefix/metoffice_ec2/blob/a103c010f5d861cf2d2d31a4938cd27d37ffeb56/scripts/ec2.py#L32-L47

https://github.com/openclimatefix/metoffice_ec2/blob/a103c010f5d861cf2d2d31a4938cd27d37ffeb56/scripts/ec2.py#L135

So if the index is name, wouldn't we need to switch the two in accessing the Df? So:

# DO THIS
height_meters = PARAMS_TO_COPY[var_name]["height"]

# Not this
height_meters = PARAMS_TO_COPY["height"][var_name]

?

Follow-up question: What happens for those that don't have a height set? Crash?

flowirtz commented 4 years ago

I think that's not it, I think the issue is with the .sel in the subset.subset 🙈