geotess.lib.libgeotess

Contents

geotess.lib.libgeotess#

This module exposes Cython GeoTess functionality from the pxd file into Python.

The class definitions here are Python-visible, and are simply wrappers that forward the Python-exposed methods directly down to their Cython-exposed C++ counterparts, which have been exposed in the imported pxd file.

This module is also responsible for converting between Python types and C++ types, which sometimes involves annoying tricks. For simple numerical types, this conversion can be done automatically in the calling signature of a “def” method if types are declared. Complex C++ class types, for example, can’t be in a Python-visible “def” method because Python objects can’t be automatically cast to C++ types. For these cases, sneaky factory functions that can accept the complex types must do the work. Unfortunately, this means that any constructor or method that accepts complex C++ can’t be “directly” exposed to Python.

Using both a pxd and a pyx file is done, partly, so that we can keep the exposed C++ GeoTess functionality together in one namespace using “cimport”, such that we can name the classes exposed to Python the same as those in the GeoTess C++. This is sometimes confusing in error messages, however.

GeoTess functionality is intentionally a one-to-one translation into Python here so that any modifications to the way models and grids are used can be developed and tested in other pure-Python modules. This makes it easier to try different Pythonic approaches to working with the underlying GeoTess library.

## Current conversion conventions

  • NumPy vectors are generally used instead of lists or vectors, such as for GeoTess unit vectors and profiles.

  • If a C++ method accepts an empty array/vector argument to be filled by the method, I leave that out of the calling signature. It is instead initialized inside the method and simply returned by it.

## Current headaches

  • Deleting or garbage-collecting objects is dangerous. Some objects are managed by other objects, so deleting them manually can crash the interpreter. I’m not sure how to fix this yet.

  • There is very little/no type checking between Python arguments and when they’re forwarded to the C++ methods. This is dangerous.

## Original C++ documentation https://sandialabs.github.io/GeoTessCPP/GeoTessCPP/doc/html/annotated.html

class geotess.lib.libgeotess.AK135Model#

Bases: object

getLayerProfile(self, double lat, double lon, int layer)#
class geotess.lib.libgeotess.EarthShape#

Bases: object

Defines the ellipsoid that is to be used to convert between geocentric and geographic latitude and between depth and radius.

EarthShape defines the ellipsoid that is to be used to convert between geocentric and geographic latitude and between depth and radius. The default is WGS84.

The following EarthShapes are defined:

Parameters:

earthShape (str) –

Define the shape of the Earth that is to be used to convert between geocentric and geographic latitude and between depth and radius.

SPHERE - Geocentric and geographic latitudes are identical and

conversion between depth and radius assume the Earth is a sphere with constant radius of 6371 km.

GRS80 - Conversion between geographic and geocentric latitudes, and

between depth and radius are performed using the parameters of the GRS80 ellipsoid.

GRS80_RCONST - Conversion between geographic and geocentric latitudes

are performed using the parameters of the GRS80 ellipsoid. Conversions between depth and radius assume the Earth is a sphere with radius 6371.

WGS84 - Conversion between geographic and geocentric latitudes, and

between depth and radius are performed using the parameters of the WGS84 ellipsoid.

WGS84_RCONST - Conversion between geographic and geocentric latitudes

are performed using the parameters of the WGS84 ellipsoid. Conversions between depth and radius assume the Earth is a sphere with radius 6371.

getLatDegrees(self, double[:] v)#

Convert a 3-component unit vector to a latitude, in degrees.

getLonDegrees(self, double[:] v)#

Convert a 3-component unit vector to a longitude, in degrees.

getVectorDegrees(self, double lat, double lon)#

Convert geographic lat, lon into a geocentric unit vector.

The x-component points toward lat,lon = 0, 0. The y-component points toward lat,lon = 0, 90. The z-component points toward north pole.

Parameters:
  • lat (float)

  • lon (float)

Return type:

numpy.ndarray of floats

class geotess.lib.libgeotess.GeoTessGrid#

Bases: object

Manages the geometry and topology of one or more multi-level triangular tessellations of a unit sphere.

