Re: plotting data on irregular grids

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon, 22 Jun 2009 08:09:10 -0600

Hi Mark

In a separate email, I will send the script which does what
you need. I think you will find it much cleaner and less
complex than your original script.

The issue with the gfdl_him is that, for some reason,
the variable had one NaN on the file. The
isnan_ieee and replace_ieeenan were used to change
the NaN to _FillValue.

Several points to note:

It is important to understand the netCDF variable model
upon which NCL variables are based.

Unlike fortran/C/Matlab/IDL/... , an NCL variable is
a structure (aka, 'data object'). Generally speaking,
it is an array, possibly, with textual information
(eg, 'units') and/or, possibly, with coordinate
variable information. The (possible) textual/coordinate
info is collectively called 'meta data'.

NCL is meta data aware. The data object can be
accessed/created via the @ and & syntax.

As noted in the pictogram
     f = addfile("", "r")
     x = f->Whatever

The variable "x" will automatically have all meta data
that conforms to the Unidata/netCDF variable model.
Hence, the variable "x" has the 'time', 'lat' and
'lon' coordinates associated with it upon import.
You do *not* have to name dimensions, etc.

The gsn_csm_* high level interfaces examine an input variable
for the presence of meta data. Textual info may be used
for plot titles. Coordinate variable info will be
used for graphics. Further, the gsn_csm_contour_map_ce
interface will automatically assign a cyclic point.

Curvilinear coordinates [eg, POP model] do not conform
to the Unidata/netCDF variable model. To handle this
non-conforming coordinate information, NCL created
the reserved attributes 'lat2d' and 'lon2d'. Upon entry
to the gsn_csm_contour_map_ce interface, NCL checks for
coordinate info, if not present, it looks for the
lat2d/lon2d attributes. The latter are automatically
assumed to have the units degrees_north and degrees_east.
Hence, no need to explicitly add this info.

An 'anomaly' is that for curvilinear the user must explicitly
tell the plot interface to add the cyclic points.

Good Luck
D wrote:
> Hi Dennis,
> thanks for pointing out the lat2d/lon2 attributes. This has almsot solved my problem. As the script was a work in progress I tried to minimise its size for the submission. Actually I am trying to reproduce all of the figures from Griffies (GFDL) Ocean Modelling paper of 2009 (with his permission of course).
> I have all of the original matlab and ferret scripts (and data) and have worked my way through most of them, it was just the lat/lon plots that I am left to write. The idea is to eventually provide them to the group for ocean model evaluation. It is very good to be able to include our own model groups result in amongst the group for a more direct comparison. Also Steve said that he wrote the ferret scripts pretty roughly and so I think they can be improved in NCL.
> If your team is prepared to help me with some of the remaining technical issues then as I say, I will provide them to the group once my boss and Steve G. gives permission which should be just a minor issue.
> The reason for the "panels" vector was so that I could switch on and off different model results as the script was being debugged.
> I have made a new version of the script called fig7.ncl (which corresponds to the paper figure, there are over 20 figures to reproduce in NCL in total) that I would really appreciate some final help with. I have put them all on the top level directory of my,macftp,macftp account.
> 1) I'm not sure why the continental outlines and missing value map (the black filled continents do not align in 3 of the panels.
> 2) the KNMI panel seems to squeeze the longitude dimension
> 3) the NCAR result looks erroneous. Actually it is quite late here and I haven't had time to look into this in detail yet.
> The other minor issues I can probably work through (tidying up the plots for final presentation) although I'm not sure why the missing values (continents) in some of the panels are white.
> Best regards,
> Mark.
> ________________________________________
> From: Dennis Shea []
> Sent: Saturday, 20 June 2009 2:04 PM
> To: Collier, Mark (CMAR, Aspendale)
> Cc:
> Subject: Re: plotting data on irregular grids
> Mark
> I will send you an 'improved' version of your script offline.
> [1]
> Why the (0,0,::-1,:) ?
> Graphics do not care about the latitude order.
> [2]
> Not all arrays containing coordinates are "coordinate variables".
> The Unidata/netCDF (hence, NCL) definition of coordinate
> variables is:
> One dimensional; monotonically {in/de}creasing;
> Further, the dimension name must be the same
> as the variable name. [Unidata/netCDf (hence, NCL) definition]
> eg: time(time), lat(lat), longitude(longitude)
> The lat/lon arrays on your file are 2-dimensional. They
> are arrays that contain coordinates but they are not
> "coordinate variables".
> NCL has reserved attributes named "lat2d" and "lon2d"
> EG:
> [3]
> Unfortunately, the CDO [Climate Data Operators] do not use
> COARDS/CF/udunits for latitude and longitude. NCL
> recognizes common udunits. I manually added the correct units.
> [4]
> The script has
> plots = new(8,graphic)
> [snip]
> plots(1)=gsn_csm_contour_map(wks,mpi(0,0,:,:),res)
> [snip]
> pnlres = True
> gsn_panel(wks,plots,(/4,2/),pnlres)
> Only "plots(1)" was filled. All other are "missing"
> When gsn_panel uses 'plot,(/4,2/)'
> will plot in the following order
> 0 1
> 2 3
> 4 5
> 6 7
> Since only 'plot(1)' was filled, the figure
> appeared in the upper right hand corner.
> Good luck
> D
> wrote:
>> Hi,
>> I'm trying to plot some data from an ocean model on a grid which is defined by a 2d latitude and longitude arrays.
>> If I remove the lonFlip command I get some filled contours, however, it doesn't
>> look right. As the files are too big for submission to the group I've put files
>> mpi.ncl, and grab.doc
>> on my anonymous ftp area,, macftp, macftp
>> Many thanks,
>> Mark.
>> CSIRO Marine and Atmospheric Research
>> Australia.
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Mon Jun 22 2009 - 08:09:10 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 22 2009 - 15:36:10 MDT