Comments (5)
I have been returning to this problem (and related out-of-domain issues) as it is becoming increasingly important for simulations involving diffusion or other, non-advection, forcing.
I'll attempt to summarise my understanding of our current functionality, to open discussion. Please correct me where if I am misunderstanding the code, particularly JIT mode where it's harder to debug the C-code converted kernels.
At present, the master branch:
- Interpolates sampled field values using
interpolator2d
- If this interpolation involves reading values from outside the domain:
- In Scipy mode this is caught, an error message printed, and a value of
None
returned for the interpolated value - In JIT mode, NaNs are returned, but no error or warning message is generated
- In Scipy mode this is caught, an error message printed, and a value of
- NaN values within the boundary demain are set to zero during initiation of individual
Field
objects
Is this an accurate summary?
This allows the user to check if sampled field values are None (for scipy) or nan (using math.isnan
for JIT mode), and act accordingly for out-of-domain instances (e.g. calling particle.die()
or perhaps moving the particle back to a previously stored position).
However, it seems that there is still no way of checking for presence on land masses within the model domain, aside from checking for zero field values within kernels (which in some instances may be a valid field value).
From the point of view of writing custom kernels, it would more useful to have a consistent NaN value returned, rather than a built in check-rejection test. It would allow users to, say, redraw the diffusion component of a time-step but keep the advection, for example.
I know NaNs cause problems with Scipy, but what options do we have here?
from parcels.
Ok, for this discussion I would like to point you to the ongoing work in the recovery-kernel-loop
branch, which provides an explicit mechanism for dealing with "kernel errors", eg. "out of bounds" sampling or "NaN sampling". The idea here is to allow users to define "recovery kernels" that are run only once a specified error event occurs, and can range from throwing an error to "re-inserting" particles into the grid. Since the recovery mechanism for out-of-bounds and NaN cases can be specified separately, this should provide enough flexibility to do what you want, right?
The current implementation works for SciPy mode, but it does not yet expose the functionality through the execute()
call. I will add this soon, including examples, so that we provide a choice for user how to deal with these special cases.
from parcels.
This sounds great @mlange05 ! I didn't realise this branch existed. I will take a proper look and try to begin implementing some recovery kernels for scipy in anticipation of the finished product. All my work arounds with the current master are becoming rather messy, but it's kind of critical for our applied tuna paper.
from parcels.
We've written some 'unbeaching kernels', see e.g. https://github.com/OceanParcels/Parcelsv2.0PaperNorthSeaScripts/blob/master/northsea_mp_kernels.py which is associated with the v2.0 paper in GMD
from parcels.
@erikvansebille and @Jacketless, are all NaNs converted to zero? I was hoping to recognize cells = NaN as beached (inside a kernel) and unbeach accordingly. Instead, I made all of my "land" cells = 0.00; but then there is the chance of actual 0 velocity occurring and being interpreted as beaching... Furthermore, I think I am running into spatial interpolation issues where the outermost land cells are not being recognized as land (since their interpolated velocity is > or < 0) and I end up with "longshore flow" on land. Is that possible?
from parcels.
Related Issues (20)
- `parcels_get_examples` deprecation notice HOT 2
- Cleaning python install process and setup.py
- Typo in documentation of `time_periodic` argument of Fieldset constructors HOT 1
- "Jumps" using different values of RK4_dt HOT 2
- Auto-update CITATION.cff file HOT 2
- Issue running oceanparcels on updated environment HOT 7
- Running notebooks in RTD CI HOT 4
- Tripolar B-grid issue in the North Pole (MOM5 velocity fields) HOT 8
- Create explicit test script which ensures the installed package works as intended? HOT 4
- Vector plotting issue for C-grid data HOT 2
- 3D run by using NEMO output HOT 1
- Breaking ReadTheDocs because of link that does work HOT 3
- Broken anchor `http://oceanparcels.org/#parallel_install` HOT 1
- Parcels Tutorial Issue: RuntimeError: Error during compilation HOT 5
- NestedField from FieldSet.from_nemo HOT 5
- Investigate integrating AI for Parcels documentation HOT 6
- Raise a Warning or Error when lon/lat in grids are not monotonically increasing
- Overlapping time values while creating a FieldSet HOT 2
- Field entry gives error when time-array has np.datetime64 entries HOT 1
- Fieldset.from_data() sets "time_origin" to 0 by default HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parcels.