Has many functions to retrieve information about the grid but knows nothing about Data.

Manages the geometry and topology of one or more multi-level triangular tessellations of a unit sphere. It knows:

  • the positions of all the vertices,

  • the connectivity information that defines how vertices are connected to form triangles,

  • for each triangle it knows the indexes of the 3 neighboring triangles,

  • for each triangle it knows the index of the triangle which is a descendant at the next higher tessellation level, if there is one.

  • information about which triangles reside on which tessellation level

GeoTessGrid is thread-safe in that its internal state is not modified after its data has been loaded into memory. The design intention is that single instances of a GeoTessGrid object and GeoTessData object can be shared among all the threads in a multi-threaded application and each thread will have it’s own instance of a GeoTessPosition object that references the common GeoTessGrid + GeoTessData combination.

Parameters:

raw (bool) – If True, return an “raw” (empty) instance (doesn’t initialize its own pointer). This is intended for use with c-level classmethods that instantiate an instance from an existing pointer.

getFirstTriangle(self, int tessellation, int level)#

Retrieve the index of the first triangle on the specified level of the specified tessellation of the model.

Parameters:
  • tessellation (int)

  • level (int) – index of a level relative to the first level of the specified tessellation

Returns:

a triangle index

Return type:

int

getGridID(self)#
getGridInputFile(self)#

Retrieve the name of the file from which the grid was loaded.

This will be the name of a GeoTessModel file if the grid was stored in the same file as the model.

Returns:

the name of the file from which the grid was loaded.

Return type:

str

getLastTriangle(self, int tessellation, int level)#

Retrieve the index of the last triangle on the specified level of the specified tessellation of the model.

Parameters:
  • tessellation (int)

  • level (int) – index of a level relative to the first level of the specified tessellation

Returns:

a triangle index

Return type:

int

getMemory(self)#

Retrieve the amount of memory required by this GeoTessGrid object in bytes.

Returns:

the amount of memory required by this GeoTessGrid object in bytes.

Return type:

int

getNLevels(self, tessellation=None)#

Returns the number of tessellation levels defined for this grid.

Parameters:

tessellation (int) – Return only number of levels for the provided tessellation index, otherwise all levels are returned.

Returns:

The number of tessellation levels defined for this grid.

Return type:

int

getNTessellations(self)#

Returns the number of tessellations in the tessellations array.

Returns:

the number of multi-level tesseallations.

Return type:

int

getNTriangles(self, tessellation=None, level=None)#

Retrieve the number of triangles that define the specified level of the specified multi-level tessellation of the model.

Parameters:
  • tessellation (int) – Specified tessellation index.

  • level (int) – index of a level relative to the first level of the specified tessellation

Returns:

number of triangles on specified tessellation and level.

Return type:

int

getNVertices(self)#

Returns the number of vertices in the vectices array.

Returns:

number of vertices

Return type:

int

getTriangleVertexIndexes(self, int triangleIndex)#

Supply an integer triangle index, get a 3-element numpy integer array, which are indices of the vertices that make this triangle.

getVertex(self, int vertex)#

Retrieve the unit vector that corresponds to the specified vertex.

Returns a 3-element NumPy vector. This array is still connected to the vertex in-memory, so don’t modify it unless you intend to!

getVertexIndex(self, int triangle, int corner, tessId=None, level=None)#

Get the index of the vertex that occupies the specified position in the hierarchy.

Parameters:
  • triangle (int) – the i’th triangle in the grid

  • corner (int) – the i’th corner of the specified triangle

  • tessId (int) – tessellation index

  • level (int) – index of a level relative to the first level of the specified tessellation

Returns:

index of a vertex

Return type:

int

getVertexTriangles(self, int tessId, int level, int vertex)#

Retrieve a list of the triangles a particular vertex is a member of, considering only triangles in the specified tessellation/level.

getVertices(self)#

Retrieve a reference to all of the vertices.

Vertices consists of an nVertices x 3 array of doubles. The double[3] array associated with each vertex is the 3 component unit vector that defines the position of the vertex.

Users should not modify the contents of the array.

