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

ATL06 example in readme results in ValueError #241

Closed
scottyhq opened this issue May 16, 2023 · 2 comments · Fixed by #267
Closed

ATL06 example in readme results in ValueError #241

scottyhq opened this issue May 16, 2023 · 2 comments · Fixed by #267

Comments

@scottyhq
Copy link

Executing the code cells in the repository README results in a ValueError.

(earthaccess v0.5.2 running in AWS us-west-2 https://opensciencelab.asf.alaska.edu with netrc auth)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], line 3
      1 import xarray as xr
----> 3 ds = xr.open_mfdataset(earthaccess.open(results))

File ~/.local/envs/odc/lib/python3.10/site-packages/xarray/backends/api.py:1011, in open_mfdataset(paths, chunks, concat_dim, compat, preprocess, engine, data_vars, coords, combine, parallel, join, attrs_file, combine_attrs, **kwargs)
    998     combined = _nested_combine(
    999         datasets,
   1000         concat_dims=concat_dim,
   (...)
   1006         combine_attrs=combine_attrs,
   1007     )
   1008 elif combine == "by_coords":
   1009     # Redo ordering from coordinates, ignoring how they were ordered
   1010     # previously
-> 1011     combined = combine_by_coords(
   1012         datasets,
   1013         compat=compat,
   1014         data_vars=data_vars,
   1015         coords=coords,
   1016         join=join,
   1017         combine_attrs=combine_attrs,
   1018     )
   1019 else:
   1020     raise ValueError(
   1021         "{} is an invalid option for the keyword argument"
   1022         " ``combine``".format(combine)
   1023     )

File ~/.local/envs/odc/lib/python3.10/site-packages/xarray/core/combine.py:976, in combine_by_coords(data_objects, compat, data_vars, coords, fill_value, join, combine_attrs, datasets)
    974     concatenated_grouped_by_data_vars = []
    975     for vars, datasets_with_same_vars in grouped_by_vars:
--> 976         concatenated = _combine_single_variable_hypercube(
    977             list(datasets_with_same_vars),
    978             fill_value=fill_value,
    979             data_vars=data_vars,
    980             coords=coords,
    981             compat=compat,
    982             join=join,
    983             combine_attrs=combine_attrs,
    984         )
    985         concatenated_grouped_by_data_vars.append(concatenated)
    987 return merge(
    988     concatenated_grouped_by_data_vars,
    989     compat=compat,
   (...)
    992     combine_attrs=combine_attrs,
    993 )

File ~/.local/envs/odc/lib/python3.10/site-packages/xarray/core/combine.py:623, in _combine_single_variable_hypercube(datasets, fill_value, data_vars, coords, compat, join, combine_attrs)
    617 if len(datasets) == 0:
    618     raise ValueError(
    619         "At least one Dataset is required to resolve variable names "
    620         "for combined hypercube."
    621     )
--> 623 combined_ids, concat_dims = _infer_concat_order_from_coords(list(datasets))
    625 if fill_value is None:
    626     # check that datasets form complete hypercube
    627     _check_shape_tile_ids(combined_ids)

File ~/.local/envs/odc/lib/python3.10/site-packages/xarray/core/combine.py:145, in _infer_concat_order_from_coords(datasets)
    140             tile_ids = [
    141                 tile_id + (position,) for tile_id, position in zip(tile_ids, order)
    142             ]
    144 if len(datasets) > 1 and not concat_dims:
--> 145     raise ValueError(
    146         "Could not find any dimension coordinates to use to "
    147         "order the datasets for concatenation"
    148     )
    150 combined_ids = dict(zip(tile_ids, datasets))
    152 return combined_ids, concat_dims

ValueError: Could not find any dimension coordinates to use to order the datasets for concatenation
@asteiker
Copy link
Member

@scottyhq Thanks for submitting this Issue- great catch. This is due to us not specifying a group when attempting to open the granules (so that line is more generic for files that do not have a group structure, yet we've included ATL06 as the example). We can update with a group specified like in our latest ICESat-2 cloud tutorial (https://github.com/nsidc/NSIDC-Data-Tutorials/blob/main/notebooks/ICESat-2_Cloud_Access/nsidc_daac_uwg_cloud_access_tutorial.ipynb) and/or or update to a different dataset example without groups. What do you think would be most helpful @scottyhq ? I did just test an example group and this should fix the error:

ds = xr.open_mfdataset(earthaccess.open(results), group='/gt1l/land_ice_segments')

@scottyhq
Copy link
Author

What do you think would be most helpful @scottyhq ?

Sorry for the delayed response @asteiker , the fix makes sense! I'd advocate for starting with a much simpler ds = xr.open_dataset(earthaccess.open(results[0]), group='/gt1l/land_ice_segments') single file example. Often the readme is a gateway for new users who want to quickly kick the tires. xr.open_mfdataset() is pretty advanced and slow if not opening local or cloud-optimized data.

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

Successfully merging a pull request may close this issue.

2 participants