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

...

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. By 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). 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.

...