Returns:

nVertices x 3 array of unit vectors.

Return type:

numpy.ndarray

loadGrid(self, str inputFile)#

Load GeoTessGrid object from a File.

Parameters:

inputFile (str) – name of file from which to load grid.

Return type:

pointer to a Grid object

testGrid(self)#

Tests the integrity of the grid.

Visits every triangle T, and (1) checks to ensure that every neighbor of T includes T in its list of neighbors, and (2) checks that every neighbor of T shares exactly two nodes with T.

Exceptions#

GeoTessException if anything is amiss.

toString(self)#

Summary information about this GeoTessGrid object.

Returns:

Summary description string for current grid.

Return type:

str

writeGrid(self, str fileName)#
class geotess.lib.libgeotess.GeoTessMetaData#

Bases: object

Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Earth model.

GeoTessModel manages the grid and data that comprise a 3D Earth model. The Earth is assumed to be composed of a number of layers each of which spans the entire geographic extent of the Earth. It is assumed that layer boundaries do not fold back on themselves, i.e., along any radial profile through the model, each layer boundary is intersected exactly one time. Layers may have zero thickness over some or all of their geographic extent. Earth properties stored in the model are assumed to be continuous within a layer, both geographically and radially, but may be discontinuous across layer boundaries.

A GeoTessModel is comprised of 3 major components:

The model grid (geometry and topology) is managed by a GeoTessGrid object. The grid is made up of one or more 2D triangular tessellations of a unit sphere.

The data are managed by a 2D array of Profile objects. A Profile is essentially a list of radii and Data objects distributed along a radial profile that spans a single layer at a single vertex of the 2D grid. The 2D Profile array has dimensions nVertices by nLayers.

Important metadata about the model, such as the names of the major layers, the names of the data attributes stored in the model, etc., are managed by a GeoTessMetaData object. The term ‘vertex’ refers to a position in the 2D tessellation. They are 2D positions represented by unit vectors on a unit sphere. The term ‘node’ refers to a 1D position on a radial profile associated with a vertex and a layer in the model. Node indexes are unique only within a given profile (all profiles have a node with index 0 for example). The term ‘point’ refers to all the nodes in all the profiles of the model. There is only one ‘point’ in the model with index 0. PointMap is introduced to manage all these different indexes.

getAttributeNamesString(self)#

Retrieve the names of all the attributes assembled into a single, semi-colon separated string.

Returns:

the names of all the attributes assembled into a single, semi-colon separated string.

Return type:

str

getAttributeUnitsString(self)#

Retrieve the units of all the attributes assembled into a single, semi-colon separated string.

Returns:

the units of all the attributes assembled into a single, semi-colon separated string.

Return type:

str

getDescription(self)#

Retrieve the description of the model.

Returns:

the description of the model.

Return type:

str

getLayerIndex(self, str layerName)#

Retrieve the index of the layer that has the specified name, or -1.

Parameters:

layerName (str) – the name of the layer whose index is sought.

Returns:

the index of the layer that has the specified name, or -1.

Return type:

int

getLayerName(self, int layerIndex)#

Retrieve the name of one of the layers supported by the model.

Parameters:

layerIndex (int) – the index of the layer

Returns:

the name of the layer

Return type:

str

getLayerNamesString(self)#

Retrieve the names of all the layers assembled into a single, semi-colon separated string.

Returns:

the names of all the layers assembled into a single, semi-colon separated string.

Return type:

str

getLayerTessIds(self)#

Retrieve a reference to layerTessIds

An int[] with an entry for each layer specifying the index of the tessellation that supports that layer.

Returns:

layerTessIds

Return type:

list of int

getModelFileFormat(self)#
getModelSoftwareVersion(self)#

Get the name and version of the software that generated the content of this model.

Returns:

the name and version of the software that generated this model.

Return type:

str

getNLayers(self)#

Retrieve the number of layers represented in the model.

Returns:

number of layers represented in the model.

Return type:

int

setAttributes(self, string nms, string unts)#

Specify the names and units of the attributes.

Parameters:
  • nms (str) – the names of the attributes, separated by a semicolon

  • unts (str) – the units of the attributes, separated by a semicolon

setDataType(self, dt)#

Specify the type of the data that is stored in the model;

Must be one of DOUBLE, FLOAT, LONG, INT, SHORTINT, BYTE.

Parameters:

dt (str) – the dataType to set.

setDescription(self, str dscr)#

Set the description of the model.

Adds a newline as final character.

Parameters:

dscr (str) – the description of the model.

setEarthShape(self, str earthShapeName)#

Specify the name of the ellipsoid that is to be used to convert between geocentric and geographic latitude and between depth and radius.

This ellipsoid will be save in this GeoTessModel if it is written to file. The following EarthShapes are supported:

SPHERE - Geocentric and geographic latitudes are identical and conversion between depth and

radius assume the Earth is a sphere with constant radius of 6371 km.

GRS80 - Conversion between geographic and geocentric latitudes, and between depth and

radius are performed using the parameters of the GRS80 ellipsoid.

GRS80_RCONST - Conversion between geographic and geocentric latitudes are performed using

the parameters of the GRS80 ellipsoid. Conversions between depth and radius assume the Earth is a sphere with radius 6371.

WGS84 - Conversion between geographic and geocentric latitudes, and between depth and radius

are performed using the parameters of the WGS84 ellipsoid.

WGS84_RCONST - Conversion between geographic and geocentric latitudes are performed

using the parameters of the WGS84 ellipsoid. Conversions between depth and radius assume the Earth is a sphere with radius 6371.

IERS2003 - Conversion between geographic and geocentric latitudes, and between depth and

radius are performed using the parameters of the IERS2003 ellipsoid.

IERS2003_RCONST - Conversion between geographic and geocentric latitudes are performed

using the parameters of the IERS2003 ellipsoid. Conversions between depth and radius assume the Earth is a sphere with radius 6371.

Parameters:

earthShapeName (str) – the name of the ellipsoid that is to be used.

setLayerNames(self, str lyrNms)#

Specify the names of all the layers that comprise the model.

This will determine the value of nLayers as well. The input lyrNms is a semicolon concatenation of all layer names (i.e. LAYERNAME1; LAYERNAME2; …). Whitespaces will be removed.

Parameters:

lyrNms (str) – single string containing all the layer names separated by semi-colons

setLayerTessIds(self, vector[int] layrTsIds)#

LayerTessIds is a map from a layer index to a tessellation index.

There is an element for each layer.

Parameters:

layrTsIds (iterable of int) – of length equal to the number of layers in the model.

setModelFileFormat(self, version)#
setModelGenerationDate(self, string genDate)#

Set the date when this model was generated.

This is not necessarily the same as the date when the file was copied or translated.

Parameters:

genDate (str (free-form text date field))

setModelSoftwareVersion(self, string swVersion)#

Set the name and version number of the software that generated the contents of this model.

Parameters:

swVersion (str)

toString(self)#

Returns a string representation of this meta data object

class geotess.lib.libgeotess.GeoTessModel#

Bases: object

Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Earth model.

GeoTessModel manages the grid and data that comprise a 3D Earth model. The Earth is assumed to be composed of a number of layers each of which spans the entire geographic extent of the Earth. It is assumed that layer boundaries do not fold back on themselves, i.e., along any radial profile through the model, each layer boundary is intersected exactly one time. Layers may have zero thickness over some or all of their geographic extent. Earth properties stored in the model are assumed to be continuous within a layer, both geographically and radially, but may be discontinuous across layer boundaries.

A GeoTessModel is comprised of 3 major components:

The model grid (geometry and topology) is managed by a GeoTessGrid object. The grid is made up of one or more 2D triangular tessellations of a unit sphere.

The data are managed by a 2D array of Profile objects. A Profile is essentially a list of radii and Data objects distributed along a radial profile that spans a single layer at a single vertex of the 2D grid. The 2D Profile array has dimensions nVertices by nLayers.

