{"action":"opened","issue":{"url":"https://api.github.com/repos/pydata/xarray/issues/2233","repository_url":"https://api.github.com/repos/pydata/xarray","labels_url":"https://api.github.com/repos/pydata/xarray/issues/2233/labels{/name}","comments_url":"https://api.github.com/repos/pydata/xarray/issues/2233/comments","events_url":"https://api.github.com/repos/pydata/xarray/issues/2233/events","html_url":"https://github.com/pydata/xarray/issues/2233","id":332471780,"node_id":"MDU6SXNzdWUzMzI0NzE3ODA=","number":2233,"title":"Can't open these unstructured grid ocean forecasts","user":{"login":"rsignell-usgs","id":1872600,"node_id":"MDQ6VXNlcjE4NzI2MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/1872600?v=4","gravatar_id":"","url":"https://api.github.com/users/rsignell-usgs","html_url":"https://github.com/rsignell-usgs","followers_url":"https://api.github.com/users/rsignell-usgs/followers","following_url":"https://api.github.com/users/rsignell-usgs/following{/other_user}","gists_url":"https://api.github.com/users/rsignell-usgs/gists{/gist_id}","starred_url":"https://api.github.com/users/rsignell-usgs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsignell-usgs/subscriptions","organizations_url":"https://api.github.com/users/rsignell-usgs/orgs","repos_url":"https://api.github.com/users/rsignell-usgs/repos","events_url":"https://api.github.com/users/rsignell-usgs/events{/privacy}","received_events_url":"https://api.github.com/users/rsignell-usgs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-14T16:15:56Z","updated_at":"2018-06-14T16:15:56Z","closed_at":null,"author_association":"NONE","body":"We can't open the IOOS New England triangular mesh ocean forecasts with Xarray because it doesn't understand their more complex CF vertical coordinate system.  \r\n\r\n```python\r\nimport xarray as xr\r\nurl='http://www.smast.umassd.edu:8080/thredds/dodsC/FVCOM/NECOFS/Forecasts/NECOFS_GOM3_FORECAST.nc'\r\nxr.open_dataset(url)\r\n```\r\nfails with:\r\n```\r\nMissingDimensionsError: 'siglay' has more than 1-dimension and the same name as one of its dimensions ('siglay', 'node'). xarray disallows such variables because they conflict with the coordinates used to label dimensions.\r\n```\r\nIf you open this dataset with `nc = netCDF4.Dataset(url)` you can see what the data variables (e.g. `temp`) and coordinates (e.g. `siglay`) look like:\r\n```\r\nprint(nc['temp'])\r\n\r\n<class 'netCDF4._netCDF4.Variable'>\r\nfloat32 temp(time, siglay, node)\r\n    long_name: temperature\r\n    standard_name: sea_water_potential_temperature\r\n    units: degrees_C\r\n    coordinates: time siglay lat lon\r\n    type: data\r\n    coverage_content_type: modelResult\r\n    mesh: fvcom_mesh\r\n    location: node\r\nunlimited dimensions: time\r\ncurrent shape = (145, 40, 53087)\r\n\r\nprint(nc['siglay'])\r\n\r\n<class 'netCDF4._netCDF4.Variable'>\r\nfloat32 siglay(siglay, node)\r\n    long_name: Sigma Layers\r\n    standard_name: ocean_sigma_coordinate\r\n    positive: up\r\n    valid_min: -1.0\r\n    valid_max: 0.0\r\n    formula_terms: sigma: siglay eta: zeta depth: h\r\nunlimited dimensions: \r\ncurrent shape = (40, 53087)\r\n```\r\nSo the `siglay` variable in this dataset specifies the fraction of water column contained in the layer and because this fraction changes over the grid, it has dimensions of `siglay` and `node`.   The variable `siglay` is just one of the variables used in the calculation of this CF-compliant vertical coordinate.  \r\n\r\nWhile we understand that there is no way to represent the vertical coordinate with a one-dimensional coordinate that xarray would like, it would be nice if there way to at least load the variable array data like `temp` into xarray.    \r\n\r\nIs there any workaround for this?\r\n\r\n<details>\r\n\r\n```\r\n---------------------------------------------------------------------------\r\nMissingDimensionsError                    Traceback (most recent call last)\r\n<ipython-input-18-723c5c460db2> in <module>()\r\n----> 1 xr.open_dataset(url)\r\n\r\n~/miniconda3/envs/pangeo/lib/python3.6/site-packages/xarray/backends/api.py in open_dataset(filename_or_obj, group, decode_cf, mask_and_scale, decode_times, autoclose, concat_characters, decode_coords, engine, chunks, lock, cache, drop_variables, backend_kwargs)\r\n    344             lock = _default_lock(filename_or_obj, engine)\r\n    345         with close_on_error(store):\r\n--> 346             return maybe_decode_store(store, lock)\r\n    347     else:\r\n    348         if engine is not None and engine != 'scipy':\r\n\r\n~/miniconda3/envs/pangeo/lib/python3.6/site-packages/xarray/backends/api.py in maybe_decode_store(store, lock)\r\n    256             store, mask_and_scale=mask_and_scale, decode_times=decode_times,\r\n    257             concat_characters=concat_characters, decode_coords=decode_coords,\r\n--> 258             drop_variables=drop_variables)\r\n    259 \r\n    260         _protect_dataset_variables_inplace(ds, cache)\r\n\r\n~/miniconda3/envs/pangeo/lib/python3.6/site-packages/xarray/conventions.py in decode_cf(obj, concat_characters, mask_and_scale, decode_times, decode_coords, drop_variables)\r\n    428         vars, attrs, concat_characters, mask_and_scale, decode_times,\r\n    429         decode_coords, drop_variables=drop_variables)\r\n--> 430     ds = Dataset(vars, attrs=attrs)\r\n    431     ds = ds.set_coords(coord_names.union(extra_coords).intersection(vars))\r\n    432     ds._file_obj = file_obj\r\n\r\n~/miniconda3/envs/pangeo/lib/python3.6/site-packages/xarray/core/dataset.py in __init__(self, data_vars, coords, attrs, compat)\r\n    363             coords = {}\r\n    364         if data_vars is not None or coords is not None:\r\n--> 365             self._set_init_vars_and_dims(data_vars, coords, compat)\r\n    366         if attrs is not None:\r\n    367             self.attrs = attrs\r\n\r\n~/miniconda3/envs/pangeo/lib/python3.6/site-packages/xarray/core/dataset.py in _set_init_vars_and_dims(self, data_vars, coords, compat)\r\n    381 \r\n    382         variables, coord_names, dims = merge_data_and_coords(\r\n--> 383             data_vars, coords, compat=compat)\r\n    384 \r\n    385         self._variables = variables\r\n\r\n~/miniconda3/envs/pangeo/lib/python3.6/site-packages/xarray/core/merge.py in merge_data_and_coords(data, coords, compat, join)\r\n    363     indexes = dict(extract_indexes(coords))\r\n    364     return merge_core(objs, compat, join, explicit_coords=explicit_coords,\r\n--> 365                       indexes=indexes)\r\n    366 \r\n    367 \r\n\r\n~/miniconda3/envs/pangeo/lib/python3.6/site-packages/xarray/core/merge.py in merge_core(objs, compat, join, priority_arg, explicit_coords, indexes)\r\n    433     coerced = coerce_pandas_values(objs)\r\n    434     aligned = deep_align(coerced, join=join, copy=False, indexes=indexes)\r\n--> 435     expanded = expand_variable_dicts(aligned)\r\n    436 \r\n    437     coord_names, noncoord_names = determine_coords(coerced)\r\n\r\n~/miniconda3/envs/pangeo/lib/python3.6/site-packages/xarray/core/merge.py in expand_variable_dicts(list_of_variable_dicts)\r\n    209                     var_dicts.append(coords)\r\n    210 \r\n--> 211                 var = as_variable(var, name=name)\r\n    212                 sanitized_vars[name] = var\r\n    213 \r\n\r\n~/miniconda3/envs/pangeo/lib/python3.6/site-packages/xarray/core/variable.py in as_variable(obj, name)\r\n    112                 'dimensions %r. xarray disallows such variables because they '\r\n    113                 'conflict with the coordinates used to label '\r\n--> 114                 'dimensions.' % (name, obj.dims))\r\n    115         obj = obj.to_index_variable()\r\n    116 \r\n\r\nMissingDimensionsError: 'siglay' has more than 1-dimension and the same name as one of its dimensions ('siglay', 'node'). xarray disallows such variables because they conflict with the coordinates used to label dimensions.\r\n```\r\n</details>"}}
{"actor":{"display_login":"rsignell-usgs"}}