With #2646 - we need to decide on an API for adding VectorFields.
I was looking at the docs build, and saw an example that adds a second velocity field
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
import parcels
import parcels.tutorial
# Load the CopernicusMarine data in the Agulhas region from the example_datasets
ds_fields = parcels.tutorial.open_dataset("CopernicusMarine_data_for_Argo_tutorial/data")
ds_fields.load() # load the dataset into memory
# Create an idealised wind field and add it to the dataset
tdim, ydim, xdim = (len(ds_fields.time),len(ds_fields.latitude), len(ds_fields.longitude))
ds_fields["UWind"] = xr.DataArray(
data=np.ones((tdim, ydim, xdim)) * np.sin(ds_fields.latitude.values)[None, :, None],
coords=[ds_fields.time, ds_fields.latitude, ds_fields.longitude])
ds_fields["VWind"] = xr.DataArray(
data=np.zeros((tdim, ydim, xdim)),
coords=[ds_fields.time, ds_fields.latitude, ds_fields.longitude])
fields = {
"U": ds_fields["uo"],
"V": ds_fields["vo"],
"UWind": ds_fields["UWind"],
"VWind": ds_fields["VWind"],
}
ds_fset = parcels.convert.copernicusmarine_to_sgrid(fields=fields)
fieldset = parcels.FieldSet.from_sgrid_conventions(ds_fset)
# Create a vecorfield for the wind
windvector = parcels.VectorField(
"Wind",
fieldset.UWind,
fieldset.VWind,
interp_method=parcels.interpolators.XLinear_Velocity
)
fieldset.add_field(windvector)
We no longer have add_field - I think we need to map out exactly how we should be defining velocity fields under this new refactoring... I think that can be done in a future PR
Originally posted by @VeckoTheGecko in #2646 (comment)
With #2646 - we need to decide on an API for adding VectorFields.
I was looking at the docs build, and saw an example that adds a second velocity field
We no longer have
add_field- I think we need to map out exactly how we should be defining velocity fields under this new refactoring... I think that can be done in a future PROriginally posted by @VeckoTheGecko in #2646 (comment)