diff --git a/modules/balloon/__init__.py b/modules/balloon/__init__.py index 6a12e42..66fca2a 100644 --- a/modules/balloon/__init__.py +++ b/modules/balloon/__init__.py @@ -7,8 +7,8 @@ from quart import Blueprint from CONSTANT import DATA_BASEPATH import modules.balloon as balloon from quart import jsonify, request, send_file -from modules.balloon.plot_once_backend import render_by_mode_single -from modules.balloon.plot_year_backend import get_all_modes, render_based_on_mode +from modules.balloon.gravityw_plot_perday import render_by_mode_single +from modules.balloon.gravityw_plot_year import get_all_modes, render_based_on_mode from modules.balloon.utils import * BASE_PATH_BALLOON = DATA_BASEPATH.balloon diff --git a/modules/balloon/plot_once.py b/modules/balloon/archive/plot_once.py similarity index 100% rename from modules/balloon/plot_once.py rename to modules/balloon/archive/plot_once.py diff --git a/modules/balloon/plot_year.py b/modules/balloon/archive/plot_year.py similarity index 100% rename from modules/balloon/plot_year.py rename to modules/balloon/archive/plot_year.py diff --git a/modules/balloon/plot_once_backend.py b/modules/balloon/gravityw_plot_perday.py similarity index 100% rename from modules/balloon/plot_once_backend.py rename to modules/balloon/gravityw_plot_perday.py diff --git a/modules/balloon/plot_year_backend.py b/modules/balloon/gravityw_plot_year.py similarity index 100% rename from modules/balloon/plot_year_backend.py rename to modules/balloon/gravityw_plot_year.py diff --git a/modules/cosmic/__init__.py b/modules/cosmic/__init__.py index f0026c8..d9f9a36 100644 --- a/modules/cosmic/__init__.py +++ b/modules/cosmic/__init__.py @@ -15,6 +15,7 @@ def get_meta(): return [] +@cosmic_module.route('/render/planet_wave/daily') @cosmic_module.route('/temp_render') async def render(): T = request.args.get("T", 16) @@ -26,6 +27,7 @@ async def render(): return await send_file(buf, mimetype="image/png") +@cosmic_module.route('/render/gravity_wave/perday') @cosmic_module.route('/render/single') async def single_render(): year = request.args.get("year", 2008) diff --git a/modules/saber/__init__.py b/modules/saber/__init__.py index e615dbb..121f7d2 100644 --- a/modules/saber/__init__.py +++ b/modules/saber/__init__.py @@ -22,7 +22,7 @@ saber_module = Blueprint('saber', __name__) renderer = SaberGravitywRenderer() -def get_processer(): +def get_gravityw_processer(): lat_str = request.args.get("lat_range") if lat_str is None: lat_str = "30.0,40.0" @@ -71,6 +71,7 @@ async def get_days(): return ncfile.date_time.tolist() +@saber_module.route("/render/gravity_wave/per_day/wave_fitting") @saber_module.route("/render/plot_wave_fitting") async def do_plot_wave_day_fitting(): path = request.args.get("path") @@ -78,12 +79,13 @@ async def do_plot_wave_day_fitting(): height = request.args.get("height_no") ncfile = await run_sync(data_nc_load)(path) - processor = await run_sync(get_processer)() + processor = await run_sync(get_gravityw_processer)() data = await run_sync(processor.process_day)(ncfile, int(day)) await run_sync(renderer.plot_wave_fitting)(data, int(height)) return await extract_payload() +@saber_module.route("/render/gravity_wave/per_day/fft_ifft") @saber_module.route("/render/day_fft_ifft_plot") async def do_day_fft_ifft_plot(): path = request.args.get("path") @@ -91,13 +93,14 @@ async def do_day_fft_ifft_plot(): cycle_no = request.args.get("cycle_no") ncfile = await run_sync(data_nc_load)(path) - processor = await run_sync(get_processer)() + processor = await run_sync(get_gravityw_processer)() data = await run_sync(processor.process_day)(ncfile, int(day)) # 高度滤波处理 await run_sync(renderer.day_fft_ifft_plot)(wave_data=data, cycle_no=int(cycle_no)) return await extract_payload() +@saber_module.route("/render/gravity_wave/per_day/power_wave_plot") @saber_module.route("/render/day_cycle_power_wave_plot") async def do_day_cycle_power_wave_plot(): path = request.args.get("path") @@ -105,28 +108,30 @@ async def do_day_cycle_power_wave_plot(): cycle_no = request.args.get("cycle_no") ncfile = await run_sync(data_nc_load)(path) - processor = await run_sync(get_processer)() + processor = await run_sync(get_gravityw_processer)() data = await run_sync(processor.process_day)(ncfile, int(day)) await run_sync(renderer.day_cycle_power_wave_plot)(wave_data=data, cycle_no=int(cycle_no)) return await extract_payload() +@saber_module.route("/render/gravity_wave/per_month/power_wave_plot") @saber_module.route("/render/month_power_wave_plot") async def do_month_power_wave_plot(): path = request.args.get("path") month = request.args.get("month") ncfile = await run_sync(data_nc_load)(path) - processor = await run_sync(get_processer)() + processor = await run_sync(get_gravityw_processer)() data = await run_sync(processor.process_month)(ncfile) await run_sync(renderer.month_power_wave_plot)(wave_data=data, date_time=ncfile.date_time) return await extract_payload() +@saber_module.route("/render/gravity_wave/per_year/power_wave_plot") @saber_module.route("/render/year_power_wave_plot") async def do_year_power_wave_plot(): year = request.args.get("year") - processor = await run_sync(get_processer)() + processor = await run_sync(get_gravityw_processer)() data = await run_sync(processor.process_year)([ data_nc_load(path) for path in glob.glob(f"{DATA_BASEPATH.saber}/{year}/*.nc") ]) @@ -134,6 +139,9 @@ async def do_year_power_wave_plot(): return await extract_payload() +@saber_module.route("/render/planet_wave/per_year/energy_plot") +# above path is named correctly +# below path is named wrongly, but kept due to compatibility @saber_module.route("/render/gravity_year") async def do_gravity_year(): year = request.args.get("year") diff --git a/modules/tidi/__init__.py b/modules/tidi/__init__.py index 097845c..85cf094 100644 --- a/modules/tidi/__init__.py +++ b/modules/tidi/__init__.py @@ -5,8 +5,8 @@ from quart.utils import run_sync from matplotlib import pyplot as plt from CONSTANT import DATA_BASEPATH -from modules.tidi.gravity_wave_year import TidiPlotGWYear -from modules.tidi.planet_wave_daily import TidiPlotPWDaily +from modules.tidi.gravity_wave_year import TidiGravityWPlotMonthly +from modules.tidi.planet_wave_daily import TidiPlotPlanetWDaily tidi_module = Blueprint("Tidi", __name__) @@ -22,6 +22,7 @@ def get_all_years(): } +@tidi_module.route("/render/planet_wave/daily") @tidi_module.route('/render/wave') async def render_wave(): mode = request.args.get('mode') @@ -37,7 +38,7 @@ async def render_wave(): height = float(height) lat_range = tuple(map(int, lat_range.split('~'))) - await run_sync(TidiPlotPWDaily)(mode, year, k, height, lat_range, T) + await run_sync(TidiPlotPlanetWDaily)(mode, year, k, height, lat_range, T) buffer = BytesIO() plt.savefig(buffer, format="png") buffer.seek(0) @@ -45,26 +46,28 @@ async def render_wave(): return await send_file(buffer, mimetype="image/png") +@tidi_module.route('/render/gravity_wave/monthly_height') @tidi_module.route('/render/month_stats_v1') async def render_stats_v1(): year = request.args.get('year') year = int(year) - plotter = await run_sync(TidiPlotGWYear)(year) - await run_sync(plotter.plot_v1)() + plotter: TidiGravityWPlotMonthly = await run_sync(TidiGravityWPlotMonthly)(year) + await run_sync(plotter.plot_height)() buffer = BytesIO() plt.savefig(buffer, format="png") buffer.seek(0) return await send_file(buffer, mimetype="image/png") +@tidi_module.route('/render/gravity_wave/monthly_energy') @tidi_module.route('/render/month_stats_v2') async def render_stats_v2(): year = request.args.get('year') year = int(year) - plotter = await run_sync(TidiPlotGWYear)(year) - await run_sync(plotter.plot_month)() + plotter: TidiGravityWPlotMonthly = await run_sync(TidiGravityWPlotMonthly)(year) + await run_sync(plotter.plot_energy)() buffer = BytesIO() plt.savefig(buffer, format="png") buffer.seek(0) diff --git a/modules/tidi/gravity_wave_year.py b/modules/tidi/gravity_wave_year.py index 71a2a5c..b1953fd 100644 --- a/modules/tidi/gravity_wave_year.py +++ b/modules/tidi/gravity_wave_year.py @@ -759,7 +759,7 @@ def day_to_month(day): return f'{["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][i]}' -class TidiPlotGWYear: +class TidiGravityWPlotMonthly: def __init__(self, year): self.year = year cache_path = f"{DATA_BASEPATH.tidi}/cache" @@ -842,7 +842,7 @@ class TidiPlotGWYear: self.dates = dates self.months = [day_to_month(day) for day in dates] - def plot_v1(self): + def plot_height(self): h_reversed = self.h_reversed data0_reversed = self.data0_reversed dates = self.dates @@ -875,7 +875,7 @@ class TidiPlotGWYear: # 显示图形 # plt.show() - def plot_month(self): + def plot_energy(self): HP = self.HP # --------------绘制月统计图------------------------------------------------------------------- # 获取HP的列数 diff --git a/modules/tidi/planet_wave_daily.py b/modules/tidi/planet_wave_daily.py index 9c1b731..c57caf0 100644 --- a/modules/tidi/planet_wave_daily.py +++ b/modules/tidi/planet_wave_daily.py @@ -13,7 +13,7 @@ import matplotlib.pyplot as plt import matplotlib from CONSTANT import DATA_BASEPATH -from modules.tidi.tidi_pw_process import extract_tidi_pw_data +from modules.tidi.tidi_planetw_process import extract_tidi_planetw_data # 设置中文显示和负号正常显示 matplotlib.rcParams['font.sans-serif'] = ['SimHei'] # 显示中文 matplotlib.rcParams['axes.unicode_minus'] = False # 正常显示负号 @@ -33,7 +33,7 @@ bounds = ( # 定义拟合函数 -def TidiPlotPWDaily( +def TidiPlotPlanetWDaily( mode, year, k, @@ -55,7 +55,7 @@ def TidiPlotPWDaily( if os.path.exists(data_cache_path): df = pd.read_parquet(data_cache_path) else: - df = extract_tidi_pw_data( + df = extract_tidi_planetw_data( year, input_height, lat_range )[mode] df.to_parquet(data_cache_path) @@ -146,8 +146,8 @@ def TidiPlotPWDaily( if __name__ == '__main__': - TidiPlotPWDaily('V_Zonal', 2015, 1) - TidiPlotPWDaily('V_Meridional', 2015, 1) + TidiPlotPlanetWDaily('V_Zonal', 2015, 1) + TidiPlotPlanetWDaily('V_Meridional', 2015, 1) # # 用于存储拟合参数结果的列表 # all_fit_results = [] diff --git a/modules/tidi/tidi_pw_process.py b/modules/tidi/tidi_planetw_process.py similarity index 97% rename from modules/tidi/tidi_pw_process.py rename to modules/tidi/tidi_planetw_process.py index 2de397b..1b9f6a7 100644 --- a/modules/tidi/tidi_pw_process.py +++ b/modules/tidi/tidi_planetw_process.py @@ -15,7 +15,7 @@ HEIGHTS_CONSTANT = [ ] -def extract_tidi_pw_data( +def extract_tidi_planetw_data( year, input_height: float = 82.5, lat_range: tuple = (0, 5),