# Re: Where oh where

From: Bridget Thrasher <bthrasher_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 28 2011 - 19:49:49 MDT

Perhaps something like this:

hi_tmp = hi(rh_ref2m, t_ref2m) ; Or however you call your function
hi_out = where(t_ref2m.gt.324.15.and.t_ref2m.lt.293.15, missing, 0.0)
hi_out = where(rh_ref2m.lt.10.and.t_ref2m.gt.322.15, hi_tmp ,hi_out)
hi_out = where(rh_ref2m.lt.20.and.t_ref2m.gt.318.15.and.t_ref2m.lt.322.15,
hi_tmp,hi_out)
hi_out = where(rh_ref2m.lt.30.and.t_ref2m.gt.314.15.and.t_ref2m.lt.318.15,
hi_tmp,hi_out)
...

-Bridget

On Fri, Oct 28, 2011 at 6:39 PM, James Correia, Jr <jimmyc42@gmail.com>wrote:

> I suppose you can string a few where's together until you have the
> conditions required for your polynomial
>
> var = where(t_ref2m .lt. condition1 .or. t_ref2m .gt. condition2, missing,
> t_ref2m)
>
> Then do another variation using rh:
> var1 = where(rh .gt. rhcondition1 .or. rh .lt. condition2, missing, rh)
>
> temp = ind(where(.not.ismissing(var) .and. .not.ismissing(var1), 1, 0))
>
> do polynomial computation using the arrays rh(temp) and t_ref2m(temp) where
> temp represents only the eements of the array that satisfy your conditions
> you defined in var and var1.
>
> Does that make sense?
> jimmyc
>
>
> On Fri, Oct 28, 2011 at 8:13 PM, jrbuzan <jbuzan@purdue.edu> wrote:
>
>> Hmmm.
>> I guess I left a piece of information out.
>> The function is calculating a third array: hi (a polynomial that uses Temp
>> and RH as inputs)
>> The function (hi) only works over very specific combinations of t and rh.
>>
>> I could bound the Temperature range, as in your statement, however the
>> relative humidity range varies as temperature varies. I am not sure how to
>> continue the statement from that point.
>>
>> -Jonathan
>>
>>
>> On Oct 28, 2011, at 8:58 PM, James Correia, Jr wrote:
>>
>> It might be complicated in fortran but I dont see how that effects the
>> where in NCL.
>>
>> You can still write:
>> var = where((t_ref2m .gt. 324.15) .or. (t_refm .lt. 293.15),
>> Missing_value, t_ref2m) ; .and. would fail since 1 grid point can not have
>> two values
>>
>> You can keep making changes to the array "var".
>> ;code is untested
>> jimmyc
>>
>> On Fri, Oct 28, 2011 at 7:43 PM, jrbuzan <jbuzan@purdue.edu> wrote:
>>
>>> Hello,
>>>
>>> I have complicated where statement.
>>> I am not sure how to approach this in NCL. The examples do not seem
>>> to show how to bound a region with 2 arrays where there is a specific
>>> range that the function may be calculated.
>>>
>>> Is there a way to write multiple where statements within one where
>>> statement?
>>>
>>> Thanks,
>>>
>>> -Jonathan
>>>
>>> Example code.
>>> In fortran:
>>>
>>> WHERE ((t_ref2m.gt.324.15) .and. (t_ref2m.lt.293.15))
>>> Missing value
>>> ELSEWHERE
>>> WHERE ((rh_ref2m.lt.10.) .and. (t_ref2m.gt.322.15))
>>> Function
>>> END WHERE
>>> WHERE ((rh_ref2m.lt.20.) .and. (t_ref2m.gt.318.15) .and.
>>> (t_ref2m.lt.322.15))
>>> Function
>>> END WHERE
>>> WHERE ((rh_ref2m.lt.30.) .and. (t_ref2m.gt.314.15) .and.
>>> (t_ref2m.lt.318.15))
>>> Function
>>> END WHERE
>>> WHERE ((rh_ref2m.lt.40.) .and. (t_ref2m.gt.311.15) .and.
>>> (t_ref2m.lt.314.15))
>>> Function
>>> END WHERE
>>> WHERE ((rh_ref2m.lt.50.) .and. (t_ref2m.gt.308.15) .and.
>>> (t_ref2m.lt.311.15))
>>> Function
>>> END WHERE
>>> WHERE ((rh_ref2m.lt.60.) .and. (t_ref2m.gt.307.15) .and.
>>> (t_ref2m.lt.308.15))
>>> Function
>>> END WHERE
>>> WHERE ((rh_ref2m.lt.70.) .and. (t_ref2m.gt.306.15) .and.
>>> (t_ref2m.lt.307.15))
>>> Function
>>> END WHERE
>>> WHERE ((rh_ref2m.lt.80.) .and. (t_ref2m.gt.303.15) .and.
>>> (t_ref2m.lt.306.15))
>>> Function
>>> END WHERE
>>> WHERE ((rh_ref2m.lt.90.) .and. (t_ref2m.gt.301.15) .and.
>>> (t_ref2m.lt.303.15))
>>> Function
>>> END WHERE
>>> WHERE ((rh_ref2m.lt.100.) .and. (t_ref2m.gt.293.15) .and.
>>> (t_ref2m.lt.301.15))
>>> Function
>>> END WHERE
>>> END WHERE
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>>
>>
>> --
>>
>> James Correia Jr.
>> OU CIMMS Research Associate
>> SPC HWT Liaison
>>
>> "The highest function of the teacher consists not so much in imparting
>> knowledge as in stimulating the pupil in its love and pursuit. To know how
>> to suggest is the art of teaching."
>>
>>
>> ------------------------------------------------------------------------------------------
>> The views expressed in this email do not necessarily reflect those of
>> NOAA, the National Weather Service, or the University of Oklahoma.
>>
>> ------------------------------------------------------------------------------------------
>>
>>
>>
>
>
> --
>
> James Correia Jr.
> OU CIMMS Research Associate
> SPC HWT Liaison
>
> "The highest function of the teacher consists not so much in imparting
> knowledge as in stimulating the pupil in its love and pursuit. To know how
> to suggest is the art of teaching."
>
>
> ------------------------------------------------------------------------------------------
> The views expressed in this email do not necessarily reflect those of NOAA,
> the National Weather Service, or the University of Oklahoma.
>
> ------------------------------------------------------------------------------------------
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

```--
Bridget Thrasher, PhD
Independent Contractor, Research Scientist

```

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 28 19:49:57 2011

This archive was generated by hypermail 2.1.8 : Tue Nov 01 2011 - 13:43:04 MDT