Re: Problem calculating % of values in timeseries below a cutoff point - how to define a variable that you later calculate?

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue May 29 2012 - 15:42:52 MDT

I mis-typed several things
   copy_varCoords(precip_knt(;,:,0),precip_pcrt) ; contributed.ncl

should be
copy_VarCoords(precip_mod1(:,:,0),precip_pcrt) ; contributed.ncl

On 5/29/12 3:34 PM, Madeleine Patterson wrote:
> Hi -thanks for this; the script executes until the copy_varCoords part,
> I get an error message that the number of subscripts do not match number
> of dimensions of variable; 3 subscripts used, 2 subscripts expected...
>
> ? Can I plot a global map of these percentages without var coords?
>
> Thanks,
> M
>
> On Wed, May 30, 2012 at 6:50 AM, Dennis Shea <shea@ucar.edu
> <mailto:shea@ucar.edu>> wrote:
>
> [1] When reading an entire variable, it is more efficient
> to not reference each dimension
>
> precip_mod1 = in1->rainfall ; more efficient
>
> precip_mod1 = in1->rainfall(:,:,:) ; less efficient
>
> If you want to indicate a variable's rank, then use a comment
>
> precip_mod1 = in1->rainfall ; (:,:,:) or 3D or (lat,lon,time)
>
> ===
> [2]
>
> pcrt = 2.0
> precip_knt = dim_num_n(precip_mod1.lt.pcrt, 2) ; (:,:)
> precip_tot = dim_num_n(.not.ismissing(__precip_mod1), 2) ; (:,:)
> precip_pcrt= (100.*precip_knt))/precip_tot ; %(:,:)
>
> copy_varCoords(precip_knt(;,:,__0),precip_pcrt) ; contributed.ncl
> precip_pcrt@long_name = "..."
> precip_pcrt@units = "%"
> printVarSummary*precip_pcrt)
>
>
> On 5/29/12 1:25 PM, Madeleine Patterson wrote:
>
> Hi,
>
> I am trying to calculate % of values in a timeseries below a cutoff
> point, but keep getting error messages related to not having
> defined the
> variables that I am calculating (not reading in) properly. Just
> calculating the variable in the do loop doesn't seem to define
> them, and
> when I try to define them before I calculate them, I've tried a
> couple
> ways but haven't got it right so far. Can anyone help me out
> with this
> problem? My script is below...
>
> The error message is: undefined identifer: pct_drought_mod1 is
> undefined, can't continue.
>
> ******************************__*************************
> begin
>
> 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"
>
> load "$NCARG_ROOT/lib/ncarg/__nclscripts/csm/shea_util.ncl"
>
> ; use "$NCARG_ROOT/lib/ncarg/data/__cdf/landsea.nc
> <http://landsea.nc> <http://landsea.nc>"
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;__;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;__;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;__;
>
> setfileoption("nc","__SuppressClose",False)
>
>
> ; open 1st pft map;
>
> in1 = addfile("rainfall.nc <http://rainfall.nc>
> <http://rainfall.nc>","r")
>
>
> lat =in1->lat
> lon=in1->lon
>
> precip_mod1 = in1->rainfall(:,:,:) ;;; this is lat, lon time
> (91,144, 360)
>
> ; calculate the percentage of months in the timeseries where
> rainfall <
> 2 mm/d
>
>
> ;pct_drought_mod1(i,j)=0 ---> this sort of thing
> doesn't
> seem to work
> ;num_drought_mnth_mod1(i,j)=0
>
> ;num_drought_mnth_mod1 =0
> ;pct_drought_mod1 = 0
>
> count = 0
> do i=1,144
> do j=1,91
> do k=1,348
> if (k .lt. 2.0) then
> count = count +1
> end if
> end do
> print(count)
>
> num_drought_mnth_mod1(i,j) = count
> pct_drought_mod1(i,j) = count/348
> end do
> end do
>
>
> end
>
>
> _________________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/__mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue May 29 15:43:05 2012

This archive was generated by hypermail 2.1.8 : Wed May 30 2012 - 09:25:29 MDT