Re: contouring on irregular spaced grids

From: Mary Haley (haley AT XXXXXX)
Date: Tue Nov 07 2000 - 10:43:42 MST

  • Next message: Erik Kluzek: "Gaussian weights for Lin-Rood grid"

    >
    > Hi ncl-talk group:
    >
    > Does ncl have an equivalent to the conpack LLU cpsps2, i.e.,
    > contouring on an irregularly spaced grid? I have some 3d data
    > in which one dimension (latitude) is irregularly spaced, and
    > would like to interpolate to a regular grid before contouring.
    >
    > --Ben

    Hi Ben,

    Since you have 1-dimensional coordinate arrays that represent the
    grid that your data is on, you don't need to put this on a regular
    grid like you did with NCAR Graphics and the cpsps2 routine.

    With this in mind, I'll provide a short example below that shows how
    you can create a contour plot of your data, assuming that the "lat"
    coordinate array is irregular. Note that use of the gsn_csm_contour
    function below assumes that your data variable has coordinate arrays
    called "lat" and "lon". This is very important in order for the
    gsm_csm_contour function to work properly. For more information on
    gsn_csm_contour and other similar plotting routines, go to the CSM
    Graphics Tutorial:

       http://www.cgd.ucar.edu/csm/support/CSM_Graphics/index.shtml

    The example below assumes you have a netCDF file called "uvt.nc" with
    a 4-dimensional variable "T" that has coordinate arrays "time", "lev",
    "lat", and "lon". You can get a contour plot of the first level and
    time step of T with the following NCL code:

    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

    begin
      a = addfile("uvt.nc","r") ; Open netCDF file.

      T = a->T(0,0,:,:) ; Read in first time & level of temperature.

      wks = gsn_open_wks("x11","test") ; Open X11 workstation.

      res = True
      res@tiMainString = "Temperature"

      contour = gsn_csm_contour(wks,T,res) ; Create and draw the plot.
    end

    If you want your latitude data to be "linearized", then add the line:

      res@gsnYAxisIrregular2Linear = True

    before the call to gsn_csm_contour.

    For a more complicated example that has a non-linear Y axis, see the
    "ocean_4.ncl" script at:

       http://www.cgd.ucar.edu/csm/support/CSM_Graphics/ocean.shtml

    --Mary



    This archive was generated by hypermail 2b29 : Tue Nov 07 2000 - 10:44:27 MST