-
Notifications
You must be signed in to change notification settings - Fork 9
Titanlib in Python
Thomas Nipen edited this page Jun 6, 2020
·
7 revisions
The function signature for python is similar to the C++ signatures, except that variables passed by reference in C++ are instead return variables.
import titanlib
flags = titanlib.range_check([-4,2],[1],[3])
The Dataset class stores the lats, lons, elevs, and values internally. It also stores the flags, which can be retrieved after a test has been run.
Run the range_check on all values:
import titanlib
dataset = titanlib.Dataset([60,60,61], [10, 11, 12], [0, 100, 0], [-4, 2, 1])
dataset.range_check([1], [3])
print([i for i in dataset.flags[:]])
Run the range_check on a subset of values:
import titanlib
dataset = titanlib.Dataset([60,60,61], [10, 11, 12], [0, 100, 0], [-4, 2, 1])
dataset.range_check([1], [3], [1, 2])
print([i for i in dataset.flags[:]])
Some functions have arguments passed in as non-const references. These are intended to be output arguments, and are automatically made output arguments in python. This means that the C++ function:
ivec sct(const vec& lats,
const vec& lons,
const vec& elevs,
const vec& values,
int num_min,
int num_max,
double inner_radius,
double outer_radius,
int num_iterations,
int num_min_prof,
double dzmin,
double dhmin,
float dz,
const vec& pos,
const vec& neg,
const vec& eps2,
vec& sct,
vec& rep);
will return the following in python:
flags, sct, rep = gridpp.sct(...)
Copyright © 2019-2023 Norwegian Meteorological Institute