Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curly vector plot #314

Open
fcodron opened this issue Feb 27, 2021 · 10 comments
Open

Curly vector plot #314

fcodron opened this issue Feb 27, 2021 · 10 comments
Assignees
Labels
blocked Work got blocked waiting the output of some other source/work

Comments

@fcodron
Copy link

fcodron commented Feb 27, 2021

Hello,

Is there any plan to implement "curly vector" plots in some way for "standard" Python (matplotlib, cartopy...) ?
I guess through a modification of streamlines ?

This plot type is fairly unique to NCL (as far as I know), and very useful especially for oceanography plots, where strong currents tend to flow along the coastlines, and vectors ending over land are not very nice...

Thanks,

Francis

@michaelavs
Copy link
Contributor

Hi Francis,
I don't think there is an explicit plan in place for implementing the curly vector, but it could become part of later releases of GeoCAT software. I've been looking into if there is an already established Python version for curly vectors and it looks like currently the closest would be streamlines (which as you probably know, is slightly different than the curly vector from NCL). I'll bring this issue up with the rest of the team later this week and see what they think about it and get back to you then!

@fcodron
Copy link
Author

fcodron commented Mar 3, 2021 via email

@pilotchute pilotchute self-assigned this Sep 16, 2022
@pilotchute
Copy link
Contributor

@fcodron I've just been assigned to look into this.
From my understanding, you curly vectors are arrows in a grid, that are scaled by the magnitude and curved based on the curl derivative of the field.
So I think, it's the curl of the arrows that differentiates it from a standard quiver plot.
Though looking closely at the IDL output for curly vectors it actually seems more similar to broken up lines of a streamplot(), with the broken up arrows scaled by magnitude.

Could you in your own words (or with a sketch) show what you'd be looking for in a curly vector plot?

@fcodron
Copy link
Author

fcodron commented Sep 22, 2022

Hello,

Nice to hear you'll get into this !

Curly vectors are originally part of NCL visualization (don't know about IDL), where it's an option in vector plots. You can see an example image here : https://www.ncl.ucar.edu/Applications/Images/vector_4_lg.png

The script used to create the figure is https://www.ncl.ucar.edu/Applications/Scripts/vector_4.ncl (key argument is the @vcGlyphStyle = "CurlyVector" option).

The python "translation" here https://geocat-examples.readthedocs.io/en/latest/gallery/Vectors/NCL_vector_4.html#sphx-glr-gallery-vectors-ncl-vector-4-py
using standard vectors is much less nice...

I am not sure how exactly curly vectors were coded in NCL; they have a good documentation online but not the source code. At first glance it seems indeed similar to streamlines plot (streamplot), but with arrows at the end and a a length scaled by magnitude. I guess there would be defaults or options for density, scaling, and non-overlapping conditions.

Some attempts for implementation are described in the stackoverflow discussion above, but ideally these would work also with map projections (Cartopy...). I think these curly vectors are particularly useful when the flow is constrained by borders, like ocean currents following (but not crossing) the coast.

Francis

@pilotchute
Copy link
Contributor

Thanks for the prompt reply.
On a more conversational tone, given that python is a different software environment with a separate toolset, I'm wanting to find out what is valuable about the curly vector plot, and what sets it apart, so that I can focus on those parts of the implementation, without blindly duplicating the output of the NCL or IDL functions.

I'm attaching a sketch of a possible way to make a curly vector plot, please let me know what you think.
0A4B742D-9E4F-4F88-B536-4192FAEE0416

@pilotchute
Copy link
Contributor

the notes on the image are:

  1. some number to define resolution, if different from grid (useful in high grid densities where we may not want too many lines)
  2. use the grid data to create a field through interpolation (probably bi-cubic but any second order continuous interpolation should be fine)
  3. for each grid point, (or resolution point) use the gradient of the field to forward and back propagate a line, for some user defined or automated (based on maximum grid value) time, which will become a distance that varies with field strength once used with the field gradient.

This seems to be what the ncl plot is doing.

@fcodron
Copy link
Author

fcodron commented Sep 27, 2022

Hello,

Your explanation sounds good !

Apart from the "cute" factor, I find that curly vectors are quite useful to get a good representation of the flow when there are large speed (shear) or direction (curvature) variations, that will be poorly sampled by a vector field.

For example, there are often strong currents along coastlines; the curly / stream function representation will show the current following the coast, including around capes or bays, while vectors will have big arrows in different directions (depending on the grid and sampling), that will sometimes go into the continent...

Here is another example map in the Arctic (left).
Arctic
Central Arctic would be fine with vectors, the marginal seas (water entering from the Bering strait, Norvegian / Barents seas, Bafin bay...) less so.

And of course there are the beautiful NASA videos at
https://svs.gsfc.nasa.gov/cgi-bin/details.cgi?aid=3827
(check out the Mediterranean). Although I'm not sure how they propagate the lines with time...

Francis

@ivicajan
Copy link

ivicajan commented Jun 6, 2023

My vote for curly vectors!
This was one of the reasons I started a long time ago with NCL and then pyNGL.
Think that would make GEOCAT unique and in the top of the game. Using them still with the old version of the pyNGL and shouldn't be a problem (a naive comment) to capitalize from pyNGL if there is already part of the code (or it was using NCL engine).

Cheers
IVica

@erogluorhan
Copy link
Collaborator

+1 curly vectors have been a much desired plotting for a long while in Python; would make a great addition -GeoCAT-examples (and maybe -viz)

@kafitzgerald
Copy link
Collaborator

Yeah, it does seem like there's a good bit of interest in this type of plot and not a lot in terms of Python solutions.

Unfortunately, pyngl relies upon NGL for this and there's not an out-of-the-box solution over in matplotlib (see matplotlib/matplotlib#20038), but perhaps that's all the more reason to address it in geocat-viz? There is an open issue over there as well in NCAR/geocat-viz#4.

@kafitzgerald kafitzgerald changed the title Curly vector plot ? Curly vector plot Feb 5, 2024
@kafitzgerald kafitzgerald added the blocked Work got blocked waiting the output of some other source/work label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Work got blocked waiting the output of some other source/work
Projects
None yet
Development

No branches or pull requests

7 participants