unit attributes problem

From: Uma S. Bhatt <bhatt_at_nyahnyahspammersnyahnyah>
Date: Fri, 13 Oct 2006 11:48:55 -0800

Hi NCL folks,

   I have put together an NCL program to read in an array of
radiosonde data (18 levels, and 49 Januarys) and want to make a
contour pressure vs time plot. The data seems to be read in correctly
and I can make a plain contour plot (commented out part below with
the heading PLOT 1). But when I try to plot using pressure on one of
the axis I get the following error:
--------
0) gsn_csm_pres_hgt: Fatal: The coordinate array for the first
dimension of the input data must be in Pascals, Hecto-pascals, or
millibars
(0) and it must contain the attribute 'units' set to one of the
following strings (depending on your units):
(0) 'mb' 'Mb' 'MB' 'millibar' 'millibars' 'MILLIBARS'
'hybrid_sigma_pressure' 'Pa' 'pa' 'PA' 'Pascals' 'pascals' 'PASCALS'
'hpa' 'hPa' 'HPA' 'hecto-pascals' 'HECTO-PASCALS'
(0) Cannot create plot.
fatal:Illegal right-hand side type for assignment
fatal:Execute: Error occurred at or near line 89
--------
   The lev array has units of mb. I tried several of the different
spellings as well converting to Pa. But I get the same message. Help!

Thanks,
Regards,
Uma

My full screen dump and program are below:

--------------------------------------
[Uma-Bhatts-Computer-2:AK_climate/radiosonde.data/contour.plots]
bhatt% ncl < contour.ncl
  Copyright (C) 1995-2006 - All Rights Reserved
  University Corporation for Atmospheric Research
  NCAR Command Language Version 4.2.0.a033
  The use of this software is governed by a License Agreement.
  See http://www.ncl.ucar.edu/ for more details.

Variable: lev
Type: integer
Total Size: 72 bytes
             18 values
Number of Dimensions: 1
Dimensions and sizes: [18]
Coordinates:
Number Of Attributes: 2
   longname : pressure
   units : mb

Variable: T
Type: float
Total Size: 3528 bytes
             882 values
Number of Dimensions: 2
Dimensions and sizes: [lev | 18] x [time | 49]
Coordinates:
             lev: [1013..5]
             time: [1957..2005]
Number Of Attributes: 3
   long_name : FAI Temperature
   units : K
   _FillValue : -999

Variable: slice
Type: float
Total Size: 3528 bytes
             882 values
Number of Dimensions: 2
Dimensions and sizes: [lev | 18] x [time | 49]
Coordinates:
             lev: [1013..5]
             time: [1957..2005]
Number Of Attributes: 3
   _FillValue : -999
   units : K
   long_name : FAI Temperature

Variable: lev
Type: integer
Total Size: 72 bytes
             18 values
Number of Dimensions: 1
Dimensions and sizes: [18]
Coordinates:
Number Of Attributes: 2
   longname : pressure
   units : mb
(0) 1013
(1) 1000
(2) 850
(3) 700
(4) 500
(5) 400
(6) 300
(7) 200
(8) 250
(9) 150
(10) 100
(11) 70
(12) 50
(13) 30
(14) 20
(15) 10
(16) 7
(17) 5
(0) gsn_csm_pres_hgt: Fatal: The coordinate array for the first
dimension of the input data must be in Pascals, Hecto-pascals, or
millibars
(0) and it must contain the attribute 'units' set to one of the
following strings (depending on your units):
(0) 'mb' 'Mb' 'MB' 'millibar' 'millibars' 'MILLIBARS'
'hybrid_sigma_pressure' 'Pa' 'pa' 'PA' 'Pascals' 'pascals' 'PASCALS'
'hpa' 'hPa' 'HPA' 'hecto-pascals' 'HECTO-PASCALS'
(0) Cannot create plot.
fatal:Illegal right-hand side type for assignment
fatal:Execute: Error occurred at or near line 89
--------------------------------------------------------------------

My Program is a combination of the ascii read conwomap_2.ncl and a
pressure/height vs. Time plot h_time_3.ncl.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[Uma-Bhatts-Computer-2:AK_climate/radiosonde.data/contour.plots]
bhatt% cat contour.ncl
;================================================;
; conwomap_2.ncl
;================================================;
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
; ================================================;
begin
;=================================================;
; open file and read in ascii data
;=================================================;
;&& declare the new variable T and prep to read it in
   lev =(/1013,1000,850,700,500,400,300,200,250,150,100,\
              70,50,30,20,10,7,5 /)
   time = (/1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, \
            1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, \
            1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, \
            1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, \
            1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, \
            1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 /)
; 1) Radiosonde Temperatures
; declare the new variable
; row and column
        T = new((/18,49/),float)
        T!0="lev"
        T!1="time"

        T&lev = lev
        lev_at_units = "mb"
        lev_at_longname = "pressure"

        printVarSummary(lev)
        T&time = time
        time_at_units = "years"
        time_at_longname = "time"

        T_at_units = "K"
        T_at_long_name = "FAI Temperature"
        T@_FillValue = -999.
        printVarSummary(T)

;&& enter numbers and give meta data for data
; rows and then columns
   T=asciiread("Dect_p.txt",(/18,49/),"float")
;=================================================;
; PLOT 1
;=================================================;
; wks = gsn_open_wks("ps","conwomap") ; open a ncgm file
; gsn_define_colormap(wks,"gui_default") ; choose a colormap
;
; res = True ; plot mods desired
;
; res_at_cnFillOn = True ; turn on color
; res_at_gsnSpreadColors = True ; use full range of colormap
;
;; res_at_vpWidthF = 0.5 ; change aspect ratio of plot
;; res_at_vpHeightF = 0.3
;
; plot = gsn_csm_contour(wks,T,res) ; contour the variable
;
;=================================================;
; PLOT 2
;=================================================;
;================================================
; smooth data
;================================================
   wgt = (/ 1., 3., 4., 3., 1./) ; wgts for temporal smooth
   wgt = wgt/sum(wgt) ; normalize

   slice = T
   slice = wgt_runave(T, wgt, 0)
   printVarSummary(slice)
;================================================
; plot
;================================================
   wks = gsn_open_wks ("ps", "h_time") ; open ps file
   gsn_define_colormap(wks,"BlWhRe") ; choose colormap
   res = True ; plot mods desired

   res_at_cnFillOn = True ; turn on color
   res_at_cnLinesOn = False ; no contour lines
   res_at_gsnSpreadColors = True ; use full range of colors
   res_at_lbLabelAutoStride = True ; optimal labels

   res_at_cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
   res_at_cnMinLevelValF = -70. ; set min contour level
   res_at_cnMaxLevelValF = 10. ; set max contour level
   res_at_cnLevelSpacingF = 5. ; set contour spacing
   print(lev)
   plot = gsn_csm_pres_hgt (wks,slice,res)

   end

-- 
Uma S. Bhatt
Assoc. Professor
Geophysical Institute
IARC Room 307  
University of Alaska Fairbanks
903 Koyukuk Dr.                           
Fairbanks, Alaska  99775-7320
tel: (907) 474-2662  fax: (907) 474-2643
bhatt_at_gi.alaska.edu
www.gi.alaska.edu/~bhatt/

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 13 2006 - 13:48:55 MDT

This archive was generated by hypermail 2.2.0 : Fri Oct 13 2006 - 14:01:26 MDT