# [ncl-talk] (Hopefully easy) random_uniform question

Bassill, Nicholas nbassill at albany.edu
Mon Dec 18 09:44:21 MST 2017

```That's it! You'd think I would have figured that out ... but nope.

Thanks!

Nick Bassill, PhD

Modeler & Meteorologist, New York State Mesonet

LC SB-28, 1400 Washington Ave.,

SUNY, University at Albany, NY 12222

(518) 442-6375

http://nysmesonet.org/

________________________________
From: Dennis Shea <shea at ucar.edu>
Sent: Monday, December 18, 2017 11:41 AM
To: Bassill, Nicholas
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] (Hopefully easy) random_uniform question

I don't think the use of  'num' is correct.

https://www.ncl.ucar.edu/Document/Functions/Built-in/num.shtml
num - University Corporation for Atmospheric Research<https://www.ncl.ucar.edu/Document/Functions/Built-in/num.shtml>
www.ncl.ucar.edu
NCL Home > Documentation > Functions > Array query num. Counts the number of True values in the input. Prototype function num ( val : logical ) return_val [1 ...

function num (
val  : logical   <===
)

pastregimecorrs is a variible of type 'float' not 'logical'

The error message

warning:Argument 0 of the current function or procedure was coerced to the appropriate type and thus will not change if the function or procedure modifies its value

is occurring within the 'random_uniform' call BUT it refers to the 'num' function usage. It is informing you that NCL is trying to convert 'floats' to logicals' under-the-hood.

Should not
randomcorrs = random_uniform(min(pastregimecorrs),max(pastregimecorrs),num(pastregimecorrs))
be
randomcorrs = random_uniform(min(pastregimecorrs),max(pastregimecorrs),dimsizes(pastregimecorrs))

On Mon, Dec 18, 2017 at 9:00 AM, Bassill, Nicholas <nbassill at albany.edu<mailto:nbassill at albany.edu>> wrote:

Hi All,
I have a variable with a list of values (they're correlations) in it. I'm creating a new variable with an equally sized list of synthetic values spanning the "range" of values in the original variable, like so:

randomcorrs = random_uniform(min(pastregimecorrs),max(pastregimecorrs),num(pastregimecorrs))

a printVarSummary on "pastregimecorrs" yields:

Variable: pastregimecorrs

Type: float

Total Size: 308 bytes

77 values

Number of Dimensions: 1

Dimensions and sizes: [77]

Coordinates:

Number Of Attributes: 1

_FillValue : 9.96921e+36

Although this always seems to work as expected, I get the following warning:

warning:Argument 0 of the current function or procedure was coerced to the appropriate type and thus will not change if the function or procedure modifies its value

This isn't the biggest deal, other than I loop through this 1000x20x11 times, so it creates a lot of warning text which is making it difficult to debug other portions of my code. "randomcorrs" has not been previously defined.

My question is, am I doing something wrong here? It's not clear to me that I'm doing anything other than what random_uniform (or min, max, or num) expect. I've spent an inordinate amount of time trying to figure this out, so either I'm missing something exceptionally obvious (very possible) or this is a gratuitous warning. I'm using NCL 6.3.

Nick Bassill, PhD

Modeler & Meteorologist, New York State Mesonet

LC SB-28, 1400 Washington Ave.,

SUNY, University at Albany, NY 12222

(518) 442-6375<tel:(518)%20442-6375>

http://nysmesonet.org/

_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto: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/20171218/e0c9328b/attachment.html>
```