Important metadata about the model, such as the names of the major layers, the names of the data attributes stored in the model, etc., are managed by a GeoTessMetaData object. The term ‘vertex’ refers to a position in the 2D tessellation. They are 2D positions represented by unit vectors on a unit sphere. The term ‘node’ refers to a 1D position on a radial profile associated with a vertex and a layer in the model. Node indexes are unique only within a given profile (all profiles have a node with index 0 for example). The term ‘point’ refers to all the nodes in all the profiles of the model. There is only one ‘point’ in the model with index 0. PointMap is introduced to manage all these different indexes.

Parameterized constructor, specifying the grid and metadata for the model.

The grid is constructed and the data structures are initialized based on information supplied in metadata. The data structures are not populated with any information however (all Profiles are null). The application should populate the new model’s Profiles after this constructor completes.

Before calling this constructor, the supplied MetaData object must be populated with required information by calling the following MetaData methods:

setDescription() setLayerNames() setAttributes() setDataType() setLayerTessIds() (only required if grid has more than one multi-level tessellation)

Parameters:
  • gridFileName (str) – name of file from which to load the grid.

  • metaData (geotess.lib.MetaData) – See Notes.

Notes

GeoTessModel accepts a grid file name and GeoTessMetaData instance. The metadata is _copied_ into the GeoTessModel, so be warned that changes to it are _not_ reflected in the original instances. This is done to simplify the life cycle of the underlying C++ memory, because GeoTessModel wants to assumes ownership of the provided C++ objects, including destruction.

convertToNPArray(self)#

Extracts from geotess object to a set of 3 location vectors and an attribute matrix returns longitude vector, latitude vector, radius vector, and data matrix

getConnectedVertices(self, int layerid)#

Function fo find which vertices are connected

If a vertex is not connected, then it won’t have a set profile.

Paramters#

layerIDint

layer index

returns:

connected vertices at this layer

rtype:

numpy.ndarray

getEarthShape(self)#

Retrieve a reference to the ellipsoid that is stored in this GeoTessModel.

This EarthShape object can be used to convert between geographic and geocentric latitude, and between radius and depth in the Earth.

Returns:

The EarthShape currently in use.

Return type:

Earthshape

getGeographicLocationAttribute(self, float lat, float lon, float radius, int attribute, int layer, float dz=1.0, horizontalType='LINEAR', radialType='LINEAR')#

Uses interpolation to lookup the value of an attribute at a point given latitude, longitude, radius, attribute index, and layer index Optionally give dz for depth search to check the layer Optionally give horizontalType and/or radialType interpolators On success, returns a single value. On failure, returns None object.

getGrid(self)#

Return the current model’s grid object.

Returns:

Current model’s grid object.

Return type:

GeoTessGrid

getMetaData(self)#

Return a reference to the GeoTessMetaData object associated with this model.

The metadata object stores information about the models such as a description of the model, the layer names, attribute names, attribute units, the data type, etc.

Returns:

The metadata object.

Return type:

GeoTessMetaData

getNAttributes(self)#

Return the number of attributes that are associated with each node in the model.

Returns:

the number of attributes that are associated with each node in the model.

Return type:

int

getNLayers(self)#

Return the number of layers that comprise the model as an integer.

getNPoints(self)#

Retrieve the number of points in the model, including all nodes along all profiles at all grid vertices, as an integer.

getNRadii(self, int vertex, int layer)#

For a given vertex and layer, returns the number of radii (nodes)

getNVertices(self)#

Return number of vertices in the 2D geographic grid as an integer.

getNearestPointIndex(self, float latitude, float longitude, float radius)#

Warning! This does not always work. Layer definitions need to be included before it will work properly! This is also quite slow.

Parameters:
  • latitude (float) – floating point from -90 to 90 Defines the latitude of the lookup point

  • longitude (float) – floating point from -180 to 360 Defines the longitude of the lookup point.

  • radius (float) – floating point from 0 to ~6371 (earth’s radius out from center’) Defines the radius of the lookup point.

Return type:

(int) pointIndex used to map the given location to the nearest point in the tesselation.

getPointData(self, pointIndex)#

For a given point index, returns a vector of attribute values

getPointDepth(self, pointIndex)#

