Peano
TestSphereProjectionInverse.py
Go to the documentation of this file.
1 import Wrapper
2 import numpy as np
3 from pyproj import Transformer
4 import MyAssert
5 
6 # 1. Gitter in lon/lat erzeugen
7 lons = np.linspace(-98, -70, 1000)
8 lats = np.linspace(15, 35, 1000)
9 LON, LAT = np.meshgrid(lons, lats)
10 
11 # 2. Albers-Projektion (WGS84 → AEA)
12 proj_str = (
13  "+proj=aea "
14  "+lon_0=-84 +lat_1=18.3333333 +lat_2=31.6666667 +lat_0=25 "
15  "+a=6371000 +b=6371000 "
16  "+units=m +no_defs"
17 )
18 transformer = Transformer.from_crs("EPSG:4326", proj_str, always_xy=True)
19 X, Y = transformer.transform(LON, LAT) # in Meter
20 
21 # 3. Inverse Projektion mit deiner Funktion `Z(x, y)` → gibt vermutlich (lon, lat)
22 # Wenn Z nur `lat` zurückgibt, dann:
23 lon_reconstructed = np.vectorize(
24  lambda x, y: Wrapper.sphereTransformInverse(x, y).first
25 )(X, Y)
26 
27 lon_diff = lon_reconstructed - LON
29 
30 lat_reconstructed = np.vectorize(
31  lambda x, y: Wrapper.sphereTransformInverse(x, y).second
32 )(X, Y)
33 
34 lat_diff = lat_reconstructed - LAT
def test_array_within_threshold(arr, lower_threshold=-1e-8, upper_threshold=1e-8)
Definition: MyAssert.py:1
sphereTransformInverse
Definition: Wrapper.py:38