Skip to content
Snippets Groups Projects
Commit b25473de authored by Sabine Schröder's avatar Sabine Schröder
Browse files

activate download of MLAir plots

parent c6db61c6
Branches cmake_add_soversion
Tags
No related merge requests found
...@@ -278,10 +278,12 @@ def generate_ml_fcast_output_body(language_id, jobnr): ...@@ -278,10 +278,12 @@ def generate_ml_fcast_output_body(language_id, jobnr):
] ]
@callback( @callback(
Output('image-container-ml-output', 'children'), [Output('image-container-ml-output', 'children'),
Output("plot-info", "data", allow_duplicate=True)],
Input('station-dropdown-ml-output', 'value'), Input('station-dropdown-ml-output', 'value'),
[State("user-info", "data"), [State("user-info", "data"),
State("job-info", "data")] State("job-info", "data")],
prevent_initial_call=True
) )
def update_mlair_image(selected_station, users_dict, job_dict): def update_mlair_image(selected_station, users_dict, job_dict):
jobid = json.loads(job_dict)["jobnr"] jobid = json.loads(job_dict)["jobnr"]
...@@ -290,13 +292,28 @@ def update_mlair_image(selected_station, users_dict, job_dict): ...@@ -290,13 +292,28 @@ def update_mlair_image(selected_station, users_dict, job_dict):
language_id = json.loads(users_dict)["language_id"] language_id = json.loads(users_dict)["language_id"]
except: except:
language_id = 0 language_id = 0
job_props = get_db_job_entry(jobid) job_props = get_db_job_entry(jobid)
station_code, station_label = selected_station.split(',')
station_code = station_code.strip()
plotinfo_dict = {}
plotinfo_dict["station"] = station_code
ispec = job_props['species']
species = guitr.species_options[0][ispec]
ml_species = guiconst.ml_names[species]
plotinfo_dict["species"] = ml_species
plotinfo_dict["start_date"] = job_props['start_date'][0:10]
forecast_length = job_props['forecast_length']
fc_length_str = "{}{}{}".format(forecast_length, guitr.day_label[language_id], guitr.day_plural_label[language_id] if forecast_length > 1 else "")
plotinfo_dict["fc_length"] = fc_length_str
plotinfo_json = json.dumps(plotinfo_dict)
image_path = plot_ml_time_series(selected_station, language_id, image_path = plot_ml_time_series(selected_station, language_id,
ispec=job_props['species'], ispec=job_props['species'],
start_date=job_props['start_date'], start_date=job_props['start_date'],
forecast_length=job_props['forecast_length']) forecast_length=job_props['forecast_length'])
image = html.Img(src=image_path, className='image-fit-container') image = html.Img(src=image_path, className='image-fit-container')
return image return image, plotinfo_json
else: else:
return None return None
...@@ -1228,15 +1245,13 @@ def mlair_output_download(download_button, job_dict): ...@@ -1228,15 +1245,13 @@ def mlair_output_download(download_button, job_dict):
prevent_initial_call=True prevent_initial_call=True
) )
def mlair_plots_download(download_button, job_dict, plot_dict): def mlair_plots_download(download_button, job_dict, plot_dict):
# jobid = json.loads(job_dict)["jobnr"] species = json.loads(plot_dict)["species"]
# species = json.loads(job_dict)["variable"] station = json.loads(plot_dict)["station"]
# start_date = json.loads(job_dict)["start_date"] start_date = json.loads(plot_dict)["start_date"]
# station = json.loads(plot_dict)["station"] fc_length = json.loads(plot_dict)["fc_length"]
# file name according to users selection # file name according to users selection
# output_file_name = f"mlair_{ml_species}_{station_code}_{start_date}_{fc_length_str}.png" output_file_name = f"mlair_{species}_{station}_{start_date}_{fc_length}.png"
# just to test
output_file_name = "mlair_O3_DENW067_2018-07-18_4Tage.png"
infile = str(ASSETS_PATH.joinpath('mlair', output_file_name)) infile = str(ASSETS_PATH.joinpath('mlair', output_file_name))
return dcc.send_file( return dcc.send_file(
infile infile
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment