Releasing particles uniformly from one time step, error in executing pset #1840
-
QuestionHello! I am trying to release particles uniformly along a line with C-grid model output. The initial and final longitude and latitude positions (start, finish) were found along the model grid. This should be a simple experiment, just releasing 50,000 particles uniformly along a section and then backtracking them for one year. Setting up the fieldset, kernels, pset etc. all works fine, I am just getting an error when executing the pset: I'm unclear if this has to do with the output dt or what this means exactly. Thank you so much! Please let me know if anything is unclear as well... (attaching code below showing the experiment setup etc.): Supporting code/error messages# loading last 2 years
ufiles = sorted(glob(f"{inpath}/U/*.nc"))[-366*2:] #[:5]#[:360]
vfiles = sorted(glob(f"{inpath}/V/*.nc"))[-366*2:] #[:5]#[:360]
wfiles = sorted(glob(f"{inpath}/W/*.nc"))[-366*2:] #[:5]#[:360] #-366*3:
sfiles = sorted(glob(f"{inpath}/S/*.nc"))[-366*2:]#[:5]
tfiles = sorted(glob(f"{inpath}/T/*.nc"))[-366*2:]#[:5]
variables = {
"U": "vozocrtx",
"V": "vomecrty",
"W": "vovecrtz",
"S": "vosaline",
"T": "votemper",
}
filenames = {
"U": {
"lon": wfiles[0],
"lat": wfiles[0],
"depth": wfiles[0],
"data": ufiles,
}, # must use same everywhere w,files. but w depth is 0, northeast corner of T grid is lid
"V": {"lon": wfiles[0], "lat": wfiles[0], "depth": wfiles[0], "data": vfiles},
"W": {"lon": wfiles[0], "lat": wfiles[0], "depth": wfiles[0], "data": wfiles},
"S": {"lon": wfiles[0], "lat": wfiles[0], "depth": wfiles[0], "data": sfiles},
"T": {"lon": wfiles[0], "lat": wfiles[0], "depth": wfiles[0], "data": tfiles},
}
c_grid_dimensions = {
"lon": "nav_lon",
"lat": "nav_lat",
"depth": "depthw",
"time": "time_counter",
}
dimensions = {
"U": c_grid_dimensions,
"V": c_grid_dimensions,
"W": c_grid_dimensions,
"S": c_grid_dimensions,
"T": c_grid_dimensions,
}
with warnings.catch_warnings():
warnings.simplefilter("ignore", parcels.FileWarning)
fieldsetC = parcels.FieldSet.from_nemo(
filenames,
variables,
dimensions,
timestamps=timestamps,
allow_time_extrapolation=True,
)
#initializing
n_particles = 50_000
start = (-6.418901, 61.34403)
finish = (-2.245853, 60.331955)
depth = np.linspace(600,1100,n_particles)
class SampleParticle(JITParticle):
temp = Variable('temp', dtype=np.float32, initial=-100) #fieldsetC.T
salt = Variable('salt', dtype=np.float32, initial=-100)
age = Variable('age', dtype=np.float32, initial=0)
uvel = Variable("uvel", dtype=np.float32, initial=0)
vvel = Variable("vvel", dtype=np.float32, initial=0)
# setting up pset, where fieldsetC.u.grid.time[-1] is the time step at which i would like to release the particles
pset = parcels.ParticleSet.from_line(
fieldset=fieldsetC,
pclass=SampleParticle,
size=n_particles,
start=start,
finish=finish,
depth=depth,
time=fieldsetC.U.grid.time[-1],
repeatdt=timedelta(hours=12)
)
outputfile = ParticleFile('V_backwards_50k_subsample_linearly_released.zarr',pset,timedelta(hours=12), chunks=(n_particles,-1)) # timedelta was 6 before
pset.execute(kernels, runtime=timedelta(days=365), dt=-timedelta(minutes=10), output_file=outputfile)
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @pecos27 , I think the issue is the |
Beta Was this translation helpful? Give feedback.
Hi @pecos27 ,
I think the issue is the
-1
inchunks=(n_particles,-1)
. What was your intention with this part of the code? You'll need to determine a chunksize for the observations.