[ncl-talk] process valid range

Dennis Shea shea at ucar.edu
Tue Sep 11 14:18:06 MDT 2018


My hasty response was *not* correct.

Rashed Mahmood sent me the following offline. [ THX! ]
He also suggested that the .lt. and .gt. be changed to .le. and .ge.
============================================
 a   = (/0.1, 1, 2, 3, .5, -10, 30, 1, 2, 3/)      ; type float
 a at valid_range = (/-0.2, 5/)                      ; indices 0 and 1
 a at _FillValue = -999.0                              ; match type of
variable 'a'
 print(a)
 print("-----")
 a = *where*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml>( a*.ge.*
a at valid_range(*0*) *.and.* a*.le.*a at valid_range(*1*), a, a at _FillValue )
 print(a)
============================================

Variable: a
Type: float
Total Size: 40 bytes
            10 values
Number of Dimensions: 1
Dimensions and sizes:    [10]
Coordinates:
Number Of Attributes: 2
  _FillValue :    -999
  valid_range :    *( -0.2,  5 )*
(0)    0.1
(1)     1
(2)     2
(3)     3
(4)    0.5
(5)    -10
(6)    30
(7)     1
(8)     2
(9)     3
(0)    -----


Variable: a
Type: float
Total Size: 40 bytes
            10 values
Number of Dimensions: 1
Dimensions and sizes:    [10]
Coordinates:
Number Of Attributes: 2
  _FillValue :    -999
  valid_range :    ( -0.2,  5 )
(0)    0.1
(1)     1
(2)     2
(3)     3
(4)    0.5

*(5)    -999(6)    -999*
(7)     1
(8)     2
(9)     3



ncl 0> a = (/0.1, 1, 2, 3, .5, -10, 30, 1, 2, 3/)      ; type *float*
ncl 1> valid_range = (/-0.2, 5/)
ncl 2> a at _FillValue = -999.0                            ; match type of
variable 'a'
ncl 3> data = *where*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml>(a.gt.valid_range(0)
*.or.*  a.lt.valid_range(1) , a , a at _FillValue)

ncl 4> print(data)


Variable: data
Type: float
Total Size: 40 bytes
            10 values
Number of Dimensions: 1
Dimensions and sizes:   [10]
Coordinates:
Number Of Attributes: 1
  _FillValue :  -999
(0)     0.1
(1)      1
(2)      2
(3)      3
(4)     0.5
(5)     -10
(6)     30
(7)      1
(8)      2
(9)      3
ncl 5> data = where(a.gt.valid_range(0) .and. a.lt.valid_range(1) , a
, a at _FillValue)

ncl 6> print(data)

Variable: data
Type: float
Total Size: 40 bytes
            10 values
Number of Dimensions: 1


Dimensions and sizes:   [10]


Coordinates:


Number Of Attributes: 1


  _FillValue :  -999
(0)     0.1
(1)      1
(2)      2
(3)      3
(4)     0.5
(5)     -999
(6)     -999
(7)      1
(8)      2
(9)      3


On Tue, Sep 11, 2018 at 7:54 AM, Dennis Shea <shea at ucar.edu> wrote:

> .and. ===> .or.
>
> data = where(data_raw.gt.data_hdf4 at valid_range(0) *.or.*
> data_raw.lt.data_hdf4 at valid_range(1) ,data_raw, data_hdf4 at _FillValue)
>
>
>
> On Tue, Sep 11, 2018 at 1:34 AM, Elham Ghasemifar <
> elham.ghasemifar at modares.ac.ir> wrote:
>
>> dear colleges
>>
>> anyone can help me how i can change valid range, i tried more but NCL got
>> me error ,
>>
>>
>>
>> ; Process valid_range. Fill value and missing value will be handled by
>> this
>>
>> ; since they are outside of range values.
>>
>> data = where(data_raw.gt.data_hdf4 at valid_range(0) .and.
>> data_raw.lt.data_hdf4 at valid_range(1) ,data_raw, data_hdf4 at _FillValue)
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180911/d3efb703/attachment.html>


More information about the ncl-talk mailing list