parcels icon indicating copy to clipboard operation
parcels copied to clipboard

raise FieldOutOfBoundError(f"Field sampled out-of-bound, at (depth={z}, lat={y}, lon={x})")

Open clementbricaud opened this issue 8 months ago • 5 comments

Parcels version

parcels 3.1.2

Description

Hello I am trying to launch parcels with NEMO outputs on ORCA36 fields.

I want to compare trajectories with drifters comoing from https://data.marine.copernicus.eu/product/INSITU_GLO_PHY_UV_DISCRETE_NRT_013_048/description The trajectories are initialised at 15m depth.

As ORCA36 is huge for memomry, I made an extraction of the first 10 levels of the model: depthv = 0.50576, 1.555855, 2.667682, 3.85628, 5.140361, 6.543034, 8.092519, 9.82275, 11.77368, 13.99104, 16.52532, 19.4298, 22.75762

I have this errors and I don't understant where it comes from: out_of_bound_error raise FieldOutOfBoundError(f"Field sampled out-of-bound, at (depth={z}, lat={y}, lon={x})") parcels.tools.statuscodes.FieldOutOfBoundError: Field sampled out-of-bound, at (depth=15.0, lat=27.415000915527344, lon=-61.00699996948242)

Code sample

# Paste your code within this block
# Paste your error message within this block

clementbricaud avatar Jun 30 '25 09:06 clementbricaud

Hi @clementbricaud, what is the horizontal extent of your fieldaet? What is the output of print(fieldset)? Could it be that -61 lon is outside the domain? What if you add 360 degrees to all your practice longitudes?

erikvansebille avatar Jun 30 '25 09:06 erikvansebille

Hello thank you very much for your help !

I am trying that: fieldset.U.grid.lon = np.where(fieldset.U.grid.lon > 180, fieldset.U.grid.lon-360, fieldset.U.grid.lon)

but I have an error:

fieldset.U.grid.lon = np.where(fieldset.U.grid.lon > 180, fieldset.U.grid.lon-360, fieldset.U.grid.lon) ^^^^^^^^^^^ AttributeError: property 'lon' of 'CurvilinearZGrid' object has no setter

print(fieldset) gives:

fields: name : 'U' grid : CurvilinearZGrid(lon=array([[ 73.00, 73.03, 73.06, ..., 72.92, 72.94, 72.97], [ 73.00, 73.03, 73.06, ..., 72.92, 72.94, 72.97], [ 73.00, 73.03, 73.06, ..., 72.92, 72.94, 72.97], ..., [ 73.00, 73.00, 73.00, ..., 73.00, 73.00, 73.00], [ 73.00, 73.00, 73.00, ..., 73.00, 73.00, 73.00], [ 73.00, 73.00, 73.00, ..., 73.00, 73.00, 73.00]], shape=(10842, 12960), dtype=float32), lat=array([[-84.20, -84.20, -84.20, ..., -84.20, -84.20, -84.20], [-84.19, -84.19, -84.19, ..., -84.19, -84.19, -84.19], [-84.20, -84.20, -84.20, ..., -84.20, -84.20, -84.20], ..., [ 50.00, 50.00, 50.00, ..., 50.00, 50.00, 50.00], [ 50.00, 50.00, 50.00, ..., 50.00, 50.00, 50.00], [ 50.00, 50.00, 50.00, ..., 50.00, 50.00, 50.00]], shape=(10842, 12960), dtype=float32), time=array([ 0.00, 86400.00, 172800.00, 259200.00]), time_origin=2023-02-01T12:00:00.000000000, mesh='spherical') extrapolate time: True time_periodic : False gridindexingtype: 'nemo' to_write : False name : 'V' grid : CurvilinearZGrid(lon=array([[ 73.00, 73.03, 73.06, ..., 72.92, 72.94, 72.97], [ 73.00, 73.03, 73.06, ..., 72.92, 72.94, 72.97], [ 73.00, 73.03, 73.06, ..., 72.92, 72.94, 72.97], ..., [ 73.00, 73.00, 73.00, ..., 73.00, 73.00, 73.00], [ 73.00, 73.00, 73.00, ..., 73.00, 73.00, 73.00], [ 73.00, 73.00, 73.00, ..., 73.00, 73.00, 73.00]], shape=(10842, 12960), dtype=float32), lat=array([[-84.20, -84.20, -84.20, ..., -84.20, -84.20, -84.20], [-84.19, -84.19, -84.19, ..., -84.19, -84.19, -84.19], [-84.20, -84.20, -84.20, ..., -84.20, -84.20, -84.20], ..., [ 50.00, 50.00, 50.00, ..., 50.00, 50.00, 50.00], [ 50.00, 50.00, 50.00, ..., 50.00, 50.00, 50.00], [ 50.00, 50.00, 50.00, ..., 50.00, 50.00, 50.00]], shape=(10842, 12960), dtype=float32), time=array([ 0.00, 86400.00, 172800.00, 259200.00]), time_origin=2023-02-01T12:00:00.000000000, mesh='spherical') extrapolate time: True time_periodic : False gridindexingtype: 'nemo' to_write : False name: 'UV' U: V: W: None

