some fix
This commit is contained in:
parent
7cf201ff8c
commit
27a24ba6a8
@ -20,7 +20,8 @@ def get_meta():
|
|||||||
@cosmic_module.route('/temp_render')
|
@cosmic_module.route('/temp_render')
|
||||||
async def render():
|
async def render():
|
||||||
T = request.args.get("T", 16)
|
T = request.args.get("T", 16)
|
||||||
await run_sync(cosmic_planetw_daily_plot)(T=int(T))
|
k = request.args.get("k", 1)
|
||||||
|
await run_sync(cosmic_planetw_daily_plot)(T=int(T), k=int(k))
|
||||||
buf = BytesIO()
|
buf = BytesIO()
|
||||||
|
|
||||||
plt.savefig(buf, format="png")
|
plt.savefig(buf, format="png")
|
||||||
@ -61,7 +62,7 @@ async def multiday_render():
|
|||||||
day_range=(start_day, end_day))
|
day_range=(start_day, end_day))
|
||||||
if mode == "布伦特-维萨拉频率分布":
|
if mode == "布伦特-维萨拉频率分布":
|
||||||
await run_sync(p.plot_heatmap_tempNz)()
|
await run_sync(p.plot_heatmap_tempNz)()
|
||||||
elif mode == "位温分布":
|
elif mode == "不同高度下的逐日统计分析":
|
||||||
await run_sync(p.plot_heatmap_tempPtz)()
|
await run_sync(p.plot_heatmap_tempPtz)()
|
||||||
elif mode == "每月浮力频率变化趋势":
|
elif mode == "每月浮力频率变化趋势":
|
||||||
await run_sync(p.plot_floatage_trend)()
|
await run_sync(p.plot_floatage_trend)()
|
||||||
|
|||||||
@ -17,7 +17,11 @@ matplotlib.rcParams['axes.unicode_minus'] = False # 正常显示负号
|
|||||||
# 读取一年的数据文件
|
# 读取一年的数据文件
|
||||||
|
|
||||||
|
|
||||||
def cosmic_planetw_daily_plot(path: str = f"{DATA_BASEPATH.cosmic}/cosmic.txt", T=16):
|
def cosmic_planetw_daily_plot(
|
||||||
|
path: str = f"{DATA_BASEPATH.cosmic}/cosmic.txt",
|
||||||
|
T=16,
|
||||||
|
k=0
|
||||||
|
):
|
||||||
def u_func(x, *params):
|
def u_func(x, *params):
|
||||||
a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, a8, b8, a9, b9 = params
|
a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, a8, b8, a9, b9 = params
|
||||||
return (
|
return (
|
||||||
@ -100,23 +104,22 @@ def cosmic_planetw_daily_plot(path: str = f"{DATA_BASEPATH.cosmic}/cosmic.txt",
|
|||||||
x_values = fit_df.index.to_numpy()
|
x_values = fit_df.index.to_numpy()
|
||||||
|
|
||||||
# 对每一列生成独立的图
|
# 对每一列生成独立的图
|
||||||
for k, col in k_to_a.items():
|
# for k, col in k_to_a.items():
|
||||||
plt.figure(figsize=(8, 6)) # 创建新的图形
|
col = k_to_a[f'k={k}']
|
||||||
plt.plot(x_values, fit_df[col].values)
|
plt.figure(figsize=(8, 6)) # 创建新的图形
|
||||||
plt.title(f'{k} 振幅图')
|
plt.plot(x_values, fit_df[col].values)
|
||||||
plt.xlabel('Day')
|
plt.title(f'k={k} 振幅图')
|
||||||
plt.ylabel('振幅')
|
plt.xlabel('Day')
|
||||||
|
plt.ylabel('振幅')
|
||||||
|
|
||||||
# 设置横坐标的动态调整
|
# 设置横坐标的动态调整
|
||||||
adjusted_x_values = x_values + (3 * T + 1) / 2
|
adjusted_x_values = x_values + (3 * T + 1) / 2
|
||||||
if len(adjusted_x_values) > 50:
|
if len(adjusted_x_values) > 50:
|
||||||
step = 30
|
step = 30
|
||||||
tick_positions = adjusted_x_values[::step] # 选择每30个点
|
tick_positions = adjusted_x_values[::step] # 选择每30个点
|
||||||
tick_labels = [f'{int(val)}' for val in tick_positions]
|
tick_labels = [f'{int(val)}' for val in tick_positions]
|
||||||
else:
|
else:
|
||||||
tick_positions = adjusted_x_values
|
tick_positions = adjusted_x_values
|
||||||
tick_labels = [f'{int(val)}' for val in tick_positions]
|
tick_labels = [f'{int(val)}' for val in tick_positions]
|
||||||
|
|
||||||
plt.xticks(ticks=tick_positions, labels=tick_labels)
|
plt.xticks(ticks=tick_positions, labels=tick_labels)
|
||||||
|
|
||||||
plt.show() # 显示图形
|
|
||||||
|
|||||||
@ -146,10 +146,13 @@ async def do_year_power_wave_plot():
|
|||||||
async def do_gravity_year():
|
async def do_gravity_year():
|
||||||
year = request.args.get("year")
|
year = request.args.get("year")
|
||||||
T = request.args.get("T")
|
T = request.args.get("T")
|
||||||
|
k = request.args.get("k")
|
||||||
|
H = request.args.get("H")
|
||||||
|
lat_range = request.args.get("lat_range")
|
||||||
year = int(year)
|
year = int(year)
|
||||||
T = int(T)
|
T = int(T)
|
||||||
if T not in [5, 10, 16]:
|
if T not in [5, 10, 16]:
|
||||||
raise ValueError("T must be in [5, 10, 16]")
|
raise ValueError("T must be in [5, 10, 16]")
|
||||||
data = await run_sync(saber_planetw_process)(year)
|
data = await run_sync(saber_planetw_process)(year)
|
||||||
await run_sync(saber_planetw_plot)(data, T)
|
await run_sync(saber_planetw_plot)(data, T, k=int(k))
|
||||||
return await extract_payload()
|
return await extract_payload()
|
||||||
|
|||||||
@ -27,7 +27,11 @@ bounds = (
|
|||||||
np.inf, np.inf, np.inf]) # 上界
|
np.inf, np.inf, np.inf]) # 上界
|
||||||
|
|
||||||
|
|
||||||
def saber_planetw_plot(df: pd.DataFrame, T=16):
|
def saber_planetw_plot(
|
||||||
|
df: pd.DataFrame,
|
||||||
|
T=16,
|
||||||
|
k=0
|
||||||
|
):
|
||||||
# 定义拟合函数
|
# 定义拟合函数
|
||||||
def u_func(x, *params):
|
def u_func(x, *params):
|
||||||
a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, a8, b8, a9, b9 = params
|
a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, a7, b7, a8, b8, a9, b9 = params
|
||||||
@ -96,27 +100,26 @@ def saber_planetw_plot(df: pd.DataFrame, T=16):
|
|||||||
x_values = fit_df.index.to_numpy()
|
x_values = fit_df.index.to_numpy()
|
||||||
|
|
||||||
# 创建一个包含多个子图的图形
|
# 创建一个包含多个子图的图形
|
||||||
fig, axs = plt.subplots(len(k_to_a), 1, figsize=(10, 2 * len(k_to_a)))
|
|
||||||
|
|
||||||
# 对每一列生成独立的子图
|
# 对每一列生成独立的子图
|
||||||
for ax, (k, col) in zip(axs, k_to_a.items()):
|
col = k_to_a[f'k={k}']
|
||||||
ax.plot(x_values, fit_df[col].values)
|
plt.plot(x_values, fit_df[col].values)
|
||||||
ax.set_title(f'{k} 振幅图')
|
plt.set_title(f'k = {k} 振幅图')
|
||||||
ax.set_xlabel('Day')
|
plt.set_xlabel('Day')
|
||||||
ax.set_ylabel('振幅')
|
plt.set_ylabel('振幅')
|
||||||
|
|
||||||
# 设置横坐标的动态调整
|
# 设置横坐标的动态调整
|
||||||
adjusted_x_values = x_values + (3 * T + 1) / 2
|
adjusted_x_values = x_values + (3 * T + 1) / 2
|
||||||
if len(adjusted_x_values) > 50:
|
if len(adjusted_x_values) > 50:
|
||||||
step = 30
|
step = 30
|
||||||
tick_positions = adjusted_x_values[::step] # 选择每30个点
|
tick_positions = adjusted_x_values[::step] # 选择每30个点
|
||||||
tick_labels = [f'{int(val)}' for val in tick_positions]
|
tick_labels = [f'{int(val)}' for val in tick_positions]
|
||||||
else:
|
else:
|
||||||
tick_positions = adjusted_x_values
|
tick_positions = adjusted_x_values
|
||||||
tick_labels = [f'{int(val)}' for val in tick_positions]
|
tick_labels = [f'{int(val)}' for val in tick_positions]
|
||||||
|
|
||||||
ax.set_xticks(tick_positions)
|
plt.set_xticks(tick_positions)
|
||||||
ax.set_xticklabels(tick_labels)
|
plt.set_xticklabels(tick_labels)
|
||||||
|
|
||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
# plt.show()
|
# plt.show()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user