Open VeckoTheGecko opened 2 years ago
Happy to be assigned this. Will develop it and hopefully have it up within a couple weeks
@erikvansebille I've been working on this feature, and have been making quite a bit of progress. I have also been encountering a roadblock, which I feel the only way to overcome would be through knowing more about the internal workings and design decisions of parcels.
In Delft3D Flow, you specify an arbitrary mesh which represents the water cells for the simulation. Of course, this mesh is not necessarily rectangular, and can stagger towards the shape of a coastline. There is no concept of land cells (whatever is outside the mesh is either land or just outside the domain of the simulation).
The NetCDF output from Delft3D Flow provides the hydrodynamical data, as well as the coordinates of the gridpoints for the mesh. As the NetCDF output is array-like, the shape of the mesh data is (M_MAX, N_MAX)
which correspond to the maximum width and height of the mesh. For mesh-points that do not exist, Delft3D fills the corresponding value in the array with 0 (which can be replaced for nan
).
My question is, how does parcels handle land cells? Options:
If option 1, I would need to generate (interpolate/extrapolate) these missing gridcells before passing it to parcels, which would need to fundamentally work off the assumption that the grid is flat or geopolar curvilinear (as arbitrary curvilinear grids won't have an intuitive way to generate the missing gridpoints).
This leads me into my other question.
Delft3D Flow allows users to specify a completely arbitrary curvilinear grid (eg. for modelling a river). From my understanding parcels has support for flat meshes and for geopolar curvilinear meshes. Are there any limitations within parcels that prevent it from dealing with arbitrary curvilinear grids (eg. interpolation schemes or fieldset plotting)?
Let me know if you'd like any code or Delft Flow data to assist with this discussion.
Hi @VeckoTheGecko, sorry for the delay in responding; I was on holidays last week.
To answer your questions:
Hi @erikvansebille
I was on holidays last week.
All good 😁. Hope you had a good break
NaN points in the FieldSet are set to zero
To clarify, I don't mean nan
s for currents in the Fields U and V (which would lead to "beaching" of particles). Moreso I mean whether parcels can handle nan
values for the (lon, lat)
gridpoints themselves. Delft doesn't have land cells in the domain of the mesh, so these gridpoints conceptually just don't exist in Delft.
Whipped up a diagram which should illustrate.
Thanks for the links.
Thanks for the sketch @VeckoTheGecko, that clarifies what you meant.
The answer is 'No', Parcels can't handle NaN
s in lot
and lat
, unfortunately. Because we use a binary search to find the indices of the grid cell where a particle is located, NaN
s don' play nice and it may be tricky to adapt the code (see here for the Scipy version of the index search, and here for the C/JIT version).
My hunch is that ti will be easier to preprocess the Fields so that they end up as 'clean' rectangular arrays (your bottom-left sketch)
I've managed to get a working implementation of this up and going for my own work with cartesian meshes.
I'd like to refactor and develop tests for this before submitting a PR (possibly also supporting curvilinear meshes), but am distracted other work at the moment.
I'll aim to get this done and cleaned up by late November/early Dec.
@erikvansebille let me know if you want me to submit a (very rough) draft PR for this in the meantime.
Great to hear that you've got a working implementation! Perhaps you can indeed already upload a rough PR, so that others may also be able to work/advance it. That's what open source development is about 😉
Currently
parcels
doesn't have the capability to readDelf3D Flow
simulation NetCDF flow output. Writing a function likeFieldSet.from_nemo()
that parses the NetCDF file fromFlow
into aparcels
fieldset would be a useful addition to the codebase for those working withDelft3D
.Discussed in https://github.com/OceanParcels/parcels/discussions/1204