sync
This commit is contained in:
parent
df29a6229e
commit
2f0f3fe22f
@ -1,10 +1,12 @@
|
||||
import base64
|
||||
from urllib import response
|
||||
from quart import Blueprint
|
||||
from CONSTANT import DATA_BASEPATH
|
||||
import balloon.extract_wave
|
||||
import balloon.read_data
|
||||
import balloon.plot_once
|
||||
import balloon.plot_year
|
||||
from quart import jsonify, request, send_file
|
||||
from quart import jsonify, request, send_file
|
||||
from balloon.plot_once_backend import render_by_mode_single
|
||||
from balloon.plot_year_backend import get_all_modes, render_based_on_mode
|
||||
from balloon.utils import *
|
||||
@ -13,7 +15,6 @@ BASE_PATH_BALLOON = DATA_BASEPATH.balloon
|
||||
|
||||
all_year_data = pd.read_parquet(f"{BASE_PATH_BALLOON}/ballon_data_lin.parquet")
|
||||
|
||||
all_ballon_files = glob.glob(f"{BASE_PATH_BALLOON}/**/**.nc", recursive=True)
|
||||
|
||||
def get_dataframe_between_year(start_year, end_year):
|
||||
res = all_year_data
|
||||
@ -48,6 +49,9 @@ def supermeta():
|
||||
|
||||
@balloon_module.route("/metadata")
|
||||
def list_ballon():
|
||||
all_ballon_files = glob.glob(
|
||||
f"{BASE_PATH_BALLOON}/**/**.nc", recursive=True)
|
||||
|
||||
return all_ballon_files
|
||||
|
||||
|
||||
@ -55,6 +59,7 @@ def list_ballon():
|
||||
def list_ballon_year_modes():
|
||||
return get_all_modes()
|
||||
|
||||
|
||||
@balloon_module.route("/metadata/stations")
|
||||
def list_stations():
|
||||
return []
|
||||
@ -78,8 +83,17 @@ async def render_single_path():
|
||||
path = request.args.get('path')
|
||||
mode = request.args.get('mode')
|
||||
data = balloon.read_data(path)
|
||||
buff = render_by_mode_single(data, mode)
|
||||
if buff is None:
|
||||
result = render_by_mode_single(data, mode)
|
||||
if result.has_data is False:
|
||||
# give a 204 response if no data is found
|
||||
return '', 204
|
||||
return await send_file(buff, mimetype='image/png')
|
||||
img_str = base64.b64encode(result.image.getvalue()).decode("utf-8")
|
||||
|
||||
response_data = {
|
||||
"image": img_str,
|
||||
"metadata": {
|
||||
"是否是地形波": "是" if result.is_terrain_wave else "否",
|
||||
}
|
||||
}
|
||||
|
||||
return response_data
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
from dataclasses import dataclass
|
||||
from io import BytesIO
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
@ -80,8 +81,8 @@ def plot_uv_vector(u_fit, v_fit, height, specified_heights, markers):
|
||||
plt.scatter(u_fit[index], v_fit[index],
|
||||
marker=marker, s=100, label=f"{h} km")
|
||||
|
||||
plt.xlim(-8, 8)
|
||||
plt.ylim(-4, 4)
|
||||
# plt.xlim(-8, 8)
|
||||
# plt.ylim(-4, 4)
|
||||
plt.axvline(0, color="gray", linestyle="--")
|
||||
plt.axhline(0, color="gray", linestyle="--")
|
||||
plt.xlabel("Zonal Wind (m/s)")
|
||||
@ -113,8 +114,15 @@ def plot_temp_horizontal_wind(uh, T_fit, height, specified_heights, markers):
|
||||
def render_by_mode_single(data, mode):
|
||||
wave = calculate_wave(
|
||||
data[(data["alt"] >= 15) & (data["alt"] <= 25)], lat, g)
|
||||
|
||||
@dataclass
|
||||
class ReturnValue:
|
||||
image: BytesIO
|
||||
is_terrain_wave: bool
|
||||
has_data: bool
|
||||
|
||||
if len(wave) == 0:
|
||||
return None
|
||||
return ReturnValue(image=BytesIO(), is_terrain_wave=False, has_data=False)
|
||||
|
||||
c = is_terrain_wave(data, lat, g)
|
||||
a, b, omega_upper, w_f, λ_z, λ_h, c_x, c_y, c_z, Ek, E_p, MFu1, MFv1, params_u, params_v, params_T = wave[
|
||||
@ -142,4 +150,9 @@ def render_by_mode_single(data, mode):
|
||||
plt.close()
|
||||
|
||||
buff.seek(0)
|
||||
return buff
|
||||
|
||||
return ReturnValue(
|
||||
image=buff,
|
||||
is_terrain_wave=c,
|
||||
has_data=True
|
||||
)
|
||||
|
||||
506
main.py
506
main.py
@ -1,506 +0,0 @@
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow, QTableWidget, QTableWidgetItem, QHeaderView
|
||||
from PySide6.QtGui import QPixmap
|
||||
from PySide6.QtCore import Qt
|
||||
from qt import Ui_MainWindow
|
||||
from qt_material import apply_stylesheet
|
||||
import pandas as pd
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import balloon
|
||||
|
||||
|
||||
lat = 52.21
|
||||
g = 9.76
|
||||
|
||||
tag_balloon_once = [
|
||||
[
|
||||
"地形重力波",
|
||||
"垂直传播方向",
|
||||
"水平传播方向",
|
||||
"本征(固有)频率",
|
||||
"本征周期",
|
||||
"本征频率与固有频率的比值(即长短轴之比)",
|
||||
],
|
||||
[
|
||||
"垂直波长",
|
||||
"水平波长",
|
||||
"纬向本征相速度",
|
||||
"经向本征相速度",
|
||||
"垂直本征相速度",
|
||||
"波动能",
|
||||
],
|
||||
[
|
||||
"势能",
|
||||
"纬向动量通量",
|
||||
"经向动量通量",
|
||||
"纬向风扰动振幅",
|
||||
"经向风扰动振幅",
|
||||
"温度扰动振幅",
|
||||
],
|
||||
]
|
||||
|
||||
|
||||
def set_table_balloon_once(table: QTableWidget, data: list):
|
||||
for i in range(3):
|
||||
for j in range(6):
|
||||
table.setItem(i, j * 2, QTableWidgetItem(tag_balloon_once[i][j]))
|
||||
if data[0] == True:
|
||||
data[0] = "是"
|
||||
else:
|
||||
data[0] = "否"
|
||||
if data[1] == 1:
|
||||
data[1] = "上"
|
||||
else:
|
||||
data[1] = "下"
|
||||
for i in range(2, len(data)):
|
||||
data[i] = f"{data[i]} "
|
||||
data[2] += "°"
|
||||
data[3] += "rad/s"
|
||||
data[4] += "h"
|
||||
data[6] += "km"
|
||||
data[7] += "km"
|
||||
for i in [8, 9, 10, 15, 16]:
|
||||
data[i] += "m/s"
|
||||
data[11] += "J/kg"
|
||||
data[12] += "J/kg"
|
||||
data[13] += "mPa"
|
||||
data[14] += "mPa"
|
||||
data[17] += "K"
|
||||
for i in range(18):
|
||||
table.setItem(i // 6, (i % 6) * 2 + 1, QTableWidgetItem(data[i]))
|
||||
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
comboType = [
|
||||
"探空气球",
|
||||
"流星雷达",
|
||||
"Saber",
|
||||
"TIDI",
|
||||
"COSMIC",
|
||||
]
|
||||
|
||||
comboMode = [
|
||||
["重力波单次", "重力波统计"],
|
||||
["重力波月统计", "潮汐波单次", "潮汐波月统计"],
|
||||
["行星波月统计", "重力波单次", "重力波月统计"],
|
||||
["行星波月统计"],
|
||||
["行星波月统计"],
|
||||
]
|
||||
|
||||
comboDate = [
|
||||
[["年", "时间"], ["起始年", "终止年"]],
|
||||
[["年", "月"], ["年", "日期"], ["年", "月"]],
|
||||
[["起始月", "-"], ["月", "日"], ["月", "-"]],
|
||||
[["起始月", "-"]],
|
||||
[["起始月", "-"]],
|
||||
]
|
||||
|
||||
comboMap = [
|
||||
[1, 2],
|
||||
[3, 4, 5],
|
||||
[6, 7, 8],
|
||||
[9],
|
||||
[10],
|
||||
]
|
||||
|
||||
def get_date0_items(self):
|
||||
match self.dataType:
|
||||
case 0:
|
||||
try:
|
||||
self.currentDate0 = os.listdir(
|
||||
f"./data/{self.comboType[self.dataType]}/{self.dataStation}")
|
||||
except FileNotFoundError:
|
||||
return []
|
||||
return [i[-4:] for i in self.currentDate0]
|
||||
case 1:
|
||||
self.currentDate0 = ["2024"]
|
||||
return self.currentDate0
|
||||
case 2:
|
||||
try:
|
||||
self.currentDate0 = os.listdir(
|
||||
f"./data/{self.comboType[self.dataType]}/{self.dataStation}")
|
||||
except FileNotFoundError:
|
||||
return []
|
||||
return [re.search(r"_([A-z]+)\d{4}_", i).group(1) for i in self.currentDate0]
|
||||
case _:
|
||||
self.currentDate0 = ["Feb"]
|
||||
return self.currentDate0
|
||||
|
||||
def get_date1_items(self):
|
||||
if self.dataType == 0 and self.dataMode == 0:
|
||||
try:
|
||||
self.currentDate1 = os.listdir(
|
||||
f"./data/{self.comboType[self.dataType]}/{self.dataStation}/{self.currentDate0[self.dataDate0]}")
|
||||
except FileNotFoundError:
|
||||
return []
|
||||
return [re.search(r"_(\d{8}T\d{6}_\d+)", i).group(1) for i in self.currentDate1]
|
||||
elif self.dataType == 0 and self.dataMode == 1:
|
||||
return [i[-4:] for i in [end for j, end in enumerate(self.currentDate0) if j >= self.dataDate0]]
|
||||
elif self.dataType == 1 and self.dataMode == 0:
|
||||
self.currentDate1 = ["01"]
|
||||
return self.currentDate1
|
||||
elif self.dataType == 1 and self.dataMode == 1:
|
||||
self.currentDate1 = ["20240317T000000"]
|
||||
return self.currentDate1
|
||||
elif self.dataType == 1 and self.dataMode == 2:
|
||||
if self.dataStation == "黑龙江漠河":
|
||||
self.currentDate1 = ["01"]
|
||||
else:
|
||||
self.currentDate1 = ["03"]
|
||||
return self.currentDate1
|
||||
elif self.dataType == 2 and self.dataMode == 1:
|
||||
return [f"{i:02d}" for i in range(1, 31)]
|
||||
else:
|
||||
self.currentDate1 = [f"{i:02d}" for i in range(1, 13)]
|
||||
return self.currentDate1
|
||||
|
||||
def __init__(self):
|
||||
super(MainWindow, self).__init__()
|
||||
self.setupUi(self)
|
||||
|
||||
self.stackedWidget.setCurrentIndex(0)
|
||||
self.pixmap_logo = QPixmap("./data/logo.png")
|
||||
|
||||
self.dataType = -1
|
||||
self.dataMode = -1
|
||||
self.currentDate0 = []
|
||||
self.currentDate1 = []
|
||||
|
||||
self.funcMap = [
|
||||
[self.on_balloon_once_change, self.on_balloon_year_change],
|
||||
[self.on_meteor_g_change, self.on_meteor_once_change,
|
||||
self.on_meteor_month_change],
|
||||
[self.on_Saber_twice_change, self.on_Saber_g_once_change,
|
||||
self.on_Saber_g_month_change],
|
||||
[self.on_TIDI_twice_change],
|
||||
[self.on_COSMIC_twice_change],
|
||||
]
|
||||
|
||||
self.clear_combo(0)
|
||||
self.combo_type.addItems(self.comboType)
|
||||
|
||||
self.combo_type.currentTextChanged.connect(self.on_change_type)
|
||||
self.combo_mode.currentTextChanged.connect(self.on_change_mode)
|
||||
self.combo_station.currentTextChanged.connect(self.on_change_station)
|
||||
self.combo_date0.currentTextChanged.connect(self.on_change_date0)
|
||||
self.combo_date1.currentTextChanged.connect(self.on_change_date1)
|
||||
|
||||
s = self.size()
|
||||
self.resize(s.width() + 1, s.height() + 1)
|
||||
self.resize(s)
|
||||
|
||||
def resizeEvent(self, event):
|
||||
self.on_resize()
|
||||
super().resizeEvent(event)
|
||||
|
||||
def on_resize(self):
|
||||
tmp = [
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
self.label_meteor_g,
|
||||
self.label_meteor_once,
|
||||
self.label_meteor_month,
|
||||
self.label_Saber_twice,
|
||||
self.label_Saber_g_once,
|
||||
self.label_Saber_g_month,
|
||||
self.label_TIDI_twice,
|
||||
self.label_COSMIC_twice,
|
||||
]
|
||||
match self.stackedWidget.currentIndex():
|
||||
case 0:
|
||||
l = self.label_idle_logo
|
||||
p = self.pixmap_logo
|
||||
l.setPixmap(p.scaled(l.size(), Qt.KeepAspectRatio,
|
||||
Qt.SmoothTransformation))
|
||||
case 1:
|
||||
l = self.label_balloon_once
|
||||
p = self.pixmap_balloon_once
|
||||
if p.isNull():
|
||||
self.clear_pixmap()
|
||||
l.setText("无重力波")
|
||||
else:
|
||||
l.setPixmap(
|
||||
p.scaled(l.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
|
||||
case 2:
|
||||
l = self.label_balloon_year
|
||||
p = self.pixmap_balloon_year
|
||||
if p.isNull():
|
||||
self.clear_pixmap()
|
||||
l.setText("无数据")
|
||||
else:
|
||||
l.setPixmap(
|
||||
p.scaled(l.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
|
||||
case 5:
|
||||
i = self.stackedWidget.currentIndex()
|
||||
l = tmp[i]
|
||||
|
||||
if self.dataStation == "黑龙江漠河":
|
||||
p = QPixmap("./output/tmp_5_01.png")
|
||||
else:
|
||||
p = QPixmap("./output/tmp_5_03.png")
|
||||
|
||||
l.setPixmap(p.scaled(l.size(), Qt.KeepAspectRatio,
|
||||
Qt.SmoothTransformation))
|
||||
l.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
case _:
|
||||
i = self.stackedWidget.currentIndex()
|
||||
l = tmp[i]
|
||||
|
||||
p = QPixmap(f"./output/tmp_{i}.png")
|
||||
l.setPixmap(p.scaled(l.size(), Qt.KeepAspectRatio,
|
||||
Qt.SmoothTransformation))
|
||||
l.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
|
||||
def clear_pixmap(self):
|
||||
self.pixmap_balloon_once = QPixmap()
|
||||
self.pixmap_balloon_year = QPixmap()
|
||||
self.pixmap_meteor_g = QPixmap()
|
||||
self.pixmap_meteor_once = QPixmap()
|
||||
self.pixmap_meteor_month = QPixmap()
|
||||
self.pixmap_Saber_twice = QPixmap()
|
||||
self.pixmap_Saber_g_once = QPixmap()
|
||||
self.pixmap_Saber_g_month = QPixmap()
|
||||
self.pixmap_TIDI_twice = QPixmap()
|
||||
self.pixmap_COSMIC_twice = QPixmap()
|
||||
|
||||
self.table_balloon_once.setVisible(False)
|
||||
|
||||
for l in [
|
||||
self.label_balloon_once,
|
||||
self.label_balloon_year,
|
||||
self.label_meteor_g,
|
||||
self.label_meteor_once,
|
||||
self.label_meteor_month,
|
||||
self.label_Saber_twice,
|
||||
self.label_Saber_g_once,
|
||||
self.label_Saber_g_month,
|
||||
self.label_TIDI_twice,
|
||||
self.label_COSMIC_twice,
|
||||
]:
|
||||
l.setCursor(Qt.CursorShape.ArrowCursor)
|
||||
|
||||
def clear_combo(self, level: int):
|
||||
self.clear_pixmap()
|
||||
|
||||
self.on_resize()
|
||||
self.stackedWidget.setCurrentIndex(0)
|
||||
|
||||
for i, combo in enumerate(
|
||||
[
|
||||
self.combo_type,
|
||||
self.combo_mode,
|
||||
self.combo_station,
|
||||
self.combo_date0,
|
||||
self.combo_date1,
|
||||
]
|
||||
):
|
||||
if i >= level:
|
||||
combo.clear()
|
||||
combo.setEnabled(i <= level)
|
||||
|
||||
def on_change_type(self):
|
||||
if self.combo_type.currentIndex() < 0:
|
||||
return
|
||||
self.clear_combo(1)
|
||||
self.dataType = self.combo_type.currentIndex()
|
||||
self.combo_mode.addItems(self.comboMode[self.dataType])
|
||||
|
||||
self.combo_date0.setPlaceholderText("-")
|
||||
self.combo_date1.setPlaceholderText("-")
|
||||
|
||||
def on_change_mode(self):
|
||||
if self.combo_mode.currentIndex() < 0:
|
||||
return
|
||||
self.clear_combo(2)
|
||||
self.dataMode = self.combo_mode.currentIndex()
|
||||
|
||||
if self.dataType < 2:
|
||||
self.combo_station.setPlaceholderText("台站")
|
||||
else:
|
||||
self.combo_station.setPlaceholderText("年")
|
||||
list_station = []
|
||||
try:
|
||||
# list_station = [i for i in os.listdir(f"./data/{self.comboType[self.dataType]}") if i.encode("utf-8").isupper()]
|
||||
list_station = [i for i in os.listdir(
|
||||
f"./data/{self.comboType[self.dataType]}")]
|
||||
except FileNotFoundError:
|
||||
return
|
||||
self.combo_station.addItems(list_station)
|
||||
|
||||
date0, date1 = self.comboDate[self.dataType][self.dataMode]
|
||||
self.combo_date0.setPlaceholderText(date0)
|
||||
self.combo_date1.setPlaceholderText(date1)
|
||||
|
||||
def on_change_station(self):
|
||||
if self.combo_station.currentIndex() < 0:
|
||||
return
|
||||
self.clear_combo(3)
|
||||
self.dataStation = self.combo_station.currentText()
|
||||
self.combo_date0.addItems(self.get_date0_items())
|
||||
|
||||
def on_change_date0(self):
|
||||
if self.combo_date0.currentIndex() < 0:
|
||||
return
|
||||
self.clear_combo(4)
|
||||
self.dataDate0 = self.combo_date0.currentIndex()
|
||||
if self.dataType < 2 or (self.dataType == 2 and self.dataMode == 1):
|
||||
self.combo_date1.addItems(self.get_date1_items())
|
||||
return
|
||||
self.combo_date1.setEnabled(False)
|
||||
self.stackedWidget.setCurrentIndex(
|
||||
self.comboMap[self.dataType][self.dataMode])
|
||||
if f := self.funcMap[self.dataType][self.dataMode]:
|
||||
f()
|
||||
|
||||
def on_change_date1(self):
|
||||
if self.combo_date1.currentIndex() < 0:
|
||||
return
|
||||
self.dataDate1 = self.combo_date1.currentIndex()
|
||||
self.stackedWidget.setCurrentIndex(
|
||||
self.comboMap[self.dataType][self.dataMode])
|
||||
if f := self.funcMap[self.dataType][self.dataMode]:
|
||||
f()
|
||||
|
||||
def on_balloon_once_change(self):
|
||||
path = os.path.join("./data/探空气球", self.dataStation,
|
||||
self.currentDate0[self.dataDate0], self.currentDate1[self.dataDate1])
|
||||
|
||||
try:
|
||||
data = balloon.read_data(path)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return
|
||||
|
||||
path = "./output" + path[6:-2] + "png"
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
result = balloon.plot_once(data, path, lat, g)
|
||||
|
||||
if len(result) == 0:
|
||||
self.pixmap_balloon_once = QPixmap()
|
||||
self.on_resize()
|
||||
return
|
||||
|
||||
self.pixmap_balloon_once = QPixmap(path)
|
||||
self.label_balloon_once.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
|
||||
t = self.table_balloon_once
|
||||
t.clear()
|
||||
t.setRowCount(3)
|
||||
t.setColumnCount(12)
|
||||
t.setVisible(True)
|
||||
t.verticalHeader().setHidden(True)
|
||||
t.horizontalHeader().setHidden(True)
|
||||
t.verticalScrollBar().setHidden(True)
|
||||
t.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||
set_table_balloon_once(t, result)
|
||||
t.setMaximumHeight(t.rowHeight(0) * 3)
|
||||
|
||||
s = self.size()
|
||||
self.resize(s.width() + 1, s.height() + 1)
|
||||
self.resize(s)
|
||||
|
||||
def on_balloon_year_change(self):
|
||||
columns = [
|
||||
"file_name",
|
||||
"c",
|
||||
"a",
|
||||
"b",
|
||||
"omega_upper",
|
||||
"w_f",
|
||||
"ver_wave_len",
|
||||
"hori_wave_len",
|
||||
"c_x",
|
||||
"c_y",
|
||||
"c_z",
|
||||
"Ek",
|
||||
"E_p",
|
||||
"MFu",
|
||||
"MFv",
|
||||
"u1",
|
||||
"v1",
|
||||
"T1",
|
||||
"zhou_qi",
|
||||
]
|
||||
combined_df = pd.DataFrame()
|
||||
for i in range(self.dataDate1 + 1):
|
||||
path = f"./output/探空气球/{self.dataStation}/{self.currentDate0[self.dataDate0 + i]}.csv"
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
if os.path.exists(path):
|
||||
year_df = pd.read_csv(path)
|
||||
combined_df = pd.concat([combined_df, year_df])
|
||||
continue
|
||||
folder = "./data" + path[8:-4]
|
||||
year_df = pd.DataFrame()
|
||||
for file in os.listdir(folder):
|
||||
print(file)
|
||||
data = balloon.read_data(os.path.join(folder, file))
|
||||
try:
|
||||
wave = balloon.extract_wave(data, lat, g)
|
||||
except Exception:
|
||||
wave = []
|
||||
if len(wave) == 0:
|
||||
continue
|
||||
c = balloon.is_terrain_wave(data, lat, g)
|
||||
wave.insert(0, c)
|
||||
wave.insert(0, file)
|
||||
line = pd.DataFrame([wave], columns=columns)
|
||||
year_df = pd.concat([year_df, line])
|
||||
combined_df = pd.concat([combined_df, year_df])
|
||||
year_df.to_csv(path, index=False)
|
||||
path = f"./output/探空气球/{self.dataStation}/{self.currentDate0[self.dataDate0]}_{self.dataDate1}.png"
|
||||
if not balloon.plot_year(combined_df, path, lat, g):
|
||||
self.pixmap_balloon_year = QPixmap()
|
||||
self.on_resize()
|
||||
return
|
||||
|
||||
self.pixmap_balloon_year = QPixmap(path)
|
||||
self.label_balloon_year.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
|
||||
s = self.size()
|
||||
self.resize(s.width() + 1, s.height() + 1)
|
||||
self.resize(s)
|
||||
|
||||
def on_meteor_g_change(self):
|
||||
self.on_resize()
|
||||
|
||||
def on_meteor_once_change(self):
|
||||
self.on_resize()
|
||||
|
||||
def on_meteor_month_change(self):
|
||||
self.on_resize()
|
||||
|
||||
def on_Saber_twice_change(self):
|
||||
self.spin_Saber_twice_lat.setValue(0)
|
||||
self.spin_Saber_twice_alt.setValue(90)
|
||||
self.on_resize()
|
||||
|
||||
def on_Saber_g_once_change(self):
|
||||
self.spin_Saber_g_once_lat.setValue(0)
|
||||
self.spin_Saber_g_once_lon.setValue(0)
|
||||
self.spin_Saber_g_once_alt.setValue(90)
|
||||
self.on_resize()
|
||||
|
||||
def on_Saber_g_month_change(self):
|
||||
self.spin_Saber_g_month_lat.setValue(0)
|
||||
self.spin_Saber_g_month_alt.setValue(90)
|
||||
self.on_resize()
|
||||
|
||||
def on_TIDI_twice_change(self):
|
||||
self.spin_TIDI_twice_lat.setValue(0)
|
||||
self.spin_TIDI_twice_alt.setValue(90)
|
||||
self.on_resize()
|
||||
|
||||
def on_COSMIC_twice_change(self):
|
||||
self.spin_COSMIC_twice_lat.setValue(0)
|
||||
self.spin_COSMIC_twice_alt.setValue(40)
|
||||
self.on_resize()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
window = MainWindow()
|
||||
apply_stylesheet(app, theme="light_blue.xml", invert_secondary=True)
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
616
qt.py
616
qt.py
@ -1,616 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
################################################################################
|
||||
# Form generated from reading UI file 'qt.ui'
|
||||
##
|
||||
# Created by: Qt User Interface Compiler version 6.8.0
|
||||
##
|
||||
# WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
|
||||
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||
QMetaObject, QObject, QPoint, QRect,
|
||||
QSize, QTime, QUrl, Qt)
|
||||
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QApplication, QComboBox, QHBoxLayout, QHeaderView,
|
||||
QLabel, QMainWindow, QPushButton, QSizePolicy,
|
||||
QSpinBox, QStackedWidget, QStatusBar, QTableWidget,
|
||||
QTableWidgetItem, QVBoxLayout, QWidget)
|
||||
|
||||
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
if not MainWindow.objectName():
|
||||
MainWindow.setObjectName(u"MainWindow")
|
||||
MainWindow.resize(800, 600)
|
||||
MainWindow.setMinimumSize(QSize(800, 600))
|
||||
self.centralwidget = QWidget(MainWindow)
|
||||
self.centralwidget.setObjectName(u"centralwidget")
|
||||
self.verticalLayout = QVBoxLayout(self.centralwidget)
|
||||
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||
self.horizontalLayout = QHBoxLayout()
|
||||
self.horizontalLayout.setObjectName(u"horizontalLayout")
|
||||
self.combo_type = QComboBox(self.centralwidget)
|
||||
self.combo_type.setObjectName(u"combo_type")
|
||||
sizePolicy = QSizePolicy(
|
||||
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Maximum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(
|
||||
self.combo_type.sizePolicy().hasHeightForWidth())
|
||||
self.combo_type.setSizePolicy(sizePolicy)
|
||||
|
||||
self.horizontalLayout.addWidget(self.combo_type)
|
||||
|
||||
self.combo_mode = QComboBox(self.centralwidget)
|
||||
self.combo_mode.setObjectName(u"combo_mode")
|
||||
sizePolicy.setHeightForWidth(
|
||||
self.combo_mode.sizePolicy().hasHeightForWidth())
|
||||
self.combo_mode.setSizePolicy(sizePolicy)
|
||||
|
||||
self.horizontalLayout.addWidget(self.combo_mode)
|
||||
|
||||
self.combo_station = QComboBox(self.centralwidget)
|
||||
self.combo_station.setObjectName(u"combo_station")
|
||||
sizePolicy.setHeightForWidth(
|
||||
self.combo_station.sizePolicy().hasHeightForWidth())
|
||||
self.combo_station.setSizePolicy(sizePolicy)
|
||||
|
||||
self.horizontalLayout.addWidget(self.combo_station)
|
||||
|
||||
self.combo_date0 = QComboBox(self.centralwidget)
|
||||
self.combo_date0.setObjectName(u"combo_date0")
|
||||
sizePolicy.setHeightForWidth(
|
||||
self.combo_date0.sizePolicy().hasHeightForWidth())
|
||||
self.combo_date0.setSizePolicy(sizePolicy)
|
||||
|
||||
self.horizontalLayout.addWidget(self.combo_date0)
|
||||
|
||||
self.combo_date1 = QComboBox(self.centralwidget)
|
||||
self.combo_date1.setObjectName(u"combo_date1")
|
||||
sizePolicy.setHeightForWidth(
|
||||
self.combo_date1.sizePolicy().hasHeightForWidth())
|
||||
self.combo_date1.setSizePolicy(sizePolicy)
|
||||
|
||||
self.horizontalLayout.addWidget(self.combo_date1)
|
||||
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
|
||||
self.stackedWidget = QStackedWidget(self.centralwidget)
|
||||
self.stackedWidget.setObjectName(u"stackedWidget")
|
||||
self.page_idle = QWidget()
|
||||
self.page_idle.setObjectName(u"page_idle")
|
||||
self.verticalLayout_0 = QVBoxLayout(self.page_idle)
|
||||
self.verticalLayout_0.setObjectName(u"verticalLayout_0")
|
||||
self.label_idle_logo = QLabel(self.page_idle)
|
||||
self.label_idle_logo.setObjectName(u"label_idle_logo")
|
||||
sizePolicy1 = QSizePolicy(
|
||||
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||
sizePolicy1.setHorizontalStretch(0)
|
||||
sizePolicy1.setVerticalStretch(0)
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_idle_logo.sizePolicy().hasHeightForWidth())
|
||||
self.label_idle_logo.setSizePolicy(sizePolicy1)
|
||||
font = QFont()
|
||||
font.setPointSize(40)
|
||||
self.label_idle_logo.setFont(font)
|
||||
self.label_idle_logo.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_0.addWidget(self.label_idle_logo)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_idle)
|
||||
self.page_balloon_once = QWidget()
|
||||
self.page_balloon_once.setObjectName(u"page_balloon_once")
|
||||
self.verticalLayout_1 = QVBoxLayout(self.page_balloon_once)
|
||||
self.verticalLayout_1.setObjectName(u"verticalLayout_1")
|
||||
self.table_balloon_once = QTableWidget(self.page_balloon_once)
|
||||
self.table_balloon_once.setObjectName(u"table_balloon_once")
|
||||
sizePolicy2 = QSizePolicy(
|
||||
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
|
||||
sizePolicy2.setHorizontalStretch(0)
|
||||
sizePolicy2.setVerticalStretch(0)
|
||||
sizePolicy2.setHeightForWidth(
|
||||
self.table_balloon_once.sizePolicy().hasHeightForWidth())
|
||||
self.table_balloon_once.setSizePolicy(sizePolicy2)
|
||||
|
||||
self.verticalLayout_1.addWidget(self.table_balloon_once)
|
||||
|
||||
self.label_balloon_once = QLabel(self.page_balloon_once)
|
||||
self.label_balloon_once.setObjectName(u"label_balloon_once")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_balloon_once.sizePolicy().hasHeightForWidth())
|
||||
self.label_balloon_once.setSizePolicy(sizePolicy1)
|
||||
self.label_balloon_once.setMinimumSize(QSize(0, 0))
|
||||
self.label_balloon_once.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_1.addWidget(self.label_balloon_once)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_balloon_once)
|
||||
self.page_balloon_year = QWidget()
|
||||
self.page_balloon_year.setObjectName(u"page_balloon_year")
|
||||
self.verticalLayout_2 = QVBoxLayout(self.page_balloon_year)
|
||||
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
|
||||
self.label_balloon_year = QLabel(self.page_balloon_year)
|
||||
self.label_balloon_year.setObjectName(u"label_balloon_year")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_balloon_year.sizePolicy().hasHeightForWidth())
|
||||
self.label_balloon_year.setSizePolicy(sizePolicy1)
|
||||
self.label_balloon_year.setMinimumSize(QSize(0, 0))
|
||||
self.label_balloon_year.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_2.addWidget(self.label_balloon_year)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_balloon_year)
|
||||
self.page_meteor_g = QWidget()
|
||||
self.page_meteor_g.setObjectName(u"page_meteor_g")
|
||||
self.verticalLayout_3 = QVBoxLayout(self.page_meteor_g)
|
||||
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
|
||||
self.label_meteor_g = QLabel(self.page_meteor_g)
|
||||
self.label_meteor_g.setObjectName(u"label_meteor_g")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_meteor_g.sizePolicy().hasHeightForWidth())
|
||||
self.label_meteor_g.setSizePolicy(sizePolicy1)
|
||||
self.label_meteor_g.setMinimumSize(QSize(0, 0))
|
||||
self.label_meteor_g.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_3.addWidget(self.label_meteor_g)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_meteor_g)
|
||||
self.page_meteor_once = QWidget()
|
||||
self.page_meteor_once.setObjectName(u"page_meteor_once")
|
||||
self.verticalLayout_4 = QVBoxLayout(self.page_meteor_once)
|
||||
self.verticalLayout_4.setObjectName(u"verticalLayout_4")
|
||||
self.label_meteor_once = QLabel(self.page_meteor_once)
|
||||
self.label_meteor_once.setObjectName(u"label_meteor_once")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_meteor_once.sizePolicy().hasHeightForWidth())
|
||||
self.label_meteor_once.setSizePolicy(sizePolicy1)
|
||||
self.label_meteor_once.setMinimumSize(QSize(0, 0))
|
||||
self.label_meteor_once.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_4.addWidget(self.label_meteor_once)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_meteor_once)
|
||||
self.page_meteor_month = QWidget()
|
||||
self.page_meteor_month.setObjectName(u"page_meteor_month")
|
||||
self.verticalLayout_5 = QVBoxLayout(self.page_meteor_month)
|
||||
self.verticalLayout_5.setObjectName(u"verticalLayout_5")
|
||||
self.label_meteor_month = QLabel(self.page_meteor_month)
|
||||
self.label_meteor_month.setObjectName(u"label_meteor_month")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_meteor_month.sizePolicy().hasHeightForWidth())
|
||||
self.label_meteor_month.setSizePolicy(sizePolicy1)
|
||||
self.label_meteor_month.setMinimumSize(QSize(0, 0))
|
||||
self.label_meteor_month.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_5.addWidget(self.label_meteor_month)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_meteor_month)
|
||||
self.page_Saber_twice = QWidget()
|
||||
self.page_Saber_twice.setObjectName(u"page_Saber_twice")
|
||||
self.verticalLayout_6 = QVBoxLayout(self.page_Saber_twice)
|
||||
self.verticalLayout_6.setObjectName(u"verticalLayout_6")
|
||||
self.horizontalLayout_6 = QHBoxLayout()
|
||||
self.horizontalLayout_6.setObjectName(u"horizontalLayout_6")
|
||||
self.label_Saber_twice_lat = QLabel(self.page_Saber_twice)
|
||||
self.label_Saber_twice_lat.setObjectName(u"label_Saber_twice_lat")
|
||||
sizePolicy3 = QSizePolicy(
|
||||
QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Preferred)
|
||||
sizePolicy3.setHorizontalStretch(0)
|
||||
sizePolicy3.setVerticalStretch(0)
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_Saber_twice_lat.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_twice_lat.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_6.addWidget(self.label_Saber_twice_lat)
|
||||
|
||||
self.spin_Saber_twice_lat = QSpinBox(self.page_Saber_twice)
|
||||
self.spin_Saber_twice_lat.setObjectName(u"spin_Saber_twice_lat")
|
||||
self.spin_Saber_twice_lat.setMaximum(80)
|
||||
self.spin_Saber_twice_lat.setMinimum(-80)
|
||||
self.spin_Saber_twice_lat.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_6.addWidget(self.spin_Saber_twice_lat)
|
||||
|
||||
self.label_Saber_twice_alt = QLabel(self.page_Saber_twice)
|
||||
self.label_Saber_twice_alt.setObjectName(u"label_Saber_twice_alt")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_Saber_twice_alt.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_twice_alt.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_6.addWidget(self.label_Saber_twice_alt)
|
||||
|
||||
self.spin_Saber_twice_alt = QSpinBox(self.page_Saber_twice)
|
||||
self.spin_Saber_twice_alt.setObjectName(u"spin_Saber_twice_alt")
|
||||
self.spin_Saber_twice_alt.setMaximum(100)
|
||||
self.spin_Saber_twice_alt.setMinimum(25)
|
||||
self.spin_Saber_twice_alt.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_6.addWidget(self.spin_Saber_twice_alt)
|
||||
|
||||
self.button_Saber_twice = QPushButton(self.page_Saber_twice)
|
||||
self.button_Saber_twice.setObjectName(u"button_Saber_twice")
|
||||
sizePolicy4 = QSizePolicy(
|
||||
QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Fixed)
|
||||
sizePolicy4.setHorizontalStretch(0)
|
||||
sizePolicy4.setVerticalStretch(0)
|
||||
sizePolicy4.setHeightForWidth(
|
||||
self.button_Saber_twice.sizePolicy().hasHeightForWidth())
|
||||
self.button_Saber_twice.setSizePolicy(sizePolicy4)
|
||||
|
||||
self.horizontalLayout_6.addWidget(self.button_Saber_twice)
|
||||
|
||||
self.verticalLayout_6.addLayout(self.horizontalLayout_6)
|
||||
|
||||
self.label_Saber_twice = QLabel(self.page_Saber_twice)
|
||||
self.label_Saber_twice.setObjectName(u"label_Saber_twice")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_Saber_twice.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_twice.setSizePolicy(sizePolicy1)
|
||||
self.label_Saber_twice.setMinimumSize(QSize(0, 0))
|
||||
self.label_Saber_twice.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_6.addWidget(self.label_Saber_twice)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_Saber_twice)
|
||||
self.page_Saber_g_once = QWidget()
|
||||
self.page_Saber_g_once.setObjectName(u"page_Saber_g_once")
|
||||
self.verticalLayout_7 = QVBoxLayout(self.page_Saber_g_once)
|
||||
self.verticalLayout_7.setObjectName(u"verticalLayout_7")
|
||||
self.horizontalLayout_7 = QHBoxLayout()
|
||||
self.horizontalLayout_7.setObjectName(u"horizontalLayout_7")
|
||||
self.label_Saber_g_once_lat = QLabel(self.page_Saber_g_once)
|
||||
self.label_Saber_g_once_lat.setObjectName(u"label_Saber_g_once_lat")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_Saber_g_once_lat.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_g_once_lat.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.label_Saber_g_once_lat)
|
||||
|
||||
self.spin_Saber_g_once_lat = QSpinBox(self.page_Saber_g_once)
|
||||
self.spin_Saber_g_once_lat.setObjectName(u"spin_Saber_g_once_lat")
|
||||
self.spin_Saber_g_once_lat.setMaximum(80)
|
||||
self.spin_Saber_g_once_lat.setMinimum(-80)
|
||||
self.spin_Saber_g_once_lat.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.spin_Saber_g_once_lat)
|
||||
|
||||
self.label_Saber_g_once_lon = QLabel(self.page_Saber_g_once)
|
||||
self.label_Saber_g_once_lon.setObjectName(u"label_Saber_g_once_lon")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_Saber_g_once_lon.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_g_once_lon.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.label_Saber_g_once_lon)
|
||||
|
||||
self.spin_Saber_g_once_lon = QSpinBox(self.page_Saber_g_once)
|
||||
self.spin_Saber_g_once_lon.setObjectName(u"spin_Saber_g_once_lon")
|
||||
self.spin_Saber_g_once_lon.setMaximum(180)
|
||||
self.spin_Saber_g_once_lon.setMinimum(-180)
|
||||
self.spin_Saber_g_once_lon.setSingleStep(25)
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.spin_Saber_g_once_lon)
|
||||
|
||||
self.label_Saber_g_once_alt = QLabel(self.page_Saber_g_once)
|
||||
self.label_Saber_g_once_alt.setObjectName(u"label_Saber_g_once_alt")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_Saber_g_once_alt.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_g_once_alt.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.label_Saber_g_once_alt)
|
||||
|
||||
self.spin_Saber_g_once_alt = QSpinBox(self.page_Saber_g_once)
|
||||
self.spin_Saber_g_once_alt.setObjectName(u"spin_Saber_g_once_alt")
|
||||
self.spin_Saber_g_once_alt.setMaximum(100)
|
||||
self.spin_Saber_g_once_alt.setMinimum(25)
|
||||
self.spin_Saber_g_once_alt.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.spin_Saber_g_once_alt)
|
||||
|
||||
self.button_Saber_g_once = QPushButton(self.page_Saber_g_once)
|
||||
self.button_Saber_g_once.setObjectName(u"button_Saber_g_once")
|
||||
sizePolicy4.setHeightForWidth(
|
||||
self.button_Saber_g_once.sizePolicy().hasHeightForWidth())
|
||||
self.button_Saber_g_once.setSizePolicy(sizePolicy4)
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.button_Saber_g_once)
|
||||
|
||||
self.verticalLayout_7.addLayout(self.horizontalLayout_7)
|
||||
|
||||
self.label_Saber_g_once = QLabel(self.page_Saber_g_once)
|
||||
self.label_Saber_g_once.setObjectName(u"label_Saber_g_once")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_Saber_g_once.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_g_once.setSizePolicy(sizePolicy1)
|
||||
self.label_Saber_g_once.setMinimumSize(QSize(0, 0))
|
||||
self.label_Saber_g_once.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_7.addWidget(self.label_Saber_g_once)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_Saber_g_once)
|
||||
self.page_Saber_g_month = QWidget()
|
||||
self.page_Saber_g_month.setObjectName(u"page_Saber_g_month")
|
||||
self.verticalLayout_8 = QVBoxLayout(self.page_Saber_g_month)
|
||||
self.verticalLayout_8.setObjectName(u"verticalLayout_8")
|
||||
self.horizontalLayout_8 = QHBoxLayout()
|
||||
self.horizontalLayout_8.setObjectName(u"horizontalLayout_8")
|
||||
self.label_Saber_g_month_lat = QLabel(self.page_Saber_g_month)
|
||||
self.label_Saber_g_month_lat.setObjectName(u"label_Saber_g_month_lat")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_Saber_g_month_lat.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_g_month_lat.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_8.addWidget(self.label_Saber_g_month_lat)
|
||||
|
||||
self.spin_Saber_g_month_lat = QSpinBox(self.page_Saber_g_month)
|
||||
self.spin_Saber_g_month_lat.setObjectName(u"spin_Saber_g_month_lat")
|
||||
self.spin_Saber_g_month_lat.setMaximum(80)
|
||||
self.spin_Saber_g_month_lat.setMinimum(-80)
|
||||
self.spin_Saber_g_month_lat.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_8.addWidget(self.spin_Saber_g_month_lat)
|
||||
|
||||
self.label_Saber_g_month_alt = QLabel(self.page_Saber_g_month)
|
||||
self.label_Saber_g_month_alt.setObjectName(u"label_Saber_g_month_alt")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_Saber_g_month_alt.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_g_month_alt.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_8.addWidget(self.label_Saber_g_month_alt)
|
||||
|
||||
self.spin_Saber_g_month_alt = QSpinBox(self.page_Saber_g_month)
|
||||
self.spin_Saber_g_month_alt.setObjectName(u"spin_Saber_g_month_alt")
|
||||
self.spin_Saber_g_month_alt.setMaximum(100)
|
||||
self.spin_Saber_g_month_alt.setMinimum(25)
|
||||
self.spin_Saber_g_month_alt.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_8.addWidget(self.spin_Saber_g_month_alt)
|
||||
|
||||
self.button_Saber_g_month = QPushButton(self.page_Saber_g_month)
|
||||
self.button_Saber_g_month.setObjectName(u"button_Saber_g_month")
|
||||
sizePolicy4.setHeightForWidth(
|
||||
self.button_Saber_g_month.sizePolicy().hasHeightForWidth())
|
||||
self.button_Saber_g_month.setSizePolicy(sizePolicy4)
|
||||
|
||||
self.horizontalLayout_8.addWidget(self.button_Saber_g_month)
|
||||
|
||||
self.verticalLayout_8.addLayout(self.horizontalLayout_8)
|
||||
|
||||
self.label_Saber_g_month = QLabel(self.page_Saber_g_month)
|
||||
self.label_Saber_g_month.setObjectName(u"label_Saber_g_month")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_Saber_g_month.sizePolicy().hasHeightForWidth())
|
||||
self.label_Saber_g_month.setSizePolicy(sizePolicy1)
|
||||
self.label_Saber_g_month.setMinimumSize(QSize(0, 0))
|
||||
self.label_Saber_g_month.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_8.addWidget(self.label_Saber_g_month)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_Saber_g_month)
|
||||
self.page_TIDI_twice = QWidget()
|
||||
self.page_TIDI_twice.setObjectName(u"page_TIDI_twice")
|
||||
self.verticalLayout_9 = QVBoxLayout(self.page_TIDI_twice)
|
||||
self.verticalLayout_9.setObjectName(u"verticalLayout_9")
|
||||
self.horizontalLayout_9 = QHBoxLayout()
|
||||
self.horizontalLayout_9.setObjectName(u"horizontalLayout_9")
|
||||
self.label_TIDI_twice_lat = QLabel(self.page_TIDI_twice)
|
||||
self.label_TIDI_twice_lat.setObjectName(u"label_TIDI_twice_lat")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_TIDI_twice_lat.sizePolicy().hasHeightForWidth())
|
||||
self.label_TIDI_twice_lat.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_9.addWidget(self.label_TIDI_twice_lat)
|
||||
|
||||
self.spin_TIDI_twice_lat = QSpinBox(self.page_TIDI_twice)
|
||||
self.spin_TIDI_twice_lat.setObjectName(u"spin_TIDI_twice_lat")
|
||||
self.spin_TIDI_twice_lat.setMaximum(80)
|
||||
self.spin_TIDI_twice_lat.setMinimum(-80)
|
||||
self.spin_TIDI_twice_lat.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_9.addWidget(self.spin_TIDI_twice_lat)
|
||||
|
||||
self.label_TIDI_twice_alt = QLabel(self.page_TIDI_twice)
|
||||
self.label_TIDI_twice_alt.setObjectName(u"label_TIDI_twice_alt")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_TIDI_twice_alt.sizePolicy().hasHeightForWidth())
|
||||
self.label_TIDI_twice_alt.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_9.addWidget(self.label_TIDI_twice_alt)
|
||||
|
||||
self.spin_TIDI_twice_alt = QSpinBox(self.page_TIDI_twice)
|
||||
self.spin_TIDI_twice_alt.setObjectName(u"spin_TIDI_twice_alt")
|
||||
self.spin_TIDI_twice_alt.setMaximum(100)
|
||||
self.spin_TIDI_twice_alt.setMinimum(25)
|
||||
self.spin_TIDI_twice_alt.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_9.addWidget(self.spin_TIDI_twice_alt)
|
||||
|
||||
self.button_TIDI_twice = QPushButton(self.page_TIDI_twice)
|
||||
self.button_TIDI_twice.setObjectName(u"button_TIDI_twice")
|
||||
sizePolicy4.setHeightForWidth(
|
||||
self.button_TIDI_twice.sizePolicy().hasHeightForWidth())
|
||||
self.button_TIDI_twice.setSizePolicy(sizePolicy4)
|
||||
|
||||
self.horizontalLayout_9.addWidget(self.button_TIDI_twice)
|
||||
|
||||
self.verticalLayout_9.addLayout(self.horizontalLayout_9)
|
||||
|
||||
self.label_TIDI_twice = QLabel(self.page_TIDI_twice)
|
||||
self.label_TIDI_twice.setObjectName(u"label_TIDI_twice")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_TIDI_twice.sizePolicy().hasHeightForWidth())
|
||||
self.label_TIDI_twice.setSizePolicy(sizePolicy1)
|
||||
self.label_TIDI_twice.setMinimumSize(QSize(0, 0))
|
||||
self.label_TIDI_twice.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_9.addWidget(self.label_TIDI_twice)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_TIDI_twice)
|
||||
self.page_COSMIC_twice = QWidget()
|
||||
self.page_COSMIC_twice.setObjectName(u"page_COSMIC_twice")
|
||||
self.verticalLayout_10 = QVBoxLayout(self.page_COSMIC_twice)
|
||||
self.verticalLayout_10.setObjectName(u"verticalLayout_10")
|
||||
self.horizontalLayout_10 = QHBoxLayout()
|
||||
self.horizontalLayout_10.setObjectName(u"horizontalLayout_10")
|
||||
self.label_COSMIC_twice_lat = QLabel(self.page_COSMIC_twice)
|
||||
self.label_COSMIC_twice_lat.setObjectName(u"label_COSMIC_twice_lat")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_COSMIC_twice_lat.sizePolicy().hasHeightForWidth())
|
||||
self.label_COSMIC_twice_lat.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_10.addWidget(self.label_COSMIC_twice_lat)
|
||||
|
||||
self.spin_COSMIC_twice_lat = QSpinBox(self.page_COSMIC_twice)
|
||||
self.spin_COSMIC_twice_lat.setObjectName(u"spin_COSMIC_twice_lat")
|
||||
self.spin_COSMIC_twice_lat.setMaximum(60)
|
||||
self.spin_COSMIC_twice_lat.setMinimum(-60)
|
||||
self.spin_COSMIC_twice_lat.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_10.addWidget(self.spin_COSMIC_twice_lat)
|
||||
|
||||
self.label_COSMIC_twice_alt = QLabel(self.page_COSMIC_twice)
|
||||
self.label_COSMIC_twice_alt.setObjectName(u"label_COSMIC_twice_alt")
|
||||
sizePolicy3.setHeightForWidth(
|
||||
self.label_COSMIC_twice_alt.sizePolicy().hasHeightForWidth())
|
||||
self.label_COSMIC_twice_alt.setSizePolicy(sizePolicy3)
|
||||
|
||||
self.horizontalLayout_10.addWidget(self.label_COSMIC_twice_alt)
|
||||
|
||||
self.spin_COSMIC_twice_alt = QSpinBox(self.page_COSMIC_twice)
|
||||
self.spin_COSMIC_twice_alt.setObjectName(u"spin_COSMIC_twice_alt")
|
||||
self.spin_COSMIC_twice_alt.setMaximum(100)
|
||||
self.spin_COSMIC_twice_alt.setMinimum(75)
|
||||
self.spin_COSMIC_twice_alt.setSingleStep(5)
|
||||
|
||||
self.horizontalLayout_10.addWidget(self.spin_COSMIC_twice_alt)
|
||||
|
||||
self.button_COSMIC_twice = QPushButton(self.page_COSMIC_twice)
|
||||
self.button_COSMIC_twice.setObjectName(u"button_COSMIC_twice")
|
||||
sizePolicy4.setHeightForWidth(
|
||||
self.button_COSMIC_twice.sizePolicy().hasHeightForWidth())
|
||||
self.button_COSMIC_twice.setSizePolicy(sizePolicy4)
|
||||
|
||||
self.horizontalLayout_10.addWidget(self.button_COSMIC_twice)
|
||||
|
||||
self.verticalLayout_10.addLayout(self.horizontalLayout_10)
|
||||
|
||||
self.label_COSMIC_twice = QLabel(self.page_COSMIC_twice)
|
||||
self.label_COSMIC_twice.setObjectName(u"label_COSMIC_twice")
|
||||
sizePolicy1.setHeightForWidth(
|
||||
self.label_COSMIC_twice.sizePolicy().hasHeightForWidth())
|
||||
self.label_COSMIC_twice.setSizePolicy(sizePolicy1)
|
||||
self.label_COSMIC_twice.setMinimumSize(QSize(0, 0))
|
||||
self.label_COSMIC_twice.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout_10.addWidget(self.label_COSMIC_twice)
|
||||
|
||||
self.stackedWidget.addWidget(self.page_COSMIC_twice)
|
||||
|
||||
self.verticalLayout.addWidget(self.stackedWidget)
|
||||
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.statusbar = QStatusBar(MainWindow)
|
||||
self.statusbar.setObjectName(u"statusbar")
|
||||
MainWindow.setStatusBar(self.statusbar)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
|
||||
self.stackedWidget.setCurrentIndex(6)
|
||||
|
||||
QMetaObject.connectSlotsByName(MainWindow)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
MainWindow.setWindowTitle(QCoreApplication.translate(
|
||||
"MainWindow", u"\u4e2d\u9ad8\u5c42\u5927\u6c14\u6ce2\u52a8\u89e3\u6790\u8bc6\u522b\u6280\u672f\u7cfb\u7edf", None))
|
||||
self.combo_type.setCurrentText("")
|
||||
self.combo_type.setPlaceholderText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u89c2\u6d4b\u8bbe\u5907", None))
|
||||
self.combo_mode.setPlaceholderText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u5904\u7406\u6a21\u5f0f", None))
|
||||
self.combo_station.setPlaceholderText(
|
||||
QCoreApplication.translate("MainWindow", u"\u53f0\u7ad9", None))
|
||||
self.combo_date0.setPlaceholderText(
|
||||
QCoreApplication.translate("MainWindow", u"-", None))
|
||||
self.combo_date1.setPlaceholderText(
|
||||
QCoreApplication.translate("MainWindow", u"-", None))
|
||||
self.label_idle_logo.setText(
|
||||
QCoreApplication.translate("MainWindow", u"logo", None))
|
||||
self.label_balloon_once.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
self.label_balloon_year.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
self.label_meteor_g.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
self.label_meteor_once.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
self.label_meteor_month.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
self.label_Saber_twice_lat.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u7eac\u5ea6\uff1a", None))
|
||||
self.spin_Saber_twice_lat.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" \u00b0", None))
|
||||
self.label_Saber_twice_alt.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u9ad8\u5ea6\uff1a", None))
|
||||
self.spin_Saber_twice_alt.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" km", None))
|
||||
self.button_Saber_twice.setText(
|
||||
QCoreApplication.translate("MainWindow", u"\u66f4\u65b0", None))
|
||||
self.label_Saber_twice.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
self.label_Saber_g_once_lat.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u7eac\u5ea6\u5e26\u8d77\u70b9\uff1a", None))
|
||||
self.spin_Saber_g_once_lat.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" \u00b0", None))
|
||||
self.label_Saber_g_once_lon.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u7ecf\u5ea6\u5e26\u8d77\u70b9\uff1a", None))
|
||||
self.spin_Saber_g_once_lon.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" \u00b0", None))
|
||||
self.label_Saber_g_once_alt.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u9ad8\u5ea6\uff1a", None))
|
||||
self.spin_Saber_g_once_alt.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" km", None))
|
||||
self.button_Saber_g_once.setText(
|
||||
QCoreApplication.translate("MainWindow", u"\u66f4\u65b0", None))
|
||||
self.label_Saber_g_once.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
self.label_Saber_g_month_lat.setText(
|
||||
QCoreApplication.translate("MainWindow", u"\u7eac\u5ea6\uff1a", None))
|
||||
self.spin_Saber_g_month_lat.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" \u00b0", None))
|
||||
self.label_Saber_g_month_alt.setText(
|
||||
QCoreApplication.translate("MainWindow", u"\u9ad8\u5ea6\uff1a", None))
|
||||
self.spin_Saber_g_month_alt.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" km", None))
|
||||
self.button_Saber_g_month.setText(
|
||||
QCoreApplication.translate("MainWindow", u"\u66f4\u65b0", None))
|
||||
self.label_Saber_g_month.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
self.label_TIDI_twice_lat.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u7eac\u5ea6\uff1a", None))
|
||||
self.spin_TIDI_twice_lat.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" \u00b0", None))
|
||||
self.label_TIDI_twice_alt.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u9ad8\u5ea6\uff1a", None))
|
||||
self.spin_TIDI_twice_alt.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" km", None))
|
||||
self.button_TIDI_twice.setText(
|
||||
QCoreApplication.translate("MainWindow", u"\u66f4\u65b0", None))
|
||||
self.label_TIDI_twice.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
self.label_COSMIC_twice_lat.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u7eac\u5ea6\uff1a", None))
|
||||
self.spin_COSMIC_twice_lat.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" \u00b0", None))
|
||||
self.label_COSMIC_twice_alt.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u9ad8\u5ea6\uff1a", None))
|
||||
self.spin_COSMIC_twice_alt.setSuffix(
|
||||
QCoreApplication.translate("MainWindow", u" km", None))
|
||||
self.button_COSMIC_twice.setText(
|
||||
QCoreApplication.translate("MainWindow", u"\u66f4\u65b0", None))
|
||||
self.label_COSMIC_twice.setText(QCoreApplication.translate(
|
||||
"MainWindow", u"\u65e0\u6570\u636e", None))
|
||||
# retranslateUi
|
||||
117
saber/archive/gravity_plot.py
Normal file
117
saber/archive/gravity_plot.py
Normal file
@ -0,0 +1,117 @@
|
||||
# 此代码是对数据处理后的txt数据进行行星波参数提取绘图
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
from scipy.optimize import curve_fit
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# 解决绘图中中文不能显示的问题
|
||||
import matplotlib
|
||||
# 设置中文显示和负号正常显示
|
||||
matplotlib.rcParams['font.sans-serif'] = ['SimHei'] # 显示中文
|
||||
matplotlib.rcParams['axes.unicode_minus'] = False # 正常显示负号
|
||||
# 读取一年的数据文件
|
||||
df = pd.read_csv(r'C:\pythonProject3\combined_data.txt', sep='\s+')
|
||||
|
||||
# 设置初始参数
|
||||
# initial_guess = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0] # v0, a1, b1, a2, b2, a3, b3
|
||||
initial_guess = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
|
||||
0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5] # 9个 a 和 9个 b 参数
|
||||
|
||||
# 设置参数界限
|
||||
bounds = (
|
||||
[0, -np.inf, 0, -np.inf, 0, -np.inf, 0, -np.inf, 0, -np.inf,
|
||||
0, -np.inf, 0, -np.inf, 0, -np.inf, 0, -np.inf], # 下界
|
||||
[np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf,
|
||||
np.inf, np.inf, np.inf]) # 上界
|
||||
|
||||
|
||||
# 定义拟合函数
|
||||
def u_func(x, *params):
|
||||
a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, a8, b8, a9, b9 = params
|
||||
return (
|
||||
a1 * np.sin((2 * np.pi / T) * t - 4 * x + b1)
|
||||
+ a2 * np.sin((2 * np.pi / T) * t - 3 * x + b2)
|
||||
+ a3 * np.sin((2 * np.pi / T) * t - 2 * x + b3)
|
||||
+ a4 * np.sin((2 * np.pi / T) * t - x + b4)
|
||||
+ a5 * np.sin((2 * np.pi / T) * t + b5)
|
||||
+ a6 * np.sin((2 * np.pi / T) * t + x + b6)
|
||||
+ a7 * np.sin((2 * np.pi / T) * t + 2 * x + b7)
|
||||
+ a8 * np.sin((2 * np.pi / T) * t + 3 * x + b8)
|
||||
+ a9 * np.sin((2 * np.pi / T) * t + 4 * x + b9)
|
||||
)
|
||||
|
||||
|
||||
# 用于存储拟合参数结果的列表
|
||||
all_fit_results = []
|
||||
|
||||
# 设置最小数据量的阈值
|
||||
min_data_points = 36
|
||||
|
||||
# 进行多个时间窗口的拟合
|
||||
# T应该取5、10、16
|
||||
|
||||
T = 16 # 设置 T,可以动态调整
|
||||
for start_day in range(0, 365-3*T): # 最后一个窗口为[351, 366]
|
||||
end_day = start_day + 3 * T # 每个窗口的结束时间为 start_day + 3*T
|
||||
|
||||
# 选择当前窗口的数据
|
||||
df_8 = df[(df['Time'] >= start_day) & (df['Time'] <= end_day)]
|
||||
|
||||
# 检查当前窗口的数据量
|
||||
if len(df_8) < min_data_points:
|
||||
# 输出数据量不足的警告
|
||||
print(f"数据量不足,无法拟合:{start_day} 到 {end_day},数据点数量:{len(df_8)}")
|
||||
# 将拟合参数设置为 NaN
|
||||
all_fit_results.append([np.nan] * 18)
|
||||
continue # 跳过当前时间窗口,继续下一个窗口
|
||||
|
||||
# 提取时间、经度、温度数据
|
||||
t = np.array(df_8['Time']) # 时间
|
||||
x = np.array(df_8['Longitude_Radians']) # 经度弧度制
|
||||
temperature = np.array(df_8['Temperature']) # 温度,因变量
|
||||
|
||||
# 用T进行拟合
|
||||
popt, pcov = curve_fit(u_func, x, temperature,
|
||||
p0=initial_guess, bounds=bounds, maxfev=50000)
|
||||
|
||||
# 将拟合结果添加到列表中
|
||||
all_fit_results.append(popt)
|
||||
|
||||
# 将结果转换为DataFrame
|
||||
columns = ['a1', 'b1', 'a2', 'b2', 'a3', 'b3', 'a4', 'b4',
|
||||
'a5', 'b5', 'a6', 'b6', 'a7', 'b7', 'a8', 'b8', 'a9', 'b9']
|
||||
fit_df = pd.DataFrame(all_fit_results, columns=columns) # fit_df即为拟合的参数汇总
|
||||
|
||||
# -------------------------------画图----------------------------
|
||||
# a1-a9,对应波数-4、-3、-2、-1、0、1、2、3、4的行星波振幅
|
||||
a_columns = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9']
|
||||
k_values = list(range(-4, 5)) # 从 -4 到 4
|
||||
|
||||
# 创建一个字典映射 k 值到 a_columns
|
||||
k_to_a = {f'k={k}': a for k, a in zip(k_values, a_columns)}
|
||||
|
||||
# 获取索引并转换为 numpy 数组
|
||||
x_values = fit_df.index.to_numpy()
|
||||
|
||||
# 对每一列生成独立的图
|
||||
for k, col in k_to_a.items():
|
||||
plt.figure(figsize=(8, 6)) # 创建新的图形
|
||||
plt.plot(x_values, fit_df[col].values)
|
||||
plt.title(f'{k} 振幅图')
|
||||
plt.xlabel('Day')
|
||||
plt.ylabel('振幅')
|
||||
|
||||
# 设置横坐标的动态调整
|
||||
adjusted_x_values = x_values + (3 * T + 1) / 2
|
||||
if len(adjusted_x_values) > 50:
|
||||
step = 30
|
||||
tick_positions = adjusted_x_values[::step] # 选择每30个点
|
||||
tick_labels = [f'{int(val)}' for val in tick_positions]
|
||||
else:
|
||||
tick_positions = adjusted_x_values
|
||||
tick_labels = [f'{int(val)}' for val in tick_positions]
|
||||
|
||||
plt.xticks(ticks=tick_positions, labels=tick_labels)
|
||||
|
||||
plt.show() # 显示图形
|
||||
175
saber/archive/gravity_process.py
Normal file
175
saber/archive/gravity_process.py
Normal file
@ -0,0 +1,175 @@
|
||||
# 高度、纬度可以指定,得到指定高度纬度下的数据,高度在101行,一般输入70、90、110,纬度在115行,纬度一般输入-20、30、60
|
||||
|
||||
import netCDF4 as nc
|
||||
import numpy as np
|
||||
import netCDF4 as nc
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from datetime import datetime, timedelta
|
||||
from scipy.optimize import curve_fit
|
||||
from scipy.optimize import least_squares
|
||||
|
||||
from CONSTANT import DATA_BASEPATH
|
||||
# 定义月份的英文名称
|
||||
months = [
|
||||
"January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"
|
||||
]
|
||||
|
||||
|
||||
def process_gravity_data(year):
|
||||
# 定义文件路径模板和年份
|
||||
|
||||
base_path = DATA_BASEPATH.saber + \
|
||||
"/{year}/SABER_Temp_O3_{month}{year}_v2.0.nc"
|
||||
|
||||
# 初始化空数组来存储拼接后的数据
|
||||
tplongitude = None
|
||||
tplatitude = None
|
||||
ktemp = None
|
||||
tpaltitude = None
|
||||
date = None
|
||||
tpSolarLT = None
|
||||
|
||||
# 循环遍历每个月
|
||||
for month_name in months:
|
||||
# 构造文件路径
|
||||
file_path = base_path.format(month=month_name, year=year)
|
||||
|
||||
# 打开文件并读取数据
|
||||
dataset = nc.Dataset(file_path, 'r')
|
||||
tplongitude_month = dataset.variables['tplongitude'][:]
|
||||
tplatitude_month = dataset.variables['tplatitude'][:]
|
||||
ktemp_month = dataset.variables['ktemp'][:]
|
||||
tpaltitude_month = dataset.variables['tpaltitude'][:]
|
||||
date_month = dataset.variables['date'][:]
|
||||
tpSolarLT_month = dataset.variables['tpSolarLT'][:]
|
||||
dataset.close()
|
||||
|
||||
# 动态获取两个数组的较小维度,并截取较大的数组以匹配较小的维度
|
||||
if tplatitude is None:
|
||||
# 如果是第一个月,初始化数组
|
||||
tplongitude = tplongitude_month
|
||||
tplatitude = tplatitude_month
|
||||
ktemp = ktemp_month
|
||||
tpaltitude = tpaltitude_month
|
||||
date = date_month
|
||||
tpSolarLT = tpSolarLT_month
|
||||
else:
|
||||
min_dim = min(tplatitude.shape[1], tplatitude_month.shape[1])
|
||||
if tplatitude.shape[1] < tplatitude_month.shape[1]:
|
||||
tplatitude_month = tplatitude_month[:, :min_dim]
|
||||
ktemp_month = ktemp_month[:, :min_dim]
|
||||
tpaltitude_month = tpaltitude_month[:, :min_dim]
|
||||
tpSolarLT_month = tpSolarLT_month[:, :min_dim]
|
||||
tplongitude_month = tplongitude_month[:, :min_dim]
|
||||
else:
|
||||
tplatitude = tplatitude[:, :min_dim]
|
||||
ktemp = ktemp[:, :min_dim]
|
||||
tpaltitude = tpaltitude[:, :min_dim]
|
||||
tpSolarLT = tpSolarLT[:, :min_dim]
|
||||
tplongitude = tplongitude[:, :min_dim]
|
||||
|
||||
# 拼接数据
|
||||
tplongitude = np.concatenate(
|
||||
(tplongitude, tplongitude_month), axis=0)
|
||||
tplatitude = np.concatenate((tplatitude, tplatitude_month), axis=0)
|
||||
ktemp = np.concatenate((ktemp, ktemp_month), axis=0)
|
||||
tpaltitude = np.concatenate((tpaltitude, tpaltitude_month), axis=0)
|
||||
date = np.concatenate((date, date_month), axis=0)
|
||||
tpSolarLT = np.concatenate((tpSolarLT, tpSolarLT_month), axis=0)
|
||||
|
||||
# ----------数据处理------------------------------------------------------
|
||||
# 时间处理
|
||||
time_hour = tpSolarLT / 1000 / 3600
|
||||
# 假设date的格式为YYYYDDD,其中DDD是一年中的第几天
|
||||
dates = [datetime.strptime(f'{d:07d}', '%Y%j') for d in date]
|
||||
# 创建一个辅助函数来调整time_hour
|
||||
|
||||
def adjust_time_hour(time_hour, dates):
|
||||
# 初始化一个和time_hour形状相同的数组,用于存储调整后的时间
|
||||
adjusted_time_hour = np.zeros_like(time_hour)
|
||||
# 获取第一个日期作为参考点
|
||||
first_date = dates[0]
|
||||
# 遍历dates和time_hour,根据日期调整时间
|
||||
for i, (dt, th) in enumerate(zip(dates, time_hour)):
|
||||
# 计算当前日期和第一个日期之间的天数差
|
||||
delta_days = (dt - first_date).days
|
||||
# 根据天数差调整时间
|
||||
adjusted_time_hour[i] = th + delta_days * 24
|
||||
|
||||
return adjusted_time_hour
|
||||
|
||||
# 调整time_hour
|
||||
adjusted_time_hour = adjust_time_hour(time_hour, dates)
|
||||
# 将小时转换为天
|
||||
adjusted_time_day = adjusted_time_hour / 24.0 # 转换为天
|
||||
# 找到第一个事件中与70最接近的高度的索引
|
||||
# 输入高度
|
||||
target_h = 70
|
||||
first_event_altitudes = tpaltitude[0]
|
||||
diff = np.abs(first_event_altitudes - target_h)
|
||||
closest_height_index = np.argmin(diff)
|
||||
# 读取每个事件对应closest_height_index下的纬度、tplongitude和adjusted_time_day数据
|
||||
selected_latitude = tplatitude[:, closest_height_index]
|
||||
selected_tplongitude = tplongitude[:, closest_height_index]
|
||||
selected_adjusted_time_day = adjusted_time_day[:, closest_height_index]
|
||||
selected_ktemp = ktemp[:, closest_height_index]
|
||||
# 将时间数据转换为整数天数,方便按天分组
|
||||
int_days = np.array([int(day) for day in selected_adjusted_time_day])
|
||||
# 1. 创建经度分组(0到360°,每20°一个区间)
|
||||
longitude_bins = np.arange(0, 361, 20)
|
||||
# 2. 创建纬度目标值
|
||||
target_lat = 60 # 假设目标纬度为60°
|
||||
# 3. 用于存储结果
|
||||
closest_event_indices = []
|
||||
|
||||
# 4. 遍历每天的所有数据(按天分组),并查找与每个经度区间最接近的经度事件索引
|
||||
for day in np.unique(int_days): # 遍历每个独特的天数
|
||||
# 获取当前天数下的所有经度和纬度
|
||||
current_day_indices = np.where(int_days == day)[0]
|
||||
current_longitudes = selected_tplongitude[current_day_indices]
|
||||
current_latitudes = selected_latitude[current_day_indices]
|
||||
|
||||
# 初始化列表用于存储该天的最接近经度和纬度的索引
|
||||
closest_indices_for_day = []
|
||||
|
||||
# 遍历每个经度区间(20°为一个区间)
|
||||
for lon_bin_start in longitude_bins[:-1]:
|
||||
lon_bin_end = lon_bin_start + target_lat
|
||||
# 找到当前经度区间内的经度
|
||||
indices_in_bin = np.where((current_longitudes >= lon_bin_start) & (
|
||||
current_longitudes < lon_bin_end))[0]
|
||||
# 如果有经度落入该区间,找到与目标纬度20°最接近的纬度
|
||||
if len(indices_in_bin) > 0:
|
||||
# 计算纬度与目标纬度的差值
|
||||
latitudes_in_bin = current_latitudes[indices_in_bin]
|
||||
diff_latitude = np.abs(latitudes_in_bin - target_lat)
|
||||
# 找到与目标纬度最接近的索引
|
||||
closest_latitude_index = indices_in_bin[np.argmin(
|
||||
diff_latitude)]
|
||||
# 将该经度区间和最接近纬度的索引添加到结果中
|
||||
closest_indices_for_day.append(
|
||||
current_day_indices[closest_latitude_index])
|
||||
# 将该天的所有最接近的经度和纬度索引添加到总结果中
|
||||
closest_event_indices.extend(closest_indices_for_day)
|
||||
|
||||
# 4. 获取这些事件的相关信息
|
||||
closest_latitudes = selected_latitude[closest_event_indices]
|
||||
closest_longitudes = selected_tplongitude[closest_event_indices]
|
||||
closest_times = selected_adjusted_time_day[closest_event_indices]
|
||||
closest_temperatures = selected_ktemp[closest_event_indices]
|
||||
# 5. 将经度从度数转换为弧度制
|
||||
closest_longitudes_radians = np.radians(closest_longitudes)
|
||||
# 将三列数据组合成一个二维数组
|
||||
combined_data = np.column_stack(
|
||||
(closest_longitudes_radians, closest_times, closest_temperatures))
|
||||
|
||||
return combined_data
|
||||
|
||||
|
||||
# 将数据保存为txt文件
|
||||
# np.savetxt('combined_data.txt', combined_data, fmt='%f', delimiter='\t',
|
||||
# header="Longitude_Radians\tTime\tTemperature", comments='')
|
||||
|
||||
# print("数据已保存为 'combined_data.txt'")
|
||||
Loading…
x
Reference in New Issue
Block a user