OceanParcels / Parcels

Main code for Parcels (Probably A Really Computationally Efficient Lagrangian Simulator)
https://www.oceanparcels.org
MIT License
295 stars 136 forks source link

How to change Particle Size and Color? #778

Closed isabelyuyingwu closed 4 years ago

isabelyuyingwu commented 4 years ago

Hi Erik,

You really did a great work!!! I like your ocean parcels package very much! In recent days, I used your package to track particles in the ocean and it did very well. However, I met problems about changing the particle's size, density, color.

(1) First, when I ran your tutorial plotting.py, it successfully launched a set of particles, but the default particle's size was a little bigger if I plotted all of them in my research area. Therefore, I will appreciate it if you remember where to set the particle's size in your python file.

(2) Second, I plan to launch two sets of particles in the research area, so I want to use two different colors to tag them. I am sorry that I am new to programming (T_T). After reading some of your files carefully, I think the most relevant files are particleset.py & plottrajectory.py, but I feel lost in hundreds of codes...

Screen Shot 2020-03-30 at 9 38 38 AM

I've found two codes to set the particle size & color in plottrajectory.py, but it doesn't work for 'pset..(var....) ' in plotting the particles in gif.

Screen Shot 2020-03-30 at 9 37 47 AM

If you know how to change the size & color in your python file, feel free to let me know!!! Thank you so much (^_^). I've noticed that you solved some similar issues, like # 252, #675, but I still don't find the specific codes to achieve that.

Hope you stay well! Thank you again!!

Best, Isabel

erikvansebille commented 4 years ago

Thank you for this kind message, @isabelyuyingwu. Indeed, the plotting routines in Parcels are very rudimentary, and really should not be used for anything more than a quick check of the data. We made the decision for now to focus on the particle computation, not plotting; with the limited resources we have, we can't do it both ;-)

My recommendation is just to write your own plotting routines from scratch, specific for your own experiment and tailored to whatever you need. As a hint, you can write your plotting scripts based on what we do in https://github.com/OceanParcels/parcels/blob/master/parcels/plotting.py. Note of course that you don't even need to use python to plot the particles; since the output files are netcdf you should also be able to plot these in any other data analysis programme that you use

isabelyuyingwu commented 4 years ago

WOW. That makes sense! Thanks for your quick response.

Yeah, I forget that we've already saved the NetCDF file as below, so we can use it directly for plotting . Thanks for your recommendation. I will read your plotting.py carefully and try later in Matlab or python matplotlib.

Screen Shot 2020-03-30 at 11 55 02 AM

In addition, I have a little question. When we input pset (parameter.........), it will automatically plot the default size (s=20) of particles in black color. Is it because you set the particles' size in particleset.py, or plotting.py?

Screen Shot 2020-03-30 at 12 12 14 PM

I am sorry for my entry-level programming skills.

Thank you so much!

erikvansebille commented 4 years ago

The size parameter in ParticleSet.from_line() is the size of the particleset, so in the example above there are 5 particles. It is not the size for the plotting. See also the documentation at http://oceanparcels.org/gh-pages/html/#parcels.particleset.ParticleSet.from_line

isabelyuyingwu commented 4 years ago

Thank you so much!!! Thanks for your quick response!

I will keep following your research!!! Great! Cheer up!