Files
RadarSingalAnalyzer/crosslocation.py
shuibing811 d0932b7d18 ---
2025-01-24 16:11:34 +08:00

126 lines
3.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import marimo
__generated_with = "0.10.16"
app = marimo.App(width="medium")
@app.cell
def _():
import numpy as np
import matplotlib.pyplot as plt
import marimo as mo
import define
return define, mo, np, plt
@app.cell
def _(lla2ecef, np):
class Station:
def __init__(self, lat, lon, alt):
self.lla = np.array([lat, lon, alt])
self.xyz = np.array(lla2ecef(*self.lla))
class Target:
def __init__(self, lat, lon, alt):
self.lla = np.array([lat, lon, alt])
self.xyz = np.array(lla2ecef(*self.lla))
class Radar:
def __init__(self, lat, lon, alt, /, *, pri_info, rf_info, pt, gt, pw):
self.lla = np.array([lat, lon, alt])
self.xyz = np.array(lla2ecef(*self.lla))
self.pri_info = pri_info
self.rf_info = rf_info
self.pt = pt
self.gt = gt
self.pw = pw
class RadarPdw:
def __init__(self):
pass
return Radar, RadarPdw, Station, Target
@app.cell
def _(Station, Target):
stations = [Station(31.2304, 121.4737, 0), Station(31.5200, 121.6400, 0)]
targets = [
Target(31.2550, 121.4890, 0), # 目标1 陆
Target(31.2800, 121.5200, 0), # 目标2 陆
Target(31.1900, 121.4800, 0), # 目标3 陆
Target(31.2700, 121.5500, 0), # 目标4 陆
# Target(31.2000, 121.6000, 0), # 目标5 陆
Target(30.9500, 121.6500, 0), # 目标6 海
Target(30.8500, 121.7200, 0), # 目标7 海
Target(30.7800, 121.8000, 0), # 目标8 海
Target(30.9200, 121.8500, 0), # 目标9 海
Target(30.6700, 121.9000, 0), # 目标10 海
]
return stations, targets
@app.cell
def _():
return
@app.cell
def _():
import pyproj
def lla2ecef(lat,lon,alt):
"""
将经纬度高度LLA转换为地心地固坐标系ECEF坐标。
参数:
lon (float): 经度,单位为度。
lat (float): 纬度,单位为度。
alt (float): 海拔,单位为米。
返回:
tuple: 包含 ECEF 坐标 (x, y, z) 的元组,单位为米。
"""
# 定义源坐标系统WGS84 经纬度)
lla = pyproj.CRS("EPSG:4326")
# 定义目标坐标系统ECEF
ecef = pyproj.CRS("EPSG:4978")
# 创建转换器对象
transformer = pyproj.Transformer.from_crs(lla, ecef)
# 进行坐标转换
x, y, z = transformer.transform(lat, lon, alt, radians=False)
return x, y, z
def lla2enu(lat, lon, alt, lat0, lon0, alt0):
"""
将经度、纬度和高度LLA坐标转换为东 - 北 - 天ENU坐标。
参数:
lon (float): 待转换点的经度(度)
lat (float): 待转换点的纬度(度)
alt (float): 待转换点的高度(米)
lon0 (float): 参考点的经度(度)
lat0 (float): 参考点的纬度(度)
alt0 (float): 参考点的高度(米)
返回:
tuple: 包含 E、N、U坐标的元组
"""
# 定义 WGS84 经纬度坐标系统
lla = pyproj.CRS("EPSG:4326")
# 定义局部的 ENU 坐标系统
enu = pyproj.CRS.from_string(f"+proj=aeqd +lat_0={lat0} +lon_0={lon0} +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs")
# 创建坐标转换器
transformer = pyproj.Transformer.from_crs(lla, enu)
# 执行坐标转换
e, n, u = transformer.transform(lon, lat, alt)
u = u - alt0
return e, n, u
return lla2ecef, lla2enu, pyproj
if __name__ == "__main__":
app.run()