Comments (10)
Hi!
Just tried that, but it does not hang on that command. The output is 3600 (don't know if that's useful somehow)
from parcels.
Oh okay, just realized I should add this to the output_file line:
output_file=pset.ParticleFile(name='output_example.zarr' , outputdt=timedelta(hours=1))
I have tried this and now everything is working just fine. Maybe this has changed from v2.4.2 to v3.0? I looked it up in https://docs.oceanparcels.org/en/latest/examples/parcels_tutorial.html but i don't recall this extra argument in the output_file was necessary in the former version (maybe I'm wrong).
Anyway, thank you so much for your help (and patience) !!
Cheers,
Martinho Rial
from parcels.
Hi @martoconnh,
It's quite difficult to diagnose a problem without all the information. Would you be able to share a minimal example of code that reproduces this issue and we can try and help from there?
Cheers,
Michael
from parcels.
Sure!
Here it is my code. It simulates only 2 particles through 5 days. I still get the same problem even with this one.
# -*- coding: utf-8 -*-
""" Brief example """
import os
from datetime import timedelta as delta
from parcels import (AdvectionRK4,FieldSet,JITParticle,ParticleSet,StatusCode)
# Parameters
total_days = 5 # Max of 23 days (since 7 to 30 september)
#%% FieldSet creation
# List with our .nc4 files to create the FieldSet
dataset_folder = r'C:\Users\Marto\Documents\UNIVERSIDADE\TFG\FICHEIROS_AROUSA\hidrodinamicos_desde_20170907'
arquivos_nc4 = [os.path.join(dataset_folder, archivo) for archivo in os.listdir(dataset_folder) if archivo.endswith('.nc4')]
# Variables and dimensions
variables = {'U': 'u', 'V': 'v'}
dimensions = {'time': 'time', 'lon': 'lon', 'lat': 'lat'}
# FieldSet Creation
fieldset = FieldSet.from_netcdf(arquivos_nc4, variables, dimensions)
#%% Coordinates and ParticleSet definition
class Particula(JITParticle):
pass
# Only 2 particles from 2 separate points
lats = [42.635,42.5]
lons = [-8.78,-8.83]
pset = ParticleSet(fieldset=fieldset, pclass=Particula, lon=lons, lat=lats)
#%% Execution
total_runtime = delta(days=total_days)
dt = delta(minutes=15)
# Delete particle if out of bounds
def DeleteParticle(particle, fieldset, time):
if particle.state == StatusCode.ErrorOutOfBounds:
particle.delete()
kernels = [AdvectionRK4,DeleteParticle]
pset.execute(kernels,
runtime=total_runtime,
dt=dt,
output_file=pset.ParticleFile(name='output_example.zarr'))
Thanks!
Martinho
from parcels.
Hmm, it's strange that this code hangs. And what if you make these two changes to further simplify the code:
- Use
pset = ParticleSet(fieldset=fieldset, pclass=JITParticle, lon=lons, lat=lats)
(so use a simple JITParticle) - Use
kernels = [AdvectionRK4]
(so don't delete the particles)
Does either of these make a difference?
from parcels.
Hi !
I have just tried, but it does not make any difference. Maybe there is something else that changed from v2.4.2 to v3.0.0 that I'm not using propperly??
from parcels.
OK, good to know it's not either of these two options at #1461 (comment)
Can you then try to add, immediately after you created the fieldset
fieldset.computeTimeChunk(0,1)
If your script then hangs on that command, it clearly is related to the loading in of the fieldset data from the NectCDF files. But that would be strange, because changes to the code for the fieldset creation were minimal going from 2.4.2 to 3.0.0. Still, good to check it before we dig deeper.
from parcels.
OK, final test: what if you remove the output_file=pset.ParticleFile(name='output_example.zarr')
line in the pset.execute()
? Does that make a difference?
from parcels.
Oh, that did actually work. So maybe I should store the simulation data in some other way??
from parcels.
Ah, good to know that adding outputdt
fixed your problem. This was already necessary in v2.4.2 too, but perhaps the code would back then be bit more lenient if you had forgotten it. Glad it's solved!
from parcels.
Related Issues (20)
- `NaN` padding in zarr files with delayed start times HOT 2
- RunTimeErrorWarning in output files HOT 1
- Delayed particles does not repeat the set initial locations HOT 2
- Field[time, depth, lat, lon] indexing not working correctly in JIT mode. HOT 1
- FieldSet.from_mom does not consider grid rotation HOT 2
- Rename FieldSet.from_mom to FieldSet.from_mom5 and create new FieldSet.from_mom6 HOT 2
- Add tutorial information about `indices` keyword when creating FieldSet
- Confusing compilation error message when variable in Kernel has same name as FieldSet constant HOT 1
- RK45 not working HOT 1
- Fieldset.from_zarr? HOT 1
- How to Output or Check Interpolation Results of u_uss and v_uss in Parcels Custom Kernel? HOT 2
- KDTree is not installed by default, notification or warning is missing when called upon
- nearest neighbor interpolation is still interpolating via iteration HOT 1
- Add a tutorial to help users choose an appropriate advection kernel
- Missing dependencies in pyproject.toml HOT 7
- Why time indices are ignored in FieldSet.from_netcdf? HOT 1
- Zarr 2.18 Breaks ParticleSet.execute(): ValueError: buffer source array is read-only HOT 6
- Feature: Indexing fields by latitude/longitude rather than grid indices HOT 1
- Changing Parcels -> parcels and importing all of parcels throughout HOT 2
- Updating for NumPy 2.0 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.