-
QuestionQuestionHi, I keep running into an error when I try to execute the ParticleSet, from the Parcels tutorial webpage. I use Windows 10 Pro on a 64-bit operating system. I am using Visual Studio Code to run Python 3.12.3. Can you help me figure out the problem? My code and the error messages can be found below. # Code
#import relevant packages
import math
from datetime import timedelta
from operator import attrgetter
import matplotlib.pyplot as plt
import numpy as np
import trajan as ta
import xarray as xr
from IPython.display import HTML
from matplotlib.animation import FuncAnimation
import parcels
#run particles by first defining a FieldSet or a collection of hydrodynamic fields
example_dataset_folder = parcels.download_example_dataset("MovingEddies_data")
fieldset = parcels.FieldSet.from_parcels(f"{example_dataset_folder}/moving_eddies") #zonal velocities
print(fieldset)
#load the first time frame of the field set
fieldset.computeTimeChunk()
plt.pcolormesh(fieldset.U.grid.lon, fieldset.U.grid.lat, fieldset.U.data[0,:,:])
plt.xlabel("Zonal distance [m]")
plt.ylabel("Meridional distance [m]")
plt.colorbar()
plt.show()
#define a ParticleSet, start with 2 particles at locations (330km, 100km) and (330km, 280km)
#particles will be advected on the fieldset we defined above
pset = parcels.ParticleSet.from_list(
fieldset=fieldset, #the fields on which the particles are advected
pclass=parcels.JITParticle, #the type of particles (JITParticle or ScipyParticle)
lon=[3.3e5, 3.3e5], #a vector of release longitudes
lat=[1e5, 2.8e5], #a vector of release latitudes
)
#print the ParticleSet to see where they the 2 particles start
#output shows (longitude, latitude, depth, time). time is "not_yet_set" because we did not specify a time when we defined pset
print(pset)
#plot positions of particles on the zonal velocity
plt.pcolormesh(fieldset.U.grid.lon, fieldset.U.grid.lat, fieldset.U.data[0,:,:])
plt.xlabel("Zonal distance [m]")
plt.ylabel("Meridional distance [m]")
plt.colorbar()
plt.plot(pset.lon, pset.lat, "ko")
plt.show()
#create ParticleFile object to store the output of the particles at every one-hour interval
output_file = pset.ParticleFile(
name="EddyParticles.zarr", #the file name
outputdt=timedelta(hours=1) #the time step of the outputs
)
print(output_file)
#final step is to run or execute the ParticleSet, i.e. move the particles forward in time
#because time was "not_yet_set", the particles will be advected from the first data available in the fieldset, which is the default behaviour
pset.execute(
parcels.AdvectionRK4, #the kernel (which defines how particles move)
runtime=timedelta(days=6), #the total length of the run
dt=timedelta(minutes=5), #the timestep of the kernel
output_file=output_file, #every time particles are executed, output file is updated, I believe
)
|
Beta Was this translation helpful? Give feedback.
Answered by
xiazhu111
Nov 11, 2024
Replies: 1 comment 4 replies
-
This seems the same issue as #1753 from three days ago. Does the solution at #1753 (comment) also work for you? @VeckoTheGecko, it seems newer versions of gcc don't support |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried it and it didn't work, but also I just realized I am not using miniconda. I am going to install that first and try everything again!