euroargodev / euroargodev/argopy
`ds.argo.teos10` does not work on a raw Argo dataset returned by an `ArgoFloat` instance
- Dominant language
- Python
- Stars
- 229
- Forks
- 52
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 5
Description
The `argo.teos10` does not work on a raw Argo dataset returned by an `ArgoFloat` instance:
```python
import argopy
argopy.ArgoFloat(1901393).open_dataset().argo.teos10()
```
will raise a xarray `MergeError`
Traceback
```python
---------------------------------------------------------------------------
MergeError Traceback (most recent call last)
Cell In[9], line 1
----> 1 argopy.ArgoFloat(1901393).open_dataset().argo.teos10()
File [~/git/github/euroargodev/argopy/argopy/xarray.py:1554](http://localhost:8888/lab/tree/~/git/github/euroargodev/argopy/argopy/xarray.py#line=1553), in ArgoAccessor.teos10(self, vlist, inplace)
1552 for k in this:
1553 if k not in self._obj:
-> 1554 self._obj[k] = this[k]
1555 return self._obj
1556 else:
File [~/miniconda3/envs/argopy-py311-all-pinned/lib/python3.11/site-packages/xarray/core/dataset.py:1328](http://localhost:8888/lab/tree/~/miniconda3/envs/argopy-py311-all-pinned/lib/python3.11/site-packages/xarray/core/dataset.py#line=1327), in Dataset.__setitem__(self, key, value)
1323 if isinstance(value, Dataset):
1324 raise TypeError(
1325 "Cannot assign a Dataset to a single key - only a DataArray or Variable "
1326 "object can be stored under a single key."
1327 )
-> 1328 self.update({key: value})
1330 elif utils.iterable_of_hashable(key):
1331 keylist = list(key)
File [~/miniconda3/envs/argopy-py311-all-pinned/lib/python3.11/site-packages/xarray/core/dataset.py:5552](http://localhost:8888/lab/tree/~/miniconda3/envs/argopy-py311-all-pinned/lib/python3.11/site-packages/xarray/core/dataset.py#line=5551), in Dataset.update(self, other)
5516 def update(self, other: CoercibleMapping) -> Self:
5517 """Update this dataset's variables with those from another dataset.
5518
5519 Just like :py:meth:`dict.update` this is a in-place operation.
(...) 5550 Dataset.merge
5551 """
-> 5552 merge_result = dataset_update_method(self, other)
5553 return self._replace(inplace=True, **merge_result._asdict())
File [~/miniconda3/envs/argopy-py311-all-pinned/lib/python3.11/site-packages/xarray/structure/merge.py:1063](http://localhost:8888/lab/tree/~/miniconda3/envs/argopy-py311-all-pinned/lib/python3.11/site-packages/xarray/structure/merge.py#line=1062), in dataset_update_method(dataset, other)
1060 if coord_names:
1061 other[key] = value.drop_vars(coord_names)
-> 1063 return merge_core(
1064 [dataset, other],
1065 priority_arg=1,
1066 indexes=dataset.xindexes,
1067 combine_attrs="override",
1068 )
File [~/miniconda3/envs/argopy-py311-all-pinned/lib/python3.11/site-packages/xarray/structure/merge.py:726](http://localhost:8888/lab/tree/~/miniconda3/envs/argopy-py311-all-pinned/lib/python3.11/site-packages/xarray/structure/merge.py#line=725), in merge_core(objects, compat, join, combine_attrs, priority_arg, explicit_coords, indexes, fill_value, skip_align_args)
724 ambiguous_coords = coord_names.intersection(noncoord_names)
725 if ambiguous_coords:
--> 726 raise MergeError(
727 "unable to determine if these variables should be "
728 f"coordinates or not in the merged result: {ambiguous_coords}"
729 )
731 attrs = merge_attrs(
732 [var.attrs for var in coerced if isinstance(var, Dataset | DataArray)],
733 combine_attrs,
734 )
736 return _MergeResult(variables, coord_names, dims, out_indexes, attrs)
MergeError: unable to determine if these variables should be coordinates or not in the merged result: {np.str_('LATITUDE'), np.str_('JULD'), np.str_('LONGITUDE')}
```
what we expect is a similar behaviour to the `DataFetcher` in expert mode:
```python
argopy.DataFetcher(src='gdac', mode='expert').float(1901393).data.argo.teos10()
```
Given the trace error above, this probably has to do with point vs profile structures of the dataset and some incoherence between the internal argo accessor object and TEOS-10 new datarrays.
Because the following explicit point vs profile conversion makes the TEOS-10 works:
```python
ds = argopy.ArgoFloat(1901393).open_dataset()
ds = ds.argo.profile2point()
ds.argo.teos10()
```
Contributor guide
Assessment
This issue has not been assessed yet.