Hello ROMS users
I am trying to show a vertical section of salinity (or any 3D or 4D variable) along a latitude using filled contours. Along x-axis I have values of Longitudes or distance along the section (vector) but along y-axis, I have a 2D array of depths of salinity since depths at each lat lon point are different for ROMS output (3D or 4D) variables. I am confused since filled contours require both x and y to be vectors (monotonically increasing or decreasing) or 2D arrays (obtained by meshgrid on x and y vectors). How do I get the filled contours? I use matplotlib. I am putting this question in the forum with the hope that there are many ROMS users who would have made this kind of plot using matplotlib. Thanks in advance.
vertical section of a roms output variable
-
- Posts: 27
- Joined: Mon Jan 27, 2014 9:50 pm
- Location: Indian Institute of Science
Re: vertical section of a roms output variable
I have a simple Jupyter notebook example using matplotlib here, does that help?
https://github.com/rsignell-usgs/notebo ... ture.ipynb
https://github.com/rsignell-usgs/notebo ... ture.ipynb
-
- Posts: 27
- Joined: Mon Jan 27, 2014 9:50 pm
- Location: Indian Institute of Science
Re: vertical section of a roms output variable
Thank you very much rsignell. Although I am looking for a way to do it using filled contours (without having to interpolate the variable on a fixed set of depth values), your notebook is very helpful. Thanks a lot.
Re: vertical section of a roms output variable
Uh, there is no interpolation going on there in the vertical section. If you want to plot color filled contours, just replace pcolormesh with contourf and contour, something like:
Code: Select all
fig=figure(figsize=(12,10))
plt.contourf(lon3d[:,jval,irange],z[:,jval,irange],temp[:,jval,irange])
plt.colorbar()
plt.contour(lon3d[:,jval,irange],z[:,jval,irange],temp[:,jval,irange])
-
- Posts: 27
- Joined: Mon Jan 27, 2014 9:50 pm
- Location: Indian Institute of Science
Re: vertical section of a roms output variable
Thank you very much rsignell. That is very helpful.