Re: Plotting curvi linear grids ?

From: Mary Haley (haley AT XXXXXX)
Date: Fri Oct 25 2002 - 07:53:56 MDT


>
>
> Hi Mary,
>
> after plotting several examples with (quasi) curvilinear co-ordinates,
> I would like give some comments.
>
> 1) Indeed it takes forever, especially if the fields are large.

Hi Adolf,

I'm looking into this, by running some timing tests on various
modifications of your script. I'll let you know if I discover a good
way to speed it up.

> 2) There seems to be a quality/accuracy problem, if I print the same data
> using coarse/medium/rangss resolution, not only the boundaries are
> different,
> but only my data appear very different (coarse with losses of
> data/better but still
> some white patches/best). Why the map resolution influences the quality
> of the contour plot ?

As far as I know, the map resolution that you select should not be
affecting the quality of the contour plot. Again, I'll run the
version of your script that I have, to see how the map resolution
affects it.

> Another question - what is the effort of implementing a "where" function
> like in F95/IDL, which is not restricted to 1D fields like the ind
> function (which
> don't like to much, as I quasi never have 1D fields...), so using ND
> fields and
> returning ND field of logical expressions ?

The "where" function has been requested a number of times for NCL, and
is on our list of enhancement requests that we keep. It is my
understanding that implementing the "where" function will involve
changes to the core NCL language, and is thus something we need to
undertake carefully.

There are ways you can use NCL to behave similarly to the "where"
function. We had an ncl-talk posting on this subject a couple of
years ago, and I'll include part of that post below:

Let's say you have an array "x" dimensioned ntim x nlat mlon, and that
you want to do the equivalent of:

   where (x .lt. -1.8) sst = -1.8

or

   where (x .gt. 35.) sst = 35.0
 
You can use NCL's selection operators "<" and ">" in this case
(http://ngwww.ucar.edu/ngdoc/ng4.1/ref/ncl/NclExpressions.html).
    
For example:

    sst = x < -1.8 ; all values less than -1.8 are replaced with -1.8

or

    sst = x > 35.

Let's say you want something like:
  
   where (x .eq. -999.) x = 1.e36
       
This type of formulation requires NCL's "mask" function
(http://ngwww.ucar.edu/ngdoc/ng/ref/ncl/functions/mask.html).

Let x@_FillValue = 1.e36. Then:
  
      x = mask (x, x.eq.-999, False)

----------------------------------------------------------------------

Meanwhile, we have tried to address the limitations of the "ind"
function by adding a new function called "ind_resolve". See:

    http://ngwww.ucar.edu/ngdoc/ng/ref/ncl/functions/indresolve.html

For more information.

Cheers,

--Mary

>
>
> Mary Haley wrote:
>
> >>Hello
> >>
> >>I've been one of those loking forward to the feature of plotting
> >>curvi-linear grids being implemented in ncl. So when I realised it was
> >>in 4.2.0.a026 I downloaded and installed and tried to plot the
> >>bathymetry of the North Sea (the curvi-linear grid was generated using
> >>the seagrid program).
> >>
> >>I could not make it work....
> >>
> >>Here is the output of running the attached script on the data file also
> >>provided:
> >>
> >>orca% ncl < topo.ncl
> >>.
> >>.
> >>.
> >>fatal:Attributes only have one dimension, 2 subscripts used
> >>fatal:Execute: Error occurred at or near line 2752 in file
> >>$NCARG_ROOT/lib/ncarg
> >>/nclscripts/csm/gsn_csm.ncl
> >>
> >>
> >
> >Dear Karsten,
> >
> >This error message looks like an old bug that we already
> >fixed. However, you appear to be running the latest version of NCL, so
> >you should have the bug fix that goes with this version. You can look
> >at the second line of the gsn_code.ncl and gsn_csm.ncl scripts and see
> >their version numbers. They should be 1.93 and 1.105 respectively.
> >
> >If you don't seem to have the latest versions, you can download them
> >from:
> >
> > http://ngwww.ucar.edu/ngdoc/ng/ug/ncl/gsun/scripts/gsn_csm.ncl
> > http://ngwww.ucar.edu/ngdoc/ng/ug/ncl/gsun/scripts/gsn_code.ncl
> >
> >Here are some things I changed in your script to make it run properly,
> >and to have the plot look a little cleaner:
> >
> > 1) Your data seems to contain missing values, but no _FillValue
> > attribute was set. I looked at your netCDF file, and saw that
> > a *global* _FillValue attribute had been set, so I did the
> > following:
> >
> > t@_FillValue = f@_FillValue
> >
> > 2) Since your data is not global, you don't want "gsnAddCyclic" to
> > be on, so I set this to False.
> >
> > 3) I zoomed in on the part of the map that contains the data, because
> > otherwise it's too hard to see the plot.
> >
> > 4) I set "gsnMaximize" to True so that the plot is maximized in the
> > window.
> >
> > 5) I set "lbLabelStride" to 2 so that the labelbar labels don't run
> > into each other.
> >
> > 6) I set "mpFillDrawOrder" to "PostDraw" so that you get the land
> > filled (in a light gray). Since "LightGray" is not part of the
> > "gui_default" colormap, I added it by using the
> > "gsn_merge_colormaps" procedure.
> >
> > If you do not desire filled land, then remove the setting of
> > "mpFillDrawOrder", and also set "mpFillOn" to False.
> >
> >There's one thing I don't like about the new script, however, and that
> >is that it takes a long time to run. I think it's a problem at our
> >end, so I'm going to pass it on to our developers.
> >
> >Below is your script with all the modifications I made. If you have
> >any questions, feel free to email me directly.
> >
> >Cheers,
> >
> >--Mary Haley
> > haley@ucar.edu
> >
> >
> >;************************************************
> >; commonly loaded
> >;************************************************
> >load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> >load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> >load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> >
> >begin
> >;************************************************
> >; open netCDF file: read in selected variables
> >;************************************************
> > diri = "./"
> > fili = "topo.nc"
> > f = addfile(diri+fili,"r")
> >
> > lat2d = f->latc
> > lon2d = f->lonc
> >
> > printVarSummary(lat2d)
> > printVarSummary(lon2d)
> >
> > t = f->h
> > t@_FillValue = f@_FillValue ; Set t's _FillValue to global _FillValue
> >
> > t@lon2d = lon2d
> > t@lat2d = lat2d
> >
> >;************************************************
> >; open graphic wkstation
> >;************************************************
> > wks = gsn_open_wks("x11","topo")
> >; wks = gsn_open_wks("ps","topo")
> > gsn_merge_colormaps (wks, "gui_default","LightGray")
> >
> >;************************************************
> >; plot options (NCL refers to these as resources)
> >;************************************************
> > res = True ; options desired
> > res@gsnAddCyclic = False
> > res@gsnMaximize = True ; maximize size of plot
> >
> > res@tiMainString = "North Sea Bathymetry (curvi)"
> >
> > res@mpFillDrawOrder = "PostDraw"
> > res@mpMinLatF = min(lat2d) ; zoom in on map
> > res@mpMaxLatF = max(lat2d)
> > res@mpMinLonF = min(lon2d)
> > res@mpMaxLonF = max(lon2d)
> >
> > res@cnFillOn = True
> > res@cnRasterModeOn = True
> > res@cnLinesOn = False
> > res@cnLineLabelsOn = False
> >
> > res@cnLevelSelectionMode = "ManualLevels"
> > res@cnMinLevelValF = 0.
> > res@cnMaxLevelValF = 400.
> > res@cnLevelSpacingF = 25.
> >
> > res@lbLabelStride = 2 ; Only label every other label box.
> >
> > plot = gsn_csm_contour_map_ce(wks,t,res) ; Draw a contour plot.
> >
> >end
> >
> >
> >_______________________________________________
> >ncl-talk mailing list
> >ncl-talk@ucar.edu
> >http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> >
> >
>
>
> --
> -----------------------------------------------------
> Adolf Stips
> Inland and Marine Waters unit
> CEC Joint Research Centre, TP 272
> I-21020 Ispra, Italy
> Tel: +39-0332-789876
> Fax: +39-0332-789034
> -----------------------------------------------------
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk@ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Wed Oct 30 2002 - 12:10:50 MST