Given a point index, return the depth

getPointIndex(self, vertex, layer, node)#

Given a vertex, layer, and node, returns the point index

getPointIndexFirst(self, vertex, layer)#

Returns the point index of the deepest node in the profile defined by vertex and layer

getPointIndexLast(self, vertex, layer)#

Returns the point index of the shallowest node in the profile defined by vertex and layer

getPointLatitude(self, pointIndex)#

Use the pointMap object to find the latitude given a pointIndex value

getPointLayerIndex(self, pointIndex)#

Returns the layer index given a pointIndex

getPointLocation(self, pointIndex)#

Returns the latitude, longitude, radius, and depth of a point in a model defined by the point index

getPointLongitude(self, pointIndex)#

Use the pointMap object to find the longitude given a pointIndex value

getPointNodeIndex(self, pointIndex)#

Returns the node index (in a profile) given a point index

getPointRadius(self, pointIndex)#

Given a point index, return the radius

getPointTessId(self, pointIndex)#

Returns the Tesselation ID given a pointIndex

getPointVertex(self, pointIndex)#

Returns the vertex given a point index

getPointVertexTessLayerNode(self, pointIndex)#
Parameters:

pointIndex (Integer from 0 to self.getNPoints()-1)

Returns:

ints for

Return type:

vertex, tessID, layerID, and Node

getPointWeights(self, double lat, double lon, double radius, str horizontalType='LINEAR')#
getPointWeightsVector(self, double[:] v, double radius, str horizontalType='LINEAR')#
getProfile(self, int vertex, int layer)#

Get a reference to the Profile object for the specified vertex and layer.

Gets values in a profile given the vertex and layer.

Parameters:
  • vertex (int) – index of a vertex in the 2D grid

  • layer (int) – index of one of the layers that comprise the model

Returns:

  • radii (numpy.ndarray of floats [nradius x 1]) – Profile radius values for the profile.

  • attributes (numpy.ndarray of floats [nradius x nattributes]) – Profile attribute values corresponding to each radius.

getValueFloat(self, int pointIndex, int attributeIndex)#

Return the value of the attribute at the specified pointIndex, attributeIndex, cast to a float if necessary.

Parameters:
  • pointIndex (int)

  • attributeIndex (int) – the attributeIndex

Returns:

the value of the specifed attribute, cast to float if necessary

Return type:

float

getWeights(self, const double[::1] pointA, const double[::1] pointB, double pointSpacing, double radius, str horizontalType)#

Compute the weights on each model point that results from interpolating positions along the specified ray path.

This method is only applicable to 2D GeoTessModels.

Parameters:
  • pointA (array_like) – The 3-element unit vector of floats defining the beginning, end of the great circle path C-contiguous layout of floats.

  • pointB (array_like) – The 3-element unit vector of floats defining the beginning, end of the great circle path C-contiguous layout of floats.

  • pointSpacing (float) – The maximum spacing between points, in radians. The actual spacing will generally be slightly less than the specified value in order for there to be an integral number of uniform intervals along the great circle path.

  • radius (float) – The radius of the great circle path, in km. If the value is less than or equal to zero then the radius of the Earth determined by the current EarthShape is used. See getEarthShape() and setEarathShape() for more information about EarthShapes.

  • horizontalType (str {'LINEAR', 'NATURAL_NEIGHBOR'})

Returns:

weights – Integer keys to float values. (output) map from pointIndex to weight. The sum of the weights will equal the length of the ray path in km.

Return type:

dict

Notes

The following procedure is implemented: 1. divide the great circle path from pointA to pointB into nIntervals which each are of length less than or equal to pointSpacing. 2. multiply the length of each interval by the radius of the earth at the center of the interval, which converts the length of the interval into km. 3. interpolate the value of the specified attribute at the center of the interval. 4. sum the length of the interval times the attribute value, along the path.

loadModel(self, str inputFile, relGridFilePath=b'')#

Read model data and grid from a file.

