vertical section of a roms output variable

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
shrikantmp
Posts: 26
Joined: Mon Jan 27, 2014 9:50 pm
Location: Indian Institute of Science

vertical section of a roms output variable

#1 Post by shrikantmp » Wed Sep 07, 2016 6:19 pm

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.

rsignell
Posts: 123
Joined: Fri Apr 25, 2003 9:22 pm
Location: USGS

Re: vertical section of a roms output variable

#2 Post by rsignell » Thu Sep 08, 2016 1:09 pm

I have a simple Jupyter notebook example using matplotlib here, does that help?
https://github.com/rsignell-usgs/notebo ... ture.ipynb

shrikantmp
Posts: 26
Joined: Mon Jan 27, 2014 9:50 pm
Location: Indian Institute of Science

Re: vertical section of a roms output variable

#3 Post by shrikantmp » Fri Sep 09, 2016 10:41 am

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.

rsignell
Posts: 123
Joined: Fri Apr 25, 2003 9:22 pm
Location: USGS

Re: vertical section of a roms output variable

#4 Post by rsignell » Fri Sep 09, 2016 1:49 pm

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])

shrikantmp
Posts: 26
Joined: Mon Jan 27, 2014 9:50 pm
Location: Indian Institute of Science

Re: vertical section of a roms output variable

#5 Post by shrikantmp » Sat Sep 10, 2016 11:20 am

Thank you very much rsignell. That is very helpful.

Post Reply