[ncl-talk] error in rcm2points

Dennis Shea shea at ucar.edu
Sat Aug 17 11:04:30 MDT 2019


Your "Subject" implies that there is an error with the function itself.
This is NOT true. The error is with the user.
====
It is important that users read the function documentation... carefully!
====
        function *rcm2points* (
                *lat2d [*][*] *: numeric,      <== prototype *[*][*] *means
two-dimensions
                l*on2d [*][*] :* numeric,
                fi           : numeric,           <=== 'fi' *must be
gridded data*
                lat      [*] : numeric,
                lon      [*] : numeric,
                opt          : integer
        )
         return_val  :  numeric

Arguments:
*lat2d*: A *two-dimensional array *that specifies the latitude locations of
fi. The latitudes should proceed from south-to-north.
lon2d

*lon2d: *A *two-dimensional array *that specifies the longitude locations
of fi. The longitudes should proceed from west-to-east.
====
Your usage:    tmaxcdz = *rcm2points*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/rcm2points.shtml>
(lat2d, lon2d, tmax, latcdz, loncdz, 0)

Just naming a one-dimensional variable 'lat2d/lon2d' does not make the
variable two dimensional.

  lat2d  = values(1::ncols)                 ; ONE dimension
  lon2d  = values(2::ncols)
*printVarSummary*(lat2d)
rank =* dimsizes*(*dimsizes*(lat2d))
print("lat2d: rank="+rank)                 ; rank=1

============
NCL has several functions for 'reshaping' a variable: eg: *onedtooned*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/onedtond.shtml>,
*conform_dims*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/conform_dims.shtml>

 nlat = ???
 mlon = ???
 lat2d  := *onedtooned*(lat2d,(/nlat,mlon/))   ; syntax  *:=* means
reassign [replace]
 lon2d := *onedtooned*(lon2d,(/nlat,mlon/))
 printVarSummary(lat2d)
====
In your case it might be best to use:

  values =
asciiread("/Users/Jag/Desktop/cdz-regrid/20060101-sindia.txt",-1,"float")
  nvals = dimsizes(values)
  ncols = 9
  nrows = ncols/nvals

  nlat   = ...
  mlon = ...
  npts  = nlat*mlon
  if (nvals.ne.npts) then
      print("FATAL: size mismatch: nvals="+nvals+":  npts="+npts)
      exit
  end if

  lat2d  = *onedtond*( values(1::ncols) , (/nlat,mlon/)  )
  lon2d  = *onedtond*( values(2::ncols) , (/nlat,mlon/) )
  srad    = *onedtond*( values(3::ncols) , (/nlat,mlon/) )
  tmax   = *onedtond*( values(4::ncols) , (/nlat,mlon/))
  ....
   ....
   printVarSummary(tmax)
   printMinMax(tmax,0)
   print("============")

The function documentation  *rcm2points*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/rcm2points.shtml>
states that the array data be ordered South-to-North.
If not, the user must reorder. Again, NCL syntax [* ::-1* ] facilitates
this operation.

    lat2d = lat2d(*::-1*,:)   reordder the 'y' axis
    srad  = srad(*::-1*,:)
    tmax = tmax(*::-1*,:)

Good Luck


On Fri, Aug 16, 2019 at 10:23 PM jagan TNAU via ncl-talk <ncl-talk at ucar.edu>
wrote:

> I have an ascii output in irregular grid and trying to some station points
> using the script below
> ;*************************************************
> ; location.ncl
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> ;************************************************
> begin
> ;************************************************
> ; read ascii input file
> ;************************************************
>   values =
> asciiread("/Users/Jag/Desktop/cdz-regrid/20060101-sindia.txt",-1,"float")
>   nvals = dimsizes(values)
>   ncols = 9
>   nrows = ncols/nvals
>   lat2d  = values(1::ncols)
>   lon2d  = values(2::ncols)
>   srad = values(3::ncols)
>   tmax = values(4::ncols)
>   tmin = values(5::ncols)
>   rain = values(6::ncols)
>   wind = values(7::ncols)
>   rhum = values(8::ncols)
> ;***********************************************
>   latcdz = (/ 10.20, 10.48, 10.67 /)
>   loncdz = (/ 79.00, 78.20, 78.75 /)
>   tmaxcdz = rcm2points (lat2d, lon2d, tmax, latcdz, loncdz, 0)
> print(tmaxcdz)
> end
>
> But when I run the code it shows the following error.
>
> fatal:Number of dimensions in parameter (0) of (rcm2points) is (1), (2)
> dimensions were expected
>
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 26 in
> file check.ncl
>
>
> The file is for single time.
>
>
> Will you please help me to solve the problem
> --
> With regards
>
> Dr.R.Jagannathan
> Professor & Former Dean
> Tamil Nadu Agricultural University
> Coimbatore - 641 003 India
>
> PHONE:  Mob: +91 94438 89891
>
> DO NOT PRINT THIS E-MAIL UNLESS NECESSARY. THE ENVIRONMENT CONCERNS US ALL.
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190817/819b77ba/attachment.html>


More information about the ncl-talk mailing list