create_geo

create_geo(number_of_points[, format[, number_of_values_columns[, value_columns]]])
create_geo(number_of_points, **kwargs)

Creates a new Geopoints with the given number_of_points, all set to default values and coordinates.

Parameters
  • fs (Geopoints) – input geopoints

  • number_of_points (number) – number of points

  • format (str) – geopoints format (see below)

  • number_of_value_columns (number) – the number of value columns for the “ncols” formatted

  • value_columns (list) – the name of the value columns for the “ncols” format

  • kwargs – see below

Return type

Geopoints

It is intended that this function be used in conjunction with the “set_* geopoints” functions in order to populate the geopoints with data.

If no format is specified a “traditional” 6-column format geopoints is created. Otherwise format defines the actual format. The possible values are as follows: ‘polar_vector’, ‘xy_vector ‘, ‘xyv ‘ and ‘ncols’.

If format is “ncols”, then the number of value columns can be given by number_of_value_columns (default is 1). In this case, the value_columns can be used to provide a list of names of the value columns.

An alternative, and more efficient way to create a new geopoints variable if you already have the data to populate it, is to provide a set of keyword arguments (kwargs) as shown in the examples below. Using this syntax, you can completely create a new geopoints variable with all its column data in one go. This is much more efficient than creating an empty geopoints variable and then populating it using the ‘set_*’ functions.

Examples
import metview as mv
import numpy as np

# default geopoints format, 8 values
g = mv.create_geo(8)

# "xyv" formatted geopoints with 9 values
g = mv.create_geo(9, "xyv")

# "ncols" format with 3 named columns, each containing 4 values
g = mv.create_geo(4, "ncols", 3, ['t', 'z', 'precip'])

# default geopoints format, with keyword arguments
g = mv.create_geo(type='standard',
            latitudes=np.array([4, 5, 6]),
            longitudes=np.array([2.3, 1.1, 6.5]),
            levels=850,  # all rows will have 850 as their level
            values=np.array([1.1, 2.2, 3.3]),
            times=None)

# "xyv" geopoints format, with keyword arguments
g = mv.create_geo(type="xyv",
            latitudes=np.array([4, 5, 6]),
            longitudes=np.array([2.3, 1.1, 6.5]),
            values=np.array([1.1, 2.2, 3.3]))

# "ncols" geopoints format, with keyword arguments
g = mv.create_geo(type="ncols",
            latitudes=np.array([4, 5, 6]),
            longitudes=np.array([2.3, 1.1, 6.5]),
            levels=850,  # all rows will have 850 as their level
            times=None,
            stnids=['aberdeen', 'aviemore', 'edinburgh'],
            temp=np.array([273.15, 269.78, 281.45]),
            precip=[4, 5, 1],  # lists also work, but are less efficient
            speed=np.array([2, 3, 5]))