Versions Compared

Key

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

...

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,
               stnids:     ['aberdeen', 'aviemore', 'edinburgh'] )
g = create_geo(type:'xyv',
               latitudes:  |4, 5, 6|,
               longitudes: |2.3, 1.1, 6.5|,
               values:     |1.1, 2.2, 3.3|)
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
Anchor
dates
dates

list dates ( geopoints )

...

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 )

...

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 )

...

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 geopoints of the maximum (minimum) value of the geopoints value and the geopoints value at each grid point or spectral coefficientall geopoints values. Missing values , either in the fieldset or in the original geopoints variable, result in a value of geo_missing_valueare 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

...

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 )

...

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] )

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 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 geo_missing_value or removed with the function remove_missing_values)with the function remove_missing_values). 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)

...

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

...

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 numbersor 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, |3.3, 4.4, 5.5|
gpt['precip'] = |0.3, 0.2, 0.1|

...

0.1|


Anchor
stnids
stnids

list stnids ( geopoints )

Extracts the station id strings from all the geopoints and returns them as 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 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()

...

list stnids ( geopoints )

Extracts the station id strings from all the geopoints and returns them as a list.

...

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 beforehand.

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

...

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 )

...