Parameters:
  • inputFile (str) – the path to the file that contains the model.

  • relGridFilePath (str) – if the grid is stored in a separate file then relGridFilePath is the relative path from the directory where the model located to the directory where the grid is located. The default value for relGridFilePath is “” which indicates that the grid file resides in the same directory as the model file.

Return type:

returns a pointer to this

make1DProfile(self, float lat, float lon, int attribute, float mindepth=0, float maxdepth=6371, float dz=1, horizontalType='LINEAR', radialType='LINEAR')#

Extracts values as a 1-dimensional array of depth and attribute Returns numpy arrays of depth and value optional parameters:

mindepth: minimum depth (km) maxdepth: maximum depth (km) dz: sampling in depth (km)

makeDepthMap(self, float depth, int attribute, int layer, float dLon=8.0, float dLat=8.0, float minlon=0, float maxlon=360, float minlat=-90, float maxlat=90, horizontalType='LINEAR', radialType='LINEAR')#

Extracts values for a map at constant depth. The output from this can be used to make a map with other software, such as matplotlib Required positional arguments: depth, attribute index. Optional arguments:

dLon: gridding step in longitude dLat: gridding step in latitude minlon: minimum longitude in degrees maxlon: maximum longitude in degrees minlat: minimum latitude in degrees maxlat: maximum latitude in degrees

relies on numpy as np

positionGetBorehole(self, float lat, float lon, float dz=10.0, computeDepth=False, horizontalType='LINEAR', radialType='LINEAR')#

Returns layerID vector, radii vector, and attribute matrix for the given latitude, longitude position

Parameters:
  • lat (float) – latitude.

  • lon (float) – longitude.

  • dz (float) – regular depth sampling, km, for the borehole

  • Optionally

  • interpolators (give horizontalType and/or radialType)

  • depth (set computeDepth=True to convert output from radii to)

Return type:

vector layers, vector radii, matrix attributes

positionGetDepth(self, lat, lon, radius, horizontalType='LINEAR', radialType='LINEAR')#

Most position methods take depth. This method takes radius and converts to depth for the model’s ellipsoid

Parameters:
  • lat (float) – latitude.

  • lon (float) – longitude.

  • radius (float) – radius from center of earth (km).

Return type:

depth from surface of the earth (km).

