cars.core.utils
Utils module: contains some cars global shared general purpose functions
Functions
|
Create directories even if they already exist (mkdir -p) |
|
If path is a valid relative path with respect to directory, |
|
Safe cast to float data |
|
This function will try to derive a valid RPC altitude range |
|
Compute the smallest angle in radians between two angle_vectors |
Module Contents
- cars.core.utils.safe_makedirs(directory, cleanup=False)[source]
Create directories even if they already exist (mkdir -p)
- Parameters:
directory – path of the directory to create
- cars.core.utils.make_relative_path_absolute(path, directory)[source]
If path is a valid relative path with respect to directory, returns it as an absolute path
- Parameters:
path (string) – The relative path
directory (string) – The directory path should be relative to
- Returns:
os.path.join(directory,path) if path is a valid relative path form directory, else path
- Return type:
string
- cars.core.utils.safe_cast_float(data)[source]
Safe cast to float data
- Parameters:
data – string to get float in
:return float from data
- cars.core.utils.get_elevation_range_from_metadata(img: str, default_min: float = 0, default_max: float = 300) Tuple[float, float][source]
This function will try to derive a valid RPC altitude range from img metadata.
It will first try to read metadata with gdal. If it fails, it will look for values in the geom file if it exists If it fails, it will return the default range
- Parameters:
img – Path to the img for which the elevation range is required
default_min – Default minimum value to return if everything else fails
default_max – Default minimum value to return if everything else fails
- Returns:
(elev_min, elev_max) float tuple
- cars.core.utils.angle_vectors(vector_1: numpy.ndarray, vector_2: numpy.ndarray) float[source]
Compute the smallest angle in radians between two angle_vectors Use arctan2 more precise than arcos2 Tan θ = abs(axb)/ (a.b) (same: Cos θ = (a.b)/(abs(a)abs(b)))
- Parameters:
vector_1 – Numpy first vector
vector_2 – Numpy second vector
- Returns:
Smallest angle in radians