Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

geopoints ( geopoints & geopoints & ... )
geopoints ( nil & geopoints & ... )
geopoints ( geopoints & nil )


Anchor
merge
merge

geopoints merge ( geopoints,geopoints,... )

...

Returns the geopoints of the absolute value of the input geopoints. Missing values retain their value of geo_missing_value.


Anchor
asin
asin

Anchor
acos
acos

Anchor
atan
atan


geopoints asin ( geopoints )
geopoints acos ( geopoints )
geopoints atan  ( geopoints )

...

Takes the integer part of the geopoints values and extracts a specified bit (or number of bits if a second number parameter is specified), where bit number 1 is the least significant bit (lsb). A single bit will always be returned as 1 or 0, regardless of its position in the integer. A group of bits will be treated as if the first bit is the least significant bit of the result.

A few examples from the `number' number version of this function illustrate .

To extract the 1st, 2nd and 3rd bits from a number separately:

how it works:

Code Block
languagepy
# To extract the 1st, 2nd and 3rd bits from a number separately:
n = 6 # in bit-form, this is `00000110' with the least 

...

significant bit at the right

...


flag = intbits (n, 1) # flag is now 0

...

flag = intbits (n, 2) # flag is now 1

...

flag = intbits (n, 3) # flag is now 1

...

# To extract the 1st and 2nd bits together to make a single number:

...


flag = intbits (n, 1, 2) # flag is now 2

...


# To extract the 2nd and 3rd bits together to make a single number:

...


flag = intbits (n, 2, 2) # flag is now 3

...


#To extract the 3rd and 4th bits together to make a single number:

...


flag = intbits (n, 3, 2) # flag is now 1

...

The number of bits available depends on the machine architecture and Metview's compilation options, but at the time of writing it should be 32. This function does not treat missing values differently from any other values (for efficiency with large datasets).

...

geopoints create_geo ( number )
geopoints create_geo ( number, string )
geopoints create_geo ( number, string, number )
geopoints create_geo
 ( number, string, number, list )
geopoints create_geo ( ... )

Creates a new geopoints variable with the given number of points, all set to default values and coordinates. It is intended that this function be used in conjunction with the set_xxx geopoints functions in order to populate the geopoints with data. If saved, the geopoints file will be in the `traditional' 6-column format. If another format is desired, supply a string as the second parameter, possible values being 'polar_vector ', 'xy_vector ', 'xyv ' and 'ncols'. If format 'ncols' is specified, then the number of value columns can be given as the third argument (default is 1). In this case, an optional fourth argument can be used to provide a list of names of the value columns.

...

Code Block
languagepy
g = create_geo(8) # default geopoints format, 8 values
g = create_geo(9, 'xyv') # XYV formatted geopoints with 9 values
g = create_geo(4, 'ncols', 3, ['t', 'z', 'precip']) # NCOLS format with 3 named columns, each containing 4 values
g = create_geo(type:'standard',
               latitudes:  |4, 5, 6|,
               longitudes: |2.3, 1.1, 6.5|,
               levels:     850,  # all rows will have 850 as their level
               values:     |1.1, 2.2, 3.3|,
               times:      nil)
g = create_geo(type:'xyv',
               stnidslatitudes:     ['aberdeen', 'aviemore', 'edinburgh'] )
g = create_geo(type:'xyv',
|4, 5, 6|,
                 latitudes:  |4, 5, 6|,
               longitudes: |2.3, 1.1, 6.5|,
               values:     |1.1, 2.2, 3.3|)

...

list date ( geopoints )

Extracts the date information of all the geopoints and returns it as a list of dates.

...

string or list db_info ( geopoints,string )
string db_info ( geopoints,string,string )

Returns information about the database retrieval which generated the geopoints. The first string parameter specifies which piece of information you would like; possible values are:

...

name

...

the name of the database system, e.g. ODB

...

path

...

the path to the database

...

query

...

a list of strings containing the multi-line data query

...

column

...

the name of the database column used to populate a given element of the geopoints. A second string must be provided, naming the geopoints element of interest - possible values are `lat ', `lon ', `level ', `date ', `time ', `value ' and `value2 '.

...

alias

...

similar to column above, but returns the name of the database alias used instead of the full column name


g = create_geo(type:       'ncols',
               latitudes:  |4, 5, 6|,
               longitudes: |2.3, 1.1, 6.5|,
               levels:     850,  # all rows will have 850 as their level
               times:      nil,
               stnids:     ['aberdeen', 'aviemore', 'edinburgh'],
               temp:       |273.15, 269.78, 281.45|,
               precip:     [4, 5, 1],  # lists also work, but are less efficient
               speed:      |2, 3, 5| )


