cars.core.utils =============== .. py:module:: cars.core.utils .. autoapi-nested-parse:: Utils module: contains some cars global shared general purpose functions Functions --------- .. autoapisummary:: cars.core.utils.safe_makedirs cars.core.utils.make_relative_path_absolute cars.core.utils.safe_cast_float cars.core.utils.get_elevation_range_from_metadata cars.core.utils.angle_vectors Module Contents --------------- .. py:function:: safe_makedirs(directory, cleanup=False) Create directories even if they already exist (mkdir -p) :param directory: path of the directory to create .. py:function:: make_relative_path_absolute(path, directory) If path is a valid relative path with respect to directory, returns it as an absolute path :param path: The relative path :type path: string :param directory: The directory path should be relative to :type directory: string :return: os.path.join(directory,path) if path is a valid relative path form directory, else path :rtype: string .. py:function:: safe_cast_float(data) Safe cast to float data :param data: string to get float in :return float from data .. py:function:: get_elevation_range_from_metadata(img: str, default_min: float = 0, default_max: float = 300) -> Tuple[float, float] 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 :param img: Path to the img for which the elevation range is required :param default_min: Default minimum value to return if everything else fails :param default_max: Default minimum value to return if everything else fails :return: (elev_min, elev_max) float tuple .. py:function:: angle_vectors(vector_1: numpy.ndarray, vector_2: numpy.ndarray) -> float 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))) :param vector_1: Numpy first vector :param vector_2: Numpy second vector :return: Smallest angle in radians