PyNGL Home > Functions > Array creators

Ngl.generate_2d_array

Generates smooth 2D arrays primarily for use in examples.

Available in version 1.2.0 or later.

Prototype

array = generate_2d_array(dims, num_low, num_high,  
                 minv, maxv, seed=0, 
                 lows_at=None, highs_at=None)

Arguments

dims

A list (or array) containing the dimensions of the two-dimensional array to be returned.

num_low, num_high

Integers representing the approximate minimum and maximum number of highs and lows that the output array will have. They must be in the range 1 to 25. If not, then they will be set to either 1 (if less than 1) or 25 (if greater than 25).

minv, maxv

The exact minimum and maximum values that the output array will have.

seed=0

An optional argument specifying a seed for the random number generator. If iseed is outside the range 0 to 99, it will be set to 0.

lows_at=None

An optional argument that is a list of coordinate pairs specifying where the lows will occur. If this argument appears, then its length must equal num_low and the coordinates must be in the ranges specified in dims.

highs_at=None

An optional argument that is a list of coordinate pairs specifying where the highs will occur. If this argument appears, then its length must equal num_high and the coordinates must be in the ranges specified in dims.

Return value

array

The desired 2D array.

Description

This function generates a nice smooth 2D array. It uses pseudo random numbers to position the highs and lows. The random numbers generated are reproducible so that the same array will always be generated using the same arguments. The generated values will fall exactly within the range [minv,maxv] and there will be approximately num_low lows and num_high highs.

Examples

See cn12p.py.