diff --git a/src/pfs_target_uploader/pn_app.py b/src/pfs_target_uploader/pn_app.py index 6cb70bb..57c9810 100644 --- a/src/pfs_target_uploader/pn_app.py +++ b/src/pfs_target_uploader/pn_app.py @@ -687,7 +687,7 @@ def Table_files_tgt_psl(column_checkbox_): frozen_columns=["index"], pagination="remote", header_filters=True, - buttons={"magnify": ""}, + buttons={"magnify": "", "download": ""}, layout="fit_data_table", hidden_columns=_hidden_columns, disabled=True, @@ -711,6 +711,21 @@ def Table_files_tgt_psl(column_checkbox_): _table_files_tgt_psl.add_filter(slider_rot_l, "Time_tot_L (h)") _table_files_tgt_psl.add_filter(slider_rot_m, "Time_tot_M (h)") + # Open a file by clicking the download buttons + # https://discourse.holoviz.org/t/how-to-make-a-dynamic-link-in-panel/2137 + + def execute_javascript(script): + script = f'' + js_panel.object = script + js_panel.object = "" + + def open_panel_download(event): + if event.column == "download": + href = df_files_tgt_psl["fullpath_tgt"][event.row] + # c.f. https://www.w3schools.com/jsref/met_win_open.asp + script = f"window.open('{href}', '_blank')" + execute_javascript(script) + def open_panel_magnify(event): row_target = event.row if event.column == "magnify": @@ -912,6 +927,7 @@ def tab_ppc_save(event): ) _table_files_tgt_psl.on_click(open_panel_magnify) + _table_files_tgt_psl.on_click(open_panel_download) return _table_files_tgt_psl @@ -951,6 +967,7 @@ def tab_ppc_save(event): table_ppc = pn.Column() # ------------------------------------------------------------------- + js_panel = pn.pane.HTML(width=0, height=0, margin=0, sizing_mode="fixed") sidebar_column = pn.Column( psl_info, @@ -972,6 +989,7 @@ def tab_ppc_save(event): ), column_checkbox, table_files_tgt_psl, + js_panel, ), ), ("PPC details", table_ppc), diff --git a/src/pfs_target_uploader/utils/io.py b/src/pfs_target_uploader/utils/io.py index 0cb6cf3..8c249ed 100644 --- a/src/pfs_target_uploader/utils/io.py +++ b/src/pfs_target_uploader/utils/io.py @@ -352,6 +352,7 @@ def load_file_properties(datadir, ext="ecsv", n_uid=16): tac_rot_l = np.zeros(n_files, dtype=float) tac_rot_m = np.zeros(n_files, dtype=float) single_exptime = np.full(n_files, 900, dtype=int) + observation_type = np.full(n_files, None, dtype=object) for i, d in enumerate(dirs): uid = d[-n_uid:] @@ -391,6 +392,11 @@ def load_file_properties(datadir, ext="ecsv", n_uid=16): except KeyError: upload_ids[i] = None + try: + observation_type[i] = tb_target.meta["observation_type"] + except KeyError: + observation_type[i] = None + try: if isinstance(tb_target.meta["upload_at"], str): timestamps[i] = datetime.fromisoformat(tb_target.meta["upload_at"]) @@ -467,6 +473,7 @@ def load_file_properties(datadir, ext="ecsv", n_uid=16): "fullpath_tgt": fullpath_target, "fullpath_psl": fullpath_psl, "single_exptime": single_exptime, + "observation_type": observation_type, } ) diff --git a/src/pfs_target_uploader/utils/ppp.py b/src/pfs_target_uploader/utils/ppp.py index 275ab1c..96ce61d 100644 --- a/src/pfs_target_uploader/utils/ppp.py +++ b/src/pfs_target_uploader/utils/ppp.py @@ -1182,6 +1182,7 @@ def ppp_plotFig(RESmode, cR, sub, obj_allo, uS): obj_allo1 = obj_allo[obj_allo.argsort(keys="ppc_priority")] obj_allo1["PPC_id"] = np.arange(0, len(obj_allo), 1) + 1 + """ if len(uPPC) > 0: if "ppc_priority" in uPPC.colnames: uPPC.remove_column("ppc_priority") @@ -1193,6 +1194,12 @@ def ppp_plotFig(RESmode, cR, sub, obj_allo, uS): "Point_" + RESmode + "_" + str(count) for count in (np.arange(0, len(obj_allo), 1) + 1) ] + #""" + obj_allo1["ppc_code"] = [ + "Point_" + RESmode + "_" + str(count) + for count in (np.arange(0, len(obj_allo), 1) + 1) + ] + obj_allo1 = obj_allo1.group_by("ppc_code") obj_allo1.rename_column("tel_fiber_usage_frac", "Fiber usage fraction (%)") obj_allo2 = Table.to_pandas(obj_allo1)