[Thread Prev][Thread Next][Index]

Re: [ferret_users] Problem to plot grid



Dear Russ and Ansley, thanks a lot for your answers.

I  think I wasn't as thorough as I should have when explaining my issue. Attached is a netcdf with the the lon and lat variables.
This is the code I used to create the first figure in the previous email:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

let lon_hyc2 = (lon_hyc+lon_hyc[i=@shf:1])/2
let lat_hyc2 = (lat_hyc+lat_hyc[j=@shf:1])/2

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

set win/asp=1 1
shade/title="Hycom Grid"/nokey/x=-75.8:-73.8/y=38.0:40.0 surf_hyc
go land_detail

rep/i=1:126 (plot/ov/vs/line/dash/col=1/nolab lon_hyc2,lat_hyc2)
rep/j=1:87  (plot/ov/vs/line/dash/col=1/nolab lon_hyc2,lat_hyc2)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

The /dash in here is just because this is not my main grid. What I'm trying to accomplish here is to just show the differences between these two grids (one from the HYCOM available at hycom.org, and the other one is my grid) at my boundaries and in my area of interest.

So, the HYCOM grid works fine. However when I try to do the same to my grid (using the code below), I get the second figure

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

let lon_rho2 = (lon_rho+lon_rho[i=@shf:-1])/2
let lat_rho2 = (lat_rho+lat_rho[j=@shf:1])/2

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

set win/asp=1 2
shade/lev=(-38.5,-37.4,0.02)/hlim=-75.2:-74.4/vlim=36.4:37.1/nolab lon_rho+lat_rho,lon_rho,lat_rho

rep/i=2:150 (plot/ov/vs/line/col=7/nolab lon_rho2,lat_rho2)
rep/j=1:299 (plot/ov/vs/line/col=7/nolab lon_rho2,lat_rho2)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Inline images 2

This second figure is actually a little different from the original; I figured a mistake a had done in my code. However, the offset is still there. I've plotted using /dash just to make it easier to notice the offset.
Also, it seems that I'm not showing the first row and last column. And they seem to have just half of the size of the other cells.

Russ, I think the link you suggested me kind of cover this last issue, but I didn't understand how to use that. Should I write:

shade/lev=(-38.5,-37.4,0.02)/hlim=-75.2:-74.4/vlim=36.4:37.1/nolab lon_rho+lat_rho,lon_rho[i=1:151,j=0:300],lat_rho[i=1:151,j=0:300]

I doesn't seem to make any difference.

Any suggestions?

Thanks a lot!
Andre



On 9 September 2015 at 22:44, Russ Fiedler <russell.fiedler@xxxxxxxx> wrote:

Hi Ansley,

If you look at your plot you see lines at approximately half the cell heights. This is an artifact due to joining the wrapped endpoints (380E ->20E). Missing values need to be introduced at the ends. The vertical lines can be plotted by plotting the transposes of lon2 and lat2

yes? use coads_climatology

! Cell centres
yes? let/title="longitude"/units=degrees_east lon = x[gx=sst] + 0*y[gy=sst]
yes? let/title="latitude"/units=degrees_north  lat = 0*x[gx=sst] + y[gy=sst]
yes? shade/l=1/hlim=180:240/vlim=0:40 sst, lon, lat

! Define cell NE points
yes? let  lon2 = (lon+lon[i=@shf:1])/2
yes? let lat2 = if i ne 1 then (lat+lat[j=@shf:1])/2 ! Stop wrap.

yes? plot/dash/vs/ov/col=black/nolab lon2,lat2
yes? plot/dash/vs/ov/col=black/nolab transpose_xy(lon2),transpose_xy(lat2)


Andre, I think you want to be using the boundary specified version of the 3 argument shade plot if possible.

http://ferret.pmel.noaa.gov/static/FAQ/graphics/curvilinear_edges.html

i.e. specify the cell boundaries for your shade plot command. You can then overlay those coordinates. That should fix the offset problem that you seem to be having.

Russ


On 10/09/15 10:29, Ansley Manke wrote:
Hi,
If what you want is dashed lines, you could try fiddling with adding arguments to the /DASH qualifier, making shorter "down" segments:
http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/commands-reference/PLOT#_VPINDEXENTRY_1475 

Another alternative for showing the grids is to just make symbols, either at the grid cells or the corners,  so
yes? shade h,lon_hyc2,lat_hyc2
yes? plot/nolab/vs/ov/sym=dot lon_hyc2,lat_hyc2
or with a small symbol of some other shape.

That first plot you showed is pretty nice looking. Interestingly I can't seem to replicate what you did for a rectangular grid where I define 2-dimensional longitudes and latitudes for a simple 1-D grid, trying to simulate the 2-D coordinates:
yes? use coads_climatology

yes? let/title="longitude"/units=degrees_east lon = x[gx=sst] + 0*y[gy=sst]
yes? let/title="latitude"/units=degrees_north  lat = 0*x[gx=sst] + y[gy=sst]

yes? shade/l=1/hlim=180:240/vlim=0:40 sst, lon, lat
yes? let  lon2 = (lon+lon[i=@shf:1])/2
yes? let lat2 = (lat+lat[j=@shf:1])/2
yes? plot/dash/vs/ov lon2,lat2
I only see the horizontal dashed lines. Did you show your whole script?


On 9/9/2015 2:54 PM, Andre Paim wrote:
Dear all,

I've been trying to plot the grid from my model on top of a shade plot and I just cant seem to make it right. I have two grids, one regular and another irregular and curved along the coast. 

Here is how I'm plotting that for the regular grid.

   let lon_hyc2 = (lon_hyc+lon_hyc[i=@shf:1])/2
   let lat_hyc2 = (lat_hyc+lat_hyc[j=@shf:1])/2

   shade h,lon_hyc2,lat_hyc2
   plot/dash/vs/ov lon_hyc2,lat_hyc2

I don't know if that is a coincidence, but the plot works fine for the area I'm plotting as can be seem bellow. 
Inline
              images 3


However, when I try to do the same to the irregular grid, this is what I get.

Inline
              images 4


Both models are not projected, with lon and lat in their respective variables.
Is there an easier way to do that?

Thanks in advance,
Andre Rodrigues



Attachment: grids_example.nc
Description: Cdf file


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement