Re: ncl script problem

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue, 11 Jul 2006 16:25:36 -0600 (MDT)

>I am trying to plot fraction of each dust bin emission to total
>emission. Since in many regions the total emissions are zero. So I need
>to set Fill value for zero numbers in these region in case of divided
>by zero. But the error message: Subscript out of range. Is there any
>better ways for this?
>
>Thanks,
>
>Chao
>
> part of my script is like:
>
> diri = "/data3/chaoluo/camdst/cam3019aersombf/"
> fl_mdl_3 = addfile(diri+"cam3019aersombf_annual.nc","r")
> sfmbl = fl_mdl_3->DSTSFMBL(0,:,:)
> sfmblx01 = fl_mdl_3->DSTX01SF(0,:,:)
>
> sfmbl@_FillValue=1.e+36
> nlon=128
> nlat=64
>
> frc1 = new((/nlat,nlon/),float)
> do ilon=0,nlon-1
> do ilat=0,nlat-1
> if (sfmbl(ilon,ilat).ne.0.) then
> frc1(ilon,ilat)=sfmblx01(ilon,ilat)/(ilon,ilat)
> else
> frc1(ilon,ilat)=sfmbl@_FillValue
> end if
> end do
> end do
> print (frc1)
>_______________________________________________

  frc1 = sfmbl ; copy of sfmbl
  frc1 = frc1@_FillValue ; initialize all to _FillValue
  
  temp0 = ndtooned( frc1 ) ; a bit cumbersome but fast
  temp1 = ndtooned( sfmbl )
  temp2 = ndtooned( sfmblx01 )
  i = ind(temp1.ne.0.)
  temp0(i) = temp2(i)/temp1(i)
  
  frc1 = onedtond( temp0 )
  frc1_at_long_name = "ratio: sfmblx01/sfmbl"
  frc1_at_units = ""
  
  printVarSummary(frc1)
  printMinMax(frc1, True ) ; contributed.ncl
  
  nmsg = num( ismissing( frc1 ) )
  print("frc1: nmsg="+nmsg)
  
  delete(temp0)
  delete(temp1)
  delete(temp2)
  
good luck
D
  
=============================
P.S.

You do not have to do stuff like this:

> sfmbl@_FillValue=1.e+36
> nlon=128
> nlat=64
> frc1 = new((/nlat,nlon/),float)
  
  frc1 = new ( dimsizes(sfmbl), typeof(sfmbl), 1e20)
or
  frc1 = new ( dimsizes(sfmbl), typeof(sfmbl), getFillValue(sfmbl)
  
The above initializes all
frc1 to 1e20 or the _FillValue associated with 'sfmbl'

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

  

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jul 11 2006 - 16:25:36 MDT

This archive was generated by hypermail 2.2.0 : Tue Jul 11 2006 - 16:36:06 MDT