Re: Re: Plotting Irregular Grid data using lat2d lon2d

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu, 21 Aug 2008 22:12:15 -0600 (MDT)

On Fri, 22 Aug 2008 malmistry_at_indiatimes.com wrote:

> Mary,
> Many thanks (both for approving my request and also the solution). I have made the changes as advised and the variable 'hsl_1' now does use glat_1 and glon_1 on the X/Y axes. However, I still have a doubt on this method used and whether it is actually doing the right thing.
>
> 'glat' and 'glong' are a function of (lat,long) in the netcdf file created by me...my doubts are:
>
> (a) What do '@lat2d' and '@lon2d' exactly do in the ncl script?

Basically, if a gsn_csm_xxxx script sees these two special attributes
set, then the corresponding sf*Array resources will be set to these
arrays (same for "vf" arrays in vector plots). This is
the same as setting these two resources yourself, as I showed you
in a previous message.

However, you are calling the gsn_contour routine, and not the
gsn_csm_contour routine, so the @lat2d and @lon2d settings
will have no effect. If you are not using gsn_csm_contour,
then you need to set these two resources as I mentioned before:

    res_at_sfXArray = glon
    res_at_sfYArray = glat

Otherwise, if you use gsn_csm_contour, the @lat2d and @lon2d
attribute settings should work.

For some examples of plotting data on native grids, see:

   http://www.ncl.ucar.edu/Applications/native.shtml

For examples of using lat2d and lon2d, see:

    http://www.ncl.ucar.edu/Applications/popscal.shtml

> (b) How do I ascertain that my file is indeed an 'irregular grid' problem and not a 'native grid' problem?

> To give you a bit of history...My original task was to create a simple netcdf file from a model output ('.dat') file. The model uses a rotated lat/long (Arakawa B) grid. glat and glon are created by me (in netcdf file) by converting the rotated lat/long to the model cartesian lat/long.

There's not an automatic way for NCL to detect this. However, your
statement that your model data was on a rotated lat/lon grid implies
to me that your data is on a native grid. This simply means that when
you overlay your data on the rotated map projection, *as long as you
know the exact map projection limits that your data is measured on*,
your data values do not need to be put through a computation in order
to put them on the correct location on the map. In addition to
getting the map projection exactly right, you need to set the
resource res_at_tfDoNDCOverlay = True for this to work.

If your data was not measured on a particular map projection, and you
have either 1D or 2D values representing the locations of your data on
the lat/lon axes, then this is considered to be non-native data. You
then need to set the special lat2d/lon2d attributes (if you have 2D
lat/lon arrays), or make sure that your data contains 1D coordinate
arrays, if you don't have the 2D lat/lon arrays.

--Mary

> So I wonder whether having a rotated lat/long grid in the original model output file does make my netcdf file a native grid file (I read about the different projections on NCL website and don't think 'Rotated lat/long' falls under these projections).
>
> I hope I have been clear in explaining my doubts..
>
> Thank you once again.
> Malcolm
> Barcelona Supercomputing Center (BSC)
>
>
> ----- Original Message -----
> From: Mary Haley <haley_at_ucar.edu>
> To: malmistry_at_indiatimes.com
> Cc: ncl-talk-owner_at_ucar.edu
> Sent: Thu, 21 Aug 2008 03:05:35 +0530 (IST)
> Subject: Re: Plotting Irregular Grid data using lat2d lon2d
>
>> Hello!
>> I hope you can help..I am basically trying to plot an output variable "hsl". The model grid is Arakawa B-Grid (of NCEP UMO Model). I have created a netcdf file in fortran, the ncdump -h is below:
>>
>> {
>> dimensions:
>> west_east = 771 ;
>> south_north = 543 ;
>> bottom_top = 30 ;
>> nwets = 4 ;
>> variables:
>> float glat(south_north, west_east) ;
>> float glon(south_north, west_east) ;
>> float hsl(bottom_top, south_north, west_east) ;
>> hsl:units = "units" ;
>> hsl:title = "Hsl-UMO" ;
>> hsl:long_name = "Hsl-UMO" ;
>> }
>>
>> glat and glat are the model grid (X,Y) axis against which hsl needs to be plotted (projected). glat and glon are from (-90 to +90) and (-180 to 180)...respectively
>>
>> I believe this is NOT A NATIVE GRID issue...but an irregular grid issue. I have read all the info on Native/Irregular grid on the website...yet unable to do this.
>>
>> Below is my .ncl script. I have followed the exact method from page 19 (graphics manual from website)...
>
> I think what you need to do is add the following:
>
> res = True ; To set up a resource list
> res_at_sfXArray = glon
> res_at_sfYArray = glat
> plot = gsn_contour(xwks,hsl_1,res) ; Draw a contour plot.
>
>
> There's no way for NCL to know that it is supposed to use "glat" and
> "glon" on the X and Y axes, so the above two lines should do it. Note
> also that the third argument to gsn_contour has changed to "res".
>
> I've approved your ncl-talk request. You should be able to post
> following questions to ncl-talk_at_ucar.edu.
>
> --Mary
>
>> The script DOES NOT plot "hsl" against glat and glon...instead it continues to plot "hsl" against 'west-east' (0-771 scale) and 'south_north' (0-543 scale).
>>
>> --------------------------------------
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>
>> begin
>>
>> cdf_file = addfile("/home/malcolm/BSC/UMO/pout_g_test000.nc","r")
>>
>> glat_1 = cdf_file->glat
>> glon_1 = cdf_file->glon
>>
>> hsl_1 = cdf_file->hsl(0,:,:) ; hsl is read from input file and assigned to hsl_1
>>
>> hsl_1_at_lon2d = glon_1
>> hsl_1_at_lat2d = glat_1
>>
>> xwks = gsn_open_wks("x11","pout_g_test000") ; Open an X11 workstation.
>>
>> plot = gsn_contour(xwks,hsl_1,False) ; Draw a contour plot.
>>
>> delete(plot) ; Clean up.
>> delete(hsl_1)
>>
>> end
>> --------------------------------------
>>
>> Many Thanks
>> Malcolm
>> Barcelona Super Computing center
>>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 21 2008 - 22:12:15 MDT

This archive was generated by hypermail 2.2.0 : Mon Aug 25 2008 - 15:23:45 MDT