#!/usr/bin/env python
# coding: utf8
#
# Copyright (c) 2025 Centre National d'Etudes Spatiales (CNES).
#
# This file is part of CARS
# (see https://github.com/CNES/cars).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
Grids module:
contains functions used for grid transformation
"""
import numpy as np
import rasterio
from cars.applications.grid_generation import grid_generation_algo
[docs]
def scale(key, value, grid, resolution):
"""
Scale attributes by the resolution
"""
if key == "grid_origin":
for i, _ in enumerate(value):
grid[key][i] = np.floor(value[i] / resolution)
elif key == "grid_spacing":
for i, _ in enumerate(value):
grid[key][i] = np.floor(value[i] / resolution)
elif key == "disp_to_alt_ratio":
grid[key] = value * resolution
elif key == "epipolar_size_x":
grid[key] = np.floor(value / resolution)
elif key == "epipolar_size_y":
grid[key] = np.floor(value / resolution)
elif key == "epipolar_origin_x":
grid[key] = np.floor(value / resolution)
elif key == "epipolar_origin_y":
grid[key] = np.floor(value / resolution)
elif key == "epipolar_spacing_x":
grid[key] = np.floor(value / resolution)
elif key == "epipolar_spacing":
grid[key] = np.floor(value / resolution)
elif key == "epipolar_step":
grid[key] = np.floor(value / resolution)