Re: Ratio between two fields with some null values

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 13 2010 - 09:35:05 MDT

The "where" statemen is quite useful but not for the case.

ncl > a = (/10, 0, 6, 0, 0, 3/)*1.0
ncl > b = (/ 2, 3, 1, 0, 6, 0/)*1.0
ncl > c = a/b
fatal:divide: Division by 0, Can't continue
fatal:Div: operator failed, can't continue
fatal:Execute: Error occurred at or near line 3

ncl > q = where(b.ne.0.0, a/b, 1e20)
fatal:divide: Division by 0, Can't continue
fatal:Div: operator failed, can't continue
fatal:Execute: Error occurred at or near line 13

ncl > b@_FillValue = 0.0
ncl > c = a/b

ncl 6> print(c)

Variable: c
Type: float
Total Size: 24 bytes
             6 values
Number of Dimensions: 1
Dimensions and sizes: [6]
Coordinates:
Number Of Attributes: 1
   _FillValue : 0
(0) 5
(1) 0
(2) 6
(3) 0
(4) 0
(5) 0

===
I am not sure this is what you want.

For example c(1) = a(1)/b(1)/ = 0.0/3.0 = 0.0

or, do you want

ncl > b@_FillValue = 1e20
ncl > d = a/b
ncl > print(d)

Variable: d
Type: float
Total Size: 24 bytes
             6 values
Number of Dimensions: 1
Dimensions and sizes: [6]
Coordinates:
Number Of Attributes: 1
   _FillValue : 1e+20
(0) 5
(1) 0
(2) 6
(3) 1e+20
(4) 0
(5) 1e+20

On 7/13/10 6:29 AM, Oliver.Fuhrer@meteoswiss.ch wrote:
> Maria,
>
> The NCL where statement (
> http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml )
> usually does the trick!
>
> Cheers,
> Oli
>
>
> ________________________________________
>
> Oliver Fuhrer
> Numerical Models
>
> Federal Departement of Home Affairs FDHA
> Federal Office of Meteorology and Climatology MeteoSwiss
>
> Kraehbuehlstrasse 58, P.O. Box 514, CH-8044 Zurich, Switzerland
>
> Tel. +41 44 256 93 59
> Fax +41 44 256 92 78
> oliver.fuhrer@meteoswiss.ch
> www.meteoswiss.ch - First-hand information
>
>
>
>> -----Original Message-----
>> From: ncl-talk-bounces@ucar.edu
>> [mailto:ncl-talk-bounces@ucar.edu] On Behalf Of Maria Frontoso
>> Sent: Dienstag, 13. Juli 2010 14:04
>> To: ncl-talk@ucar.edu
>> Subject: Ratio between two fields with some null values
>>
>> Dear all,
>> I would like to plot the variable ratio between two fields A
>> and B, but some of these fields have sometimes a *null*
>> value, so I get the following error message
>>
>> *********************************************
>> fatal:divide: Division by 0, Can't continue
>> fatal:Div: operator failed, can't continue
>> *********************************************
>>
>> Since I don't mind to have an array with *missing* values
>> (i.e. the values coming from the division by zero), I would
>> like to ask you if there is a way to by-pass that and plot
>> the ratio in any cases, regardless by the values of the two
>> initial fields A and B.
>>
>>
>> Thanks,
>> Maria
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> 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
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jul 13 09:35:11 2010

This archive was generated by hypermail 2.1.8 : Mon Jul 19 2010 - 09:39:01 MDT