clementbricaud avatar Jun 30 '25 11:06 clementbricaud

@clementbricaud it would be really helpful if we could see the code that you are running. Would you be able to copy/paste your full script here so that we can have a look?

Are you following our tutorials listed on our documentation website? Perhaps if you let us know which tutorial you're following/code you're adapting we can point you in the right direction?

VeckoTheGecko avatar Jun 30 '25 11:06 VeckoTheGecko

if (grid_regularity == 'native'):
  fieldset_current = FieldSet.from_nemo(filenames, variables, dimensions, allow_time_extrapolation=True)

fieldset = fieldset_current

    if ('GLO36V1_' in model):
        print(fieldset)
        print(fieldset.U)
        print("-------------- fieldset.U.grid")
        print(fieldset.U.grid)
        print("-------------- fieldset.U.grid.lon")
        print(fieldset.U.grid.lon)
        print(fieldset.U.grid.lon[5000,0])

        #fieldset.U.grid.lon = np.where(fieldset.U.grid.lon > 180, fieldset.U.grid.lon-360, fieldset.U.grid.lon)
        fieldset.U.lon = np.where(fieldset.U.lon > 180, fieldset.U.lon-360, fieldset.U.lon)

clementbricaud avatar Jun 30 '25 11:06 clementbricaud

Hi @clementbricaud , this is not the full script (i.e., the script from top to bottom, or in the case of a notebook - the code from all the cells). Its really difficult to see from the partial snippet here what you're trying to do, or what you've attempted so far. There just isn't enough information here.

Also fieldset.U.grid.lon = is invalid code for Parcels, which is why I was asking whether you were following a tutorial. Which code did you start working with? Was it an example from our documentation? Was it someone else's code?

Also, please use code blocks so that your formatting is preserved. You can write like the following

```python
print("your code goes here")
```

which results in the following being rendered

print("your code goes here")

VeckoTheGecko avatar Jun 30 '25 12:06 VeckoTheGecko

test_parcel.py.txt

Hello, thank you for your help

I have tried the example_nemo_curvilinear.py example from https://docs.oceanparcels.org/en/latest/documentation/additional_examples.html with my model fields from ORCA36. my python script is attached to this message

I have the same error: File "/perm/ar5/conda/envs/parcels/lib/python3.13/site-packages/parcels/tools/statuscodes.py", line 61, in _raise_field_out_of_bound_error raise FieldOutOfBoundError(f"Field sampled out-of-bound, at (depth={z}, lat={y}, lon={x})") parcels.tools.statuscodes.FieldOutOfBoundError: Field sampled out-of-bound, at (depth=0.0, lat=47.0, lon=-17.0)

clementbricaud avatar Jul 01 '25 06:07 clementbricaud