Fieldset parameters #1659
Replies: 1 comment
-
@patriciaulloa You deleted the content of your message, I assume that was in error so I have edited it to put it back. If the issue you were facing has already been resolved then you can close the discussion. The
The output of the import scipy.io
import xarray as xr
import parcels
# Load the .mat file
mat_data = scipy.io.loadmat('your_data.mat')
# Extract the relevant variables
lon = mat_data['lon'] # Assuming 'lon' is in the .mat file
lat = mat_data['lat'] # Assuming 'lat' is in the .mat file
time = mat_data['time'] # Assuming 'time' is in the .mat file
depth = mat_data['depth'] # Assuming 'depth' is in the .mat file
U = mat_data['U'] # Assuming 'U' is in the .mat file
V = mat_data['V'] # Assuming 'V' is in the .mat file
# Create an Xarray dataset
ds = xr.Dataset(
{
'U': (['time', 'depth', 'lat', 'lon'], U), # Depends on the dimension order of the matrix
'V': (['time', 'depth', 'lat', 'lon'], V), # Depends on the dimension order of the matrix
},
coords={
'lon': (['lon'], lon),
'lat': (['lat'], lat),
'time': (['time'], time),
'depth': (['depth'], depth),
}
)
dimensions = {"lat": "lat", "lon": "lon", "time": "time"}
variables = {
"U": "U", # U maps to var in xarray (which is also U)
"V": "V", # ...
}
fieldset = parcels.FieldSet.from_xarray_dataset(ds, variables, dimensions) Unfortunatly I can't be of more help unless I have the dataset itself. If you still need help, please provide a link to the dataset either via wetransfer or another way |
Beta Was this translation helpful? Give feedback.
-
Dear all, I just simulate the surface velocity of the coastal ocean using the slab model, basically a grid of 100 x 100 points in were the wind-induced circulation was simulated. I have the variables, longitude(10,10), latitude(10,10),depth(20x1), u_velocity , v_velocity(10-lon,10lat,20-depths,500-hours). Now I just save all the data in a .mat file and read the file in python for using the data in parcels. Since this is not a nc file, how I need to use the fieldset parameter?
fieldset = FieldSet.from_xarray_dataset(ds, variables, dimensions,vmin=-2000,allow_time_extrapolation=True) ?
I try,
but did not work, I will appreciate any help in how to load the data into the model.
Beta Was this translation helpful? Give feedback.
All reactions