Re: problem with month_to_seasonN

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue, 25 Jul 2006 08:50:13 -0600 (MDT)

> I am trying to use month_to_seasonN. When I run it, I get the following
> errors:
>
> fatal:Assignment type mismatch, right hand side can't be coerced to type
> of left hand side
> fatal:Execute: Error occurred at or near line 4359 in file contributed.ncl
>
> fatal:Execute: Error occurred at or near line 4446 in file contributed.ncl
>
> fatal:Execute: Error occurred at or near line 12
>
> My script could not be more simple - it is pasted below. I suspect the
> error is occurring because time is a double (see netCDF header below).
> Is there any way to fix this, other than reading in the data to a new
> variable and defining a new time variable? Any help would be appreciated.
>
> thanks!
> sara
>
>
>
> 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
> ;************************************************
> ; read in data
> ;************************************************
>
> data = addfile("CRU.1960_1964.nc","r")
> out = addfile("CRU.1960_1964.seas.nc","c")
>
> xpre = month_to_seasonN (data->PRE, (/"DJF","MAM","JJA","SON"/))
> xtmp = month_to_seasonN (data->TMP, (/"DJF","MAM","JJA","SON"/))
>
> out->pre = xpre
> out->tmp = xtmp
> end
>
>
>
> My netCDF header looks like this
>
> netcdf CRU.1960_1964 {
> dimensions:
> lon = 190 ;
> lat = 206 ;
> time = UNLIMITED ; // (60 currently)
> variables:
> float lon(lon) ;
> lon:long_name = "Longitude" ;
> lon:units = "degrees_east" ;
> lon:actual_range = -19.10874f, 45.41437f ;
> float lat(lat) ;
> lat:long_name = "Latitude" ;
> lat:units = "degrees_north" ;
> lat:actual_range = 26.59317f, 72.71117f ;
> double time(time) ;
> time:long_name = "Time" ;
> time:units = "hours since 1900-1-1 00:00:0.0" ;
> time:actual_range = 526272., 534312. ;
> short PRE(time, lat, lon) ;
> PRE:long_name = "" ;
> PRE:units = "mm/day" ;
> PRE:missing_value = -32767s ;
> PRE:add_offset = 95.f ;
> PRE:scale_factor = 0.003204395f ;
> short TMP(time, lat, lon) ;
> TMP:long_name = "" ;
> TMP:units = "degC" ;
> TMP:missing_value = -32767s ;
> TMP:add_offset = 0.f ;
> TMP:scale_factor = 0.003051804f ;
>
> // global attributes:
> :domxmin = -19.10874f ;
> :domxmax = 45.41437f ;
> :domymin = 26.59317f ;
> :domymax = 72.71117f ;
> :domzmin = 1050.f ;
> :domzmax = 1050.f ;
> :history = "Tue Jul 25 15:13:21 2006: ncks -v TMP
> TMP.1960_1964.nc PRE.1960_1964.nc\n",
> "Tue Jul 25 15:12:41 2006: ncrcat -n 5,4,1 TMP1960.nc
> TMP.1960_1964.nc" ;
> data:
>
> time = 526272, 527016, 527712, 528456, 529176, 529920, 530640, 531384,
> 532128, 532848, 533592, 534312, 535056, 535800, 536472, 537216, 537936,
> 538680, 539400, 540144, 540888, 541608, 542352, 543072, 543816, 544560,
> 545232, 545976, 546696, 547440, 548160, 548904, 549648, 550368, 551112,
> 551832, 552576, 553320, 553992, 554736, 555456, 556200, 556920, 557664,
> 558408, 559128, 559872, 560592, 561336, 562080, 562776, 563520, 564240,
> 564984, 565704, 566448, 567192, 567912, 568656, 569376 ;
> }
>
>
Hi Sara

I speculate the problem is as follows:

The variables are packed data [data of type short].
        short PRE(time, lat, lon) ;
        short TMP(time, lat, lon) ;
They also have scale_factor and add_offset which are COARDS
conforming attributes for unpacking the data.

These data must be unpacked before calculations can be performed.
NCL's contributed .ncl has a funtion that does this: "short2flt"

   http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml

  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
************************************************
begin
;************************************************
; open the files
;************************************************

   data = addfile("CRU.1960_1964.nc","r")
   out = addfile("CRU.1960_1964.seas.nc","c")

   xpre = month_to_seasonN (short2flt(data->PRE), (/"DJF","MAM","JJA","SON"/))
   xtmp = month_to_seasonN (short2flt(data->TMP), (/"DJF","MAM","JJA","SON"/))
; ^^^^^^^^^
   out->pre = xpre
   out->tmp = xtmp
end
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jul 25 2006 - 08:50:13 MDT

This archive was generated by hypermail 2.2.0 : Tue Jul 25 2006 - 08:57:03 MDT