positionGetIndexOfClosestVertex(self, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

Returns the closest vertex to the given location

Parameters:
  • lat (float) – latitude.

  • lon (float) – longitude.

  • depth (float) – depth from surface of ellipsoid.

  • Optionally

  • interpolators (give horizontalType and/or radialType)

Return type:

integer vertex

positionGetIndexOfClosestVertexLayer(self, layerid, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

Returns the closest vertex to the given location and layer

Parameters:
  • layerid (integer) – layer index

  • lat (float) – latitude.

  • lon (float) – longitude.

  • depth (float) – depth from surface of ellipsoid. [km] I think.

  • Optionally

  • interpolators (give horizontalType and/or radialType)

Return type:

integer vertex

positionGetLayer(self, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

returns the layerID as a function of latitude, longitude, and depth. Optionally, give position interpolation methods horizontalType and/or radialType

positionGetRadius(self, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

determines radius from input depth

Parameters:
  • lat (float) – latitude (deg).

  • lon (float) – longitude (deg).

  • depth (float) – depth from ellipsoid surface (km).

Return type:

radius from center of earth (km).

positionGetRadiusBottomLayer(self, layer, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

Finds the bottom radius (nearest the core) for a position object defined by location and layer

Parameters:
  • layer (int) – layer index.

  • lat (float) – latitude.

  • lon (float) – longitude.

  • depth (float) – depth from surface of ellipsoid.

  • Optionally

  • interpolators (give horizontalType and/or radialType)

Return type:

radius (km) at bottom of layer.

positionGetRadiusTopLayer(self, layer, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

Finds the top radius (nearest the surface) for a position object defined by location and layer

Parameters:
  • layer (int) – layer index.

  • lat (float) – latitude.

  • lon (float) – longitude.

  • depth (float) – depth from surface of ellipsoid.

  • Optionally

  • interpolators (give horizontalType and/or radialType)

Return type:

radius (km) at top of layer.

positionGetTriangle(self, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

Returns which triangle number the given location is located within.

Parameters:
  • lat (float) – latitude.

  • lon (float) – longitude.

  • depth (float) – depth from surface of ellipsoid.

  • Optionally

  • interpolators (give horizontalType and/or radialType)

Return type:

Integer triangle where position is located

positionGetValue(self, lat, lon, depth, attribute, horizontalType='LINEAR', radialType='LINEAR')#

Returns the attribute at a position

Parameters:
  • lat (float) – latitude.

  • lon (float) – longitude.

  • depth (float) – depth from surface of ellipsoid.

  • attribute (int) – attribute index

  • Optionally

  • interpolators (give horizontalType and/or radialType)

Return type:

attribute value at position.

positionGetValueLayer(self, layer, lat, lon, depth, attribute, horizontalType='LINEAR', radialType='LINEAR')#

Returns the attribute at a position, but forces it to be in layer

Parameters:
  • layer (int) – layer index

  • lat (float) – latitude.

  • lon (float) – longitude.

  • depth (float) – depth from surface of ellipsoid.

  • attribute (int) – attribute index

  • Optionally

  • interpolators (give horizontalType and/or radialType)

Return type:

attribute value at position.

positionGetValues(self, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

Returns the attribute values at a position

Parameters:
  • lat (float) – latitude.

  • lon (float) – longitude.

  • depth (float) – depth from surface of ellipsoid.

  • Optionally

  • interpolators (give horizontalType and/or radialType)

Return type:

ndarray of attribute values at position

positionGetValuesLayer(self, layer, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

Returns the attribute at a position, but forces it to be in layer

Parameters:
  • layer (int) – layer index

  • lat (float) – latitude.

  • lon (float) – longitude.

  • depth (float) – depth from surface of ellipsoid.

  • Optionally

  • interpolators (give horizontalType and/or radialType)

Return type:

ndarray of attribute values at position

positionGetVector(self, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

For a given latitude, longitude, and depth, get the position vector Optionally, give horizontalType and/or radialType interpolators

positionToString(self, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

Returns a string for a position object given latitude, longitude, and depth optionally, give horizontalType and/or radialType interpolators

positionToStringLayer(self, layerid, lat, lon, depth, horizontalType='LINEAR', radialType='LINEAR')#

Returns a string for a position object given layerid, latitude, longitude, and depth optionally, give horizontalType and/or radialType interpolators

setPointData(self, pointIndex, values)#

For a given pointIndex, sets the values in the GeoTess Model

setPointDataSingleAttribute(self, pointIndex, attributeIndex, value)#

For a given point index and attribute index, sets the value

setProfile(self, int vertex, int layer, vector[float] radii, vector[vector[float]] values)#

Set profile values at a vertex and layer. This version works with c++ style vector types. Use setProfileND to push ndarrays instead.

Parameters:
  • vertex (int) – vertex and layer number of the profile.

  • layer (int) – vertex and layer number of the profile.

  • radii (list) – Radius values of profile data.

  • values (list of lists) – List of corresponding attribute values at the provided radii.

  • Returns – -1 on failure

toString(self)#

Returns a string with information about this model.

writeModel(self, string outputFile)#

Write the model to file.

The data (radii and attribute values) are written to outputFile. If gridFileName is ‘*’ or omitted then the grid information is written to the same file as the data. If gridFileName is something else, it should be the name of the file that contains the grid information (just the name; no path information). In the latter case, the gridFile referenced by gridFileName is not overwritten; all that happens is that the name of the grid file (with no path information) is stored in the data file.

Parameters:
  • outputFile (str) – name of the file to receive the model

  • gridFileName (str) – name of file to receive the grid (no path info), or “*”

class geotess.lib.libgeotess.GeoTessModelAmplitude#

Bases: GeoTessModel

Amplitude extension class of GeoTessModel.

getSiteTrans(self, string station, string channel, string band)#

Retrieve the site term for the specified station/channel/band or NaN if not supported.

Parameters:
  • station (str)

  • channel (str)

  • band (str)

Returns:

Site term.

Return type:

float or None