Anchor
dates
dates

list dates ( geopoints )

Extracts the date information of all the geopoints and returns it as a list of dates.


Anchor
db_info
db_info

string or list db_info ( geopoints,string )
string db_info ( geopoints,string,string )

Returns information about the database retrieval which generated the geopoints. The first string parameter specifies which piece of information you would like; possible values are:

name

the name of the database system, e.g. ODB

path

the path to the database

query

a list of strings containing the multi-line data query

column

the name of the database column used to populate a given element of the geopoints. A second string must be provided, naming the geopoints element of interest - possible values are `lat ', `lon ', `level ', `date ', `time ', `value ' and `value2 '.

alias

similar to column above, but returns the name of the database alias used instead of the full column name

Note that this information is derived from the DB_INFO section (if it exists) in the geopoints file header (see Storing Data Origin Information in a Geopoints File).


Anchor
distance
distance

geopoints distance ( geopoints,number,number )
geopoints distance ( geopoints,list )

Returns geopoints with the value of each point being the distance in meters from the given geographical location. The location may be specified by supplying either two numbers (latitude and longitude respectively) or a 2-element list containing latitude and longitude in that order. The location should be specified in degrees. A geopoint with either latitude or longitude set to missing value will have a distance of missing value.


Anchor
filter
filter

geopoints filter ( geopoints,geopoints )

A filter function to extract a subset of its geopoints input using a second geopoints as criteria. The two input geopoints must have the same number of values. The resulting output geopoints contains the values of the first geopoints where the value of the second geopoints is non-zero. It is usefully employed in conjunction with the comparison operators :

freeze = filter(temperature,temperature < 273.15)

The variable freeze will contain a subset of temperature where the value is below 273.15 . The following example shows how to plot a geopoints set with different colours :


# Filter from "temperature" points at, above, below 273.15
cold = filter( temperature,temperature<273.15 )
zero = filter( temperature,temperature=273.15 )
warm = filter( temperature,temperature>273.15 


# Create three symbol plotting definitions
red = psymb( symbol_colour : "red" )
blue = psymb( symbol_colour : "blue" )
black = psymb( symbol_colour : "black" )


# Plot everything
plot(zero,black,cold,blue,warm,red)


geopoints filter ( geopoints,vector )

A filter function to extract a subset of its geopoints input using the values in a vector as criteria. The vector should contain the same number of elements as there are in the geopoints. An example, which uses a named column for the filter criteria is:

new_gpt = filter(gpt, gpt['precip'] > 5)  # "gpt['precip'] > 5" returns a vector of 1s and 0s


geopoints filter ( geopoints,number )
geopoints filter ( geopoints,list )

A filter function to extract a subset of its geopoints input using model levels as criteria.

    • If the second argument is a number, the function extracts all the geopoints for which the level is equal to the number.
    • If the second argument is a list of two numbers [n1,n2] , the function extracts all the geopoints for which the level lies in the n1-n2 interval.


geopoints filter ( geopoints,date )
geopoints filter ( geopoints,list )

A filter function to extract a subset of its geopoints input using dates as criteria.

    • If the second argument is a date, the function extracts all the geopoints for which the date is equal to the one specified as the second argument.
    • If the second argument is a list of two dates [d1,d2] , the function extracts all the geopoints for which the date lies in the d1-d2 interval.


geopoints filter ( geopoints,list )

A filter function to extract a subset of its geopoints input using a geographical area as criteria.

The second argument is a list of four numbers (lat/long coordinates) defining a geographical area - [North,West,South,East] . The function extracts all the geopoints that fall within the specified area.


Anchor
geosort
geosort

geopoints geosort ( geopoints )

Returns a new geopoints variable that contains the input geopoints sorted geographically from North to South (and West to East in points with the same latitude value, then by height, with lowest numerical values first).


Anchor
interpolate
interpolate

geopoints interpolate ( fieldset,geopoints )

Generates a set of geopoints from a field. The first parameter must contain a single field. The field is interpolated for each position of the geopoints given as a second parameter. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, the internal geopoints missing value is used (this value can be checked for with the built-in variable geo_missing_value or removed with the function remove_missing_values ). This function will return a missing value where the geopoints have missing lat/lon.


Anchor
latitudes
latitudes

vector latitudes ( geopoints )

Extracts the latitudes of all the geopoints and returns them as a vector..


Anchor
levels
levels

vector levels ( geopoints )

Extracts the heights of all the geopoints and returns them as a vector.


Anchor
longitudes
longitudes

vector longitudes ( geopoints )

Extracts the longitudes of all the geopoints and returns them as a vector.


Anchor
max
max
Anchor
min
min

geopoints max ( geopoints,geopoints )
geopoints min ( geopoints,geopoints )

Returns the geopoints of maximum (minimum) value at each point. Missing values retain their value of geo_missing_value.


geopoints max ( geopoints,number )
geopoints min ( geopoints,number )

Returns the geopoints of the maximum (minimum) of number and the geopoints value at each point. Missing values retain their value of geo_missing_value.


geopoints max ( geopoints,fieldsets )
geopoints min ( geopoints,fieldsets )

Returns geopoints of maximum (minimum) of the geopoints value and the geopoints value at each grid point or spectral coefficient. Missing values, either in the fieldset or in the original geopoints variable, result in a value of geo_missing_value.


Anchor
maxvalue
maxvalue

Anchor
minvalue
minvalue

number maxvalue ( geopoints )
number minvalue ( geopoints )

Returns the maximum (minimum) value of all geopoints values. Missing values are bypassed in this calculation. If there are no valid values, then nil is returned.


Anchor
mean
mean

number mean ( geopoints )

Computes the mean of the geopoints. Missing values are bypassed in this calculation. If there are no valid values, then nil is returned.


Anchor
mask
mask

geopoints mask ( geopoints,list )

Creates a geopoints variable containing point values of 0 or 1 according to whether they are inside (1) or outside (0) a defined geographical area.

The list parameter must contain exactly four numbers representing a geographical area. These numbers should be in the order north, west, south and east (negative values for western and southern coordinates). Points with missing latitudes or longitudes are considered to be outside any area. See the documentation for the fieldset version of this function to see how to compose more complex regions than a simple rectangular area.


Anchor
nearest_gridpoint
nearest_gridpoint

geopoints nearest_gridpoint ( fieldset,geopoints[,string]

Note that this information is derived from the DB_INFO section (if it exists) in the geopoints file header (see Storing Data Origin Information in a Geopoints File).

...

geopoints distance ( geopoints,number,number )
geopoints distance ( geopoints,list )

Returns geopoints with the value of each point being the distance in meters from the given geographical location. The location may be specified by supplying either two numbers (latitude and longitude respectively) or a 2-element list containing latitude and longitude in that order. The location should be specified in degrees.

...

geopoints filter ( geopoints,geopoints )

A filter function to extract a subset of its geopoints input using a second geopoints as criteria. The two input geopoints must have the same number of values. The resulting output geopoints contains the values of the first geopoints where the value of the second geopoints is non-zero. It is usefully employed in conjunction with the comparison operators :

freeze = filter(temperature,temperature < 273.15)

The variable freeze will contain a subset of temperature where the value is below 273.15 . The following example shows how to plot a geopoints set with different colours :

# Filter from "temperature" points at, above, below 273.15
cold = filter( temperature,temperature<273.15 )
zero = filter( temperature,temperature=273.15 )
warm = filter( temperature,temperature>273.15 

# Create three symbol plotting definitions
red = psymb( symbol_colour : "red" )
blue = psymb( symbol_colour : "blue" )
black = psymb( symbol_colour : "black" )

# Plot everything
plot(zero,black,cold,blue,warm,red)

geopoints filter ( geopoints,vector )

A filter function to extract a subset of its geopoints input using the values in a vector as criteria. The vector should contain the same number of elements as there are in the geopoints. An example, which uses a named column for the filter criteria is:

new_gpt = filter(gpt, gpt['precip'] > 5)  # "gpt['precip'] > 5" returns a vector of 1s and 0s

geopoints filter ( geopoints,number )
geopoints filter ( geopoints,list )

A filter function to extract a subset of its geopoints input using model levels as criteria.

    • If the second argument is a number, the function extracts all the geopoints for which the level is equal to the number.
    • If the second argument is a list of two numbers [n1,n2] , the function extracts all the geopoints for which the level lies in the n1-n2 interval.

geopoints filter ( geopoints,date )
geopoints filter ( geopoints,list )

A filter function to extract a subset of its geopoints input using dates as criteria.

    • If the second argument is a date, the function extracts all the geopoints for which the date is equal to the one specified as the second argument.
    • If the second argument is a list of two dates [d1,d2] , the function extracts all the geopoints for which the date lies in the d1-d2 interval.

geopoints filter ( geopoints,list )

A filter function to extract a subset of its geopoints input using a geographical area as criteria.

The second argument is a list of four numbers (lat/long coordinates) defining a geographical area - [North,West,South,East] . The function extracts all the geopoints that fall within the specified area.

...

geopoints geosort ( geopoints )

Returns a new geopoints variable that contains the input geopoints sorted geographically from North to South (and West to East in points with the same latitude value, then by height, with lowest numerical values first).

Anchorinterpolateinterpolategeopoints interpolate ( fieldset,geopoints )

Generates a set of geopoints from a field. The first parameter must contain a single fieldfield of the input fieldset is used. The field is interpolated for each position of the geopoints result is a set of geopoints whose locations are taken from the original geopoints, but whose values are those of the nearest gridpoints in the field to the geopoints given as a second parameter. Where it is not possible to generate a sensible value due to lack of valid data in the fieldsetBy default, when the nearest gridpoint value is a missing value or the location is out of the grid area, the internal geopoints missing value is used (this value can be checked for with the built-in variable variable geo_missing_value or  or removed with the function function remove_missing_values).

...

vector latitudes ( geopoints )

Extracts the latitudes of all the geopoints and returns them as a vector..

...

vector levels ( geopoints )

Extracts the heights of all the geopoints and returns them as a vector.

...

vector longitudes ( geopoints )

Extracts the longitudes of all the geopoints and returns them as a vector.

...

geopoints max ( geopoints,geopoints )
geopoints min ( geopoints,geopoints )

Returns the geopoints of maximum (minimum) value at each point. Missing values retain their value of geo_missing_value.

geopoints max ( geopoints,number )
geopoints min ( geopoints,number )

Returns the geopoints of the maximum (minimum) of number and the geopoints value at each point. Missing values retain their value of geo_missing_value.

geopoints max ( geopoints,fieldsets )
geopoints min ( geopoints,fieldsets )

Returns geopoints of maximum (minimum) of the geopoints value and the geopoints value at each grid point or spectral coefficient. Missing values, either in the fieldset or in the original geopoints variable, result in a value of geo_missing_value.

...

number maxvalue ( geopoints )
number minvalue ( geopoints )

Returns the maximum (minimum) value of all geopoints values. Missing values are bypassed in this calculation. If there are no valid values, then nil is returned.

number mean ( geopoints )

Computes the mean of the geopoints. Missing values are bypassed in this calculation. If there are no valid values, then nil is returned.

geopoints nearest_gridpoint ( fieldset,geopoints )

Generates a set of geopoints from a field. The first field of the input fieldset is used. The result is a set of geopoints whose locations are from the original geopoints, but whose values are those of the nearest gridpoints in the field to the geopoints given as a second parameter. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, the internal geopoints missing value is used (this value can be checked for with the built-in variable geo_missing_value or removed with the function remove_missing_values).

geopoints offset ( geopoints,number,number )
geopoints offset ( geopoints,list)

Modifies the locations of a set of geopoints by specified amounts. The offsets can be specified either as two separate numbers or as a 2-element list. The original geopoints variable is unaffected; the functions return a new variable.

geopoints polar_vector ( geopoints, geopoints )

Combines two single-parameter geopoints variables into a polar vector style geopoints variable. The first represents speed, the second represents direction. Both input geopoints variables should contain the same number of points.

geopoints remove_duplicates ( geopoints )

Returns a new geopoints variable that contains just one instance of any duplicate geopoint. Two geopoints are considered to be duplicates of each other if the files have the same format and the points have the same coordinates, height, date, time and values.

geopoints remove_missing_values ( geopoints )

...

If an extra parameter 'valid' is added to the function call, then of the surrounding points, the nearest valid one is returned; geo_missing_value will still be returned if all the surrounding points are missing. This function will return a missing value where the geopoints have missing lat/lon.


Anchor
offset
offset

geopoints offset ( geopoints,number,number )
geopoints offset ( geopoints,list)

Modifies the locations of a set of geopoints by specified amounts. The offsets can be specified either as two separate numbers or as a 2-element list. The original geopoints variable is unaffected; the functions return a new variable.


Anchor
polar_vector
polar_vector

geopoints polar_vector ( geopoints, geopoints )

Combines two single-parameter geopoints variables into a polar vector style geopoints variable. The first represents speed, the second represents direction. Both input geopoints variables should contain the same number of points.


Anchor
remove_duplicates
remove_duplicates

geopoints remove_duplicates ( geopoints )

Returns a new geopoints variable that contains just one instance of any duplicate geopoint. Two geopoints are considered to be duplicates of each other if the files have the same format and the points have the same coordinates, height, date, time and values.


Anchor
remove_missing_latlons
remove_missing_latlons

geopoints remove_missing_latlons ( geopoints )

Returns a new geopoints variable that contains just the points that do not have missing latitudes or longitudes from the input geopoints variable.



Anchor
remove_missing_values
remove_missing_values

geopoints remove_missing_values ( geopoints )

Returns a new geopoints variable that contains just the non-missing values from the input geopoints variable. A geopoint is considered to be missing if either its value or value2 members are missing.


Anchor
set_latitudes
set_latitudes

Anchor
set_logitudes
set_logitudes

Anchor
set_levels
set_levels

Anchor
set_dates
set_dates

Anchor
set_stnids
set_stnids

Anchor
set_times
set_times

Anchor
set_values
set_values

geopoints set_latitudes ( geopoints, number or vector or list )
geopoints set_longitudes ( geopoints, number or vector or list )
geopoints set_levels ( geopoints, number or vector or list )
geopoints set_dates ( geopoints, number or vector or list )
geopoints set_stnids ( geopoints, list )
geopoints set_times ( geopoints, number or vector or list )
geopoints set_values ( geopoints, number or vector or list )
geopoints set_values ( geopoints, number or string, number or vector or list )

...

All these functions take two or three parameters: first one must be a geopoints variable. If three parameters are given, the second should be either the index or name of the values column to update. The last parameter defines the new values, and can be a number, a vector or a list of numbers (or dates, if set_dates()). If a number is given then all the corresponding values (latitude, longitude, level, or ...) are replaced by the given value.

...

Code Block
languagepy
gpt['latitude'] = |30, 40, 50|
gpt['value'] = |12.4, 13.3, 1.1|
gpt[name_of_column_4] = |3.3, 4.4, 5.5|
gpt['precip'] = |0.3, 0.2, 0.1|


Anchor
stnids
stnids

list stnids ( geopoints )

Extracts the station id strings from all the geopoints and returns them as a list.a list. If a given point does not have a station id, then a nil will be returned in its place in the list.


Anchor
subsample
subsample

geopoints subsample ( geopoints, geopoints )

Returns a geopoints variable containing the same locations (latitude, longitude and height) as the second geopoints variable, but whose values are from the first geopoints variable (or a missing value if point not found in the first variable). Note that the resulting geopoints variable is sorted in the same way as performed by the geosort() function. This means that you need to be careful if performing functions between the results of a subsample() operation and another geopoints variable; if the locations in the two geopoints are the same, then you should geosort() the second geopoints beforehandfunction. This means that you need to be careful if performing functions between the results of a subsample() operation and another geopoints variable; if the locations in the two geopoints are the same, then you should geosort() the second geopoints beforehand. Points with missing latitudes or longitudes will still be in the output, but the rule is that such a point is defined not to be at the same location as another point, even if its lat/lon are also missing. Advice: remove missing lat/lon points using remove_missing_latlons() before using subsample() or geosort().

You can use function remove_missing_values() if you need to get rid of the missing valued points in the returned geopoints variable.


Anchor
sum
sum

number sum ( geopoints )

Computes the sum of the geopoints. Missing values are bypassed in this calculation. If there are no valid values, then nil is returned.


Anchor
times
times

vector times ( geopoints )

Extracts the times of all the geopoints and returns them as a vector.


Anchor
values
values

vector or list values ( geopoints )
vector or list values ( geopoints, number )
vector or list values ( geopoints, string )

Extracts the values of all the geopoints and returns them as a vector. If the values are strings, then the result is a list of strings. A value column other than the first one can be specified either by index (1-based in Macro or 0-based in Python) or by name, e.g. values(gpt, 4) or values(gpt, 'geopotential'). See the description of the NCOLS subformat on the Geopoints page for more details of storing multiple value columns. Another syntax is to use direct indexing, e.g.

a = gpt['geopotential']


Anchor
value2
value2

vector value2 ( geopoints )

Extracts the second values of all the geopoints and returns them as a vector.


Anchor
value_columns
value_columns

list value_columns ( geopoints )

Returns a list containing the names of just the non-coordinate value columns in the given geopoints variable.


Anchor
xy_vector
xy_vector

geopoints xy_vector ( geopoints, geopoints )

...