Skip to content

Commit fdceaed

Browse files
Removing fieldset.from_copernicusmarine
1 parent 2eab36b commit fdceaed

1 file changed

Lines changed: 1 addition & 59 deletions

File tree

src/parcels/_core/fieldset.py

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from parcels._logger import logger
2121
from parcels._reprs import fieldset_repr
2222
from parcels._typing import Mesh
23-
from parcels.convert import _discover_U_and_V, _ds_rename_using_standard_names, _maybe_rename_coords
23+
from parcels.convert import _ds_rename_using_standard_names
2424
from parcels.interpolators import (
2525
CGrid_Velocity,
2626
Ux_Velocity,
@@ -187,64 +187,6 @@ def gridset(self) -> list[BaseGrid]:
187187
grids.append(field.grid)
188188
return grids
189189

190-
@classmethod
191-
def from_copernicusmarine(cls, ds: xr.Dataset):
192-
"""Create a FieldSet from a Copernicus Marine Service xarray.Dataset.
193-
194-
Parameters
195-
----------
196-
ds : xarray.Dataset
197-
xarray.Dataset as obtained from the copernicusmarine toolbox.
198-
199-
Returns
200-
-------
201-
FieldSet
202-
FieldSet object containing the fields from the dataset that can be used for a Parcels simulation.
203-
204-
Notes
205-
-----
206-
See https://help.marine.copernicus.eu/en/collections/9080063-copernicus-marine-toolbox for more information on the copernicusmarine toolbox.
207-
The toolbox to ingest data from most of the products on the Copernicus Marine Service (https://data.marine.copernicus.eu/products) into an xarray.Dataset.
208-
You can use indexing and slicing to select a subset of the data before passing it to this function.
209-
Note that most Parcels uses will require both U and V fields to be present in the dataset. This function will try to find out which variables in the dataset correspond to U and V.
210-
To override the automatic detection, rename the appropriate variables in your dataset to 'U' and 'V' before passing it to this function.
211-
212-
"""
213-
ds = ds.copy()
214-
ds = _discover_U_and_V(ds, _COPERNICUS_MARINE_CF_STANDARD_NAME_FALLBACKS)
215-
expected_axes = set("XYZT") # TODO: Update after we have support for 2D spatial fields
216-
if missing_axes := (expected_axes - set(ds.cf.axes)):
217-
raise ValueError(
218-
f"Dataset missing CF compliant metadata for axes "
219-
f"{missing_axes}. Expected 'axis' attribute to be set "
220-
f"on all dimension axes {expected_axes}. "
221-
"HINT: Add xarray metadata attribute 'axis' to dimension - e.g., ds['lat'].attrs['axis'] = 'Y'"
222-
)
223-
224-
ds = _maybe_rename_coords(ds, _COPERNICUS_MARINE_AXIS_VARNAMES)
225-
if "W" in ds.data_vars:
226-
# Negate W to convert from up positive to down positive (as that's the direction of positive z)
227-
ds["W"].data *= -1
228-
229-
if "grid" in ds.cf.cf_roles:
230-
raise ValueError(
231-
"Dataset already has a 'grid' variable (according to cf_roles). Didn't expect there to be grid metadata on copernicusmarine datasets - please open an issue with more information about your dataset."
232-
)
233-
ds["grid"] = xr.DataArray(
234-
0,
235-
attrs=sgrid.Grid2DMetadata( # use dummy *_center dimensions - this is A grid data (all defined on nodes)
236-
cf_role="grid_topology",
237-
topology_dimension=2,
238-
node_dimensions=("lon", "lat"),
239-
face_dimensions=(
240-
sgrid.DimDimPadding("x_center", "lon", sgrid.Padding.LOW),
241-
sgrid.DimDimPadding("y_center", "lat", sgrid.Padding.LOW),
242-
),
243-
vertical_dimensions=(sgrid.DimDimPadding("z_center", "depth", sgrid.Padding.LOW),),
244-
).to_attrs(),
245-
)
246-
return cls.from_sgrid_conventions(ds, mesh="spherical")
247-
248190
@classmethod
249191
def from_fesom2(cls, ds: ux.UxDataset):
250192
"""Create a FieldSet from a FESOM2 uxarray.UxDataset.

0 commit comments

Comments
 (0)