Peano
Loading...
Searching...
No Matches
TestSphereProjection.py
Go to the documentation of this file.
1import Wrapper
2import numpy as np
3from pyproj import Transformer
4import MyAssert
5
6# 1. Gitter in lon/lat erzeugen
7lons = np.linspace(-98, -70, 1000)
8lats = np.linspace(15, 35, 1000)
9LON, LAT = np.meshgrid(lons, lats)
10
11# 2. Albers-Projektion (WGS84 → AEA)
12proj_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)
18transformer = Transformer.from_crs(proj_str, "EPSG:4326", always_xy=True)
19
20# 3. Inverse Projektion mit deiner Funktion `Z(x, y)` → gibt vermutlich (lon, lat)
21# Wenn Z nur `lat` zurückgibt, dann:
22X = np.vectorize(lambda x, y: Wrapper.sphereTransform(x, y).first)(LON, LAT)
23Y = np.vectorize(lambda x, y: Wrapper.sphereTransform(x, y).second)(LON, LAT)
24
25lon_reconstructed, lat_reconstructed = transformer.transform(X, Y)
26
27lon_diff = lon_reconstructed - LON
29
30lat_diff = lat_reconstructed - LAT
test_array_within_threshold(arr, lower_threshold=-1e-8, upper_threshold=1e-8)
Definition MyAssert.py:1
sphereTransform
Definition Wrapper.py:37