Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valid_times key error #54

Open
emfdavid opened this issue Dec 20, 2023 · 0 comments
Open

valid_times key error #54

emfdavid opened this issue Dec 20, 2023 · 0 comments

Comments

@emfdavid
Copy link

Still having trouble using wms with the NODD forecast aggregations I am building.
I am hoping I just need to set the right magic coords/attrs but I am having trouble figuring out what the problem is. CF seems to recognize the coords and the xarray view looks reasonable too.

Partial stack trace

  File "/home/builder/.cache/bazel/_bazel_builder/99bd544777c52d5a0d8a66ea3b05626a/execroot/ritta/bazel-out/k8-dbg/bin/ingestion/noaa_nwp/xpublish_server.runfiles/common_deps_xpublish_wms/site-packages/xpublish_wms/wms/__init__.py", line 37, in wms_handler
    return get_feature_info(dataset, query_params)
  File "/home/builder/.cache/bazel/_bazel_builder/99bd544777c52d5a0d8a66ea3b05626a/execroot/ritta/bazel-out/k8-dbg/bin/ingestion/noaa_nwp/xpublish_server.runfiles/common_deps_xpublish_wms/site-packages/xpublish_wms/wms/get_feature_info.py", line 158, in get_feature_info
    selected_ds = selected_ds.cf.interp(time=times[0])
  File "/home/builder/.cache/bazel/_bazel_builder/99bd544777c52d5a0d8a66ea3b05626a/execroot/ritta/bazel-out/k8-dbg/bin/ingestion/noaa_nwp/xpublish_server.runfiles/common_deps_cf_xarray/site-packages/cf_xarray/accessor.py", line 690, in wrapper
    result = final_func(*posargs, **arguments)
  File "/home/builder/.cache/bazel/_bazel_builder/99bd544777c52d5a0d8a66ea3b05626a/execroot/ritta/bazel-out/k8-dbg/bin/ingestion/noaa_nwp/xpublish_server.runfiles/common_deps_xarray/site-packages/xarray/core/dataset.py", line 3313, in interp
    indexers = dict(self._validate_interp_indexers(coords))
  File "/home/builder/.cache/bazel/_bazel_builder/99bd544777c52d5a0d8a66ea3b05626a/execroot/ritta/bazel-out/k8-dbg/bin/ingestion/noaa_nwp/xpublish_server.runfiles/common_deps_xarray/site-packages/xarray/core/dataset.py", line 2316, in _validate_interp_indexers
    for k, v in self._validate_indexers(indexers):
  File "/home/builder/.cache/bazel/_bazel_builder/99bd544777c52d5a0d8a66ea3b05626a/execroot/ritta/bazel-out/k8-dbg/bin/ingestion/noaa_nwp/xpublish_server.runfiles/common_deps_xarray/site-packages/xarray/core/dataset.py", line 2299, in _validate_indexers
    index = self._indexes[k].to_pandas_index()
KeyError: 'valid_times'

Snippet of code that should help repro the issue

with open("/home/builder/bando/gfs_store.json", "r") as f:
    gfs_store = ujson.load(f)

gfs_dt = datatree.open_datatree(
    fsspec.filesystem("reference", fo=gfs_store).get_mapper(""),
    engine="zarr",
    consolidated=False,
)


mapping = {
    # node.path.lstrip("/").replace("/", "."): node.to_dataset().squeeze().drop_vars("time").rename_vars(valid_time="time").rename_dims(valid_times="times")
    node.path.lstrip("/").replace("/", "."): node.to_dataset().squeeze()
    # .drop_vars("time")
    .rename_vars(valid_time="valid_times")  # .rename_dims(valid_times="valid_time")
    # node.path.lstrip("/").replace("/", "."): node.to_dataset().squeeze()
    ###for node in sfcf_dt.subtree
    for node in gfs_dt.subtree
    if node.has_data
}

for name, dset in mapping.items():
    logger.info("%s \n%s", name, dset.cf)
    # dset.to_zarr(f"/home/builder/bando/{name}.zarr")

rest = xpublish.Rest(mapping)

pp.pprint(rest.plugins)

for route in rest.app.routes:
    logger.info("route: path - %s, name - %s", route.path, route.name)

rest.serve(port=59547)

sfcf_store.json
gfs_store.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant