From cf012cc7df5d5c2c0aa2b60f97c481096e3995a5 Mon Sep 17 00:00:00 2001 From: Dario Barghini <dario.barghini@inaf.it> Date: Tue, 19 Nov 2024 16:29:20 +0100 Subject: [PATCH] Massive update. Preparing for full operativity on PRISMA servers --- code/PRISMAwidget/PWpositions.pro | 86 ++ .../PWpositions/PWpositions_cleanup.pro | 40 + .../PWpositions/PWpositions_event.pro | 7 + .../PWpositions/PWpositions_file.pro | 21 + .../PWpositions/PWpositions_slider_box.pro | 32 + code/PRISMAwidget/PWwidget.pro | 314 +++++ .../PWwidget}/PW_autopos.pro | 62 +- code/PRISMAwidget/PWwidget/PW_closest_ds.pro | 9 + code/PRISMAwidget/PWwidget/PW_compute_ds.pro | 52 + code/PRISMAwidget/PWwidget/PW_draw_image.pro | 248 ++++ .../PWwidget}/PW_loadpos.pro | 47 +- .../PWwidget}/PW_open_image.pro | 205 ++- code/PRISMAwidget/PWwidget/PW_update_zoom.pro | 85 ++ .../PWwidget/PWwidget_cleanup.pro | 17 + code/PRISMAwidget/PWwidget/PWwidget_draw.pro | 90 ++ .../PWwidget}/PWwidget_event.pro | 3 +- .../PWwidget}/PWwidget_file.pro | 8 +- .../PWwidget}/PWwidget_filename.pro | 4 +- .../PWwidget/PWwidget_fullzoom.pro | 20 + .../PWwidget/PWwidget_interpolation.pro | 15 + code/PRISMAwidget/PWwidget/PWwidget_logo.pro | 89 ++ .../PWwidget}/PWwidget_logscale.pro | 2 + .../PWwidget}/PWwidget_modelist.pro | 11 +- .../PWwidget}/PWwidget_negative.pro | 1 + .../PWwidget/PWwidget_playmovie.pro | 271 ++++ .../PWwidget/PWwidget_positions.pro | 114 ++ .../PWwidget}/PWwidget_prevnextimage.pro | 14 +- .../PRISMAwidget/PWwidget/PWwidget_resize.pro | 14 + .../PWwidget}/PWwidget_slider_minmax.pro | 1 + .../PWwidget/PWwidget_slider_zoom.pro | 15 + code/PRISMAwidget/PWwidget/PWwidget_zoom.pro | 263 ++++ .../functions/widget_is_active.pro | 7 + code/calibration/calibration.pro | 60 +- code/calibration/calibration_day.pro | 61 +- code/calibration/calibration_image.pro | 38 +- code/calibration/calibration_month.pro | 25 +- code/calibration/compression_day.pro | 63 +- code/calibration/compression_image.pro | 1 + code/calibration/compression_month.pro | 51 +- code/calibration/debug/test_astrometry.pro | 8 +- code/calibration/debug/vis_fit.pro | 12 +- code/calibration/export_month.pro | 57 +- code/calibration/report_year.pro | 1096 +++++++++++++++++ code/calibration/update_config.pro | 297 +++++ code/event/compression_event.pro | 69 +- code/event/compression_result.pro | 131 +- code/event/detection_astrometry.pro | 21 +- code/event/dynamic_model.pro | 146 ++- code/event/event.pro | 2 +- code/event/orbit.pro | 35 +- code/event/triangulation.pro | 10 +- .../functions/astrometry/astro_model_info.pro | 36 +- .../functions/astrometry/astrometry_error.pro | 7 +- code/functions/astrometry/eq2hor_error.pro | 4 +- code/functions/astrometry/f_astro.pro | 20 +- code/functions/astrometry/f_astro0.pro | 20 +- code/functions/astrometry/hor2eq_error.pro | 4 +- code/functions/astrometry/mpastro_fit.pro | 12 + code/functions/astrometry/project.pro | 2 +- code/functions/astrometry/solve.pro | 2 +- code/functions/common/adjust_font_size.pro | 2 +- .../common/closest_metric_prefix.pro | 19 + code/functions/common/img_stddev.pro | 2 +- .../common/mpfunct_fit/mpfunct_fit.pro | 8 +- code/functions/common/myget_screen_size.pro | 35 + code/functions/common/myreadcol.pro | 8 +- code/functions/common/plot_range.pro | 5 + code/functions/common/sunrise.pro | 22 + code/functions/configuration/camera_par.pro | 83 +- .../configuration/config_path_filename.pro | 2 +- code/functions/configuration/get_config.pro | 33 +- code/functions/configuration/get_files.pro | 197 +-- code/functions/configuration/get_logo.pro | 47 +- code/functions/configuration/get_mask.pro | 2 +- code/functions/configuration/get_par.pro | 2 +- code/functions/configuration/get_solution.pro | 37 +- code/functions/configuration/target_jd.pro | 19 +- code/functions/dynamic/kalenichenko2006.pro | 26 +- code/functions/geometry3d/eci2geodetic.pro | 5 + code/functions/orbit/meteor_orbit.pro | 24 +- code/functions/photometry/eff_correction.pro | 38 +- code/functions/report/astrometry_report.pro | 32 +- code/functions/report/detection_report.pro | 109 +- code/functions/report/dynamic_report.pro | 188 +-- .../report/export_detection_media.pro | 4 +- code/functions/report/orbit_report.pro | 83 +- code/functions/report/photometry_report.pro | 9 +- .../functions/report/triangulation_report.pro | 29 +- code/pwwidget/PRISMAwidget.pro | 207 ---- code/pwwidget/PW_draw_image.pro | 168 --- code/pwwidget/PWwidget_cleanup.pro | 13 - code/pwwidget/PWwidget_draw.pro | 75 -- code/pwwidget/PWwidget_interpolation.pro | 25 - code/pwwidget/PWwidget_playmovie.pro | 219 ---- code/pwwidget/PWwidget_positions.pro | 98 -- code/pwwidget/PWwidget_slider_box.pro | 26 - code/pwwidget/PWwidget_slider_zoom.pro | 38 - code/pwwidget/PWwidget_zoom.pro | 229 ---- 98 files changed, 4829 insertions(+), 1796 deletions(-) create mode 100644 code/PRISMAwidget/PWpositions.pro create mode 100644 code/PRISMAwidget/PWpositions/PWpositions_cleanup.pro create mode 100644 code/PRISMAwidget/PWpositions/PWpositions_event.pro create mode 100644 code/PRISMAwidget/PWpositions/PWpositions_file.pro create mode 100644 code/PRISMAwidget/PWpositions/PWpositions_slider_box.pro create mode 100644 code/PRISMAwidget/PWwidget.pro rename code/{pwwidget => PRISMAwidget/PWwidget}/PW_autopos.pro (68%) create mode 100644 code/PRISMAwidget/PWwidget/PW_closest_ds.pro create mode 100644 code/PRISMAwidget/PWwidget/PW_compute_ds.pro create mode 100644 code/PRISMAwidget/PWwidget/PW_draw_image.pro rename code/{pwwidget => PRISMAwidget/PWwidget}/PW_loadpos.pro (65%) rename code/{pwwidget => PRISMAwidget/PWwidget}/PW_open_image.pro (62%) create mode 100644 code/PRISMAwidget/PWwidget/PW_update_zoom.pro create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_cleanup.pro create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_draw.pro rename code/{pwwidget => PRISMAwidget/PWwidget}/PWwidget_event.pro (74%) rename code/{pwwidget => PRISMAwidget/PWwidget}/PWwidget_file.pro (86%) rename code/{pwwidget => PRISMAwidget/PWwidget}/PWwidget_filename.pro (57%) create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_fullzoom.pro create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_interpolation.pro create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_logo.pro rename code/{pwwidget => PRISMAwidget/PWwidget}/PWwidget_logscale.pro (88%) rename code/{pwwidget => PRISMAwidget/PWwidget}/PWwidget_modelist.pro (81%) rename code/{pwwidget => PRISMAwidget/PWwidget}/PWwidget_negative.pro (88%) create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_playmovie.pro create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_positions.pro rename code/{pwwidget => PRISMAwidget/PWwidget}/PWwidget_prevnextimage.pro (72%) create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_resize.pro rename code/{pwwidget => PRISMAwidget/PWwidget}/PWwidget_slider_minmax.pro (96%) create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_slider_zoom.pro create mode 100644 code/PRISMAwidget/PWwidget/PWwidget_zoom.pro create mode 100644 code/PRISMAwidget/functions/widget_is_active.pro create mode 100644 code/calibration/report_year.pro create mode 100644 code/calibration/update_config.pro create mode 100644 code/functions/common/closest_metric_prefix.pro create mode 100644 code/functions/common/myget_screen_size.pro create mode 100644 code/functions/common/sunrise.pro delete mode 100644 code/pwwidget/PRISMAwidget.pro delete mode 100644 code/pwwidget/PW_draw_image.pro delete mode 100644 code/pwwidget/PWwidget_cleanup.pro delete mode 100644 code/pwwidget/PWwidget_draw.pro delete mode 100644 code/pwwidget/PWwidget_interpolation.pro delete mode 100644 code/pwwidget/PWwidget_playmovie.pro delete mode 100644 code/pwwidget/PWwidget_positions.pro delete mode 100644 code/pwwidget/PWwidget_slider_box.pro delete mode 100644 code/pwwidget/PWwidget_slider_zoom.pro delete mode 100644 code/pwwidget/PWwidget_zoom.pro diff --git a/code/PRISMAwidget/PWpositions.pro b/code/PRISMAwidget/PWpositions.pro new file mode 100644 index 0000000..a3061b6 --- /dev/null +++ b/code/PRISMAwidget/PWpositions.pro @@ -0,0 +1,86 @@ +; PWpositions widget - table of positions (frames, x, y, box) of a FreeTure detected meteor + +pro PWpositions, pwwidget + +; scaling factor of the widget +wscale = pwwidget.var.wscale + +; creating the various components of the widget +; main window +tlb = widget_base(title = 'PRISMA Widget - Positions table', mbar = mbar, xsize = 347*wscale, ysize = 590*wscale) + +; file menu +button_file = widget_button(mbar, value = 'File', event_pro = 'PWpositions_file') +button_close = widget_button(button_file, value = 'Close') + +; first row, positions table +base1 = widget_base(tlb, scr_xsize = 345*wscale, scr_ysize = 510*wscale, xoffset = 0*wscale, yoffset = 0*wscale) + +table_pos = widget_table(base1, value = ['','','',''], scr_xsize = 345*wscale, scr_ysize = 540*wscale, xoffset = 0*wscale, yoffset = 3*wscale, $ + xsize = 4, ysize = 25, /scroll, x_scroll_size = 345*wscale, y_scroll_size = 540*wscale*3./2., alignment = 2, $ + column_width = [36, 80, 175, 36]*wscale, /no_row_headers, column_labels = ['#', '(X;Y)', 'TIME UTC', 'BOX'], sensitive = 0) + +; second row, boxdim slider +base2 = widget_base(tlb, /frame, scr_xsize = 340*wscale, scr_ysize = 45*wscale, xoffset = 3*wscale, yoffset = 510*wscale) + +label = widget_label(base2, value = 'Centering Box Dim ', $ + scr_xsize = 110*wscale, scr_ysize = 18*wscale, xoffset = 10*wscale, yoffset = 15*wscale) + +slider_box = widget_slider(base2, minimum = 2, maximum = 20, value = 8, event_pro = 'PWpositions_slider_box', sensitive = 0, $ + scr_xsize = 145*wscale, scr_ysize = 18*wscale, xoffset = 120*wscale, yoffset = 15*wscale) + +base2a = widget_base(base2, /nonexclusive, scr_xsize = 50*wscale, scr_ysize = 45*wscale, xoffset = 275*wscale, yoffset = 10*wscale) +button_fixbox = widget_button(base2a, value = ' Fix', sensitive = 0) + +base3_border = widget_base(tlb, scr_xsize = 345*wscale, scr_ysize = 34*wscale, xoffset = 0*wscale, yoffset = 556*wscale) +base3 = widget_base(base3_border, /frame, scr_xsize = 340*wscale, scr_ysize = 28*wscale, xoffset = 3*wscale, yoffset = 3*wscale) + +label = widget_label(base3, value = 'S/N ', $ + scr_xsize = 35*wscale, scr_ysize = 20*wscale, xoffset = 10*wscale, yoffset = 5*wscale) + +text_snrvalue = widget_text(base3, value = '', sensitive = 0, $ + scr_xsize = 40*wscale, scr_ysize = 20*wscale, xoffset = 45*wscale, yoffset = 4*wscale - 2*(wscale mod 2)) + +label = widget_label(base3, value = 'Min ', $ + scr_xsize = 35*wscale, scr_ysize = 20*wscale, xoffset = 120*wscale, yoffset = 5*wscale) + +text_minsnrvalue = widget_text(base3, value = '6.0', /editable, sensitive = 0, $ + scr_xsize = 40*wscale, scr_ysize = 20*wscale, xoffset = 155*wscale, yoffset = 4*wscale - 2*(wscale mod 2)) + +; structure to store tlb uvalue of the main window +pwpositions = { $ + TLB:tlb, $ ; main window + + BUTTON_FILE:button_file, $ ; file button on the widget bar + BUTTON_CLOSE:button_close, $ ; close button on positions window + + TABLE_POS:table_pos, $ ; table for positions file visualization + + SLIDER_BOX:slider_box, $ ; slider for box auto-centre + BUTTON_FIXBOX:button_fixbox, $ ; fix box button + + TEXT_SNRVALUE:text_snrvalue, $ ; text for SNR value in autopos + TEXT_MINSNRVALUE:text_minsnrvalue, $ ; text for Min SNR value in autopos + + PWWIDGET:pwwidget.tlb $ ; parent window PWWidget + } + +; realizing the widget and setting uvalue +widget_control, tlb, /realize +widget_control, tlb, set_uvalue = pwpositions + +widget_control, table_pos, set_table_view = [0, 0], set_table_select=[-1, -1, -1, -1] + +; launching the event manager +xmanager, 'PWpositions', tlb, /no_block, cleanup = 'PWpositions_cleanup' + +widget_control, table_pos, sensitive = 1 +widget_control, slider_box, sensitive = 1 +widget_control, button_fixbox, sensitive = 1 +widget_control, text_snrvalue, set_value = '', sensitive = 1 +widget_control, text_minsnrvalue, sensitive = 1 + +; updating pwwidget reference in pwwidget structure +pwwidget.pwpositions = tlb + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWpositions/PWpositions_cleanup.pro b/code/PRISMAwidget/PWpositions/PWpositions_cleanup.pro new file mode 100644 index 0000000..dd4a8e7 --- /dev/null +++ b/code/PRISMAwidget/PWpositions/PWpositions_cleanup.pro @@ -0,0 +1,40 @@ +; This procedure managed the action to be performed when the PWpositions widget is closed or die + +pro PWpositions_cleanup, widgetid + +compile_opt idl2 + +; retrieving values and uvalues +widget_control, widgetid, get_uvalue = pwpositions + +; if pwwidget main window is not there +if ~widget_is_active(pwpositions.pwwidget) then begin + + ; let's just destroy the widget + widget_control, widgetid, /destroy + return + +endif ; else, reset positions' related info on main window + +widget_control, pwpositions.pwwidget, get_uvalue = pwwidget + +; setting sensitivities for pwwidget components +widget_control, pwwidget.button_loadpos, set_button = 0 +widget_control, pwwidget.button_pos, get_uvalue = positions + +positions = {DEFINED:0, POSFILE:positions.posfile, FREETURE:positions.freeture, NDET:0, frame:-1, XPOS:-1, YPOS:-1, $ + STRCOORD:'', DATA:'', BOX:8} + +widget_control, pwwidget.button_pos, set_uvalue = positions + +; resetting the reference to pwpositions in pwwidget +pwwidget.pwpositions = 0L +widget_control, pwpositions.pwwidget, set_uvalue = pwwidget + +; updating image display +PW_draw_image, pwwidget + +; destroy the widget +widget_control, widgetid, /destroy + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWpositions/PWpositions_event.pro b/code/PRISMAwidget/PWpositions/PWpositions_event.pro new file mode 100644 index 0000000..f22503e --- /dev/null +++ b/code/PRISMAwidget/PWpositions/PWpositions_event.pro @@ -0,0 +1,7 @@ +; This is the standard procedure automatically invoked when an event_pro is not defined for a widget + +pro PWpositions_event, event + +compile_opt idl2 + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWpositions/PWpositions_file.pro b/code/PRISMAwidget/PWpositions/PWpositions_file.pro new file mode 100644 index 0000000..2ce721b --- /dev/null +++ b/code/PRISMAwidget/PWpositions/PWpositions_file.pro @@ -0,0 +1,21 @@ +; This is the standard procedure automatically invoked when an event_pro is not defined for a widget + +pro PWpositions_file, event + +compile_opt idl2 + +widget_control, event.id, get_value = value + +; case for different menu options +case value of + + 'Close': begin + + ; closing widget + PWpositions_cleanup, event.top + + end + +endcase + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWpositions/PWpositions_slider_box.pro b/code/PRISMAwidget/PWpositions/PWpositions_slider_box.pro new file mode 100644 index 0000000..667d05f --- /dev/null +++ b/code/PRISMAwidget/PWpositions/PWpositions_slider_box.pro @@ -0,0 +1,32 @@ +; This procedure manages the events on the box dim slider of PRISMAwidget + +pro PWpositions_slider_box, event + +compile_opt idl2 + +; retrieving values and uvalues +widget_control, event.top, get_uvalue = pwpositions +widget_control, pwpositions.slider_box, get_value = box + +widget_control, pwpositions.pwwidget, get_uvalue = pwwidget +widget_control, pwwidget.draw_big, get_uvalue = img +widget_control, pwwidget.button_pos, get_uvalue = positions + +; checking if loadpos and autopos are activated +if widget_info(pwwidget.button_loadpos, /button_set) and widget_info(pwwidget.button_autopos, /button_set) then begin + + ; if needed, overwriting current box in positions + kk = where(positions.frame eq img.framenum) + kk = kk[0] + if kk ne -1 then positions.box[kk] = box + widget_control, pwwidget.button_pos, set_uvalue = positions + + ; computing autopos + PW_autopos, pwwidget + + ; updating image display + PW_draw_image, pwwidget + +endif + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget.pro b/code/PRISMAwidget/PWwidget.pro new file mode 100644 index 0000000..3c956f4 --- /dev/null +++ b/code/PRISMAwidget/PWwidget.pro @@ -0,0 +1,314 @@ +; This widget is used to interactively visualize the PRISMA data +; (both detections and captures) and allows to produce animated gif +; and images, e.g. for meteors detections. + +pro PWwidget + +; runtime = 1 has to be set to 1 in order to produce the runtime distribution the value of "runtime" +; otherwise runtime = 0 for regular execution +runtime = 0 + +cd, current = basedir + +; configuration file path +config_file = config_path_filename() + +; finding the configuration file +if runtime or (config_file eq '') then begin + + ; opening a dialog_pickfile + config_file = dialog_pickfile(path = basedir, filter = '*.ini', /must_exist, title = 'Please select the PRISMA configuration file') + if config_file eq '' then return + +endif + +; loading the configuration file from provided path +config = get_config(config_file) + +; reading the black and white logos +logo_black = get_logo(config.path.logo_black, transparent = 'black', rescale_dim = 530) +logo_white = get_logo(config.path.logo_white, transparent = 'white', rescale_dim = 530) + +; read the solutions file +readcol, config.path.solutions, list_camera, list_pseudo, format = '(A,A)', /silent +list_camera = strupcase(list_camera) +list_pseudo = strupcase(list_pseudo) + +; scaling factor for widget dimensions +; 1 for HD and FHD screens +; 2 for QHD, UHD and 4K screens +wscale = round(mean(myget_screen_size()/[1920., 1080.])) +wscale = (wscale > 1) < 2 + +; font name and size +font = 'Verdana*' + strtrim(fix(13*wscale), 2) +widget_control, default_font = font +widget_control, units = 0 + +; creating the various components of the widget +; main window +tlb = widget_base(title = 'PRISMA Widget', mbar = mbar, xsize = 1130*wscale + (wscale mod 2), ysize = 590*wscale, /tlb_size_events) + +; file menu +button_file = widget_button(mbar, value = 'File', /menu, event_pro = 'PWwidget_file') +button_detection = widget_button(button_file, value = 'Open Detection') +button_capture = widget_button(button_file, value = 'Open Capture') +button_exit = widget_button(button_file, value = 'Exit') + +; logo menu +button_logo = widget_button(mbar, value = 'Logo', /menu) +button_showlogo = widget_button(button_logo, value = 'Show logo', /checked_menu, event_pro = 'PWwidget_logo') +button_showinfo = widget_button(button_logo, value = 'Show info', /checked_menu, event_pro = 'PWwidget_logo') +button_importlogo = cw_pdmenu(button_logo, ['1\Import\PWwidget_logo', '0\Black logo\PWwidget_logo', '0\White logo\PWwidget_logo', '2\Both logos\PWwidget_logo'], $ + /mbar, /return_name) + +; positions menu +button_pos = widget_button(mbar, value = 'Positions', /menu, event_pro = 'PWwidget_positions', sensitive = 0) +button_loadpos = widget_button(button_pos, value = 'Load', /checked_menu, sensitive = 0) +button_autopos = widget_button(button_pos, value = 'Auto-centre', /checked_menu, sensitive = 0) +button_showbox = widget_button(button_pos, value = 'Show box', /checked_menu, sensitive = 0) + +; first row +base1 = widget_base(tlb, scr_xsize = 1130*wscale + (wscale mod 2), scr_ysize = 23*wscale, xoffset = 0*wscale, yoffset = 0*wscale) + +; image filename input +list_mode = widget_droplist(base1, value = ['Detection','Capture'], event_pro = 'PWwidget_modelist', $ + scr_xsize = 80*wscale, scr_ysize = 22*wscale, xoffset = 3*wscale, yoffset = 4*wscale - 2*(wscale mod 2)) + +label_filename = widget_label(base1, value = 'Image filename: ', /align_right, $ + scr_xsize = 108*wscale, scr_ysize = 18*wscale, xoffset = 83*wscale, yoffset = 5*wscale) + +text_filename = widget_text(base1, value = '', event_pro = 'PWwidget_filename', /editable, $ + scr_xsize = 692*wscale, scr_ysize = 18*wscale, xoffset = 191*wscale, yoffset = 4*wscale) + +; prev/next image buttons +button_previmage = widget_button(base1, value = '<<', event_pro = 'PWwidget_prevnextimage', sensitive = 0, $ + scr_xsize = 30*wscale, scr_ysize = 19*wscale, xoffset = 885*wscale, yoffset = 3*wscale) +button_nextimage = widget_button(base1, value = '>>', event_pro = 'PWwidget_prevnextimage', sensitive = 0, $ + scr_xsize = 30*wscale, scr_ysize = 19*wscale, xoffset = 915*wscale, yoffset = 3*wscale) + +; Movie export +label_nframe = widget_label(base1, value = 'Movie: ', /align_right, $ + scr_xsize = 56*wscale, scr_ysize = 18*wscale, xoffset = 947*wscale, yoffset = 5*wscale) + +text_nframe = widget_text(base1, value = '', /editable, sensitive = 0, $ + scr_xsize = 45*wscale, scr_ysize = 18*wscale, xoffset = 1005*wscale, yoffset = 4*wscale) + +button_playmovie = widget_button(base1, value = 'Play', event_pro = 'PWwidget_playmovie', sensitive = 0, $ + scr_xsize = 37*wscale, scr_ysize = 19*wscale, xoffset = 1052*wscale, yoffset = 3*wscale) + +button_savemovie = widget_button(base1, value = 'Save', event_pro = 'PWwidget_playmovie', sensitive = 0, $ + scr_xsize = 37*wscale + (wscale mod 2), scr_ysize = 19*wscale, xoffset = 1090*wscale, yoffset = 3*wscale) +; second row +base2 = widget_base(tlb, scr_xsize = 1130*wscale, scr_ysize = 483*wscale, xoffset = 0*wscale, yoffset = 23*wscale) + +; big draw window +draw_big = widget_draw(base2, /motion_events, /frame, /button_events, event_pro = 'PWwidget_draw', sensitive = 0, $ + scr_xsize = 640*wscale+2, scr_ysize = 480*wscale+2, xoffset = 3*wscale, yoffset = 3*wscale) + +draw_zoom = widget_draw(base2, /motion_events, /button_events, /frame, event_pro = 'PWwidget_zoom', sensitive = 0, $ + scr_xsize = 480*wscale+2, scr_ysize = 480*wscale+2, xoffset = 646*wscale, yoffset = 3*wscale) + +; third row +base3 = widget_base(tlb, scr_xsize = 1130*wscale + (wscale mod 2), scr_ysize = 48*wscale, xoffset = 0*wscale, yoffset = 507*wscale) + +; first box, min / max image values +base31 = widget_base(base3, /frame, scr_xsize = 850*wscale, scr_ysize = 45*wscale, xoffset = 3*wscale, yoffset = 3*wscale) + +label_min = widget_label(base31, value = 'Image Cuts Min ', $ + scr_xsize = 112*wscale, scr_ysize = 18*wscale, xoffset = 10*wscale, yoffset = 15*wscale) + +slider_min = widget_slider(base31, minimum = 0, maximum = 4095, value = 0, event_pro = 'PWwidget_slider_minmax', sensitive = 0, $ + scr_xsize = 325*wscale, scr_ysize = 18*wscale, xoffset = 122*wscale, yoffset = 15*wscale) + +label_max = widget_label(base31, value = 'Max ', $ + scr_xsize = 35*wscale, scr_ysize = 18*wscale, xoffset = 470*wscale, yoffset = 15*wscale) + +slider_max = widget_slider(base31, minimum = 0, maximum = 4095, value = 4095, event_pro = 'PWwidget_slider_minmax', sensitive = 0, $ + scr_xsize = 325*wscale, scr_ysize = 18*wscale, xoffset = 505*wscale, yoffset = 15*wscale) + +; second box, zoom scale +base32 = widget_base(base3, /frame, scr_xsize = 270*wscale + (wscale mod 2), scr_ysize = 45*wscale, xoffset = 857*wscale, yoffset = 3*wscale) + +label_zoom = widget_label(base32, value = 'Zoom ', $ + scr_xsize = 40*wscale, scr_ysize = 18*wscale, xoffset = 12*wscale, yoffset = 15*wscale) + +slider_zoom = widget_slider(base32, minimum = 0, maximum = 5, value = 5, event_pro = 'PWwidget_slider_zoom', sensitive = 0, $ + scr_xsize = 140*wscale, scr_ysize = 18*wscale, xoffset = 52*wscale, yoffset = 15*wscale) + +base32a = widget_base(base32, /nonexclusive, scr_xsize = 70*wscale, scr_ysize = 45*wscale, xoffset = 202*wscale, yoffset = 10*wscale) +button_fullzoom = widget_button(base32a, value = ' Full', event_pro = 'PWwidget_fullzoom', sensitive = 0) + +; fourth row +base4_border = widget_base(tlb, scr_xsize = 1130*wscale, scr_ysize = 34*wscale, xoffset = 0*wscale, yoffset = 556*wscale) +base4 = widget_base(base4_border, scr_xsize = 1130*wscale, scr_ysize = 31*wscale, xoffset = 0*wscale, yoffset = 0*wscale) + +; first box, pixel position +base41 = widget_base(base4, /frame, scr_xsize = 178*wscale, scr_ysize = 28*wscale, xoffset = 3*wscale, yoffset = 3*wscale) + +label_xpos = widget_label(base41, value = 'Pixel X ', $ + scr_xsize = 58*wscale, scr_ysize = 20*wscale, xoffset = 10*wscale, yoffset = 5*wscale) + +; X position +text_xpos = widget_text(base41, value = '', sensitive = 0, $ + scr_xsize = 40*wscale, scr_ysize = 20*wscale, xoffset = 68*wscale, yoffset = 4*wscale - 2*(wscale mod 2)) + +; Y position +label_ypos = widget_label(base41, value = 'Y ', $ + scr_xsize = 14*wscale, scr_ysize = 20*wscale, xoffset = 116*wscale, yoffset = 5*wscale) + +text_ypos = widget_text(base41, value = '', sensitive = 0, $ + scr_xsize = 40*wscale, scr_ysize = 20*wscale, xoffset = 130*wscale, yoffset = 4*wscale - 2*(wscale mod 2)) + +; second box, pixel value +base42 = widget_base(base4, /frame, scr_xsize = 128*wscale, scr_ysize = 28*wscale, xoffset = 185*wscale, yoffset = 3*wscale) + +label_imgvalue = widget_label(base42, value = 'Pixel Value ', $ + scr_xsize = 70*wscale, scr_ysize = 20*wscale, xoffset = 10*wscale, yoffset = 5*wscale) + +text_imgvalue = widget_text(base42, value = '', sensitive = 0, $ + scr_xsize = 40*wscale, scr_ysize = 20*wscale, xoffset = 80*wscale, yoffset = 4*wscale - 2*(wscale mod 2)) + +; third box, zoom centre +base43 = widget_base(base4, /frame, scr_xsize = 240*wscale, scr_ysize = 28*wscale, xoffset = 317*wscale, yoffset = 3*wscale) + +label_zoomxc = widget_label(base43, value = 'Zoom Centre Xc ', $ + scr_xsize = 110*wscale, scr_ysize = 20*wscale, xoffset = 10*wscale, yoffset = 5*wscale) + +; Xc position +text_zoomxc = widget_text(base43, value = '', sensitive = 0, $ + scr_xsize = 40*wscale, scr_ysize = 20*wscale, xoffset = 120*wscale, yoffset = 4*wscale - 2*(wscale mod 2)) + +; Yc position +label_zoomyc = widget_label(base43, value = 'Yc ', $ + scr_xsize = 22*wscale, scr_ysize = 20*wscale, xoffset = 170*wscale, yoffset = 5*wscale) + +text_zoomyc = widget_text(base43, value = '', sensitive = 0, $ + scr_xsize = 40*wscale, scr_ysize = 20*wscale, xoffset = 192*wscale, yoffset = 4*wscale - 2*(wscale mod 2)) + +; fourth box, options +base44 = widget_base(base4, /frame, scr_xsize = 255*wscale, scr_ysize = 28*wscale, xoffset = 561*wscale, yoffset = 3*wscale) +base44a = widget_base(base44, /row, scr_xsize = 255*wscale, scr_ysize = 28*wscale, /nonexclusive, xoffset = 6*wscale, yoffset = -1*wscale) + +; options buttons +button_negative = widget_button(base44a, value = ' Negative', event_pro = 'PWwidget_negative', sensitive = 0, $ + scr_xsize = 65*wscale, scr_ysize = 28*wscale) + +button_logscale = widget_button(base44a, value = ' Log Scale', event_pro = 'PWwidget_logscale', sensitive = 0, $ + scr_xsize = 65*wscale, scr_ysize = 28*wscale) + +button_interpol = widget_button(base44a, value = ' Interpole', event_pro = 'PWwidget_interpolation', sensitive = 0, $ + scr_xsize = 65*wscale, scr_ysize = 28*wscale) + +; credits box, options +base45 = widget_base(base4, scr_xsize = 309*wscale, scr_ysize = 28*wscale, xoffset = 818*wscale, yoffset = 2*wscale) +label_authors = widget_label(base45, value = 'Authors: D. Barghini and D. Gardiol', font = font, /align_right, $ + scr_xsize = 305*wscale + (wscale mod 2), scr_ysize = 13*wscale, xoffset = 3*wscale, yoffset = 0*wscale) +label_address = widget_label(base45, value = 'INAF Osservatorio Astrofisico di Torino - 18/06/2024', font = font, /align_right, $ + scr_xsize = 305*wscale + (wscale mod 2), scr_ysize = 13*wscale, xoffset = 3*wscale, yoffset = 15*wscale) + +; saving current geometry (scr_xsize) +geom = widget_info(tlb, /geometry) +xsize = geom.xsize +ysize = geom.ysize + +; variable structure +var = { $ + RUNTIME:runtime, $ ; boolean for runtime distribution + BASEDIR:basedir, $ ; base directory + CONFIG:config, $ ; configuration structure + LOGO_BLACK:logo_black, $ ; black-background version of the logo + LOGO_WHITE:logo_white, $ ; white-background version of the logo + LIST_CAMERA:list_camera, $ ; list of cameras + LIST_PSEUDO:list_pseudo, $ ; list of pseudos + WSCALE:wscale, $ ; scaling factor for widget dimensions + XSIZE:xsize, $ ; x dimension of the widget (px) + YSIZE:ysize $ ; x dimension of the widget (px) + } + +; structure to store tlb uvalue of the main window +pwwidget = { $ + TLB:tlb, $ ; main window + + BUTTON_FILE:button_file, $ ; file menu + BUTTON_CAPTURE:button_capture, $ ; capture load button on file menu + BUTTON_DETECTION:button_detection, $ l detection load button on file menu + BUTTON_EXIT:button_exit, $ ; exit button on file menu + + BUTTON_LOGO:button_logo, $ ; logo menu + BUTTON_IMPORTLOGO:button_importlogo, $ ; upload logos (black / white / all) on logo menu + BUTTON_SHOWLOGO:button_showlogo, $ ; show logo on zoom panel + BUTTON_SHOWINFO:button_showinfo, $ ; show information on zoom panel + + + BUTTON_POS:button_pos, $ ; positions menu + BUTTON_LOADPOS:button_loadpos, $ ; load positions button on positions menu + BUTTON_AUTOPOS:button_autopos, $ ; auto positions button on positions menu + BUTTON_SHOWBOX:button_showbox, $ ; show box button on positions menu + + LIST_MODE:list_mode, $ ; droplist for detection and capture mode selection + TEXT_FILENAME:text_filename, $ ; filename text + BUTTON_PREVIMAGE:button_previmage, $ ; button to select previous image (if exists) + BUTTON_NEXTIMAGE:button_nextimage, $ ; button to select next image (if exists) + + TEXT_NFRAME:text_nframe, $ ; text widget for custom movie of n frames starting from current image + BUTTON_PLAYMOVIE:button_playmovie, $ ; button to play custom movie + BUTTON_SAVEMOVIE:button_savemovie, $ ; button to save of custom movie after play + + DRAW_BIG:draw_big, $ ; draw widget (big) + DRAW_ZOOM:draw_zoom, $ ; draw widget (small, zoom window) + + TEXT_XPOS:text_XPOS, $ ; text for current xpos cursor + TEXT_YPOS:text_YPOS, $ ; text for current ypos cursor + + TEXT_IMGVALUE:text_imgvalue, $ ; text for current imgvalue cursor + + TEXT_ZOOMXC:text_zoomxc, $ ; text for xcentre zoom box + TEXT_ZOOMYC:text_zoomyc, $ ; text for ycentre zoom box + + SLIDER_MIN:slider_min, $ ; slider for min image curt value + SLIDER_MAX:slider_max, $ ; slider for max image cut value + + SLIDER_ZOOM:slider_zoom, $ ; slider for zoom window dim + BUTTON_FULLZOOM:button_fullzoom, $ ; button to fix min zoom scale + + BUTTON_NEGATIVE:button_negative, $ ; button for negative colorscale control + BUTTON_LOGSCALE:button_logscale, $ ; button for log-scale control + BUTTON_INTERPOL:button_interpol, $ ; button for rebin interpolation control + + ; CHILDREN WIDGETS + PWPOSITIONS:0L, $ ; uvalue + + VAR:var $ ; widget variables structure + } + +; realize the widgets +widget_control, tlb, /realize +widget_control, tlb, set_uvalue = pwwidget + +; initializing uvalues +img = {IMAGE:fltarr(1280,960), XSIZE:1280, YSIZE:960, XSIZE_TRUE:1280, YSIZE_TRUE:960, IMAGE_ORIG:list(fltarr(1280,960)), $ + XSIZE_ORIG:1280, YSIZE_ORIG:960, FSCALE:1., FRAMENUM:0, DATA:'', CAMERA:'', PSEUDO:''} +widget_control, draw_big, set_uvalue = img + +imgzoom = {IMAGE:fltarr(480*wscale, 480*wscale), DS:240., FACTOR_DS:1., XSIZE:480*wscale, YSIZE:480*wscale, $ + XCOORD:lonarr(480*wscale), YCOORD:lonarr(480*wscale), XCOORD_ORIG:lonarr(480*wscale), YCOORD_ORIG:lonarr(480*wscale), $ + XCN:640, YCN:480, XCN_ORIG:640, YCN_ORIG:480} +widget_control, draw_zoom, set_uvalue = imgzoom + +posfile = '..' + path_sep() + 'newpositions.txt' +freeture = '..' + path_sep() + 'positions.txt' + +positions = {DEFINED:0, POSFILE:posfile, FREETURE:freeture, NDET:0, frame:-1, XPOS:-1, YPOS:-1, STRCOORD:'', DATA:'', BOX:8} +widget_control, button_pos, set_uvalue = positions + +widget_control, button_file, set_uvalue = basedir +widget_control, list_mode, set_uvalue = 'detection' +widget_control, text_filename, set_uvalue = '' + +; launching the event manager +xmanager, 'PWwidget', tlb, /no_block, cleanup = 'PWwidget_cleanup', event_handler = 'PWwidget_resize' + +device, /decompose + +end \ No newline at end of file diff --git a/code/pwwidget/PW_autopos.pro b/code/PRISMAwidget/PWwidget/PW_autopos.pro similarity index 68% rename from code/pwwidget/PW_autopos.pro rename to code/PRISMAwidget/PWwidget/PW_autopos.pro index 2ffeb12..5a732a5 100644 --- a/code/pwwidget/PW_autopos.pro +++ b/code/PRISMAwidget/PWwidget/PW_autopos.pro @@ -5,8 +5,9 @@ pro PW_autopos, pwwidget compile_opt idl2 ; retrieve user values -widget_control, pwwidget.button_pos, get_uvalue = position -widget_control, pwwidget.text_minvalue, get_value = snr_min +widget_control, pwwidget.button_pos, get_uvalue = positions +widget_control, pwwidget.pwpositions, get_uvalue = pwpositions +widget_control, pwpositions.text_minsnrvalue, get_value = snr_min ; checking snr_min value if valid_num(snr_min) then begin @@ -16,24 +17,24 @@ if valid_num(snr_min) then begin endif else begin snr_min = 6.0 - widget_control, pwwidget.text_minvalue, set_value = strtrim(string(snr_min, format = '(f10.1)'), 2) + widget_control, pwpositions.text_minsnrvalue, set_value = strtrim(string(snr_min, format = '(f10.1)'), 2) endelse -defined = position.defined +defined = positions.defined -; if there is at least one position +; if there is at least one positions if defined then begin - posfile = position.posfile - freeture = position.freeture - Ndet = position.Ndet - frame = position.frame - xpos = position.xpos - ypos = position.ypos - strcoord = position.strcoord - data = position.data - box = position.box + posfile = positions.posfile + freeture = positions.freeture + Ndet = positions.Ndet + frame = positions.frame + xpos = positions.xpos + ypos = positions.ypos + strcoord = positions.strcoord + data = positions.data + box = positions.box widget_control, pwwidget.draw_big, get_uvalue = img @@ -42,17 +43,17 @@ if defined then begin ii = ii[0] ; check for button_fixbox - button_fixbox = widget_info(pwwidget.button_fixbox, /button_set) - widget_control, pwwidget.slider_box, get_value = dbox + button_fixbox = widget_info(pwpositions.button_fixbox, /button_set) + widget_control, pwpositions.slider_box, get_value = dbox if button_fixbox then this_box = dbox else this_box = box[ii] ; compute the box limits minx = max([0, xpos[ii] - this_box]) - maxx = min([img.xsize-1, xpos[ii] + this_box]) + maxx = min([img.xsize_orig-1, xpos[ii] + this_box]) miny = max([0, ypos[ii] - this_box]) - maxy = min([img.ysize-1, ypos[ii] + this_box]) + maxy = min([img.ysize_orig-1, ypos[ii] + this_box]) - bocs = img.image[minx:maxx, miny:maxy] + bocs = (img.image_orig[0])[minx:maxx, miny:maxy] ; median filtering mediana = median(bocs, /even) @@ -68,12 +69,12 @@ if defined then begin endif else SNR = 0. - widget_control, pwwidget.text_snrvalue, set_value = strtrim(string(SNR, format = '(f10.1)'), 2) + widget_control, pwpositions.text_snrvalue, set_value = strtrim(string(SNR, format = '(f10.1)'), 2) ; (x,y) bolide position found: perform autocentering if jj[0] ne -1 and SNR ge snr_min then begin - ind = array_indices(bocs,jj) + ind = array_indices(bocs, jj) xpos1 = round(mean(ind[0,*])) + xpos[ii] - this_box ypos1 = round(mean(ind[1,*])) + ypos[ii] - this_box kk = where(frame eq img.framenum) @@ -130,7 +131,7 @@ if defined then begin data = data[kk0] box = box[kk0] - ; no more position in list + ; no more positions in list endif else begin defined = 0 @@ -146,18 +147,18 @@ if defined then begin endelse - ; print position to file + ; print positions to file nl = n_elements(xpos) openw, lun, posfile, /get_lun if defined then for i=0, nl-1 do printf, lun, frame[i], strcoord[i], data[i], box[i], format = '(I7,A15,A30,I7)' close, lun & free_lun, lun - ; save position values - position = {defined:defined, posfile:posfile, freeture:freeture, Ndet:Ndet, frame:frame, xpos:xpos, ypos:ypos, $ - strcoord:strcoord, data:data, box:box} - widget_control, pwwidget.button_pos, set_uvalue = position + ; save positions values + positions = {defined:defined, posfile:posfile, freeture:freeture, Ndet:Ndet, frame:frame, xpos:xpos, ypos:ypos, $ + strcoord:strcoord, data:data, box:box} + widget_control, pwwidget.button_pos, set_uvalue = positions - ; print position to widget table + ; print positions to widget table if defined then begin str = transpose([[string(fix(frame))], [string(strcoord)], [string(data)], [string(box)]]) @@ -167,8 +168,9 @@ if defined then begin str = ['', '', '', ''] endelse - - widget_control, pwwidget.table_pos, table_ysize = Ndet > 25, alignment = 2, set_value = str + + ; printing table + widget_control, pwpositions.table_pos, table_ysize = Ndet > 25, alignment = 2, set_value = str endif diff --git a/code/PRISMAwidget/PWwidget/PW_closest_ds.pro b/code/PRISMAwidget/PWwidget/PW_closest_ds.pro new file mode 100644 index 0000000..7b6b90c --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PW_closest_ds.pro @@ -0,0 +1,9 @@ +; given dim and ds integers, this function to computes the nearest and lowest ds such as dim / ds is integer + +pro PW_closest_ds, dim, ds + +; we would have to use (2.*ds), since ds is the half size of the zoom. +q = ceil(float(dim)/ds) +ds = round(float(dim)/q) + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PW_compute_ds.pro b/code/PRISMAwidget/PWwidget/PW_compute_ds.pro new file mode 100644 index 0000000..ba2805f --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PW_compute_ds.pro @@ -0,0 +1,52 @@ +; computing and adjusting the zoom image dimension + +function PW_compute_ds, pwwidget + +; retrieve uvalues +widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom + +; scaling factor of the widget +wscale = pwwidget.var.wscale + +; max. zoom scale factor +factor_ds = imgzoom.factor_ds + +; zoom scale +widget_control, pwwidget.slider_zoom, get_value = zscale +slider_min_max = widget_info(pwwidget.slider_zoom, /slider_min_max) +if widget_info(pwwidget.button_fullzoom, /button_set) then zscale = slider_min_max[1] + +; deciding the zoom image dimensions +if widget_info(pwwidget.button_fullzoom, /button_set) then begin + + ; zoom half-size + ds = long(15*2^zscale) + +endif else begin + + ; zoom half-size + ds = 15.*2^zscale/factor_ds + + ; adjusting ds to make it an integer fraction of imgzoom.xsize + PW_closest_ds, imgzoom.xsize/wscale, ds + + ; checking if zoom scale is appropriate + while ds lt 1 do begin + + ; if not adequate, decrease it by one + zscale = zscale - 1 + widget_control, pwwidget.slider_zoom, set_value = zscale + + ; zoom half-size + ds = 15.*2^zscale/factor_ds + + ; adjusting ds to make it an integer fraction of imgzoom.xsize + PW_closest_ds, imgzoom.xsize/wscale, ds + + endwhile + +endelse + +return, ds + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PW_draw_image.pro b/code/PRISMAwidget/PWwidget/PW_draw_image.pro new file mode 100644 index 0000000..6acde62 --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PW_draw_image.pro @@ -0,0 +1,248 @@ +; This procedure manages the drawing of the current image on both the big and zoom windows of PRISMAwigdget + +pro PW_draw_image, pwwidget, $ + snapshot_big = snapshot_big, $ + snapshot_zoom = snapshot_zoom + +compile_opt idl2 + +; retrieve images +widget_control, pwwidget.draw_big, get_uvalue = img +widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom +widget_control, pwwidget.text_filename, get_value = filename + +; scaling factor of the widget +wscale = pwwidget.var.wscale + +; scaling factor of the image +fscale = img.fscale + +; zoom scale / size +widget_control, pwwidget.slider_zoom, get_value = zscale +ds = imgzoom.ds + +if filename ne '' then begin + + ; display image in draw_big + s = size(img.image) + + ; image is defined + if s[1] ne 0 then begin + + ; display image in main draw window + widget_control, pwwidget.draw_big, get_value = dWin + wset, dWin + erase + + ; retrieve slider values + widget_control, pwwidget.slider_min, get_value = minimo + widget_control, pwwidget.slider_max, get_value = massimo + + ; if log-scale option is selected + if widget_info(pwwidget.button_logscale, /button_set) then begin + + ima = bytscl(alog10(img.image + 1), alog10(minimo + 1), alog10(massimo + 1)) + + endif else begin + + ima = bytscl(img.image, minimo, massimo) + + endelse + + ; if interpol option is selected + if widget_info(pwwidget.button_interpol, /button_set) then begin + + tvima = congrid(ima, 640*wscale, 480*wscale, cubic = -0.5, /center) + + endif else begin + + tvima = congrid(ima, 640*wscale, 480*wscale, /center) + + endelse + + ; if button_negative option is selected + if widget_info(pwwidget.button_negative, /button_set) then begin + + tvima = 255 - tvima + + endif + + ; displaying the full image + tv, tvima + + ; draw blue box for zoom region + if widget_info(pwwidget.button_fullzoom, /button_set) then begin ; if full zoom + + tvbox, ds*wscale, imgzoom.xcn/2*wscale, imgzoom.ycn/2*wscale, color = 'blue' + + endif else begin ; otherwise + + tvbox, ds*wscale/fscale, imgzoom.xcn/2*wscale, imgzoom.ycn/2*wscale, color = 'blue' + + endelse + + ; if positions is selected + if widget_info(pwwidget.button_loadpos, /button_set) then begin + + widget_control, pwwidget.button_pos, get_uvalue = positions + + ; if framenum is listed in positions + if positions.defined then begin + + ii = where(positions.frame eq img.framenum) + + if ii[0] ne -1 then begin + + ii = ii[0] + + ; draw red circle + tvcircle, 5*wscale, round(positions.xpos[ii]/2*wscale/fscale), round(positions.ypos[ii]/2*wscale/fscale), color = 'red',thick = 2 + + endif + + endif + + endif + + ; before displaying logo, taking a snapshot of the zoom window, + ; in case we have to export animation / track + snapshot_big = tvrd(/true) + + endif + + ; display image in draw_zoom + s = size(imgzoom.image) + + ; image is defined + if s[1] ne 0 then begin + + ; display image in main draw window + widget_control, pwwidget.draw_zoom, get_value = dWin + wset, dWin + erase + + ; retrieve slider values + widget_control, pwwidget.slider_min, get_value = minimo + widget_control, pwwidget.slider_max, get_value = massimo + + ; if log-scale option is selected + if widget_info(pwwidget.button_logscale, /button_set) then begin + + tvimazoom = bytscl(alog10(imgzoom.image + 1), alog10(minimo + 1), alog10(massimo + 1)) + + endif else begin + + tvimazoom = bytscl(imgzoom.image, minimo, massimo) + + endelse + + ; if button_negative option is selected + if widget_info(pwwidget.button_negative, /button_set) then begin + + tv, 255 - tvimazoom + + endif else begin + + tv, tvimazoom + + endelse + + ; draw position if available + if widget_info(pwwidget.button_loadpos, /button_set) then begin + + widget_control, pwwidget.button_pos, get_uvalue = positions + + ; if framenum is listed in positions + if positions.defined then begin + + ii = where(positions.frame eq img.framenum) + + if ii[0] ne -1 then begin + + ii = ii[0] + + if positions.xpos[ii] ge min(imgzoom.xcoord_orig) and positions.xpos[ii] le max(imgzoom.xcoord_orig) and $ + positions.ypos[ii] ge min(imgzoom.ycoord_orig) and positions.ypos[ii] le max(imgzoom.ycoord_orig) then begin + + dx = abs(imgzoom.xcoord_orig - positions.xpos[ii]) + dy = abs(imgzoom.ycoord_orig - positions.ypos[ii]) + + jx = where(abs(dx) eq min(dx)) + jy = where(abs(dy) eq min(dy)) + + jx = median(jx) + jy = median(jy) + + ; draw red circle (position) + tvcircle, 5*wscale, jx, jy, color = 'red', thick = 2 + + ; draw box + if widget_info(pwwidget.button_showbox, /button_set) and ~widget_info(pwwidget.button_fullzoom, /button_set) then begin + + tvbox, 2^(4 - zscale)*(2*positions.box[ii] + 1)*wscale, jx, jy, color = 'green', thick = 2, /device + + endif + + endif + + endif + + endif + + endif + + ; before displaying logo, taking a snapshot of the zoom window, + ; in case we have to export animation / track + snapshot_zoom = tvrd(/true) + + ; displaying logo if required + if widget_info(pwwidget.button_showlogo, /button_set) then begin + + ; loading the appropriate logo for the background + if widget_info(pwwidget.button_negative, /button_set) then begin + + logo = pwwidget.var.logo_white + + endif else begin + + logo = pwwidget.var.logo_black + + endelse + + ; overplot the logo + cgimage, logo, alphafgposition = [(479. - 132.)/480., 5./480., 1., (5. + 132.)/480.] + + endif + + ; displaying info if required + if widget_info(pwwidget.button_showinfo, /button_set) then begin + + ; loading the appropriate logo for the background + if widget_info(pwwidget.button_negative, /button_set) then begin + + text_color = 'black' + + endif else begin + + text_color = 'white' + + endelse + + ; character size for information textbox + charsize1 = 2.3*wscale + charsize2 = 1.5*wscale + + camera = img.camera + ' - ' + img.pseudo + time = repstr(strmid(img.data, 0, 22), 'T', ' @ ') + ' UT' + + ; displaying informational text + cgtext, 10./480., 450./480., camera, color = text_color, charsize = charsize1, /font, tt_font = 'Verdana Bold' + cgtext, 10./480., 425./480., time, color = text_color, charsize = charsize2, /font, tt_font = 'Verdana Bold' + + endif + + endif + +endif + +end \ No newline at end of file diff --git a/code/pwwidget/PW_loadpos.pro b/code/PRISMAwidget/PWwidget/PW_loadpos.pro similarity index 65% rename from code/pwwidget/PW_loadpos.pro rename to code/PRISMAwidget/PWwidget/PW_loadpos.pro index 19aa9b1..e657553 100644 --- a/code/pwwidget/PW_loadpos.pro +++ b/code/PRISMAwidget/PWwidget/PW_loadpos.pro @@ -1,12 +1,16 @@ -; This procedure loads the position values into the PRISMAwidget +; This procedure loads the positions values into the PRISMAwidget pro PW_loadpos, pwwidget -widget_control, pwwidget.button_pos, get_uvalue=position -widget_control, pwwidget.slider_box, get_value=dbox +compile_opt idl2 + +; retrieve user values +widget_control, pwwidget.button_pos, get_uvalue = positions +widget_control, pwwidget.pwpositions, get_uvalue = pwpositions +widget_control, pwpositions.slider_box, get_value = dbox -posfile = position.posfile -freeture = position.freeture +posfile = positions.posfile +freeture = positions.freeture ; search for the newpositions.txt file ff = file_search(posfile) @@ -43,15 +47,18 @@ if info.size gt 0 then begin ; read the file table = read_table(posfile, /text) - s = size(table) - frame = reform(fix(table[0,*])) strcoord = reform(table[1,*]) data = reform(table[2,*]) lzeros_datastring, data + ; number of rows Ndet = n_elements(strcoord) + ; table size + s = size(table) + + ; fixing box settings case s[1] of 3: box = replicate(dbox, Ndet) @@ -59,19 +66,21 @@ if info.size gt 0 then begin endcase + ; sorting list oo = sort(frame) frame = frame[oo] strcoord = strcoord[oo] data = data[oo] box = box[oo] + ; removing duplicates uu = uniq(frame) frame = frame[uu] strcoord = strcoord[uu] data = data[uu] box = box[uu] - ; extract coordinates from position string + ; extract coordinates from positions string get_coord, strcoord, xpos, ypos ; if auto-centre option is selected @@ -85,15 +94,14 @@ if info.size gt 0 then begin if kk ne -1 then begin ; if fix-box button is selected - button_fixbox = widget_info(pwwidget.button_fixbox, /button_set) - - if button_fixbox then box[kk] = dbox else widget_control, pwwidget.slider_box, set_value = box[kk] + button_fixbox = widget_info(pwpositions.button_fixbox, /button_set) + if button_fixbox then box[kk] = dbox else widget_control, pwpositions.slider_box, set_value = box[kk] endif endif -endif else begin +endif else begin ; loadpos unchecked, removing deleting positions defined = 0 Ndet = 0 @@ -106,12 +114,12 @@ endif else begin endelse -; save position values -position = {defined:defined, posfile:posfile, freeture:freeture, Ndet:Ndet, frame:frame, strcoord:strcoord, $ - xpos:xpos, ypos:ypos, data:data, box:box} -widget_control, pwwidget.button_pos, set_uvalue = position +; save positions values +positions = {defined:defined, posfile:posfile, freeture:freeture, Ndet:Ndet, frame:frame, strcoord:strcoord, $ + xpos:xpos, ypos:ypos, data:data, box:box} +widget_control, pwwidget.button_pos, set_uvalue = positions -; print position to widget table +; print positions to widget table if defined then begin str = transpose([[string(fix(frame))], [string(strcoord)], [string(data)], [string(box)]]) @@ -122,9 +130,10 @@ endif else begin endelse -widget_control, pwwidget.table_pos, table_ysize = Ndet > 25, alignment = 2, set_value = str +; printing positions table +widget_control, pwpositions.table_pos, table_ysize = Ndet > 25, alignment = 2, set_value = str -; print position to file +; print positions to file nl = n_elements(xpos) openw, lun, posfile, /get_lun if defined then for i=0, nl-1 do printf, lun, frame[i], strcoord[i], data[i], box[i], format = '(I7,A15,A30,I7)' diff --git a/code/pwwidget/PW_open_image.pro b/code/PRISMAwidget/PWwidget/PW_open_image.pro similarity index 62% rename from code/pwwidget/PW_open_image.pro rename to code/PRISMAwidget/PWwidget/PW_open_image.pro index a7e56db..c2ea3e6 100644 --- a/code/pwwidget/PW_open_image.pro +++ b/code/PRISMAwidget/PWwidget/PW_open_image.pro @@ -1,24 +1,29 @@ -; This procedure takes care of all the actions to be performed when a new -; fits file is requested for PRISMAwidget +; This procedure takes care of all the actions to be performed when a new fits file is requested for PRISMAwidget pro PW_open_image, pwwidget, $ sensitive = sensitive, $ cd = cd, $ detection = detection, $ capture = capture, $ + snapshot_big = snapshot_big, $ + snapshot_zoom = snapshot_zoom, $ status = status compile_opt idl2 status = 0 -; retrieve filename +; retrieve filenames widget_control, pwwidget.text_filename, get_value = filename +filename = filename[0] + widget_control, pwwidget.text_filename, get_uvalue = currfile widget_control, pwwidget.list_mode, get_uvalue = mode -filename = filename[0] +; scaling factor of the widget +wscale = pwwidget.var.wscale +; resetting input if filename is empty if filename eq '' then begin widget_control, pwwidget.text_filename, set_value = currfile @@ -29,6 +34,7 @@ endif ; check if file exists ver = file_search(filename, /test_regular) +; displaying error if cannot find the file if ver[0] eq '' then begin status = 1 @@ -38,6 +44,7 @@ if ver[0] eq '' then begin endif +; checking widget mode if keyword_set(detection) then mode = 'detection' if keyword_set(capture) then mode = 'capture' @@ -47,11 +54,12 @@ case mode of 'detection': begin + ; checking for folder structure of event dir = strsplit(path, path_sep(), /extract) fdecomp, filename, disk, folder, name, ext name = strmid(name, 0, 6) - ; check for freeture directories and filename + ; if the structure is not compatible, displying error if dir[n_elements(dir)-1] ne 'fits2D' or name ne 'frame_' then begin status = 1 @@ -72,7 +80,7 @@ if keyword_set(cd) then cd, path, current = currdir ; retrieve image ima = readfits(filename, header, /silent) -; adjust max slider range (e.g. stack) +; adjust max slider range (e.g. stack) max_ima = max(ima) > 4095 slider_min = widget_info(pwwidget.slider_min, /slider_min_max) @@ -92,35 +100,29 @@ if (max_ima ne slider_min[1] or max_ima ne slider_max[1]) or max_ima gt 4095 the endif +; image dimensions s = size(ima) +; getting uvalues of big and zoom windows widget_control, pwwidget.draw_big, get_uvalue = img widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom -; if image is not defined +; if image is not defined, displaying error if s[0] ne 2 then begin status = 1 dialog = dialog_message('The image in ' + filename + $ - ' was not loaded properly or is not a .fit file or does not have the right dimensions.', /error) - if keyword_set(cd) then cd, currdir - widget_control, pwwidget.text_filename, set_value = currfile - return - -endif - -if s[1] lt img.xsize or s[2] lt img.ysize then begin - - status = 1 - dialog = dialog_message('The image in ' + filename + ' does not have the right dimensions.', /error) + ' was not loaded properly or is not a .fit file or does not have the right dimensions.', /error) if keyword_set(cd) then cd, currdir widget_control, pwwidget.text_filename, set_value = currfile return endif +; reading observation date obsdate = sxpar(header, 'DATE-OBS') +; if wrong format, displaying error if typename(obsdate) ne 'STRING' then begin status = 1 @@ -131,13 +133,17 @@ if typename(obsdate) ne 'STRING' then begin endif +; adjusting obsdate format obsdate = strtrim(obsdate) - lzeros_datastring, obsdate + +; saving obsdate img.data = obsdate +; reading station name pseudo = sxpar(header, 'TELESCOP') - + +; if wrong format, displaying error if typename(pseudo) ne 'STRING' then begin status = 1 @@ -147,24 +153,31 @@ if typename(pseudo) ne 'STRING' then begin return endif - + +; formatting station name pseudo = strupcase(strtrim(pseudo)) +; checking for station name into solutions list ii = where(pseudo eq pwwidget.var.list_pseudo) +; converting name into code if ii[0] ne -1 then begin camera = pwwidget.var.list_camera[ii[0]] -endif else begin +endif else begin ; cannot find the station into solutions list, displaying error status = 1 - dialog = dialog_message('Add ' + pseudo + ' in ' + pwwidget.var.solutions, /error) + dialog = dialog_message('Add ' + pseudo + ' in ' + pwwidget.var.config.path.solutions, /error) if keyword_set(cd) then cd, currdir widget_control, pwwidget.text_filename, set_value = currfile return endelse + +; updating station name and code +img.camera = camera +img.pseudo = pseudo ; if /sensitive has been requested if keyword_set(sensitive) and strlen(currfile) eq 0 then begin @@ -180,6 +193,7 @@ if keyword_set(sensitive) and strlen(currfile) eq 0 then begin widget_control, pwwidget.slider_min, sensitive = 1 widget_control, pwwidget.slider_max, sensitive = 1 widget_control, pwwidget.slider_zoom, sensitive = 1 + widget_control, pwwidget.button_fullzoom, sensitive = 1 widget_control, pwwidget.button_negative, sensitive = 1 widget_control, pwwidget.button_logscale, sensitive = 1 widget_control, pwwidget.button_interpol, sensitive = 1 @@ -203,42 +217,107 @@ endif ; if /capture has been requested if keyword_set(capture) then begin - + ; setting sensitivities for widget components widget_control, pwwidget.button_pos, sensitive = 0 widget_control, pwwidget.button_loadpos, set_button = 0, sensitive = 0 widget_control, pwwidget.button_autopos, set_button = 0, sensitive = 0 widget_control, pwwidget.button_showbox, set_button = 0, sensitive = 0 - widget_control, pwwidget.table_pos, sensitive = 0, table_ysize = 25, alignment = 2, set_value = ['', '', '', ''], $ - set_table_view = [0,0], set_table_select = [-1, -1, -1, -1] - widget_control, pwwidget.slider_box, sensitive = 0 - widget_control, pwwidget.button_fixbox, set_button=0, sensitive = 0 widget_control, pwwidget.list_mode, set_droplist_select = 1, set_uvalue = mode - widget_control, pwwidget.button_pos, get_uvalue = position - widget_control, pwwidget.slider_box, get_value = dbox + widget_control, pwwidget.button_pos, get_uvalue = positions - position = {DEFINED:0, POSFILE:position.posfile, FREETURE:position.freeture, NDET:0, frame:0, XPOS:0, YPOS:0, $ - STRCOORD:'', DATA:'', BOX:dbox} + positions = {DEFINED:0, POSFILE:positions.posfile, FREETURE:positions.freeture, NDET:0, frame:-1, XPOS:-1, YPOS:-1, $ + STRCOORD:'', DATA:'', BOX:8} - widget_control, pwwidget.button_pos, set_uvalue = position + widget_control, pwwidget.button_pos, set_uvalue = positions + + if widget_is_active(pwwidget.pwpositions) then PWpositions_cleanup, pwwidget.pwpositions endif -img.camera = camera -img.pseudo = pseudo - -img.image = ima[0:img.xsize-1, 0:img.ysize-1] - -ds = long(15*2^imgzoom.scale) +; updating original image and x/y dimensions +img.image_orig[0] = ima +img.xsize_orig = s[1] +img.ysize_orig = s[2] + +; resetting image to be displayed +img.image = fltarr(1280, 960) + +; relative delta between display size and new image to be displayed +dx = float(s[1] - img.xsize)/img.xsize +dy = float(s[2] - img.ysize)/img.ysize + +; updating image to be displayed +tol = 0.05 ; tolerance to not scale the image to display window dimensions +case 1 of + + ; if delta is within tolerance, do not scale, just remove excess or leave empty margin + abs(dx) le tol and abs(dy) le tol : begin + + ; scaling factor to preserve aspect ratio of the image + fscale = 1. + + ; x/y dimension to be updated + dimx = min([s[1], img.xsize]) + dimy = min([s[2], img.ysize]) + + ; saving image into img uvalue + img.image[0:dimx-1, 0:dimy-1] = ima[0:dimx-1, 0:dimy-1] + img.fscale = fscale + + end + + ; if delta exceed tolerance, scale the image using frebin + else : begin + + ; scaling factor to preserve aspect ratio of the image + fscale = max([s[1]/float(img.xsize), s[2]/float(img.ysize)]) + + ; scaling the image, leaving empty margin in the dimension with the lower delta + dimx = round(s[1]/fscale) + dimy = round(s[2]/fscale) + ima1 = frebin(ima, dimx, dimy) + + ; saving image into img uvalue + img.image[0:dimx-1, 0:dimy-1] = ima1[0:dimx-1, 0:dimy-1] + img.fscale = fscale + + end + +endcase + +; updating dimx/dimy +img.xsize_true = dimx +img.ysize_true = dimy + +; adjusting imgzoom attributes according to computed fscale +imgzoom.xcn_orig = round(imgzoom.xcn*fscale) +imgzoom.ycn_orig = round(imgzoom.ycn*fscale) -imgtmp = img.image[imgzoom.xcn - ds:imgzoom.xcn + ds - 1, imgzoom.ycn - ds:imgzoom.ycn + ds - 1] -xcoord = imgzoom.xcn - ds + indgen(2*ds) -ycoord = imgzoom.ycn - ds + indgen(2*ds) +; evaluating if the maximum zoom scale is adequate +slider_min_max = widget_info(pwwidget.slider_zoom, /slider_min_max) + +factor_ds = 1. +ds_max = long(15*2^slider_min_max[1]/factor_ds) +PW_closest_ds, imgzoom.xsize/wscale, ds_max +dimzoom_max = 2*ds_max + +while dimzoom_max gt s[1] or dimzoom_max gt s[2] do begin + + factor_ds = factor_ds*2. + ds_max = long(15*2^slider_min_max[1]/factor_ds) + PW_closest_ds, imgzoom.xsize/wscale, ds_max + dimzoom_max = 2.*ds_max + +endwhile -imgzoom.xcoord = rebin(xcoord, imgzoom.xsize) -imgzoom.ycoord = rebin(ycoord, imgzoom.ysize) -imgzoom.image = rebin(imgtmp, imgzoom.xsize, imgzoom.ysize, sample = ~widget_info(pwwidget.button_interpol, /button_set)) +imgzoom.factor_ds = factor_ds + +; updating uvalues of widget +widget_control, pwwidget.draw_big, set_uvalue = img +widget_control, pwwidget.draw_zoom, set_uvalue = imgzoom +; setting frame number case mode of 'detection': begin @@ -256,14 +335,15 @@ case mode of end endcase - -widget_control,pwwidget.draw_big, set_uvalue = img -widget_control,pwwidget.draw_zoom, set_uvalue = imgzoom + +; updating uvalues of widget +widget_control, pwwidget.draw_big, set_uvalue = img +widget_control, pwwidget.draw_zoom, set_uvalue = imgzoom widget_control, pwwidget.text_filename, set_uvalue = filename widget_control, pwwidget.button_file, set_uvalue = path -; if position is checked, retrieve newposition.txt (or create new file from position.txt if first time) +; if positions is checked, retrieve newposition.txt (or create new file from positions.txt if first time) if widget_info(pwwidget.button_loadpos, /button_set) then begin PW_loadpos, pwwidget @@ -273,8 +353,11 @@ if widget_info(pwwidget.button_loadpos, /button_set) then begin endif -; draw image -PW_draw_image, pwwidget +; updating zoom image to be displayed +PW_update_zoom, pwwidget + +; draw image, an acquiring snapshots if needed +PW_draw_image, pwwidget, snapshot_big = snapshot_big, snapshot_zoom = snapshot_zoom ; check if previous and next images exists files = file_search(path + path_sep() + '*.fit*') @@ -290,9 +373,11 @@ if ii ne -1 then begin iip = ii + 1 while iip le n_elements(files)-1 and next eq '' do begin + ; checking next file in the list next_im = readfits(files[iip], /silent) s = size(next_im) + ; if next image has wrong dimensions if s[0] ne 2 then begin iip = iip + 1 @@ -300,17 +385,11 @@ if ii ne -1 then begin endif - if s[1] lt img.xsize or s[2] lt img.ysize then begin - - iip = iip + 1 - continue - - endif - next = files[iip] endwhile + ; setting sensitivity of next file button widget_control, pwwidget.button_nextimage, set_uvalue = next if next eq '' then widget_control, pwwidget.button_nextimage, sensitive = 0 $ else widget_control, pwwidget.button_nextimage, /sensitive @@ -319,9 +398,11 @@ if ii ne -1 then begin iim = ii - 1 while iim ge 0 and prev eq '' do begin + ; checking prev file in the list prev_im = readfits(files[iim], /silent) s = size(prev_im) + ; if next image has wrong dimensions if s[0] ne 2 then begin iim = iim - 1 @@ -329,17 +410,11 @@ if ii ne -1 then begin endif - if s[1] lt img.xsize or s[2] lt img.ysize then begin - - iim = iim - 1 - continue - - endif - prev = files[iim] endwhile + ; setting sensitivity of prev file button widget_control, pwwidget.button_previmage, set_uvalue = prev if prev eq '' then widget_control, pwwidget.button_previmage, sensitive = 0 $ else widget_control, pwwidget.button_previmage, /sensitive diff --git a/code/PRISMAwidget/PWwidget/PW_update_zoom.pro b/code/PRISMAwidget/PWwidget/PW_update_zoom.pro new file mode 100644 index 0000000..79240af --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PW_update_zoom.pro @@ -0,0 +1,85 @@ +; This procedure takes care of updating the image data to be displayed in the zoom panel + +pro PW_update_zoom, pwwidget + +; retrieve uvalues +widget_control, pwwidget.draw_big, get_uvalue = img +widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom + +; scaling factor of the image +fscale = img.fscale + +; zoom level / size +ds = PW_compute_ds(pwwidget) +imgzoom.ds = ds + +; deciding wether to use the regridded image or the original one +if widget_info(pwwidget.button_fullzoom, /button_set) then begin + + ; correct for border effects + if imgzoom.xcn lt ds then imgzoom.xcn = ds + if imgzoom.xcn gt img.xsize_true - ds then imgzoom.xcn = img.xsize_true - ds + if imgzoom.ycn lt ds then imgzoom.ycn = ds + if imgzoom.ycn gt img.ysize_true - ds then imgzoom.ycn = img.ysize_true - ds + + ; adjusting imgzoom attributes according to border effects (if any) + imgzoom.xcn_orig = round(imgzoom.xcn*fscale) + imgzoom.ycn_orig = round(imgzoom.ycn*fscale) + + ; min zoom level, using regridded image + imgtmp = img.image[imgzoom.xcn - ds:imgzoom.xcn + ds - 1, imgzoom.ycn - ds:imgzoom.ycn + ds - 1] + xcoord = imgzoom.xcn - ds + indgen(2*ds) + ycoord = imgzoom.ycn - ds + indgen(2*ds) + + ; original coordinates + xcoord_orig = round(xcoord*fscale) + ycoord_orig = round(ycoord*fscale) + +endif else begin + + ; correct for border effects + if imgzoom.xcn_orig lt ds then imgzoom.xcn_orig = ds + if imgzoom.xcn_orig gt img.xsize_orig - ds then imgzoom.xcn_orig = img.xsize_orig - ds + if imgzoom.ycn_orig lt ds then imgzoom.ycn_orig = ds + if imgzoom.ycn_orig gt img.ysize_orig-ds then imgzoom.ycn_orig = img.ysize_orig - ds + + ; adjusting imgzoom attributes according to border effects (if any) + imgzoom.xcn = round(imgzoom.xcn_orig/fscale) + imgzoom.ycn = round(imgzoom.ycn_orig/fscale) + + ; using original image + imgtmp = (img.image_orig[0])[imgzoom.xcn_orig - ds:imgzoom.xcn_orig + ds - 1, imgzoom.ycn_orig - ds:imgzoom.ycn_orig + ds - 1] + xcoord_orig = imgzoom.xcn_orig - ds + indgen(2*ds) + ycoord_orig = imgzoom.ycn_orig - ds + indgen(2*ds) + + ; scaled coordinates + xcoord = round(xcoord_orig/fscale) + ycoord = round(ycoord_orig/fscale) + +endelse + +; updating zoom image structure +imgzoom.xcoord = rebin(xcoord, imgzoom.xsize) +imgzoom.ycoord = rebin(ycoord, imgzoom.ysize) +imgzoom.xcoord_orig = rebin(xcoord_orig, imgzoom.xsize) +imgzoom.ycoord_orig = rebin(ycoord_orig, imgzoom.ysize) + +; regridding the image to display it in zoom window, and interpoling it if needed +if widget_info(pwwidget.button_interpol, /button_set) then begin + + imgzoom.image = congrid(imgtmp, imgzoom.xsize, imgzoom.ysize, cubic = -0.5, /center) + +endif else begin + + imgzoom.image = congrid(imgtmp, imgzoom.xsize, imgzoom.ysize, /center) + +endelse + +; displaying zoom centre in textbox +widget_control, pwwidget.text_zoomxc, set_value = strtrim(imgzoom.xcn_orig, 2) +widget_control, pwwidget.text_zoomyc, set_value = strtrim(imgzoom.ycn_orig, 2) + +; updating uvalues of widget +widget_control, pwwidget.draw_zoom, set_uvalue = imgzoom + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PWwidget_cleanup.pro b/code/PRISMAwidget/PWwidget/PWwidget_cleanup.pro new file mode 100644 index 0000000..165cc65 --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_cleanup.pro @@ -0,0 +1,17 @@ +; This procedure managed the action to be performed when the main window (PWwidget0 of PRISMAwidget is closed or die + +pro PWwidget_cleanup, widgetid + +compile_opt idl2 + +; retrieving uvalue +widget_control, widgetid, get_uvalue = pwwidget + +; destroying the pwpositions window, if present +if widget_is_active(pwwidget.pwpositions) then PWpositions_cleanup, pwwidget.pwpositions + +; go to the initial directory and destroy the widget +cd, pwwidget.var.basedir +widget_control, widgetid, /destroy + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PWwidget_draw.pro b/code/PRISMAwidget/PWwidget/PWwidget_draw.pro new file mode 100644 index 0000000..68cbae1 --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_draw.pro @@ -0,0 +1,90 @@ +; This procedure manages the events on the draw widget big (main) window of PRISMAwidget + +pro PWwidget_draw, event + +compile_opt idl2 + +; retrieving values and uvalues +widget_control, event.top, get_uvalue = pwwidget +widget_control, pwwidget.text_filename, get_value = filename + +; scaling factor of the widget +wscale = pwwidget.var.wscale + +; scaling factor of the image +widget_control, pwwidget.draw_big, get_uvalue = img +fscale = img.fscale + +; if there is a loaded image on the widget +if filename ne '' then begin + + case event.type of + + ; moving mouse on image + 2: begin + + ; index of (x,y) + ix = round(event.x*2/wscale*fscale) + iy = round(event.y*2/wscale*fscale) + + ; if within image dimensions, then begin + if ix lt img.xsize_orig and iy lt img.ysize_orig then begin + + widget_control, pwwidget.text_xpos, set_value = strtrim(ix, 2) + widget_control, pwwidget.text_ypos, set_value = strtrim(iy, 2) + widget_control, pwwidget.text_imgvalue, set_value = strtrim(round((img.image_orig[0])[ix, iy]), 2) + + endif else begin ; empty textbox + + widget_control, pwwidget.text_xpos, set_value = '' + widget_control, pwwidget.text_ypos, set_value = '' + widget_control, pwwidget.text_imgvalue, set_value = '' + + endelse + + + + end + + ; button released + 1: begin + + ; right click + if event.release eq 4 then begin + + ;left click + endif else begin + + ; update window centre coordinates + widget_control, pwwidget.draw_big, get_uvalue = img + widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom + imgzoom.xcn = event.x*2/wscale + imgzoom.ycn = event.y*2/wscale + + ; updating scaled values of centre + imgzoom.xcn_orig = round(imgzoom.xcn*fscale) + imgzoom.ycn_orig = round(imgzoom.ycn*fscale) + + ; updating uvalues of widget + widget_control, pwwidget.draw_zoom, set_uvalue = imgzoom + + ; updating zoom image to be displayed + PW_update_zoom, pwwidget + + ; updating display window + PW_draw_image, pwwidget + + endelse + + end + + ; no action to be performed + else: begin + + end + + endcase + +endif + +end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_event.pro b/code/PRISMAwidget/PWwidget/PWwidget_event.pro similarity index 74% rename from code/pwwidget/PWwidget_event.pro rename to code/PRISMAwidget/PWwidget/PWwidget_event.pro index 1e07c54..3897f57 100644 --- a/code/pwwidget/PWwidget_event.pro +++ b/code/PRISMAwidget/PWwidget/PWwidget_event.pro @@ -1,5 +1,4 @@ -; This is the standard procedure automatically invoked when an event_pro -; is not defined for a widget +; This is the standard procedure automatically invoked when an event_pro is not defined for a widget pro PWwidget_event, event diff --git a/code/pwwidget/PWwidget_file.pro b/code/PRISMAwidget/PWwidget/PWwidget_file.pro similarity index 86% rename from code/pwwidget/PWwidget_file.pro rename to code/PRISMAwidget/PWwidget/PWwidget_file.pro index d4c127a..355c483 100644 --- a/code/pwwidget/PWwidget_file.pro +++ b/code/PRISMAwidget/PWwidget/PWwidget_file.pro @@ -13,26 +13,30 @@ case value of 'Open Detection': begin + ; reading filename filename = dialog_pickfile(path = currdir, filter = '*.fit*', /must_exist, dialog_parent = event.top) widget_control, pwwidget.text_filename, set_value = filename + ; opening image PW_open_image, pwwidget, /cd, /sensitive, /detection end 'Open Capture': begin + ; reading filename filename = dialog_pickfile(path = currdir, filter = '*.fit*', /must_exist, dialog_parent = event.top) widget_control, pwwidget.text_filename, set_value = filename + ; opening image PW_open_image, pwwidget, /cd, /sensitive, /capture end 'Exit': begin - cd, pwwidget.var.basedir - widget_control, event.top, /destroy + ; closing widget + PWwidget_cleanup, event.top end diff --git a/code/pwwidget/PWwidget_filename.pro b/code/PRISMAwidget/PWwidget/PWwidget_filename.pro similarity index 57% rename from code/pwwidget/PWwidget_filename.pro rename to code/PRISMAwidget/PWwidget/PWwidget_filename.pro index 3ebf57a..eb37011 100644 --- a/code/pwwidget/PWwidget_filename.pro +++ b/code/PRISMAwidget/PWwidget/PWwidget_filename.pro @@ -1,5 +1,4 @@ -; This procedure manages the modification events on the -; filename text of PRISMAwidget +; This procedure manages the modification events on the filename text of PRISMAwidget pro PWwidget_filename, event @@ -7,6 +6,7 @@ compile_opt idl2 widget_control, event.top, get_uvalue = pwwidget +; opening image file PW_open_image, pwwidget, /cd, /sensitive end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PWwidget_fullzoom.pro b/code/PRISMAwidget/PWwidget/PWwidget_fullzoom.pro new file mode 100644 index 0000000..702e9cb --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_fullzoom.pro @@ -0,0 +1,20 @@ +; This procedure manages the event of fullzoom button of PRISMAwidget + +pro PWwidget_fullzoom, event + +compile_opt idl2 + +; retrieving uvalue +widget_control, event.top, get_uvalue = pwwidget + +; enabling zoom slider +if widget_info(pwwidget.button_fullzoom, /button_set) then widget_control, pwwidget.slider_zoom, sensitive = 0 $ + else widget_control, pwwidget.slider_zoom, sensitive = 1 + +; updating zoom image to be displayed +PW_update_zoom, pwwidget + +; updating display window +PW_draw_image, pwwidget + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PWwidget_interpolation.pro b/code/PRISMAwidget/PWwidget/PWwidget_interpolation.pro new file mode 100644 index 0000000..c94791d --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_interpolation.pro @@ -0,0 +1,15 @@ +; This procedure manages the event of interpol button of PRISMAwidget + +pro PWwidget_interpolation, event + +compile_opt idl2 + +widget_control, event.top, get_uvalue = pwwidget + +; updating zoom image +PW_update_zoom, pwwidget + +; refrashing image display +PW_draw_image, pwwidget + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PWwidget_logo.pro b/code/PRISMAwidget/PWwidget/PWwidget_logo.pro new file mode 100644 index 0000000..034e5c0 --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_logo.pro @@ -0,0 +1,89 @@ +; This procedure is called when the user select the Logo menu button of PRISMAwidget + +pro PWwidget_logo, event + +; retrieving event info +widget_control, event.top, get_uvalue = pwwidget +widget_control, event.id, get_value = value + +; case for different menu options +case value of + + 'Show logo': begin + + ; setting button after click + widget_control, pwwidget.button_showlogo, set_button = ~widget_info(pwwidget.button_showlogo, /button_set) + + ; refreshing the draw image + PW_draw_image, pwwidget + + end + + 'Show info': begin + + ; setting button after click + widget_control, pwwidget.button_showinfo, set_button = ~widget_info(pwwidget.button_showinfo, /button_set) + + ; refreshing the draw image + PW_draw_image, pwwidget + + end + + 'Black logo': begin + + ; reading filename + filename = dialog_pickfile(path = pwwidget.var.basedir, filter = '*.png*', /must_exist, dialog_parent = event.top, $ + title = 'Please select new logo (dark background)') + + ; if new logo was not selected, nothing to be done + if filename eq '' then return + + ; reading the new logo + logo_black = get_logo(filename, transparent = 'black', rescale_dim = 530) + + ; updating the logo in pwwidget + pwwidget.var.logo_black = logo_black + + end + + 'White logo': begin + + ; reading filename + filename = dialog_pickfile(path = pwwidget.var.basedir, filter = '*.png*', /must_exist, dialog_parent = event.top, $ + title = 'Please select new logo (light background)') + + ; if new logo was not selected, nothing to be done + if filename eq '' then return + + ; reading the new logo + logo_white = get_logo(filename, transparent = 'white', rescale_dim = 530) + + ; updating the logo in pwwidget + pwwidget.var.logo_white = logo_white + + end + + 'Both logos': begin + + ; reading filename + filename = dialog_pickfile(path = pwwidget.var.basedir, filter = '*.png*', /must_exist, dialog_parent = event.top, $ + title = 'Please select new logo (transparent background)') + + ; if new logo was not selected, nothing to be done + if filename eq '' then return + + ; reading the new logo + logo = get_logo(filename, rescale_dim = 530) + + ; updating both logos in pwwidget + pwwidget.var.logo_black = logo + pwwidget.var.logo_white = logo + + end + +endcase + +; updating pwwidget uvalue +widget_control, event.top, set_uvalue = pwwidget + +end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_logscale.pro b/code/PRISMAwidget/PWwidget/PWwidget_logscale.pro similarity index 88% rename from code/pwwidget/PWwidget_logscale.pro rename to code/PRISMAwidget/PWwidget/PWwidget_logscale.pro index 657a869..29bc1d1 100644 --- a/code/pwwidget/PWwidget_logscale.pro +++ b/code/PRISMAwidget/PWwidget/PWwidget_logscale.pro @@ -5,6 +5,8 @@ pro PWwidget_logscale, event compile_opt idl2 widget_control, event.top, get_uvalue = pwwidget + +; refreshing image display PW_draw_image, pwwidget end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_modelist.pro b/code/PRISMAwidget/PWwidget/PWwidget_modelist.pro similarity index 81% rename from code/pwwidget/PWwidget_modelist.pro rename to code/PRISMAwidget/PWwidget/PWwidget_modelist.pro index ce7474c..293e4be 100644 --- a/code/pwwidget/PWwidget_modelist.pro +++ b/code/PRISMAwidget/PWwidget/PWwidget_modelist.pro @@ -1,5 +1,4 @@ -; This procedure manages the choice of the mode of PRISMAwidget -; between Detection and Capture (droplist) +; This procedure manages the choice of the mode of PRISMAwidget between Detection and Capture (droplist) pro PWwidget_modelist, event @@ -19,12 +18,13 @@ case mode of endcase -; check if there is something to do +; check if there is something to do since the mode changed if filename ne '' and currmode ne mode then begin path = file_dirname(filename) dir = strsplit(path, path_sep(), /extract) - + + ; re-opening the current image with the new mode case mode of 'detection': PW_open_image, pwwidget, /detection, status = status @@ -32,8 +32,10 @@ if filename ne '' and currmode ne mode then begin endcase + ; checking for errors during opening if status then begin + ; resetting droplist case currmode of 'detection': widget_control, pwwidget.list_mode, set_droplist_select = 0 @@ -45,6 +47,7 @@ if filename ne '' and currmode ne mode then begin endif else begin + ; nothing to be done widget_control, pwwidget.list_mode, set_uvalue = mode endelse diff --git a/code/pwwidget/PWwidget_negative.pro b/code/PRISMAwidget/PWwidget/PWwidget_negative.pro similarity index 88% rename from code/pwwidget/PWwidget_negative.pro rename to code/PRISMAwidget/PWwidget/PWwidget_negative.pro index 58138b8..62d84c4 100644 --- a/code/pwwidget/PWwidget_negative.pro +++ b/code/PRISMAwidget/PWwidget/PWwidget_negative.pro @@ -6,6 +6,7 @@ compile_opt idl2 widget_control, event.top, get_uvalue = pwwidget +; refreshing image display PW_draw_image, pwwidget end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PWwidget_playmovie.pro b/code/PRISMAwidget/PWwidget/PWwidget_playmovie.pro new file mode 100644 index 0000000..c4f5b1c --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_playmovie.pro @@ -0,0 +1,271 @@ +; This procedure manages the play and save movie function of PRISMAwidget + +pro PWwidget_playmovie, event + +compile_opt idl2 + +; freezing operations by the user, waiting for the movie to be displayed and saved +widget_control, /hourglass + +; retrieving pwwidget uvalue +widget_control, event.top, get_uvalue = pwwidget + +; verify if the input is valid +widget_control, pwwidget.text_nframe, get_value = value +split = strsplit(value, ',', /extract) + +; current directory +widget_control, pwwidget.button_file, get_uvalue = currdir + +case n_elements(split) of + + ; no input in text_nframe, displaying error + 0: begin + + error = dialog_message('Please specify a non-zero number of frames', /error) + return + + end + + ; reading number of frames to use for the movie + 1: begin + + nframe = long(split[0]) + delay = long(15) + + end + + ; reading number of frames and delay time to use for the movie + 2: begin + + nframe = long(split[0]) + delay = long(split[1]) + + end + + ; wrong format, displaying error + else: begin + + error = dialog_message('Please specify a non-zero number of frames and optionally the desired delay time' + $ + 'of the animation in 1/100 seconds units, in the format nframe, delay', /error) + return + + end + +endcase + +; video settings +direction = signum(nframe) +nframe = abs(nframe) + +; not a valid frame number, displaying error +if nframe eq 0 then begin + + error = dialog_message('Please specify a non-zero number of frames', /error) + return + +endif + +; not a valid delay time, displaying error +if delay lt 1 then begin + + error = dialog_message('Please specify a delay time of at least 1 (= 1/100 seconds)', /error) + return + +endif + +; retrieve current image name +widget_control, pwwidget.text_filename, get_value = filename +current = filename[0] + +; scaling factor of the widget +wscale = pwwidget.var.wscale + +if event.id eq pwwidget.button_savemovie then begin + + ; retrieving imgzoom + widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom + + ; image stack to export the animation + imgstack = bytarr(nframe, imgzoom.xsize, imgzoom.ysize) + + ; image RGB channels + r = bytarr(nframe, 256) + g = bytarr(nframe, 256) + b = bytarr(nframe, 256) + + ; image integration + imgsum = lonarr(3, imgzoom.xsize, imgzoom.ysize) + +endif + +; iterating on the images +for i=0, nframe-1 do begin + + ; first image, just re-drawing it and take snapshot + if i eq 0 then begin + + status = 0 + PW_draw_image, pwwidget, snapshot_zoom = snapshot_zoom + + endif else begin + + ; movie going forward or backward, loading next or prev file in the list + case direction of + + 1: widget_control, pwwidget.button_nextimage, get_uvalue = filename + -1: widget_control, pwwidget.button_previmage, get_uvalue = filename + + endcase + + ; reaching the start/end of the file list, stopping animation + if filename eq '' then begin + + if event.id eq pwwidget.button_savemovie then imgstack = imgstack[0:i-1,*,*] + nframe = i + break + + endif + + ; open the image + widget_control, pwwidget.text_filename, set_value = filename + PW_open_image, pwwidget, snapshot_zoom = snapshot_zoom + + endelse + + if status then begin + + ; abort after error + widget_control, pwwidget.text_filename, set_value = current + PW_open_image, pwwidget + return + + endif + + widget_control, pwwidget.draw_big, get_uvalue = img + + ; if the user selected the save button + if event.id eq pwwidget.button_savemovie then begin + + ; adding the snapshot of the current zoom window to imgsum + imgsum = imgsum + long(snapshot_zoom) + + ; saving start time (first frame) + if i eq 0 then begin + + camera_start = img.camera + ' - ' + img.pseudo + time_start = repstr(strmid(img.data, 0, 22), 'T', ' @ ') + ' UT' + + endif + + ; taking snapshot with logo and info, if needed + snapshot = tvrd(/true) + + ; getting the RGB decomposition and converting for gif format + tvlct, r0, g0, b0, /get + imgstack[i,*,*] = color_quan(snapshot, 1, r0, g0, b0, colors = 256, dither = 0) + r[i,*] = r0 + g[i,*] = g0 + b[i,*] = b0 + + endif + + ; waiting for delay + wait, delay/100. + +endfor + +; if the user selected the save button +if event.id eq pwwidget.button_savemovie then begin + + ; display the summed image + tvscl, imgsum, /true + + ; displaying logo if required + if widget_info(pwwidget.button_showlogo, /button_set) then begin + + ; loading the appropriate logo for the background of the sum image + if widget_info(pwwidget.button_negative, /button_set) then begin + + logo = pwwidget.var.logo_white + + endif else begin + + logo = pwwidget.var.logo_black + + endelse + + ; overplot the logo + cgimage, logo, alphafgposition = [(479. - 132.)/480., 5./480., 1., (5. + 132.)/480.] + + endif + + ; displaying info if required + if widget_info(pwwidget.button_showinfo, /button_set) then begin + + ; character size for information textbox + charsize1 = 2.3*wscale + charsize2 = 1.5*wscale + + ; loading the appropriate logo for the background of the sum image + if widget_info(pwwidget.button_negative, /button_set) then begin + + text_color = 'black' + + endif else begin + + text_color = 'white' + + endelse + + ; displaying informational text + cgtext, 10./480., 450./480., camera_start, color = text_color, charsize = charsize1, /font, tt_font = 'Verdana Bold' + cgtext, 10./480., 425./480., time_start, color = text_color, charsize = charsize2, /font, tt_font = 'Verdana Bold' + + endif + + filename = dialog_pickfile(/write, path = currdir, default_extension = 'gif', filter = ['*.gif', '*.png'], $ + title = 'Please select file to write (same filename for gif animation and png track', $ + file = 'animation', /overwrite_prompt) + + ; if filename was selected + if filename ne '' then begin + + ext = strmid(filename, 3, 4, /reverse_offset) + + case ext of + + '.gif': begin + filename_gif = filename + filename_png = repstr(filename, '.gif', '.png') + end + + '.png': begin + filename_gif = repstr(filename, '.png', '.gif') + filename_png = filename + end + + endcase + + ; save the gif animation + for i=0, nframe-1 do $ + write_gif, filename_gif, reform(imgstack[i,*,*]), reform(r[i,*]), reform(g[i,*]), reform(b[i,*]), $ + /multiple, repeat_count = 0, delay_time = delay + + write_gif, filename_gif, reform(imgstack[0,*,*]), reform(r[0,*]), reform(g[0,*]), reform(b[0,*]), /close + + ; save the png track + snapshot = tvrd(/true) + write_png, filename_png, snapshot + + wait, 2 + + endif + +endif + +; reaload the initial image +widget_control, pwwidget.text_filename, set_value = current +PW_open_image, pwwidget + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PWwidget_positions.pro b/code/PRISMAwidget/PWwidget/PWwidget_positions.pro new file mode 100644 index 0000000..d9f238b --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_positions.pro @@ -0,0 +1,114 @@ +; This procedure manages the positions menu events of PRISMAwidget + +pro PWwidget_positions, event + +compile_opt idl2 + +; retrieving values and uvalues +widget_control, event.top, get_uvalue = pwwidget +widget_control, event.id, get_value = value +widget_control, pwwidget.button_pos, get_uvalue = positions + +; scaling factor of the widget +wscale = pwwidget.var.wscale + +; case for different buttons +case value of + + 'Load': begin + + ; setting button after click + widget_control, pwwidget.button_loadpos, set_button = ~widget_info(pwwidget.button_loadpos, /button_set) + + ; load positions file + if widget_info(pwwidget.button_loadpos, /button_set) then begin + + ; constructing the positions table widget + Pwpositions, pwwidget + widget_control, event.top, set_uvalue = pwwidget + + ; loading positions file on the table + PW_loadpos, pwwidget + + ; running autopos if selected + if widget_info(pwwidget.button_autopos, /button_set) then PW_autopos, pwwidget + + ; updating visualization + PW_draw_image, pwwidget + + ; clear positions + endif else begin + + ; destroying the pwpositions window, if present + if widget_is_active(pwwidget.pwpositions) then PWpositions_cleanup, pwwidget.pwpositions + + ; updating image display + PW_draw_image, pwwidget + + endelse + + end + + 'Auto-centre': begin + + ; setting button after click + widget_control, pwwidget.button_autopos, set_button = ~widget_info(pwwidget.button_autopos, /button_set) + + if widget_info(pwwidget.button_autopos, /button_set) and widget_info(pwwidget.button_loadpos, /button_set) then begin + + ; retrieving pwpositions uvalue + widget_control, pwwidget.pwpositions, get_uvalue = pwpositions + + ; check for fix-box button + button_fixbox = widget_info(pwpositions.button_fixbox, /button_set) + + ; if fix box is not selected, updating box slider + if ~button_fixbox then begin + + widget_control, pwwidget.draw_big, get_uvalue = img + kk = where(positions.frame eq img.framenum) + kk = kk[0] + + if kk ne -1 then widget_control, pwpositions.slider_box, set_value = positions.box[kk] + + ; activating textboxes + widget_control, pwpositions.text_snrvalue, set_value = '', sensitive = 1 + widget_control, pwpositions.text_minsnrvalue, sensitive = 1 + + endif + + ; computing autopos + PW_autopos, pwwidget + + ; updating image display + PW_draw_image, pwwidget + + endif else begin + + if widget_info(pwwidget.button_loadpos, /button_set) then begin + + ; retrieving pwpositions uvalue + widget_control, pwwidget.pwpositions, get_uvalue = pwpositions + + ; erasing snr box + widget_control, pwpositions.text_snrvalue, set_value = '' + + endif + + endelse + + end + + 'Show box': begin + + ; setting button after click + widget_control, pwwidget.button_showbox, set_button = ~widget_info(pwwidget.button_showbox, /button_set) + + ; updating display image to show/erase box + PW_draw_image, pwwidget + + end + +endcase + +end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_prevnextimage.pro b/code/PRISMAwidget/PWwidget/PWwidget_prevnextimage.pro similarity index 72% rename from code/pwwidget/PWwidget_prevnextimage.pro rename to code/PRISMAwidget/PWwidget/PWwidget_prevnextimage.pro index 41e7d3a..f59efe4 100644 --- a/code/pwwidget/PWwidget_prevnextimage.pro +++ b/code/PRISMAwidget/PWwidget/PWwidget_prevnextimage.pro @@ -1,5 +1,4 @@ -; This procedure manages the prev/next buttons events -; i.e. going to the prev/next image in the list of PRISMAwidget +; This procedure manages the prev/next buttons events, i.e., going to the prev/next image in the list of PRISMAwidget pro PWwidget_prevnextimage, event @@ -10,6 +9,7 @@ widget_control, event.id, get_uvalue = filename widget_control, pwwidget.list_mode, get_uvalue = mode widget_control, pwwidget.text_filename, set_value = filename +; if filename exists if filename ne '' then begin ; case for different mode @@ -20,13 +20,14 @@ if filename ne '' then begin fdecomp, filename, disk, folder, name, ext name = strmid(name,0,6) - ; check for filename + ; check for filename (if compatible with freeture detection) if name eq 'frame_' then begin - + + ; opening new image PW_open_image, pwwidget - endif else begin - + endif else begin ; not comparible, displaying error + dialog = dialog_message('This option is valid only for freeture detections', /error) widget_control, event.id, get_uvalue = currfile widget_control, event.id, set_value = currfile @@ -38,6 +39,7 @@ if filename ne '' then begin 'capture': begin + ; opening new image PW_open_image, pwwidget end diff --git a/code/PRISMAwidget/PWwidget/PWwidget_resize.pro b/code/PRISMAwidget/PWwidget/PWwidget_resize.pro new file mode 100644 index 0000000..248f227 --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_resize.pro @@ -0,0 +1,14 @@ +; This procedure handles resizing of the main window (base) of PWwidget + +pro PWwidget_resize, event + +compile_opt idl2 + +; retrieving uvalue +widget_control, event.top, get_uvalue = pwwidget + +; restoring original widget size +widget_control, event.top, xsize = pwwidget.var.xsize[0] +widget_control, event.top, ysize = pwwidget.var.ysize[0] + +end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_slider_minmax.pro b/code/PRISMAwidget/PWwidget/PWwidget_slider_minmax.pro similarity index 96% rename from code/pwwidget/PWwidget_slider_minmax.pro rename to code/PRISMAwidget/PWwidget/PWwidget_slider_minmax.pro index f22d02c..97b6fc0 100644 --- a/code/pwwidget/PWwidget_slider_minmax.pro +++ b/code/PRISMAwidget/PWwidget/PWwidget_slider_minmax.pro @@ -34,6 +34,7 @@ case event.id of endcase +; refreshing image display PW_draw_image, pwwidget end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PWwidget_slider_zoom.pro b/code/PRISMAwidget/PWwidget/PWwidget_slider_zoom.pro new file mode 100644 index 0000000..8d2743f --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_slider_zoom.pro @@ -0,0 +1,15 @@ +; This procedures manages the event on the zoom slider of PRISMAwidget + +pro PWwidget_slider_zoom, event + +compile_opt idl2 + +widget_control, event.top, get_uvalue = pwwidget + +; updating zoom image to be displayed +PW_update_zoom, pwwidget + +; draw image +PW_draw_image, pwwidget + +end \ No newline at end of file diff --git a/code/PRISMAwidget/PWwidget/PWwidget_zoom.pro b/code/PRISMAwidget/PWwidget/PWwidget_zoom.pro new file mode 100644 index 0000000..64cd720 --- /dev/null +++ b/code/PRISMAwidget/PWwidget/PWwidget_zoom.pro @@ -0,0 +1,263 @@ +; This procedure manages the events on the zoom draw window of PRISMAwidget + +pro PWwidget_zoom, event + +compile_opt idl2 + +; retrieving values and uvalues +widget_control, event.top, get_uvalue = pwwidget +widget_control, pwwidget.draw_big, get_uvalue = img +widget_control, pwwidget.text_filename, get_value = filename + +; scaling factor of the widget +wscale = pwwidget.var.wscale + +; scaling factor of the image +fscale = img.fscale + +; zoom scale +widget_control, pwwidget.slider_zoom, get_value = zscale + +if filename ne '' then begin + + ; case for different event types + case event.type of + + ; moving mouse on image + 2: begin + + widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom + + ; index of (x,y) + ix = (event.x > 0) < (n_elements(imgzoom.xcoord_orig)-1) + iy = (event.y > 0) < (n_elements(imgzoom.ycoord_orig)-1) + + ; displaying image values + widget_control, pwwidget.text_xpos, set_value = strtrim(round(imgzoom.xcoord_orig[ix]), 2) + widget_control, pwwidget.text_ypos, set_value = strtrim(round(imgzoom.ycoord_orig[iy]), 2) + widget_control, pwwidget.text_imgvalue, set_value = strtrim(fix(imgzoom.image[ix, iy]), 2) + + end + + ; button released + 1: begin + + ; retrieve images + widget_control, pwwidget.draw_big, get_uvalue = img + widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom + + ; retrieve mouse positions in data coordinates + imgzoom.xcn_orig = imgzoom.xcoord_orig[event.x] + imgzoom.ycn_orig = imgzoom.ycoord_orig[event.y] + + imgzoom.xcn = imgzoom.xcoord[event.x] + imgzoom.ycn = imgzoom.ycoord[event.y] + + ; right click - save current position in positions.txt + if event.release eq 4 then begin + + ; disabling this functionality if not enough zoomed + if widget_info(pwwidget.button_loadpos, /button_set) and zscale lt 3 then begin + + ; retrieving values and uvalues + widget_control, pwwidget.pwpositions, get_uvalue = pwpositions + widget_control, pwpositions.slider_box, get_value = dbox + widget_control, pwwidget.button_pos, get_uvalue = positions + + defined = positions.defined + Ndet = positions.Ndet + posfile = positions.posfile + freeture = positions.freeture + frame = positions.frame + xpos = positions.xpos + ypos = positions.ypos + strcoord = positions.strcoord + data = positions.data + box = positions.box + + ; flag to erase snr textbox + erase_snrvalue = 0 + + if defined then begin + + ; looking if the current image is already listed in positions + ii = where(frame eq img.framenum, complement = ii0) + + ; if listed + if ii[0] ne -1 then begin + + id = ii[0] + + ; if the selected pixel is the same already saved + if xpos[id] eq imgzoom.xcn_orig and ypos[id] eq imgzoom.ycn_orig then begin + + ; we will erase snr textbox + erase_snrvalue = 1 + + ; remove from the list + if ii0[0] ne -1 then begin + + Ndet = Ndet - 1 + frame = frame[ii0] + xpos = xpos[ii0] + ypos = ypos[ii0] + strcoord = strcoord[ii0] + data = data[ii0] + box = box[ii0] + + ; it was the last one, undefine positions + endif else begin + + defined = 0 + Ndet = 0 + frame = -1 + xpos = -1 + ypos = -1 + strcoord = '' + data = '' + box = dbox + + endelse + + ; replace the value in positions + endif else begin + + xpos[id] = imgzoom.xcn_orig + ypos[id] = imgzoom.ycn_orig + strcoord[id] = '('+strtrim(imgzoom.xcn_orig, 2) + ';' + strtrim(imgzoom.ycn_orig, 2) + ')' + data[id] = img.data + box[id] = dbox + + endelse + + ; add to the list + endif else begin + + Ndet = Ndet + 1 + frame = [frame, img.framenum] + xpos = [xpos, imgzoom.xcn_orig] + ypos = [ypos, imgzoom.ycn_orig] + strcoord = [strcoord, '(' + strtrim(imgzoom.xcn_orig, 2) + ';' + strtrim(imgzoom.ycn_orig,2) + ')'] + data = [data, img.data] + box = [box, dbox] + + jj = sort(frame) + + frame = frame[jj] + xpos = xpos[jj] + ypos = ypos[jj] + strcoord = strcoord[jj] + data = data[jj] + box = box[jj] + + endelse + + ; it is the first value inserted, define positions + endif else begin + + defined = 1 + Ndet = 1 + frame = [img.framenum] + xpos = [imgzoom.xcn_orig] + ypos = [imgzoom.ycn_orig] + strcoord = ['(' + strtrim(imgzoom.xcn_orig, 2) + ';' + strtrim(imgzoom.ycn_orig, 2) + ')'] + data = [img.data] + box = dbox + + endelse + + positions = {defined:defined, posfile:posfile, freeture:freeture, Ndet:Ndet, frame:frame, xpos:xpos, ypos:ypos, $ + strcoord:strcoord, data:data, box:box} + + widget_control, pwwidget.button_pos, set_uvalue = positions + + nl = n_elements(xpos) + openw, lun, posfile, /get_lun + if defined then for i=0, nl-1 do printf, lun, frame[i], strcoord[i], data[i], box[i], format = '(I7,A15,A30,I7)' + close, lun & free_lun, lun + + ; print positions to widget table + if defined then begin + + str = transpose([[string(fix(frame))], [string(strcoord)], [string(data)], [string(box)]]) + + endif else begin + + str = ['', '', '', ''] + + endelse + + if widget_is_active(pwwidget.pwpositions) then begin + + ; retrieving pwpositions uvalue + widget_control, pwwidget.pwpositions, get_uvalue = pwpositions + + ; printing table + widget_control, pwpositions.table_pos, table_ysize = Ndet > 25, alignment = 2, set_value = str + + endif + + ; updating image display + PW_draw_image, pwwidget + + ; compute the box limits + minx = max([0, imgzoom.xcn_orig - dbox]) + maxx = min([img.xsize_orig-1, imgzoom.xcn_orig + dbox]) + miny = max([0, imgzoom.ycn_orig - dbox]) + maxy = min([img.ysize_orig-1, imgzoom.ycn_orig + dbox]) + + bocs = (img.image_orig[0])[minx:maxx, miny:maxy] + + ; median filtering + mediana = median(bocs, /even) + sigma = sqrt(mean((bocs - mediana)^2)) + jj = where(bocs gt mediana + 3*sigma, njj, complement = jj0) + + ; evaluation of signal-to-noise ratio + if jj[0] ne -1 then begin + + signal = total(float(bocs[jj])) - mediana*njj + noise = sqrt(mean((bocs[jj0] - mediana)^2)) + SNR = signal/(noise*sqrt(njj)) + + endif else SNR = 0. + + ; let's display SNR value + if ~erase_snrvalue then begin + + widget_control, pwpositions.text_snrvalue, set_value = strtrim(string(SNR, format = '(f10.1)'), 2) + + endif else begin ; erasing SNR value + + widget_control, pwpositions.text_snrvalue, set_value = '' + + endelse + + endif + + ; left click - re-centre zoom box + endif else begin + + ; updating uvalues of widget + widget_control, pwwidget.draw_zoom, set_uvalue = imgzoom + + ; updating zoom image to be displayed + PW_update_zoom, pwwidget + + ; drawing image on widget + PW_draw_image, pwwidget + + endelse + + end + + ; nothing to do in the other case + else: begin + + end + + endcase + +endif + +end \ No newline at end of file diff --git a/code/PRISMAwidget/functions/widget_is_active.pro b/code/PRISMAwidget/functions/widget_is_active.pro new file mode 100644 index 0000000..176f608 --- /dev/null +++ b/code/PRISMAwidget/functions/widget_is_active.pro @@ -0,0 +1,7 @@ +; function to understand if a widget is active on the screen + +function widget_is_active, widgetid + +return, (widget_info(widgetid, /valid_id) and widget_info(widgetid, /managed)) + +end \ No newline at end of file diff --git a/code/calibration/calibration.pro b/code/calibration/calibration.pro index bd9c3ee..57028c3 100644 --- a/code/calibration/calibration.pro +++ b/code/calibration/calibration.pro @@ -9,15 +9,17 @@ pro calibration, camera, target, $ compress_day = compress_day, $ compress_month = compress_month, $ checksum = checksum, $ - export_month = export_month + update_config = update_config, $ + export_month = export_month, $ + report_year = report_year compile_opt idl2 useful_vars ; checking for input, if not use these ones -if ~isa(camera) then camera = 'ITPI01' -if ~isa(target) then target = '202001' +if ~isa(camera) then camera = 'ITVE03' +if ~isa(target) then target = '20201206' ; configuration file path, if not present using standard one defined in the code if ~isa(config_file) then config_file = config_path_filename() @@ -31,7 +33,10 @@ if ~isa(compress_image) then compress_image = 0 if ~isa(compress_day) then compress_day = 0 if ~isa(compress_month) then compress_month = 0 if ~isa(checksum) then checksum = 0 + +if ~isa(update_config) then update_config = 0 if ~isa(export_month) then export_month = 0 +if ~isa(report_year) then report_year = 0 ; retrieving configuration config = get_config(config_file) @@ -41,9 +46,24 @@ config = get_config(config_file) !except = config.except on_error, config.on_error +; checking for valid month +if process_image or process_day or process_month or compress_image or compress_day or compress_month or export_month then begin + + isvalid = valid_num(target) + if ~isvalid then begin + + message, target + ' has incompatible format. return:99', /informational + return + + endif + +endif + ; looking for the input type - month or day string month = get_month(target, day = day) +message, camera + '_' + target + ' - start calibration.', /informational + if process_image or compress_image then begin ; going into the captures / camera / month folder @@ -56,10 +76,12 @@ if process_image or compress_image then begin ; finding captures for the month of the camera ff = myfile_search(camera + '_????????T??????_UT-0.fit*', /check_size) - if ff[0] eq '' then return ; returning to the original directory cd, old_dir + + ; returning if no fits file was found + if ff[0] eq '' then return ; sorting files by name ff = ff[sort(ff)] @@ -110,7 +132,7 @@ if process_image or compress_image then begin endif else begin - message, camera + '_' + target + ' - cannot find data. return:3', /informational + message, 'cannot find data. return:3', /informational return endelse @@ -127,7 +149,7 @@ if process_image or compress_image then begin if ~!quiet then tic ; process captures in that day for finding stars etc... - calibration_image, config, camera, days[i], captures + calibration_image, config, camera, days[i], captures;, /yplot, /cat_yplot, /stop_iter if ~!quiet then toc @@ -190,7 +212,7 @@ if ~(process_image or compress_image) and (process_day or compress_day) then beg if ff[0] eq '' then begin - message, camera + '_' + target + ' - cannot find calibration results. return:4', /informational + message, 'cannot find calibration results. return:4', /informational return endif @@ -265,6 +287,18 @@ if compress_month then begin endif +; updating configuration file based on the calibration results +if update_config then begin + + if ~!quiet then tic + + ; updating starting points of the astrometric calibration based on the solution of this month + update_config, config, camera, month + + if ~!quiet then toc + +endif + ; exporting astrometry and photometry results to solution folder if export_month then begin @@ -277,4 +311,16 @@ if export_month then begin endif +; calibration report for available and calibrated months +if report_year then begin + + if ~!quiet then tic + + ; printing calibration report + report_year, config, camera, target, list_captures = 'C:\Users\PRISMA-User\PRISMA\check_captures\HDD\count_captures_*.txt' + + if ~!quiet then toc + +endif + end \ No newline at end of file diff --git a/code/calibration/calibration_day.pro b/code/calibration/calibration_day.pro index 4ad837e..96c6ffe 100644 --- a/code/calibration/calibration_day.pro +++ b/code/calibration/calibration_day.pro @@ -37,14 +37,14 @@ ff_sphoto = myfile_search(files.calibration.image.photometry.sigma.name) if ff_photo[0] ne '' and ff_sphoto[0] ne '' then begin ; reading photo_param.txt - readcol, ff_photo[0], name_captures, julian_date, nstars, info_mag, exposure, moon_phase, moon_az, moon_zd, $ - sun_az, sun_zd, scalev, effz, effm, effl, Cv, Kv, z1, m1, m2, m3, m4, m5, m6, m7, m8, $ + readcol, ff_photo[0], name_captures, julian_date, ns, info_mag, exposure, moon_phase, moon_az, moon_zd, $ + sun_az, sun_zd, scalev, effz, effm, effl, sd_magv, Cv, Kv, z1, m1, m2, m3, m4, m5, m6, m7, m8, $ l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, $ format = files.calibration.image.photometry.param.format_r, /silent ; reading photo_sigma.txt - readcol, ff_sphoto[0], name_captures, julian_date, nstars, info_mag, exposure, moon_phase, moon_az, moon_zd, $ - sun_az, sun_zd, scalev, effz, effm, effl, s_Cv, s_Kv, s_z1, s_m1, s_m2, s_m3, s_m4, s_m5, s_m6, s_m7, s_m8, $ + readcol, ff_sphoto[0], name_captures, julian_date, ns, info_mag, exposure, moon_phase, moon_az, moon_zd, $ + sun_az, sun_zd, scalev, effz, effm, effl, sd_magv, s_Cv, s_Kv, s_z1, s_m1, s_m2, s_m3, s_m4, s_m5, s_m6, s_m7, s_m8, $ s_l1, s_l2, s_l3, s_l4, s_l5, s_l6, s_l7, s_l8, s_l9, s_l10, s_l11, s_l12, $ format = files.calibration.image.photometry.sigma.format_r, /silent @@ -94,6 +94,8 @@ if ff_assoc[0] ne '' then begin ; number of stars nfound = n_elements(id) + message, 'processing ' + strtrim(nfound, 2) + ' associations.', /informational + ; x and y for linear fit y = m - m_s = C - k*x am = air_mass(zd) dm = mag - mags @@ -121,6 +123,9 @@ if ff_assoc[0] ne '' then begin Km = -param[1] s_Cm = sigma[0] s_Km = sigma[1] + + ; computing global std from mad - to be printed on solution files + sd_mag = medabsdev(dm[ii_phot] - yfit, /sigma, /even) endif @@ -144,6 +149,7 @@ if fm eq 0 then begin param = [Cm, -Km] sigma = [s_Cm, s_Km] + sd_mag = !values.f_NaN endif @@ -155,16 +161,20 @@ if ff_photo[0] ne '' and ff_sphoto[0] ne '' then begin ; print daily photometry param-sigma files update_daily_file, files.calibration.day.photometry.param, day, [jd0, nfound, fm, par.photometry.exposure, $ - m_ph, m_zd, scale, skyp_corr, Cm, Km, Zm, Mm, Lm], par.astrometry.model_image + m_ph, m_zd, scale, skyp_corr, sd_mag, Cm, Km, Zm, Mm, Lm], par.astrometry.model_image update_daily_file, files.calibration.day.photometry.sigma, day, [jd0, nfound, fm, par.photometry.exposure, $ - m_ph, m_zd, scale, skyp_corr, s_Cm, s_Km, s_Zm, s_Mm, s_Lm], par.astrometry.model_image - + m_ph, m_zd, scale, skyp_corr, sd_mag, s_Cm, s_Km, s_Zm, s_Mm, s_Lm], par.astrometry.model_image + + ; new lines for header of solution file + new_lines = ['2', 'ns = ' + strtrim(string(nfound, format = '(f20.0)'), 2), $ + 'sd_mag = ' + strtrim(string(sd_mag, format = '(f20.3)'), 2)] + ; print photometry solution file - print_header, files.calibration.day.photometry.solution + print_header, files.calibration.day.photometry.solution, add_lines = new_lines openw, lun, files.calibration.day.photometry.solution.name, /get_lun, /append - printf, lun, 'c = ', Cm, ' ± ', s_Cm, '/', format = files.calibration.day.photometry.solution.format_w + printf, lun, 'C = ', Cm, ' ± ', s_Cm, '/', format = files.calibration.day.photometry.solution.format_w printf, lun, 'k = ', Km, ' ± ', s_Km, '/', format = files.calibration.day.photometry.solution.format_w close, lun & free_lun, lun @@ -172,7 +182,7 @@ if ff_photo[0] ne '' and ff_sphoto[0] ne '' then begin ; print photometry report (with updated mean zero-point Cm) if par.config.calibration.report_photo then $ photometry_report, par, files.calibration.day, {target:day, julian_date:julian_date, mag_sky:mag_sky + Cm, $ - exposure:exposure, fm:fm, am:am, dm:dm, me:me, param:param, sigma:sigma, info_mag:info_mag, $ + exposure:exposure, fm:fm, am:am, dm:dm, me:me, param:param, sigma:sigma, info_mag:info_mag, sd_mag:sd_mag, $ Cm:Cm, s_Cm:s_Cm, Km:Km, s_Km:s_Km, Cv:Cv, s_Cv:s_Cv, Kv:Kv, s_Kv:s_Kv} endif @@ -186,8 +196,6 @@ if ff_assoc[0] eq '' then begin endif -message, 'processing ' + strtrim(nfound, 2) + ' associations.', /informational - ; mpfit initialization x_fit = [x, y] y_fit = [az, zd] @@ -208,15 +216,28 @@ if status ne 0 then begin endif +; error analysis +err = astrometry_error({x:x, y:y, az:az, zd:zd}, {model:par.astrometry.model_daily, param:param, sigma:sigma, $ + covar:covar}) + +; standard deviation of residuals in az and zd +sd_az = err.global.std.az +sd_zd = err.global.std.zd + ; julian day of this day jd0 = floor(jd[0], /L64) ; param-sigma file -update_daily_file, files.calibration.day.astrometry.param, day, [jd0, nfound, param], par.astrometry.model_daily -update_daily_file, files.calibration.day.astrometry.sigma, day, [jd0, nfound, sigma], par.astrometry.model_daily +update_daily_file, files.calibration.day.astrometry.param, day, [jd0, nfound, sd_az*!ramin, sd_zd*!ramin, param], par.astrometry.model_daily +update_daily_file, files.calibration.day.astrometry.sigma, day, [jd0, nfound, sd_az*!ramin, sd_zd*!ramin, sigma], par.astrometry.model_daily + +; new lines for header of solution, covar and error files +new_lines = ['3', 'ns = ' + strtrim(string(nfound, format = '(f20.0)'), 2), $ + 'sd_az = ' + strtrim(string(sd_az*!ramin, format = '(f20.2)'), 2) + ' amin', $ + 'sd_zd = ' + strtrim(string(sd_zd*!ramin, format = '(f20.2)'), 2) + ' amin'] ; print solution file -print_header, files.calibration.day.astrometry.solution +print_header, files.calibration.day.astrometry.solution, add_lines = new_lines names = astro_model_info(par.astrometry.model_daily) @@ -232,7 +253,7 @@ endfor close, lun & free_lun, lun ; print covar file -print_header, files.calibration.day.astrometry.covar +print_header, files.calibration.day.astrometry.covar, add_lines = new_lines openw, lun, files.calibration.day.astrometry.covar.name, /get_lun, /append @@ -244,9 +265,8 @@ endfor close, lun & free_lun, lun -; error analysis -err = astrometry_error({x:x, y:y, az:az, zd:zd}, {model:par.astrometry.model_daily, param:param, sigma:sigma, $ - covar:covar}) +; print error file +print_header, files.calibration.day.astrometry.error, add_lines = new_lines ; formatting error output rads = [err.az, err.zd] @@ -284,9 +304,6 @@ for i=0, nrads-1 do begin endfor -; print error file -print_header, files.calibration.day.astrometry.error - openw, lun, files.calibration.day.astrometry.error.name, /get_lun, /append for i=0, nrads-1 do begin diff --git a/code/calibration/calibration_image.pro b/code/calibration/calibration_image.pro index 1263d58..93d6bdf 100644 --- a/code/calibration/calibration_image.pro +++ b/code/calibration/calibration_image.pro @@ -21,7 +21,7 @@ if isa(stop_iter) then par.config.calibration.stop_iter = stop_iter if isa(stop_image) then par.config.calibration.stop_image = stop_image ; rebin factor for image and association display -rebin = 1. +rebin = 2. ; retrieving month string month = get_month(day) @@ -118,12 +118,13 @@ moon_zd = fltarr(n) moon_alt = fltarr(n) moon_phase = fltarr(n) info_mag = intarr(n) -nstars = fltarr(n) +ns = fltarr(n) scalev = fltarr(n) +sd_mag = fltarr(n) + !values.f_NaN Cv = fltarr(n) + par.photometry.C -s_Cv = fltarr(n) +s_Cv = fltarr(n) + !values.f_NaN Kv = fltarr(n) + par.photometry.k -s_Kv = fltarr(n) +s_Kv = fltarr(n) + !values.f_NaN mag_sky = fltarr(21, n) s_mag_sky = fltarr(21, n) param = fltarr(info.nparam, n) @@ -200,7 +201,7 @@ for i=0, n-1 do begin par.photometry.sky_aper[1:2], /nan, /flux, /silent ; radial efficiency correction - eff_correction, ski, skyp.zd, err = s_ski, /flux, corr = skyp_corr + eff_correction, par.photometry.eff_corr, ski, skyp.zd, err = s_ski, /flux, corr = skyp_corr skyp.eff_corr = skyp_corr ; computing magnitudes from flux @@ -342,10 +343,10 @@ for i=0, m-1 do begin par.photometry.star_aper[1:2], /nan, /flux, /silent ; excluding negative flux sources - ii = where(flux gt 0, ns) + ii = where(flux gt 0, nstars) ; if enough stars were found - if ns ge par.find.n_min then begin + if nstars ge par.find.n_min then begin x = x[ii] y = y[ii] @@ -522,6 +523,7 @@ for i=0, m-1 do begin endif + if par.config.calibration.stop_iter then stop ; convergence criteria to exit from the iteration @@ -531,14 +533,14 @@ for i=0, m-1 do begin ; update variables with results of last cycle nfound += res.match.n - nstars[j] = res.match.n + ns[j] = res.match.n param[*,j] = res.proj.param sigma[*,j] = res.proj.sigma ; radial efficiency correction this_mags = res.match.mags this_s_mags = res.match.s_mags - eff_correction, this_mags, res.match_ctlg.zd, err = this_s_mags, /mag, corr = this_corr + eff_correction, par.photometry.eff_corr, this_mags, res.match_ctlg.zd, err = this_s_mags, /mag, corr = this_corr ; storing results back to res res.match.mags = this_mags @@ -571,6 +573,9 @@ for i=0, m-1 do begin Kv[j] = -p[1] s_Cv[j] = sp[0] s_Kv[j] = sp[1] + + ; computing global std from mad + sd_mag[j] = medabsdev(dm[ii_phot] - yfit, /sigma, /even) endif @@ -601,6 +606,7 @@ for i=0, m-1 do begin xrange = [0, 90], sym_thick = 0.3) print, res.proj.param, res.proj.sigma + print, res.std.az*!ramin, res.std.zd*!ramin if info_mag[j] eq 1 then begin @@ -626,13 +632,13 @@ for i=0, m-1 do begin ; printing astro_param.txt (append) openw, lun, files.calibration.image.astrometry.param.name, /get_lun, /append - printf, lun, name_captures[j], julian_date[j], res.match.n, res.proj.param, $ + printf, lun, name_captures[j], julian_date[j], res.match.n, res.std.az*!ramin, res.std.zd*!ramin, res.proj.param, $ format = files.calibration.image.astrometry.param.format_w close, lun & free_lun, lun ; printing astro_sigma.txt (append) openw, lun, files.calibration.image.astrometry.sigma.name, /get_lun, /append - printf, lun, name_captures[j], julian_date[j], res.match.n, res.proj.sigma, $ + printf, lun, name_captures[j], julian_date[j], res.match.n, res.std.az*!ramin, res.std.zd*!ramin, res.proj.sigma, $ format = files.calibration.image.astrometry.sigma.format_w close, lun & free_lun, lun @@ -662,7 +668,7 @@ endfor ; free some memory undefine, x_iter, s_x_iter, y_iter, s_y_iter, mags_iter, s_mags_iter -message, 'found ' + strtrim(nfound,2) + ' associations.', /informational +message, 'found ' + strtrim(nfound, 2) + ' associations.', /informational ; if no star was found, let's erase empty files if nfound eq 0 then begin @@ -685,12 +691,12 @@ skyp_corr = skyp.eff_corr[uniq(skyp.zd)] for i=0, n-1 do begin - printf, lun, name_captures[i], julian_date[i], nstars[i], info_mag[i], exposure[i], moon_phase[i], moon_az[i], $ - moon_zd[i], sun_az[i], sun_zd[i], scalev[i], skyp_corr, Cv[i], Kv[i], mag_sky[*,i], $ + printf, lun, name_captures[i], julian_date[i], ns[i], info_mag[i], exposure[i], moon_phase[i], moon_az[i], $ + moon_zd[i], sun_az[i], sun_zd[i], scalev[i], skyp_corr, sd_mag[i], Cv[i], Kv[i], mag_sky[*,i], $ format = files.calibration.image.photometry.param.format_w - printf, lun1, name_captures[i], julian_date[i], nstars[i], info_mag[i], exposure[i], moon_phase[i], moon_az[i], $ - moon_zd[i], sun_az[i], sun_zd[i], scalev[i], skyp_corr, s_Cv[i], s_Kv[i], s_mag_sky[*,i], $ + printf, lun1, name_captures[i], julian_date[i], ns[i], info_mag[i], exposure[i], moon_phase[i], moon_az[i], $ + moon_zd[i], sun_az[i], sun_zd[i], scalev[i], skyp_corr, sd_mag[i], s_Cv[i], s_Kv[i], s_mag_sky[*,i], $ format = files.calibration.image.photometry.sigma.format_w endfor diff --git a/code/calibration/calibration_month.pro b/code/calibration/calibration_month.pro index c804a44..3306300 100644 --- a/code/calibration/calibration_month.pro +++ b/code/calibration/calibration_month.pro @@ -62,8 +62,21 @@ if status ne 0 then begin endif +; error analysis +err = astrometry_error({x:x, y:y, az:az, zd:zd}, {model:par.astrometry.model_monthly, param:param, sigma:sigma, $ + covar:covar}) + +; standard deviation of residuals in az and zd +sd_az = err.global.std.az +sd_zd = err.global.std.zd + +; new lines for header of solution, covar and error files +new_lines = ['3', 'ns = ' + strtrim(string(nfound, format = '(f20.0)'), 2), $ + 'sd_az = ' + strtrim(string(sd_az*!ramin, format = '(f20.2)'), 2) + ' amin', $ + 'sd_zd = ' + strtrim(string(sd_zd*!ramin, format = '(f20.2)'), 2) + ' amin'] + ; print solution file -print_header, files.calibration.month.astrometry.solution +print_header, files.calibration.month.astrometry.solution, add_lines = new_lines names = astro_model_info(par.astrometry.model_monthly) @@ -79,7 +92,7 @@ endfor close, lun & free_lun, lun ; print covar file -print_header, files.calibration.month.astrometry.covar +print_header, files.calibration.month.astrometry.covar, add_lines = new_lines openw, lun, files.calibration.month.astrometry.covar.name, /get_lun, /append @@ -91,9 +104,8 @@ endfor close, lun & free_lun, lun -; error analysis -err = astrometry_error({x:x, y:y, az:az, zd:zd}, {model:par.astrometry.model_monthly, param:param, sigma:sigma, $ - covar:covar}) +; print error file +print_header, files.calibration.month.astrometry.error, add_lines = new_lines ; formatting error output rads = [err.az, err.zd] @@ -131,9 +143,6 @@ for i=0, nrads-1 do begin endfor -; print error file -print_header, files.calibration.month.astrometry.error - openw, lun, files.calibration.month.astrometry.error.name, /get_lun, /append for i=0, nrads-1 do begin diff --git a/code/calibration/compression_day.pro b/code/calibration/compression_day.pro index 1acdd37..400dd0f 100644 --- a/code/calibration/compression_day.pro +++ b/code/calibration/compression_day.pro @@ -62,6 +62,29 @@ if ff[0] eq '' then begin endif +; checking the config_file for photo_param, which should always be there +files = get_files(par, day) +ff_photo = myfile_search(files.calibration.image.photometry.param.name) + +if ff_photo[0] ne '' then begin + + ; checking configuration file in header + readcol, ff_photo[0], info, junk, value, format = '(a,a,a)', /silent + + ii = where(info eq 'config') + if ii[0] ne -1 then config_file = value[ii[0]] $ + else config_file = '' + + if config_file ne par.file then begin + + message, 'config from photo_param file and loaded config_file do not match. return:2', /informational + cd, old_dir + return + + endif + +endif + ; looking for the associations file files = get_files(par, day) ff_assoc = file_search(files.calibration.image.astrometry.assoc.name) @@ -140,6 +163,7 @@ sxaddpar, header, 'code', camera, ' camera code', /null sxaddpar, header, 'name', par.pseudo, ' camera name', /null sxaddpar, header, 'date', date, ' acquisition night', /null sxaddpar, header, 'jd', target_jd(day), ' julian date', /null +sxaddpar, header, 'config', par.file, ' configuration file used for processing', /null sxaddpar, header, 'lat', par.station.latitude, ' station latitude [deg]', format = '(f20.6)', /null sxaddpar, header, 'lon', par.station.longitude, ' station longitude [deg]', format = '(f20.6)', /null sxaddpar, header, 'hgt', par.station.elevation, ' station elevation [m]', format = '(f20.1)', /null @@ -156,7 +180,7 @@ if ff_photo[0] ne '' then begin ; reading photometry file readcol, ff_photo[0], name_captures, julian_date, ns, info_mag, exposure, moon_phase, moon_az, moon_zd, $ - sun_az, sun_zd, scale, effz, effm, effl, C, K, z1, m1, m2, m3, m4, m5, m6, m7, m8, $ + sun_az, sun_zd, scale, effz, effm, effl, sd_mag, C, K, z1, m1, m2, m3, m4, m5, m6, m7, m8, $ l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, $ format = files.calibration.image.photometry.param.format_r, /silent @@ -173,8 +197,10 @@ ff_sigma = myfile_search(files.calibration.day.photometry.sigma.name) if ff_param[0] ne '' and ff_sigma[0] ne '' then begin ; reading the photometry param file - readcol, ff_param[0], dayv, jdv, nsv, fv, expv, mphv, mzdv, scalev, effzv, effmv, efflv, Cv, kv, Zv, Mv, Lv, /silent - readcol, ff_sigma[0], dayv, jdv, nsv, fv, expv, mphv, mzdv, scalev, effzv, effmv, efflv, s_Cv, s_kv, s_Zv, s_Mv, s_Lv, /silent + readcol, ff_param[0], dayv, jdv, nsv, fv, expv, mphv, mzdv, scalev, effzv, effmv, efflv, stdmagv, Cv, kv, Zv, Mv, Lv, $ + format = files.calibration.day.photometry.param.format_r, /silent + readcol, ff_sigma[0], dayv, jdv, nsv, fv, expv, mphv, mzdv, scalev, effzv, effmv, efflv, stdmagv, s_Cv, s_kv, s_Zv, s_Mv, s_Lv, $ + format = files.calibration.day.photometry.param.format_r, /silent ; looking for this day in the table ii = where(dayv eq day) @@ -195,8 +221,9 @@ if ff_param[0] ne '' and ff_sigma[0] ne '' then begin sxaddpar, header, 'magl', Lv[ii[0]], ' mean sky mag at zd = 70° [mag/as^2]', format = '(f20.3)', /null sxaddpar, header, 's_magl', s_Lv[ii[0]], ' mean sky mag at zd = 70° [mag/as^2]', format = '(f20.3)', /null sxaddpar, header, 'model_p', 'airmass', ' photometric model', /null - sxaddpar, header, 'c', Cv[ii[0]], ' zero-point magnitude [mag]', format = '(f20.3)', /null - sxaddpar, header, 's_c', s_Cv[ii[0]], ' err on zero-point magnitude [mag]', format = '(f20.3)', /null + sxaddpar, header, 'sd_mag', stdmagv[ii[0]], ' stddev of the mag residuals [mag]', format = '(f20.3)', /null + sxaddpar, header, 'C', Cv[ii[0]], ' zero-point magnitude [mag]', format = '(f20.3)', /null + sxaddpar, header, 's_C', s_Cv[ii[0]], ' err on zero-point magnitude [mag]', format = '(f20.3)', /null sxaddpar, header, 'k', kv[ii[0]], ' atm extinction coeff [mag/am]', format = '(f20.3)', /null sxaddpar, header, 's_k', s_kv[ii[0]], ' err on atm extinction coeff [mag/am]', format = '(f20.3)', /null @@ -210,23 +237,37 @@ if ff_solut[0] ne '' then begin sxaddpar, header, 'if_astr', 1, /null ; reading the solution file header - readcol, ff_solut[0], info, junk, model, format = '(a,a,a)', /silent + readcol, ff_solut[0], info, junk, value, format = '(a,a,a)', /silent + + ; astrometric model ii = where(info eq 'model') - model = model[ii[0]] + model = value[ii[0]] + + sxaddpar, header, 'model_a', model, ' astrometric model', /null + + ; std deviation of the az residuals resulting from the solution + ii = where(info eq 'sd_az') + sd_az = float(value[ii[0]]) + + sxaddpar, header, 'sd_az', sd_az, ' stddev of the az residuals [amin]', format = '(f20.2)', /null + + ; std deviation of the zd residuals resulting from the solution + ii = where(info eq 'sd_zd') + sd_zd = float(value[ii[0]]) + + sxaddpar, header, 'sd_zd', sd_zd, ' stddev of the zd residuals [amin]', format = '(f20.2)', /null ; reading the solution file readcol, ff_solut[0], junk, junk, param, junk, sigma, junk, $ format = files.calibration.day.astrometry.solution.format_r, /silent - sxaddpar, header, 'model_a', model, ' astrometric model', /null - ; writing astrometric parameters and their errors info = astro_model_info(model) for i=0, n_elements(param)-1 do begin - sxaddpar, header, info.names[i], param[i], ' ' + info.comments[i], /null - sxaddpar, header, 's_' + info.names[i], sigma[i], ' err on ' + info.comments[i], /null + sxaddpar, header, info.names[i], param[i], ' ' + info.comments[i], format = info.format_wv[i], /null + sxaddpar, header, 's_' + info.names[i], sigma[i], ' err on ' + info.comments[i], format = info.format_wv[i], /null endfor diff --git a/code/calibration/compression_image.pro b/code/calibration/compression_image.pro index c1e1818..83c764c 100644 --- a/code/calibration/compression_image.pro +++ b/code/calibration/compression_image.pro @@ -142,6 +142,7 @@ sxaddpar, header, 'code', camera, ' camera code', /null sxaddpar, header, 'name', par.pseudo, ' camera name', /null sxaddpar, header, 'date', date, ' acquisition night', /null sxaddpar, header, 'jd', target_jd(day), ' julian date', /null +sxaddpar, header, 'config', par.file, ' configuration file used for processing', /null sxaddpar, header, 'lat', par.station.latitude, ' station latitude [deg]', format = '(f20.6)', /null sxaddpar, header, 'lon', par.station.longitude, ' station longitude [deg]', format = '(f20.6)', /null sxaddpar, header, 'hgt', par.station.elevation, ' station elevation [m]', format = '(f20.1)', /null diff --git a/code/calibration/compression_month.pro b/code/calibration/compression_month.pro index 29c4bd2..2c0a7de 100644 --- a/code/calibration/compression_month.pro +++ b/code/calibration/compression_month.pro @@ -65,8 +65,30 @@ if ff[0] eq '' then begin endif -; looking for the associations file +; checking the config_file for photo_param, which should always be there files = get_files(par, month + '??') +ff_photo = myfile_search(files.calibration.day.photometry.param.name) + +if ff_photo[0] ne '' then begin + + ; checking configuration file in header + readcol, ff_photo[0], info, junk, value, format = '(a,a,a)', /silent + + ii = where(info eq 'config') + if ii[0] ne -1 then config_file = value[ii[0]] $ + else config_file = '' + + if config_file ne par.file then begin + + message, 'config from photo_param file and loaded config_file do not match. return:2', /informational + cd, old_dir + return + + endif + +endif + +; looking for the associations file ff_assoc = file_search(files.calibration.image.astrometry.assoc.name) if ff_assoc[0] ne '' then begin @@ -147,6 +169,7 @@ sxaddpar, header, 'code', camera, ' camera code', /null sxaddpar, header, 'name', par.pseudo, ' camera name', /null sxaddpar, header, 'date', date, ' acquisition month', /null sxaddpar, header, 'jd', target_jd(month), ' julian date', /null +sxaddpar, header, 'config', par.file, ' configuration file used for processing', /null sxaddpar, header, 'lat', par.station.latitude, ' station latitude [deg]', format = '(f20.6)', /null sxaddpar, header, 'lon', par.station.longitude, ' station longitude [deg]', format = '(f20.6)', /null sxaddpar, header, 'hgt', par.station.elevation, ' station elevation [m]', format = '(f20.1)', /null @@ -183,23 +206,37 @@ if ff_solut[0] ne '' then begin sxaddpar, header, 'if_astr', 1, /null ; reading the solution file header - readcol, ff_solut[0], info, junk, model, format = '(a,a,a)', /silent + readcol, ff_solut[0], info, junk, value, format = '(a,a,a)', /silent + + ; astrometric model ii = where(info eq 'model') - model = model[ii[0]] + model = value[ii[0]] + + sxaddpar, header, 'model_a', model, ' astrometric model', /null + + ; std deviation of the az residuals resulting from the solution + ii = where(info eq 'sd_az') + sd_az = float(value[ii[0]]) + + sxaddpar, header, 'sd_az', sd_az, ' stddev of the az residuals [amin]', format = '(f20.2)', /null + + ; std deviation of the zd residuals resulting from the solution + ii = where(info eq 'sd_zd') + sd_zd = float(value[ii[0]]) + + sxaddpar, header, 'sd_zd', sd_zd, ' stddev of the zd residuals [amin]', format = '(f20.2)', /null ; reading the solution file readcol, ff_solut[0], junk, junk, param, junk, sigma, junk, $ format = files.calibration.day.astrometry.solution.format_r, /silent - sxaddpar, header, 'model_a', model, ' astrometric model', /null - ; writing astrometric parameters and their errors info = astro_model_info(model) for i=0, n_elements(param)-1 do begin - sxaddpar, header, info.names[i], param[i], ' ' + info.comments[i], /null - sxaddpar, header, 's_' + info.names[i], sigma[i], ' err on ' + info.comments[i], /null + sxaddpar, header, info.names[i], param[i], ' ' + info.comments[i], format = info.format_wv[i], /null + sxaddpar, header, 's_' + info.names[i], sigma[i], ' err on ' + info.comments[i], format = info.format_wv[i], /null endfor diff --git a/code/calibration/debug/test_astrometry.pro b/code/calibration/debug/test_astrometry.pro index 5a56c50..24540d6 100644 --- a/code/calibration/debug/test_astrometry.pro +++ b/code/calibration/debug/test_astrometry.pro @@ -7,8 +7,8 @@ compile_opt idl2 useful_vars ; camera and day to be analyzed -camera = 'ITPI01' -day = '20190302' +camera = 'ITSI04' +day = '20220324' ; corresponding month month = get_month(day) @@ -47,7 +47,7 @@ case strlowcase(model_image) of 'proj_poly2': begin - readcol, files.calibration.image.astrometry.param.name, immagine, junk, junk, a_0, x_c, y_c, p_1, p_2, $ + readcol, files.calibration.image.astrometry.param.name, immagine, junk, junk, junk, junk, a_0, x_c, y_c, p_1, p_2, $ format=files.calibration.image.astrometry.param.format_r, /silent param_0 = [median(a_0, /even), median(x_c, /even), median(y_c, /even), median(p_1, /even), median(p_2, /even)] @@ -56,7 +56,7 @@ case strlowcase(model_image) of 'proj_asin1': begin - readcol, files.calibration.image.astrometry.param.name, immagine, junk, junk, a_0, x_c, y_c, z_0, f_0, $ + readcol, files.calibration.image.astrometry.param.name, immagine, junk, junk, junk, junk, a_0, x_c, y_c, z_0, f_0, $ format=files.calibration.image.astrometry.param.format_r, /silent param_0 = [median(a_0, /even), median(x_c, /even), median(y_c, /even), median(z_0, /even), median(f_0, /even)] diff --git a/code/calibration/debug/vis_fit.pro b/code/calibration/debug/vis_fit.pro index 21a7847..4715c55 100644 --- a/code/calibration/debug/vis_fit.pro +++ b/code/calibration/debug/vis_fit.pro @@ -7,10 +7,10 @@ compile_opt idl2 useful_vars ; capture to be displayed -capture = 'ITPI02_20181209T201113_UT-0.fit' +capture = 'ITTO06_20221102T005050_UT-0.fit.gz' ; rebin factor -rebin = 1. +rebin = 2. ; configuration file config_file = config_path_filename() @@ -35,15 +35,15 @@ cd, old_dir dim = img.dim ; settings for this camera -center = [530, 665] +center = [520, 635] radius = 480 horizon = 50 ; displaying image and camera / horizon circles definition window, 0, xs = dim[0]/rebin, ys = dim[1]/rebin -tvscl, bytscl(congrid(img, dim[0]/rebin, dim[1]/rebin), 0, 1000) -tvcircle, radius/rebin, center[0]/rebin, center[1]/rebin, color = 'red' -tvcircle, (radius - horizon)/rebin, center[0]/rebin, center[1]/rebin, color = 'blue' +tvscl, bytscl(congrid(img, dim[0]/rebin, dim[1]/rebin), 0, 300) +tvcircle, radius/rebin, center[0]/rebin, center[1]/rebin, color = 'red', thick = 2 +tvcircle, (radius - horizon)/rebin, center[0]/rebin, center[1]/rebin, color = 'blue', thick = 2 ; trying to load par to display mask (if defined) day = strmid(capture, 7, 8) diff --git a/code/calibration/export_month.pro b/code/calibration/export_month.pro index f444604..065a8bb 100644 --- a/code/calibration/export_month.pro +++ b/code/calibration/export_month.pro @@ -21,15 +21,15 @@ ckcd, month, check = check, old_dir = old_dir if ~check then return ; looking for all the monthly files -ff0 = myfile_search(files.calibration.month.astrometry.covar.name, /fully_qualify_path) -ff1 = myfile_search(files.calibration.month.astrometry.error.name, /fully_qualify_path) -ff2 = myfile_search(files.calibration.day.astrometry.param.name, /fully_qualify_path) -ff3 = myfile_search(files.calibration.month.astrometry.report.name, /fully_qualify_path) -ff4 = myfile_search(files.calibration.day.astrometry.sigma.name, /fully_qualify_path) -ff5 = myfile_search(files.calibration.month.astrometry.solution.name, /fully_qualify_path) -ff6 = myfile_search(files.calibration.day.photometry.param.name, /fully_qualify_path) -ff7 = myfile_search(files.calibration.day.photometry.sigma.name, /fully_qualify_path) -ff = [ff0, ff1, ff2, ff3, ff4, ff5, ff6, ff7] +ff_astro_covar = myfile_search(files.calibration.month.astrometry.covar.name, /fully_qualify_path) +ff_astro_error = myfile_search(files.calibration.month.astrometry.error.name, /fully_qualify_path) +ff_astro_param = myfile_search(files.calibration.day.astrometry.param.name, /fully_qualify_path) +ff_astro_report = myfile_search(files.calibration.month.astrometry.report.name, /fully_qualify_path) +ff_astro_sigma = myfile_search(files.calibration.day.astrometry.sigma.name, /fully_qualify_path) +ff_astro_solut = myfile_search(files.calibration.month.astrometry.solution.name, /fully_qualify_path) +ff_photo_param = myfile_search(files.calibration.day.photometry.param.name, /fully_qualify_path) +ff_photo_sigma = myfile_search(files.calibration.day.photometry.sigma.name, /fully_qualify_path) +ff = [ff_astro_covar, ff_astro_error, ff_astro_param, ff_astro_report, ff_astro_sigma, ff_astro_solut, ff_photo_param, ff_photo_sigma] ; checking is some files are missing ii = where(ff eq '') @@ -40,11 +40,42 @@ if ii[0] ne -1 then begin endif -; going into configuration directory / camera -ckcd, par.config.path.dir_config, check = check, old_dir = old_dir -if ~check then return -ckcd, camera, check = check, old_dir = old_dir +; reading solution header +readcol, ff_astro_solut, info, junk, value, format = '(a,a,a)', /silent + +; number of stars used to derive the astrometric solution +ii = where(info eq 'ns') +ns_solut = float(value[ii[0]]) + +; std deviation of the az residuals resulting from the solution +ii = where(info eq 'sd_az') +sd_az_solut = float(value[ii[0]]) + +; std deviation of the zd residuals resulting from the solution +ii = where(info eq 'sd_zd') +sd_zd_solut = float(value[ii[0]]) + +; reading solution param values +readcol, ff_astro_solut, junk, junk, param_solut, junk, sigma_solut, junk, $ + format = files.calibration.month.astrometry.solution.format_r, /silent + +; checking the quality of the solution ot be exported +try_update = (ns_solut ge par.astrometry.min_ns) and (sd_az_solut le par.astrometry.max_sd_az) and $ + (sd_zd_solut le par.astrometry.max_sd_zd) + +; the astrometric solution is not good enough, returning +if ~try_update then begin + + message, 'monthly astrometric solution is not good enough. return:99', /informational + cd, old_dir + return + +endif + +; going into solutions directory / camera +ckcd, par.config.path.dir_solutions, check = check, old_dir = old_dir if ~check then return +mkcd, camera ; name of the current solution folder = camera + '_' + month diff --git a/code/calibration/report_year.pro b/code/calibration/report_year.pro new file mode 100644 index 0000000..02209a7 --- /dev/null +++ b/code/calibration/report_year.pro @@ -0,0 +1,1096 @@ +; procedure that prints txt, pdf and excel reports of the calibration results of one camera along months and years + +pro report_year, config, camera, target, $ + report_calib = report_calib, $ + excel_calib = excel_calib, $ + list_captures = list_captures + +compile_opt idl2 + +message, camera + '_' + target + ' - start exporting calibration report.', /informational + +; going into the calibration results directory +ckcd, config.path.dir_calibrations, current = old_dir, check = check +if ~check then return +ckcd, camera, check = check, old_dir = old_dir +if ~check then return + +; searching for the last month +ff = myfile_search(target) + +if ff[0] eq '' then begin + + cd, old_dir + return + +endif + +; reading camera parameters structure from last analyzed month +par = get_par(config, camera, ff[-1]) + +; checking for keyword input +if isa(report_calib) then par.config.calibration.report_calib = report_calib +if isa(excel_calib) then par.config.calibration.excel_calib = excel_calib + +; path of the captures list file(s) +if ~isa(list_captures) then list_captures = '' + +; pdf window dimensions (A4) +dimw = [8.3, 11.7]*0.95 + +; buffer flag +buffer = 1 + +; font_size for plots +font_size = 9 + +; print resolution +output_dpi = 600 + +; correction for screen resolution scaling issue +adjust_font_size, font_size, 96., dpi = dpi + +; scale for dpi value of the device, correcting font size scaling issue +dimw = roundf(dimw*dpi) + +; retrieve files structure +files = get_files(par, target) + +; searching for astro/photo param/sigma files +ff_astro_param = file_search('.', files.calibration.day.astrometry.param.name) +ff_astro_sigma = file_search('.', files.calibration.day.astrometry.sigma.name) +ff_photo_param = file_search('.', files.calibration.day.photometry.param.name) +ff_photo_sigma = file_search('.', files.calibration.day.photometry.sigma.name) + +; number of months +n_month_astro = n_elements(ff_astro_param) +n_month_photo = n_elements(ff_photo_param) + +if n_month_astro lt 2 or n_month_photo lt 2 then begin + + message, 'not enough months to print report. return:5', /informational + cd, old_dir + return + +endif + +; reading the calibration results files +myreadcol, ff_astro_param, data_astro, jd_astro, ns_astro, sd_az, sd_zd, a0, xo, yo, xz, yz, v, s, d, j, phi, $ + format = files.calibration.day.astrometry.param.format_r, /silent +myreadcol, ff_astro_sigma, junk, junk, junk, junk, junk, s_a0, s_xo, s_yo, s_xz, s_yz, s_v, s_s, s_d, s_j, s_phi, $ + format = files.calibration.day.astrometry.sigma.format_r, /silent +myreadcol, ff_photo_param, data_photo, jd_photo, ns_photo, f, expo, m_ph, m_zd, scale, eff_z, eff_m, eff_l, sd_mag, c, k, z, m, l, $ + format = files.calibration.day.photometry.param.format_r, /silent +myreadcol, ff_photo_sigma, junk, junk, junk, junk, junk, junk, junk, junk, junk, junk, junk, junk, s_c, s_k, s_z, s_m, s_l, $ + format = files.calibration.day.photometry.sigma.format_r, /silent + +; checking astrometric model +myreadcol, ff_astro_param, info, junk, model, format = '(a,a,a)', /silent +ii = where(info eq 'model') +model = model[ii] + +; checking if astrometric model is always the same - proj_rotz_exp1_asym +jj = where(model ne 'proj_rotz_exp1_asym') +if jj[0] ne -1 then begin + + message, 'calibration report not implemented for ' + strlowcase(model) + '. return:99' + cd, old_dir + return + +endif + +; checking if there are at least two months of astrometry with results (otherwise, the plot will fail!) +ii = where(finite(a0) and finite(xo) and finite(yo) and finite(xz) and finite(yz) and $ + finite(v) and finite(s) and finite(d) and finite(j) and finite(phi)) + +if n_elements(ii) lt 2 then begin + + message, 'not enough months with astrometric calibration to print report. return:5', /informational + cd, old_dir + return + +endif + +; number of astro and photo daily results +n_astro = n_elements(data_astro) +n_photo = n_elements(data_photo) + +; reading number of captures from image photometry results +ncap_photo = lonarr(n_photo) +nheader = n_elements(files.calibration.image.photometry.param.header) + +for i=0, n_photo-1 do begin + + ff = '.' + path_sep() + strmid(data_photo[i], 0, 6) + path_sep() + camera + '_' + data_photo[i] + '_photo_param.txt' + ncap_photo[i] = file_lines(ff) - nheader + 1 + +endfor + +; binning into months and computing average C, k and sd_mag +temp = strmid(data_photo, 0, 6) +month_photo = myuniq(temp) +jd = lonarr(n_month_photo) +for i=0, n_month_photo-1 do jd[i] = julday(long(strmid(month_photo[i], 4, 2)), 15L, fix(strmid(month_photo[i], 0, 4))) + +ncap = lonarr(n_month_photo) +ns = lonarr(n_month_photo) +ft = lonarr(n_month_photo) +c_mon = fltarr(n_month_photo) + !values.f_NaN +k_mon = fltarr(n_month_photo) + !values.f_NaN +sd_mag_mon = fltarr(n_month_photo) + !values.f_NaN + +for i=0, n_month_photo-1 do begin + + ii = where(temp eq month_photo[i]) + ncap[i] = total(ncap_photo[ii]) + ns[i] = total(ns_photo[ii]) + ft[i] = max(f[ii]) + + if ns[i] ge par.astrometry.min_ns and ft[i] and sd_az[i] le par.astrometry.max_sd_az and $ + sd_zd[i] le par.astrometry.max_sd_zd then begin + + ii1 = where(temp eq month_photo[i] and f and sd_mag le 1.) + + if ii1[0] ne -1 then begin + + c_mon[i] = median(C[ii1]) + k_mon[i] = median(k[ii1]) + sd_mag_mon[i] = median(sd_mag[ii1]) + + endif + + endif + +endfor + +; computing sky magnitude with monthly C values +c_int = c_mon +kk = where(~finite(c_mon), complement = jj) +if kk[0] ne -1 then begin + + c_int[kk] = interpol(c_int[jj], jd[jj], jd[kk]) + +endif + +temp = strmid(data_photo, 0, 6) +z_mon = fltarr(n_month_photo) +m_mon = fltarr(n_month_photo) +l_mon = fltarr(n_month_photo) + +for i=0, n_month_photo-1 do begin + + ii = where(temp eq month_photo[i]) + z[ii] = z[ii] + c_int[i] + m[ii] = m[ii] + c_int[i] + l[ii] = l[ii] + c_int[i] + + z_mon[i] = median(z[ii], /even) + m_mon[i] = median(m[ii], /even) + l_mon[i] = median(l[ii], /even) + +endfor + +; reading monthly astro solution +ff_astro_solut = file_search('.', files.calibration.month.astrometry.solution.name) +n_solut = n_elements(ff_astro_solut) + +month_solut = strmid(ff_astro_solut, 16, 6) +yy_solut = long(strmid(month_solut, 0, 4)) +mn_solut = long(strmid(month_solut, 4, 2)) +dd_solut = mn_solut*0 + 15 +jd_solut = julday(mn_solut, dd_solut, yy_solut) + +sd_az_solut = fltarr(n_solut) +sd_zd_solut = fltarr(n_solut) + +a0_solut = fltarr(n_solut) +s_a0_solut = fltarr(n_solut) +xo_solut = fltarr(n_solut) +s_xo_solut = fltarr(n_solut) +yo_solut = fltarr(n_solut) +s_yo_solut = fltarr(n_solut) +xz_solut = fltarr(n_solut) +s_xz_solut = fltarr(n_solut) +yz_solut = fltarr(n_solut) +s_yz_solut = fltarr(n_solut) +v_solut = fltarr(n_solut) +s_v_solut = fltarr(n_solut) +s_solut = fltarr(n_solut) +s_s_solut = fltarr(n_solut) +d_solut = fltarr(n_solut) +s_d_solut = fltarr(n_solut) +j_solut = fltarr(n_solut) +s_j_solut = fltarr(n_solut) +phi_solut = fltarr(n_solut) +s_phi_solut = fltarr(n_solut) +ns_solut = lonarr(n_solut) +nd_solut = lonarr(n_solut) + +for i=0, n_solut-1 do begin + + ; checking if astrometric model is proj_rotz_exp1_asym + readcol, ff_astro_solut[i], info, junk, value, format = '(a,a,a)', /silent + ii = where(info eq 'model') + model = value[ii[0]] + + if model ne 'proj_rotz_exp1_asym' then begin + + message, 'calibration report not implemented for ' + strlowcase(model) + '. return:99' + cd, old_dir + return + + endif + + ii = where(strmid(data_astro, 0, 6) eq month_solut[i]) + if ii[0] ne -1 then nd_solut[i] = n_elements(ii) + + ii = where(info eq 'ns') + ns_solut[i] = float(value[ii[0]]) + + ii = where(info eq 'sd_az') + sd_az_solut[i] = float(value[ii[0]]) + + ii = where(info eq 'sd_zd') + sd_zd_solut[i] = float(value[ii[0]]) + + readcol, ff_astro_solut[i], junk, junk, param, junk, sigma, junk, $ + format = files.calibration.month.astrometry.solution.format_r, /silent + + a0_solut[i] = param[0] + s_a0_solut[i] = sigma[0] + xo_solut[i] = param[1] + s_xo_solut[i] = sigma[1] + yo_solut[i] = param[2] + s_yo_solut[i] = sigma[2] + xz_solut[i] = param[3] + s_xz_solut[i] = sigma[3] + yz_solut[i] = param[4] + s_yz_solut[i] = sigma[4] + v_solut[i] = param[5] + s_v_solut[i] = sigma[5] + s_solut[i] = param[6] + s_s_solut[i] = sigma[6] + d_solut[i] = param[7] + s_d_solut[i] = sigma[7] + j_solut[i] = param[8] + s_j_solut[i] = sigma[8] + phi_solut[i] = param[9] + s_phi_solut[i] = sigma[9] + +endfor + +; searching the captures list (from find on server) +if list_captures ne '' then ff_captures = file_search(list_captures) $ + else ff_captures = '' + +; reading the captures list +if ff_captures[0] ne '' then begin + + myreadcol, ff_captures, list_camera, list_month, list_ncap, format = '(a,a,i)', /silent + ii = where(list_camera eq camera) + if ii[0] ne -1 then begin + + list_month = list_month[ii] + list_ncap = list_ncap[ii] + + endif else begin + + list_month = month_photo + list_ncap = lonarr(n_elements(month_photo)) + + endelse + +endif else begin + + list_month = month_photo + list_ncap = lonarr(n_elements(month_photo)) + +endelse + +; checking for missing months +i = -1 +while 1 do begin + + i++ + if i gt n_elements(list_month)-2 then break + + y1 = long(strmid(list_month[i], 0, 4)) + m1 = long(strmid(list_month[i], 4, 2)) + y2 = long(strmid(list_month[i+1], 0, 4)) + m2 = long(strmid(list_month[i+1], 4, 2)) + + ; same year + if y1 eq y2 then begin + + if m2 eq m1 + 1 then continue $ ; no jump in months + else begin ; missing month(s) + + yn = y1 + mn = m1 + 1 + + ; string formatting + str_yn = strtrim(yn, 2) + if mn ge 10 then str_mn = strtrim(mn, 2) else str_mn = '0' + strtrim(mn, 2) + + ; adding next month + list_month = [list_month[0:i], str_yn + str_mn, list_month[i+1:*]] + list_ncap = [list_ncap[0:i], 0, list_ncap[i+1:*]] + + endelse + + endif else begin ; year transition + + ; december y1 -> january y2 = y1 + 1 + if y2 eq y1 + 1 and m1 eq 12 and m2 eq 1 then continue $ + else begin ; missing month(s) + + ; defining new month to be added + yn = y1 + mn = m1 + 1 + + ; december y1 -> january y1 + 1 + if mn gt 12 then begin + + yn = yn + 1 + mn = 1 + + endif + + ; string formatting + str_yn = strtrim(yn, 2) + if mn ge 10 then str_mn = strtrim(mn, 2) else str_mn = '0' + strtrim(mn, 2) + + ; adding next month + list_month = [list_month[0:i], str_yn + str_mn, list_month[i+1:*]] + list_ncap = [list_ncap[0:i], 0, list_ncap[i+1:*]] + + endelse + + endelse + +endwhile + +n_list = n_elements(list_month) +list_jd = lonarr(n_list) +list_yy = long(strmid(list_month, 0, 4)) +list_mn = long(strmid(list_month, 4, 2)) +for i=0, n_list-1 do list_jd[i] = julday(list_mn[i], 15L, list_yy[i]) + +; checking for missing months between list and computed +jd_tot = jd +ncap_tot = ncap +missing_jd = cgsetdifference(list_jd, jd_tot, noresult = -1) +if missing_jd[0] ne -1 then begin + + jd_tot = [jd_tot, missing_jd] + ncap_tot = [ncap_tot, missing_jd*0] + ii = sort(jd_tot) + jd_tot = jd_tot[ii] + ncap_tot = ncap_tot[ii] + +endif + +; loading configuration values to overplot +c_cfg = fltarr(n_list) + !values.f_NaN +k_cfg = fltarr(n_list) + !values.f_NaN +a0_cfg = fltarr(n_list) + !values.f_NaN +xo_cfg = fltarr(n_list) + !values.f_NaN +yo_cfg = fltarr(n_list) + !values.f_NaN +xz_cfg = fltarr(n_list) + !values.f_NaN +yz_cfg = fltarr(n_list) + !values.f_NaN +v_cfg = fltarr(n_list) + !values.f_NaN +s_cfg = fltarr(n_list) + !values.f_NaN +d_cfg = fltarr(n_list) + !values.f_NaN +j_cfg = fltarr(n_list) + !values.f_NaN +phi_cfg = fltarr(n_list) + !values.f_NaN + +for i=0, n_elements(list_jd)-1 do begin + + cam_par = camera_par(config.path.dir_configurations, camera, list_month[i], /return0) + if cam_par.file ne '' then begin + + ; checking if astrometric model is proj_rotz_exp1_asym + model = cam_par.astrometry.model_monthly + if model ne 'proj_rotz_exp1_asym' then begin + + message, 'calibration report not implemented for ' + strlowcase(model) + '. return:99' + cd, old_dir + return + + endif + + c_cfg[i] = cam_par.photometry.c + k_cfg[i] = cam_par.photometry.k + a0_cfg[i] = cam_par.astrometry.param_monthly[0] + xo_cfg[i] = cam_par.astrometry.param_monthly[1] + yo_cfg[i] = cam_par.astrometry.param_monthly[2] + xz_cfg[i] = cam_par.astrometry.param_monthly[3] + yz_cfg[i] = cam_par.astrometry.param_monthly[4] + v_cfg[i] = cam_par.astrometry.param_monthly[5] + s_cfg[i] = cam_par.astrometry.param_monthly[6] + d_cfg[i] = cam_par.astrometry.param_monthly[7] + j_cfg[i] = cam_par.astrometry.param_monthly[8] + phi_cfg[i] = cam_par.astrometry.param_monthly[9] + + endif + +endfor + + +; selecting solutions according to sd_az, sd_zd and sd_mag +ii_mag = where(sd_mag_mon le par.photometry.max_sd_mag) +ii_az_zd = where(sd_az_solut le par.astrometry.max_sd_az and sd_zd_solut le par.astrometry.max_sd_zd) + +if ii_az_zd[0] eq -1 or ii_mag[0] eq -1 then begin + + message, 'not enough months with good astrometric/photometric calibration to print report. return:5', /informational + cd, old_dir + return + +endif + +; computing delta w.r.t. config values +delta = (c_mon - interpol(c_cfg, list_jd, jd)) +d_c = median(delta[ii_mag], /even) +last_d_c = delta[-1] +s_d_c = medabsdev(delta[ii_mag], /sigma, /even) + +delta = (k_mon - interpol(k_cfg, list_jd, jd)) +d_k = median(delta[ii_mag], /even) +last_d_k = delta[-1] +s_d_k = medabsdev(delta[ii_mag], /sigma, /even) + +delta = (a0_solut - interpol(a0_cfg, list_jd, jd_solut))*!radeg +closest, delta, /degree +d_a0 = median(delta[ii_az_zd], /even) +last_d_a0 = delta[-1] +s_d_a0 = medabsdev(delta[ii_az_zd], /sigma, /even) + +delta = (xo_solut - interpol(xo_cfg, list_jd, jd_solut)) +d_xo = median(delta[ii_az_zd], /even) +last_d_xo = delta[-1] +s_d_xo = medabsdev(delta[ii_az_zd], /sigma, /even) + +delta = (yo_solut - interpol(yo_cfg, list_jd, jd_solut)) +d_yo = median(delta[ii_az_zd], /even) +last_d_yo = delta[-1] +s_d_yo = medabsdev(delta[ii_az_zd], /sigma, /even) + +delta = (xz_solut - interpol(xz_cfg, list_jd, jd_solut)) +d_xz = median(delta[ii_az_zd], /even) +last_d_xz = delta[-1] +s_d_xz = medabsdev(delta[ii_az_zd], /sigma, /even) + +delta = (yz_solut - interpol(yz_cfg, list_jd, jd_solut)) +d_yz = median(delta[ii_az_zd], /even) +last_d_yz = delta[-1] +s_d_yz = medabsdev(delta, /sigma, /even) + +delta = (v_solut - interpol(v_cfg, list_jd, jd_solut))*!ramin +d_v = median(delta[ii_az_zd], /even) +last_d_v = delta[-1] +s_d_v = medabsdev(delta, /sigma, /even) + +delta = (s_solut - interpol(s_cfg, list_jd, jd_solut))*!ramin +d_s = median(delta[ii_az_zd], /even) +last_d_s = delta[-1] +s_d_s = medabsdev(delta[ii_az_zd], /sigma, /even) + +delta = (d_solut - interpol(d_cfg, list_jd, jd_solut))*1e3 +d_d = median(delta[ii_az_zd], /even) +last_d_d = delta[-1] +s_d_d = medabsdev(delta[ii_az_zd], /sigma, /even) + +delta = (j_solut - interpol(j_cfg, list_jd, jd_solut))*!ramin +d_j = median(delta[ii_az_zd], /even) +last_d_j = delta[-1] +s_d_j = medabsdev(delta[ii_az_zd], /sigma, /even) + +delta = (phi_solut - interpol(phi_cfg, list_jd, jd_solut))*!radeg +closest, delta, /degree +d_phi = median(delta[ii_az_zd], /even) +last_d_phi = delta[-1] +s_d_phi = medabsdev(delta[ii_az_zd], /sigma, /even) + +; tolerance on the parameters [C, k + astro) +tol = [0.5, 0.1, abs(par.astrometry.tol_monthly)] +tol[2] = tol[2]*!radeg +tol[7] = tol[7]*!ramin +tol[8] = tol[8]*!ramin +tol[9] = tol[9]*1e3 +tol[10] = tol[10]*!ramin +tol[11] = tol[11]*!radeg + +; updating report +cd, config.path.dir_reports + +; searching for the report file +ff = file_search(files.calibration.reports.txt.name) + +; no file, creating empty arrays +if ff[0] eq '' then begin + + cam_w = [] & sd_w = [] & ed_w = [] + nc_w = [] & s_nc_w = [] & l_nc_w = [] + ns_w = [] & s_ns_w = [] & l_ns_w = [] + sm_w = [] & s_sm_w = [] & l_sm_w = [] + c_w = [] & s_c_w = [] & l_c_w = [] & t_c_w = [] + k_w = [] & s_k_w = [] & l_k_w = [] & t_k_w = [] + sa_w = [] & s_sa_w = [] & l_sa_w = [] + sz_w = [] & s_sz_w = [] & l_sz_w = [] + a0_w = [] & s_a0_w = [] & l_a0_w = [] & t_a0_w = [] + xo_w = [] & s_xo_w = [] & l_xo_w = [] & t_xo_w = [] + yo_w = [] & s_yo_w = [] & l_yo_w = [] & t_yo_w = [] + xz_w = [] & s_xz_w = [] & l_xz_w = [] & t_xz_w = [] + yz_w = [] & s_yz_w = [] & l_yz_w = [] & t_yz_w = [] + v_w = [] & s_v_w = [] & l_v_w = [] & t_v_w = [] + s_w = [] & s_s_w = [] & l_s_w = [] & t_s_w = [] + d_w = [] & s_d_w = [] & l_d_w = [] & t_d_w = [] + j_w = [] & s_j_w = [] & l_j_w = [] & t_j_w = [] + phi_w = [] & s_phi_w = [] & l_phi_w = [] & t_phi_w = [] + +endif else begin + + ; reading existing files + gtreadcol, ff[0], cam_w, sd_w, ed_w, nc_w, s_nc_w, l_nc_w, ns_w, s_ns_w, l_ns_w, sm_w, s_sm_w, l_sm_w, c_w, s_c_w, l_c_w, t_c_w, $ + k_w, s_k_w, l_k_w, t_k_w, sa_w, s_sa_w, l_sa_w, sz_w, s_sz_w, l_sz_w, a0_w, s_a0_w, l_a0_w, t_a0_w, $ + xo_w, s_xo_w, l_xo_w, t_xo_w, yo_w, s_yo_w, l_yo_w, t_yo_w, xz_w, s_xz_w, l_xz_w, t_xz_w, yz_w, s_yz_w, l_yz_w, t_yz_w, $ + v_w, s_v_w, l_v_w, t_v_w, s_w, s_s_w, l_s_w, t_s_w, d_w, s_d_w, l_d_w, t_d_w, j_w, s_j_w, l_j_w, t_j_w, $ + phi_w, s_phi_w, l_phi_w, t_phi_w, format = files.calibration.reports.txt.format_r, /silent + +endelse + +; adding results of this camera +ii = where(cam_w eq camera) +ii = ii[0] + +; if camera is not present in the list, add row to the file +if ii[0] eq -1 then begin + + cam_w = [cam_w, camera] & sd_w = [sd_w, month_photo[0]] & ed_w = [ed_w, month_photo[-1]] + nc_w = [nc_w, mean(ncap, /nan)/30.] & s_nc_w = [s_nc_w, medabsdev(ncap, /sigma, /even)/30.] & l_nc_w = [l_nc_w, ncap[-1]/30.] + ns_w = [ns_w, mean(ns_solut/nd_solut, /nan)] & s_ns_w = [s_ns_w, medabsdev(ns_solut/nd_solut, /sigma, /even)] & l_ns_w = [l_ns_w, ns_solut[-1]/nd_solut[-1]] + sm_w = [sm_w, mean(sd_mag_mon[ii_mag], /nan)] & s_sm_w = [s_sm_w, medabsdev(sd_mag_mon[ii_mag], /sigma, /even)] & l_sm_w = [l_sm_w, sd_mag_mon[-1]] + c_w = [c_w, d_c] & s_c_w = [s_c_w, s_d_c] & l_c_w = [l_c_w, last_d_c] & t_c_w = [t_c_w, tol[0]] + k_w = [k_w, d_k] & s_k_w = [s_k_w, s_d_k] & l_k_w = [l_k_w, last_d_k] & t_k_w = [t_k_w, tol[1]] + sa_w = [sa_w, mean(sd_az_solut[ii_az_zd], /nan)] & s_sa_w = [s_sa_w, medabsdev(sd_az_solut[ii_az_zd], /sigma, /even)] & l_sa_w = [l_sa_w, sd_az_solut[-1]] + sz_w = [sz_w, mean(sd_zd_solut[ii_az_zd], /nan)] & s_sz_w = [s_sz_w, medabsdev(sd_zd_solut[ii_az_zd], /sigma, /even)] & l_sz_w = [l_sz_w, sd_zd_solut[-1]] + a0_w = [a0_w, d_a0] & s_a0_w = [s_a0_w, s_d_a0] & l_a0_w = [l_a0_w, last_d_a0] & t_a0_w = [t_a0_w, tol[2]] + xo_w = [xo_w, d_xo] & s_xo_w = [s_xo_w, s_d_xo] & l_xo_w = [l_xo_w, last_d_xo] & t_xo_w = [t_xo_w, tol[3]] + yo_w = [yo_w, d_yo] & s_yo_w = [s_yo_w, s_d_yo] & l_yo_w = [l_yo_w, last_d_yo] & t_yo_w = [t_yo_w, tol[4]] + xz_w = [xz_w, d_xz] & s_xz_w = [s_xz_w, s_d_xz] & l_xz_w = [l_xz_w, last_d_xz] & t_xz_w = [t_xz_w, tol[5]] + yz_w = [yz_w, d_yz] & s_yz_w = [s_yz_w, s_d_yz] & l_yz_w = [l_yz_w, last_d_yz] & t_yz_w = [t_yz_w, tol[6]] + v_w = [v_w, d_v] & s_v_w = [s_v_w, s_d_v] & l_v_w = [l_v_w, last_d_v] & t_v_w = [t_v_w, tol[7]] + s_w = [s_w, d_s] & s_s_w = [s_s_w, s_d_s] & l_s_w = [l_s_w, last_d_s] & t_s_w = [t_s_w, tol[8]] + d_w = [d_w, d_d] & s_d_w = [s_d_w, s_d_d] & l_d_w = [l_d_w, last_d_d] & t_d_w = [t_d_w, tol[9]] + j_w = [j_w, d_j] & s_j_w = [s_j_w, s_d_j] & l_j_w = [l_j_w, last_d_j] & t_j_w = [t_j_w, tol[10]] + phi_w = [phi_w, d_phi] & s_phi_w = [s_phi_w, s_d_phi] & l_phi_w = [l_phi_w, last_d_phi] & t_phi_w = [t_phi_w, tol[11]] + +endif else begin ; if this camera is present, replace value + + cam_w[ii] = camera & sd_w[ii] = month_photo[0] & ed_w[ii] = month_photo[-1] + nc_w[ii] = mean(ncap/30., /nan) & s_nc_w[ii] = medabsdev(ncap/30., /sigma, /even) & l_nc_w[ii] = ncap[-1]/30. + ns_w[ii] = mean(ns_solut/nd_solut, /nan) & s_ns_w[ii] = medabsdev(ns_solut/nd_solut, /sigma, /even) & l_ns_w[ii] = ns_solut[-1]/nd_solut[-1] + sm_w[ii] = mean(sd_mag_mon[ii_mag], /nan) & s_sm_w[ii] = medabsdev(sd_mag_mon[ii_mag], /sigma, /even) & l_sm_w[ii] = sd_mag_mon[-1] + c_w[ii] = d_c & s_c_w[ii] = s_d_c & l_c_w[ii] = last_d_c & t_c_w[ii] = tol[0] + k_w[ii] = d_k & s_k_w[ii] = s_d_k & l_k_w[ii] = last_d_k & t_k_w[ii] = tol[1] + sa_w[ii] = mean(sd_az_solut[ii_az_zd], /nan) & s_sa_w[ii] = medabsdev(sd_az_solut[ii_az_zd], /sigma, /even) & l_sa_w[ii] = sd_az_solut[-1] + sz_w[ii] = mean(sd_zd_solut[ii_az_zd], /nan) & s_sz_w[ii] = medabsdev(sd_zd_solut[ii_az_zd], /sigma, /even) & l_sz_w[ii] = sd_zd_solut[-1] + a0_w[ii] = d_a0 & s_a0_w[ii] = s_d_a0 & l_a0_w[ii] = last_d_a0 & t_a0_w[ii] = tol[2] + xo_w[ii] = d_xo & s_xo_w[ii] = s_d_xo & l_xo_w[ii] = last_d_xo & t_xo_w[ii] = tol[3] + yo_w[ii] = d_yo & s_yo_w[ii] = s_d_yo & l_yo_w[ii] = last_d_yo & t_yo_w[ii] = tol[4] + xz_w[ii] = d_xz & s_xz_w[ii] = s_d_xz & l_xz_w[ii] = last_d_xz & t_xz_w[ii] = tol[5] + yz_w[ii] = d_yz & s_yz_w[ii] = s_d_yz & l_yz_w[ii] = last_d_yz & t_yz_w[ii] = tol[6] + v_w[ii] = d_v & s_v_w[ii] = s_d_v & l_v_w[ii] = last_d_v & t_v_w[ii] = tol[7] + s_w[ii] = d_s & s_s_w[ii] = s_d_s & l_s_w[ii] = last_d_s & t_s_w[ii] = tol[8] + d_w[ii] = d_d & s_d_w[ii] = s_d_d & l_d_w[ii] = last_d_d & t_d_w[ii] = tol[9] + j_w[ii] = d_j & s_j_w[ii] = s_d_j & l_j_w[ii] = last_d_j & t_j_w[ii] = tol[10] + phi_w[ii] = d_phi & s_phi_w[ii] = s_d_phi & l_phi_w[ii] = last_d_phi & t_phi_w[ii] = tol[11] + +endelse + +; printing txt report +print_header, files.calibration.reports.txt +openw, lun, files.calibration.reports.txt.name, /get_lun, /append + +for i=0, n_elements(cam_w)-1 do $ + printf, lun, cam_w[i], sd_w[i], ed_w[i], nc_w[i], s_nc_w[i], l_nc_w[i], ns_w[i], s_ns_w[i], l_ns_w[i], sm_w[i], s_sm_w[i], l_sm_w[i], $ + c_w[i], s_c_w[i], l_c_w[i], t_c_w[i], k_w[i], s_k_w[i], l_k_w[i], t_k_w[i], sa_w[i], s_sa_w[i], l_sa_w[i], $ + sz_w[i], s_sz_w[i], l_sz_w[i], a0_w[i], s_a0_w[i], l_a0_w[i], t_a0_w[i], xo_w[i], s_xo_w[i], l_xo_w[i], t_xo_w[i], $ + yo_w[i], s_yo_w[i], l_yo_w[i], t_yo_w[i], xz_w[i], s_xz_w[i], l_xz_w[i], t_xz_w[i], yz_w[i], s_yz_w[i], l_yz_w[i], t_yz_w[i], $ + v_w[i], s_v_w[i], l_v_w[i], t_v_w[i], s_w[i], s_s_w[i], l_s_w[i], t_s_w[i], d_w[i], s_d_w[i], l_d_w[i], t_d_w[i], $ + j_w[i], s_j_w[i], l_j_w[i], t_j_w[i], phi_w[i], s_phi_w[i], l_phi_w[i], t_phi_w[i], format = files.calibration.reports.txt.format_w + +close, lun & free_lun, lun + +; transcripting report to excel if required +if par.config.calibration.excel_calib then begin + + ; importing openpyxl python library to handle excel files + openpyxl = python.import('openpyxl') + + ; searching the report template + ff = myfile_search(par.config.path.template_calib) + if ff[0] eq '' then begin + + cd, old_dir + return + + endif + + ; copying the report template + file_copy, ff[0], files.calibration.reports.xlsx.name, /overwrite + + ; check if copy was successful + ff = myfile_search(files.calibration.reports.xlsx.name) + if ff[0] eq '' then begin + + cd, old_dir + return + + endif + + ; opening the excel file + wb = openpyxl.load_workbook(files.calibration.reports.xlsx.name) + + ; conditional formatting: green = good config, red = bad config + wb.conditional_formatting = openpyxl.formatting.formatting.ConditionalFormattingList() + greenFill = openpyxl.styles.patternfill(start_color = '99FF99', end_color = '99FF99', fill_type = 'solid') + redFill = openpyxl.styles.patternfill(start_color = 'FFB2B2', end_color = 'FFB2B2', fill_type = 'solid') + + ; value and error columns + c1 = ['M', 'P', 'Y', 'AB', 'AE', 'AH', 'AK', 'AN', 'AQ', 'AT', 'AW', 'AZ'] + c2 = ['O', 'R', 'AA', 'AD', 'AG', 'AJ', 'AM', 'AP', 'AS', 'AV', 'AY', 'BB'] + + ; sheet with average values + ws = wb.get_sheet_by_name('Average') + for i=0, n_elements(cam_w)-1 do begin + + junk = ws.cell(row = i + 2, column = 1, value = cam_w[i]) + junk = ws.cell(row = i + 2, column = 2, value = strmid(sd_w[i], 0, 4) + '/' + strmid(sd_w[i], 4, 2)) + junk = ws.cell(row = i + 2, column = 3, value = strmid(ed_w[i], 0, 4) + '/' + strmid(ed_w[i], 4, 2)) + junk = ws.cell(row = i + 2, column = 4, value = nc_w[i]) + junk = ws.cell(row = i + 2, column = 5, value = '±') + junk = ws.cell(row = i + 2, column = 6, value = s_nc_w[i]) + junk = ws.cell(row = i + 2, column = 7, value = ns_w[i]) + junk = ws.cell(row = i + 2, column = 8, value = '±') + junk = ws.cell(row = i + 2, column = 9, value = s_ns_w[i]) + junk = ws.cell(row = i + 2, column = 10, value = sm_w[i]) + junk = ws.cell(row = i + 2, column = 11, value = '±') + junk = ws.cell(row = i + 2, column = 12, value = s_sm_w[i]) + junk = ws.cell(row = i + 2, column = 13, value = c_w[i]) + junk = ws.cell(row = i + 2, column = 14, value = '±') + junk = ws.cell(row = i + 2, column = 15, value = s_c_w[i]) + junk = ws.cell(row = i + 2, column = 16, value = k_w[i]) + junk = ws.cell(row = i + 2, column = 17, value = '±') + junk = ws.cell(row = i + 2, column = 18, value = s_k_w[i]) + junk = ws.cell(row = i + 2, column = 19, value = sa_w[i]) + junk = ws.cell(row = i + 2, column = 20, value = '±') + junk = ws.cell(row = i + 2, column = 21, value = s_sa_w[i]) + junk = ws.cell(row = i + 2, column = 22, value = sz_w[i]) + junk = ws.cell(row = i + 2, column = 23, value = '±') + junk = ws.cell(row = i + 2, column = 24, value = s_sz_w[i]) + junk = ws.cell(row = i + 2, column = 25, value = a0_w[i]) + junk = ws.cell(row = i + 2, column = 26, value = '±') + junk = ws.cell(row = i + 2, column = 27, value = s_a0_w[i]) + junk = ws.cell(row = i + 2, column = 28, value = xo_w[i]) + junk = ws.cell(row = i + 2, column = 29, value = '±') + junk = ws.cell(row = i + 2, column = 30, value = s_xo_w[i]) + junk = ws.cell(row = i + 2, column = 31, value = yo_w[i]) + junk = ws.cell(row = i + 2, column = 32, value = '±') + junk = ws.cell(row = i + 2, column = 33, value = s_yo_w[i]) + junk = ws.cell(row = i + 2, column = 34, value = xz_w[i]) + junk = ws.cell(row = i + 2, column = 35, value = '±') + junk = ws.cell(row = i + 2, column = 36, value = s_xz_w[i]) + junk = ws.cell(row = i + 2, column = 37, value = yz_w[i]) + junk = ws.cell(row = i + 2, column = 38, value = '±') + junk = ws.cell(row = i + 2, column = 39, value = s_yz_w[i]) + junk = ws.cell(row = i + 2, column = 40, value = v_w[i]) + junk = ws.cell(row = i + 2, column = 41, value = '±') + junk = ws.cell(row = i + 2, column = 42, value = s_v_w[i]) + junk = ws.cell(row = i + 2, column = 43, value = s_w[i]) + junk = ws.cell(row = i + 2, column = 44, value = '±') + junk = ws.cell(row = i + 2, column = 45, value = s_s_w[i]) + junk = ws.cell(row = i + 2, column = 46, value = d_w[i]) + junk = ws.cell(row = i + 2, column = 47, value = '±') + junk = ws.cell(row = i + 2, column = 48, value = s_d_w[i]) + junk = ws.cell(row = i + 2, column = 49, value = j_w[i]) + junk = ws.cell(row = i + 2, column = 50, value = '±') + junk = ws.cell(row = i + 2, column = 51, value = s_j_w[i]) + junk = ws.cell(row = i + 2, column = 52, value = phi_w[i]) + junk = ws.cell(row = i + 2, column = 53, value = '±') + junk = ws.cell(row = i + 2, column = 54, value = s_phi_w[i]) + + ; formatting sheet cells + for jj=0, ws.max_column-1 do begin + + this_cell = ws.cell(row = i + 2, column = jj + 1) + + ; text alignment - center + this_cell.alignment = openpyxl.styles.alignment(horizontal = 'center', vertical = 'center') + + ; number format - 0.00 for deltas + if jj ge 3 and jj lt 9 then this_cell.number_format = '0' + if jj ge 9 then this_cell.number_format = '0.00' + + endfor + + ; tolerance for each cell + this_tol = [t_c_w[i], t_k_w[i], t_a0_w[i], t_xo_w[i], t_yo_w[i], t_xz_w[i], t_yz_w[i], t_v_w[i], t_s_w[i], t_d_w[i], t_j_w[i], t_phi_w[i]] + str_tol = strtrim(string(this_tol, format = '(f20.2)'), 2) + + ; applying format on each cell + for jj=0, n_elements(c1)-1 do begin + + row = strtrim(i + 2, 2) + form1 = 'OR(AND(OR(ABS(' + c1[jj] + row + ')<=3*' + c2[jj] + row + ', ABS(' + c1[jj] + row + ') < ' + str_tol[jj] + '), ' + $ + 'NOT(ISBLANK(' + c1[jj] + row + '))), ' + str_tol[jj] + ' = 0' + ')' + form2 = 'NOT(' + form1 + ')' + + junk = ws.conditional_formatting.add(c1[jj] + row, openpyxl.formatting.rule.FormulaRule(formula = [form1], fill = greenFill)) + junk = ws.conditional_formatting.add(c1[jj] + row, openpyxl.formatting.rule.FormulaRule(formula = [form2], fill = redFill)) + + endfor + + endfor + + ; sheet with values of last month + ws = wb.get_sheet_by_name('Last') + for i=0, n_elements(cam_w)-1 do begin + + junk = ws.cell(row = i + 2, column = 1, value = cam_w[i]) + junk = ws.cell(row = i + 2, column = 2, value = strmid(sd_w[i], 0, 4) + '/' + strmid(sd_w[i], 4, 2)) + junk = ws.cell(row = i + 2, column = 3, value = strmid(ed_w[i], 0, 4) + '/' + strmid(ed_w[i], 4, 2)) + junk = ws.cell(row = i + 2, column = 4, value = l_nc_w[i]) + junk = ws.cell(row = i + 2, column = 5, value = '±') + junk = ws.cell(row = i + 2, column = 6, value = s_nc_w[i]) + junk = ws.cell(row = i + 2, column = 7, value = l_ns_w[i]) + junk = ws.cell(row = i + 2, column = 8, value = '±') + junk = ws.cell(row = i + 2, column = 9, value = s_ns_w[i]) + junk = ws.cell(row = i + 2, column = 10, value = l_sm_w[i]) + junk = ws.cell(row = i + 2, column = 11, value = '±') + junk = ws.cell(row = i + 2, column = 12, value = s_sm_w[i]) + junk = ws.cell(row = i + 2, column = 13, value = l_c_w[i]) + junk = ws.cell(row = i + 2, column = 14, value = '±') + junk = ws.cell(row = i + 2, column = 15, value = s_c_w[i]) + junk = ws.cell(row = i + 2, column = 16, value = l_k_w[i]) + junk = ws.cell(row = i + 2, column = 17, value = '±') + junk = ws.cell(row = i + 2, column = 18, value = s_k_w[i]) + junk = ws.cell(row = i + 2, column = 19, value = l_sa_w[i]) + junk = ws.cell(row = i + 2, column = 20, value = '±') + junk = ws.cell(row = i + 2, column = 21, value = s_sa_w[i]) + junk = ws.cell(row = i + 2, column = 22, value = l_sz_w[i]) + junk = ws.cell(row = i + 2, column = 23, value = '±') + junk = ws.cell(row = i + 2, column = 24, value = s_sz_w[i]) + junk = ws.cell(row = i + 2, column = 25, value = l_a0_w[i]) + junk = ws.cell(row = i + 2, column = 26, value = '±') + junk = ws.cell(row = i + 2, column = 27, value = s_a0_w[i]) + junk = ws.cell(row = i + 2, column = 28, value = l_xo_w[i]) + junk = ws.cell(row = i + 2, column = 29, value = '±') + junk = ws.cell(row = i + 2, column = 30, value = s_xo_w[i]) + junk = ws.cell(row = i + 2, column = 31, value = l_yo_w[i]) + junk = ws.cell(row = i + 2, column = 32, value = '±') + junk = ws.cell(row = i + 2, column = 33, value = s_yo_w[i]) + junk = ws.cell(row = i + 2, column = 34, value = l_xz_w[i]) + junk = ws.cell(row = i + 2, column = 35, value = '±') + junk = ws.cell(row = i + 2, column = 36, value = s_xz_w[i]) + junk = ws.cell(row = i + 2, column = 37, value = l_yz_w[i]) + junk = ws.cell(row = i + 2, column = 38, value = '±') + junk = ws.cell(row = i + 2, column = 39, value = s_yz_w[i]) + junk = ws.cell(row = i + 2, column = 40, value = l_v_w[i]) + junk = ws.cell(row = i + 2, column = 41, value = '±') + junk = ws.cell(row = i + 2, column = 42, value = s_v_w[i]) + junk = ws.cell(row = i + 2, column = 43, value = l_s_w[i]) + junk = ws.cell(row = i + 2, column = 44, value = '±') + junk = ws.cell(row = i + 2, column = 45, value = s_s_w[i]) + junk = ws.cell(row = i + 2, column = 46, value = l_d_w[i]) + junk = ws.cell(row = i + 2, column = 47, value = '±') + junk = ws.cell(row = i + 2, column = 48, value = s_d_w[i]) + junk = ws.cell(row = i + 2, column = 49, value = l_j_w[i]) + junk = ws.cell(row = i + 2, column = 50, value = '±') + junk = ws.cell(row = i + 2, column = 51, value = s_j_w[i]) + junk = ws.cell(row = i + 2, column = 52, value = l_phi_w[i]) + junk = ws.cell(row = i + 2, column = 53, value = '±') + junk = ws.cell(row = i + 2, column = 54, value = s_phi_w[i]) + + ; formatting sheet cells + for jj=0, ws.max_column-1 do begin + + this_cell = ws.cell(row = i + 2, column = jj + 1) + + ; text alignment - center + this_cell.alignment = openpyxl.styles.alignment(horizontal = 'center', vertical = 'center') + + ; number format - 0.00 for deltas + if jj ge 3 and jj lt 9 then this_cell.number_format = '0' + if jj ge 9 then this_cell.number_format = '0.00' + + endfor + + ; tolerance for each cell + this_tol = [t_c_w[i], t_k_w[i], t_a0_w[i], t_xo_w[i], t_yo_w[i], t_xz_w[i], t_yz_w[i], t_v_w[i], t_s_w[i], t_d_w[i], t_j_w[i], t_phi_w[i]] + str_tol = strtrim(string(this_tol, format = '(f20.2)'), 2) + + ; applying format on each cell + for jj=0, n_elements(c1)-1 do begin + + row = strtrim(i + 2, 2) + form1 = 'OR(AND(OR(ABS(' + c1[jj] + row + ')<=3*' + c2[jj] + row + ', ABS(' + c1[jj] + row + ') < ' + str_tol[jj] + '), ' + $ + 'NOT(ISBLANK(' + c1[jj] + row + '))), ' + str_tol[jj] + ' = 0' + ')' + form2 = 'NOT(' + form1 + ')' + + junk = ws.conditional_formatting.add(c1[jj] + row, openpyxl.formatting.rule.FormulaRule(formula = [form1], fill = greenFill)) + junk = ws.conditional_formatting.add(c1[jj] + row, openpyxl.formatting.rule.FormulaRule(formula = [form2], fill = redFill)) + + endfor + + endfor + + junk = wb.save(filename = files.calibration.reports.xlsx.name) + +endif + +; printing pdf report if required +if par.config.calibration.report_calib then begin + + ; window 1 + w1 = window(dimensions = dimw, buffer = buffer) + + ; formatting x axis (date) + ld = label_date(date_format = ['%N/%Z']) + xrange = plot_range([list_jd - 15., list_jd + 15.], border = 0) + + delta = (xrange[1] - xrange[0])/365. + + case 1 of + + delta le 1 : xtickinterval = 365./3. + delta gt 1 and delta le 3 : xtickinterval = 365./2. + delta gt 3 : xtickinterval = 365. + + endcase + + ; number of captures + yrange = [-15., 175.] + if ff_captures[0] eq '' then nodata = 1 else nodata = 0 + p1 = plot(list_jd, list_ncap/30., current = w1, 'o', nodata = nodata, position = [0.16, 0.75, 0.46, 0.86], title = 'captures data', $ + xtitle = 'date', ytitle = '# captures / day', xminor = 4, yminor = 1, xrange = xrange, sym_size = 0.4, $ + yrange = yrange, font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p1a = plot(jd_tot, ncap_tot/30., 'o', overplot = p1, color = 'red', sym_size = 0.4, /sym_filled) + + ; number of identified stars + yrange = plot_range(ns_astro/1e3, /min0) & yrange[0] = 1./1e3 + p2 = plot(jd_astro, ns_astro/1e3, current = w1, '.', position = [0.58, 0.75, 0.88, 0.86], title = 'identified stars', $ + xtitle = 'date', ytitle = '# stars / night ($\cdot$10$^3$)', xminor = 4, yminor = 1, xrange = xrange, $ + yrange = yrange, font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p2a = plot(jd_solut, ns_solut/nd_solut/1e3, 'o', overplot = p2, color = 'red', sym_size = 0.4, /sym_filled) + + ; selecting only photometric days + ii0 = where(f) + + ; sky magnitude @ zenith + yrange = plot_range([z, m, l], border = 0.2, /reverse) + p3 = plot(jd_photo, z, current = w1, '.', position = [0.16, 0.59, 0.46, 0.70], title = 'sky magnitude @ z = 0°', $ + xtitle = 'date', ytitle = 'mag/arcsec$^2$', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p3a = plot(jd, z_mon, 'o', overplot = p3, color = 'red', sym_size = 0.4, /sym_filled) + + ; sky magnitude @ z = 45 deg + p4 = plot(jd_photo, m, current = w1, '.', position = [0.58, 0.59, 0.88, 0.70], title = 'sky magnitude @ z = 45°', $ + xtitle = 'date', ytitle = 'mag/arcsec$^2$', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p4a = plot(jd, m_mon, 'o', overplot = p4, color = 'red', sym_size = 0.4, /sym_filled) + + ; sky magnitude @ z = 70 deg + p5 = plot(jd_photo, l, current = w1, '.', position = [0.16, 0.43, 0.46, 0.54], title = 'sky magnitude @ z = 70°', $ + xtitle = 'date', ytitle = 'mag/arcsec$^2$', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p5a = plot(jd, l_mon, 'o', overplot = p5, color = 'red', sym_size = 0.4, /sym_filled) + + ; std.dev mag + ii = where(ns gt par.astrometry.min_ns and ft and sd_mag_mon le par.photometry.max_sd_mag) + yrange = plot_range(sd_mag_mon[ii], border = 0.2) + p6 = plot(jd_photo[ii0], sd_mag[ii0], current = w1, '.', position = [0.58, 0.43, 0.88, 0.54], title = 'std.dev mag residuals', $ + xtitle = 'date', ytitle = 'sd_mag [mag]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p6a = plot(jd, sd_mag_mon, 'o', overplot = p6, color = 'red', sym_size = 0.4, /sym_filled) + + ; zero-point + yrange = plot_range(c_mon[ii], border = 0.2) + title = 'zero-point magnitude ($\Delta$ = ' + strtrim(string(d_c, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_c, format = '(f20.2)'), 2) + ' mag)' + p7 = plot(jd_photo[ii0], C[ii0], current = w1, '.', position = [0.16, 0.27, 0.46, 0.38], title = title, $ + xtitle = 'date', ytitle = 'C [mag]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p7a = plot(jd, c_mon, 'o', overplot = p7, color = 'red', sym_size = 0.4, /sym_filled) + p7b = plot(list_jd, C_cfg, overplot = p7, color = 'deep sky blue', thick = 2) + p7b.order, /send_to_back + + ; atmospheric extinction coeff + yrange = plot_range(k_mon[ii], border = 0.2, /min0) + title = 'atm. ext. coeff. ($\Delta$ = ' + strtrim(string(d_k, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_k, format = '(f20.2)'), 2) + ' mag/am)' + p8 = plot(jd_photo[ii0], k[ii0], current = w1, '.', position = [0.58, 0.27, 0.88, 0.38], title = title, $ + xtitle = 'date', ytitle = 'k [mag/am]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p8a = plot(jd, k_mon, 'o', overplot = p8, color = 'red', sym_size = 0.4, /sym_filled) + p8b = plot(list_jd, k_cfg, overplot = p8, color = 'deep sky blue', thick = 2) + p8b.order, /send_to_back + + ; std.dev az + ii = where(ns_solut gt par.astrometry.min_ns and sd_az_solut le par.astrometry.max_sd_az and sd_zd_solut le par.astrometry.max_sd_zd) + yrange = plot_range([sd_az_solut[ii], sd_zd_solut[ii]], border = 0.2) + p9 = plot(jd_astro, sd_az, current = w1, '.', position = [0.16, 0.11, 0.46, 0.22], title = 'std.dev az residuals', $ + xtitle = 'date', ytitle = 'sd_az [amin]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p9a = plot(jd_solut, sd_az_solut, 'o', overplot = p9, color = 'red', sym_size = 0.4, /sym_filled) + + ; std.dev zd + p10 = plot(jd_astro, sd_zd, current = w1, '.', position = [0.58, 0.11, 0.88, 0.22], title = 'std.dev zd residuals', $ + xtitle = 'date', ytitle = 'sd_zd [amin]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p10a = plot(jd_solut, sd_zd_solut, 'o', overplot = p10, color = 'red', sym_size = 0.4, /sym_filled) + + ; window 2 + w2 = window(dimensions = dimw, buffer = buffer) + + ; North direction + yrange = plot_range(a0_solut[ii]*!radeg, border = 0.4) + title = 'North direction ($\Delta$ = ' + strtrim(string(d_a0, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_a0, format = '(f20.2)'), 2) + ' deg)' + p11 = plot(jd_astro, a0*!radeg, current = w2, '.', position = [0.16, 0.75, 0.46, 0.86], title = title, $ + xtitle = 'date', ytitle = 'a$_0$ [deg]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p11a = plot(jd_solut, a0_solut*!radeg, 'o', overplot = p11, color = 'red', sym_size = 0.4, /sym_filled) + p11b = plot(list_jd, a0_cfg*!radeg, overplot = p11, color = 'deep sky blue', thick = 2) + p11b.order, /send_to_back + + ; linear plate scale + yrange = plot_range(v_solut[ii]*!ramin, border = 0.4) + title = 'lin. plate scale ($\Delta$ = ' + strtrim(string(d_v, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_v, format = '(f20.2)'), 2) + ' amin/px)' + p12 = plot(jd_astro, v*!ramin, current = w2, '.', position = [0.58, 0.75, 0.88, 0.86], title = title, $ + xtitle = 'date', ytitle = '$V$ [amin/px]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p12a = plot(jd_solut, v_solut*!ramin, 'o', overplot = p12, color = 'red', sym_size = 0.4, /sym_filled) + p12b = plot(list_jd, v_cfg*!ramin, overplot = p12, color = 'deep sky blue', thick = 2) + p12b.order, /send_to_back + + ; optical centre (x) + yrange = plot_range(xo_solut[ii], border = 0.4) + title = 'optical centre x ($\Delta$ = ' + strtrim(string(d_xo, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_xo, format = '(f20.2)'), 2) + ' px)' + p13 = plot(jd_astro, xo, current = w2, '.', position = [0.16, 0.59, 0.46, 0.70], title = title, $ + xtitle = 'date', ytitle = '$x_o$ [px]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p13a = plot(jd_solut, xo_solut, 'o', overplot = p13, color = 'red', sym_size = 0.4, /sym_filled) + p13b = plot(list_jd, xo_cfg, overplot = p13, color = 'deep sky blue', thick = 2) + p13b.order, /send_to_back + + ; optical centre (y) + yrange = plot_range(yo_solut[ii], border = 0.4) + title = 'optical centre y ($\Delta$ = ' + strtrim(string(d_yo, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_yo, format = '(f20.2)'), 2) + ' px)' + p14 = plot(jd_astro, yo, current = w2, '.', position = [0.58, 0.59, 0.88, 0.70], title = title, $ + xtitle = 'date', ytitle = '$y_o$ [px]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p14a = plot(jd_solut, yo_solut, 'o', overplot = p14, color = 'red', sym_size = 0.4, /sym_filled) + p14b = plot(list_jd, yo_cfg, overplot = p14, color = 'deep sky blue', thick = 2) + p14b.order, /send_to_back + + ; zenith direction (x) + yrange = plot_range(xz_solut[ii], border = 0.4) + title = 'zenith direction x ($\Delta$ = ' + strtrim(string(d_xz, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_xz, format = '(f20.2)'), 2) + ' px)' + p15 = plot(jd_astro, xz, current = w2, '.', position = [0.16, 0.43, 0.46, 0.54], title = title, $ + xtitle = 'date', ytitle = '$x_z$ [px]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p15a = plot(jd_solut, xz_solut, 'o', overplot = p15, color = 'red', sym_size = 0.4, /sym_filled) + p15b = plot(list_jd, xz_cfg, overplot = p15, color = 'deep sky blue', thick = 2) + p15b.order, /send_to_back + + ; zenith direction (y) + yrange = plot_range(yz_solut[ii], border = 0.4) + title = 'zenith direction y ($\Delta$ = ' + strtrim(string(d_yz, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_yz, format = '(f20.2)'), 2) + ' px)' + p16 = plot(jd_astro, yz, current = w2, '.', position = [0.58, 0.43, 0.88, 0.54], title = title, $ + xtitle = 'date', ytitle = '$y_z$ [px]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p16a = plot(jd_solut, yz_solut, 'o', overplot = p16, color = 'red', sym_size = 0.4, /sym_filled) + p16b = plot(list_jd, yz_cfg, overplot = p16, color = 'deep sky blue', thick = 2) + p16b.order, /send_to_back + + ; radial distortion amplitude + yrange = plot_range(s_solut[ii]*!ramin, border = 0.4) + title = 'FET amplitude ($\Delta$ = ' + strtrim(string(d_s, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_s, format = '(f20.2)'), 2) + ' amin)' + p17 = plot(jd_astro, s*!ramin, current = w2, '.', position = [0.16, 0.27, 0.46, 0.38], title = title, $ + xtitle = 'date', ytitle = 'S [amin]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p17a = plot(jd_solut, s_solut*!ramin, 'o', overplot = p17, color = 'red', sym_size = 0.4, /sym_filled) + p17b = plot(list_jd, s_cfg*!ramin, overplot = p17, color = 'deep sky blue', thick = 2) + p17b.order, /send_to_back + + ; radial distortion scale + yrange = plot_range(d_solut[ii]*1e3, border = 0.4) + title = 'FET scale ($\Delta$ = ' + strtrim(string(d_d, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_d, format = '(f20.2)'), 2) + ' 10$^3$/px)' + p18 = plot(jd_astro, d*1e3, current = w2, '.', position = [0.58, 0.27, 0.88, 0.38], title = title, $ + xtitle = 'date', ytitle = 'D [10$^3$/px]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p18a = plot(jd_solut, d_solut*1e3, 'o', overplot = p18, color = 'red', sym_size = 0.4, /sym_filled) + p18b = plot(list_jd, d_cfg*1e3, overplot = p18, color = 'deep sky blue', thick = 2) + p18b.order, /send_to_back + + ; elliptic distortion amplitude + yrange = plot_range(j_solut[ii]*!ramin, border = 0.4) + title = 'elliptic amplitude ($\Delta$ = ' + strtrim(string(d_j, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_j, format = '(f20.2)'), 2) + ' amin)' + p19 = plot(jd_astro, j*!ramin, current = w2, '.', position = [0.16, 0.11, 0.46, 0.22], title = title, $ + xtitle = 'date', ytitle = 'J [amin]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p19a = plot(jd_solut, j_solut*!ramin, 'o', overplot = p19, color = 'red', sym_size = 0.4, /sym_filled) + p19b = plot(list_jd, j_cfg*!ramin, overplot = p19, color = 'deep sky blue', thick = 2) + p19b.order, /send_to_back + + ; elliptic distortion phase + yrange = plot_range(phi_solut[ii]*!radeg, border = 0.4) + title = 'elliptic phase ($\Delta$ = ' + strtrim(string(d_phi, format = '(f20.2)'), 2) + ' ± ' + strtrim(string(s_d_phi, format = '(f20.2)'), 2) + ' deg)' + p20 = plot(jd_astro, phi*!radeg, current = w2, '.', position = [0.58, 0.11, 0.88, 0.22], title = title, $ + xtitle = 'date', ytitle = '$\phi$ [deg]', xminor = 4, yminor = 1, xrange = xrange, yrange = yrange, $ + font_size = font_size/1.2, xtickformat = 'LABEL_DATE', xtickinterval = xtickinterval, /sym_filled) + p20a = plot(jd_solut, phi_solut*!radeg, 'o', overplot = p20, color = 'red', sym_size = 0.4, /sym_filled) + p20b = plot(list_jd, phi_cfg*!radeg, overplot = p20, color = 'deep sky blue', thick = 2) + p20b.order, /send_to_back + + ; loading PRISMA logo + logo = get_logo(config.path.logo_white, transparent = 'white') + + ; compute logo positions + dim_logo = logo.dim + dim_logo = roundf(dim_logo[1:2]) + pos_logo = [0.83, 1.00 - (1.00 - 0.83)*(dimw[0]/dimw[1])*(dim_logo[1]/dim_logo[0]), $ + 0.99, 1.00 - (1.00 - 0.99)*(dimw[0]/dimw[1])] + + ; logo overlay + im1_logo = image(logo, current = w1, position = pos_logo) + im2_logo = image(logo, current = w2, position = pos_logo) + + ; title overlay + title = camera + ' ' + month_photo[0] + ' - ' + month_photo[-1] + text1_month = text(0.05, 1.00 - 0.05*(dimw[0]/dimw[1]), title, target = w1, font_size = 1.25*font_size, $ + vertical_alignment = 0.5) + text2_month = text(0.05, 1.00 - 0.05*(dimw[0]/dimw[1]), title, target = w2, font_size = 1.25*font_size, $ + vertical_alignment = 0.5) + + ; credits overlay + text1_credits = text(0.05, 0.05*(dimw[0]/dimw[1]), !credits, target = w1, font_size = 0.75*font_size, $ + vertical_alignment = 0.5) + text2_credits = text(0.05, 0.05*(dimw[0]/dimw[1]), !credits, target = w2, font_size = 0.75*font_size, $ + vertical_alignment = 0.5) + + ; printing windows to pdf + w1.save, files.calibration.reports.pdf.name, /append, /memory, /bitmap, page_size = 'A4', resolution = output_dpi + w2.save, files.calibration.reports.pdf.name, /append, /close, /memory, /bitmap, page_size = 'A4', resolution = output_dpi + + ; closing windows + if isa(w1) then w1.close + if isa(w1) then w2.close + +endif + +; returning to the original directory +cd, old_dir + +message, camera + '_' + target + ' - finish exporting calibration report.', /informational + +end \ No newline at end of file diff --git a/code/calibration/update_config.pro b/code/calibration/update_config.pro new file mode 100644 index 0000000..adc6852 --- /dev/null +++ b/code/calibration/update_config.pro @@ -0,0 +1,297 @@ +; function to update config based on the astrometry results of the current month + +pro update_config, config, camera, month + +compile_opt idl2 + +message, camera + '_' + month + ' - start updating configuration file.', /informational + +; retrieve setting parameters +par = get_par(config, camera, month) + +; going into calibration results directory / camera / month +ckcd, par.config.path.dir_calibrations, current = old_dir, check = check +if ~check then return +ckcd, camera, check = check, old_dir = old_dir +if ~check then return +ckcd, month, check = check, old_dir = old_dir +if ~check then return + +; retrieving list of names for output files +; searching for daily and monthly astrometry result files +files_day = get_files(par, month + '??') +files_month = get_files(par, month) + +; reading image astro results +ff_image_param = myfile_search('.', files_day.calibration.image.astrometry.param.name) +if ff_image_param[0] eq '' then begin + + cd, old_dir + return + +endif + +; checking image astrometric model +myreadcol, ff_image_param, info, junk, model, format = '(a,a,a)', /silent +ii = where(info eq 'model') +model = model[ii] + +; checking if model_image is appropriate +model_image = myuniq(model) +if n_elements(model_image) gt 1 then begin + + message, 'model_image is not unique, return: 99', /informational + cd, old_dir + return + +endif + +if model_image ne par.astrometry.model_image then begin + + message, 'astrometric model does not match the camera configuration, return: 99', /informational + cd, old_dir + return + +endif + +; readcol string for custom parameters - depending on the model +str_readcol_image = 'myreadcol, ff_image_param, image, jd_image, ns_image, sd_az_image, sd_zd_image' +info = astro_model_info(model_image) +m_image = n_elements(info.names) + +for i=0, m_image-1 do str_readcol_image = str_readcol_image + ', param' + strtrim(i, 2) + +str_readcol_image = str_readcol_image + $ + ', namelist = file_image, format = files_day.calibration.image.astrometry.param.format_r, /silent' + +junk = execute(str_readcol_image) + +; composing param-i in a matrix, computing median and madabsdev +n_image = n_elements(image) +param_image = fltarr(n_image, m_image) +for i=0, m_image-1 do junk = execute('param_image[*,i] = param' + strtrim(i, 2)) + +param_image_solut = median(param_image, dimension = 1, /even) + +sigma_image_solut = fltarr(m_image) +for i=0, m_image-1 do sigma_image_solut[i] = medabsdev(param_image[*,i], /sigma, /even)/sqrt(n_image) + +; reading monthly astro solution +ff_astro_solut = myfile_search('.', files_month.calibration.month.astrometry.solution.name) +if ff_astro_solut[0] eq '' then begin + + cd, old_dir + return + +endif + +; reading solution header +readcol, ff_astro_solut, info, junk, value, format = '(a,a,a)', /silent + +; astrometric model of the solution +ii = where(info eq 'model') +model_solut = value[ii[0]] + +if model_solut ne par.astrometry.model_monthly or model_solut ne par.astrometry.model_daily then begin + + message, 'astrometric model does not match the camera configuration, return: 99', /informational + cd, old_dir + return + +endif + +; number of stars used to derive the astrometric solution +ii = where(info eq 'ns') +ns_solut = float(value[ii[0]]) + +; std deviation of the az residuals resulting from the solution +ii = where(info eq 'sd_az') +sd_az_solut = float(value[ii[0]]) + +; std deviation of the zd residuals resulting from the solution +ii = where(info eq 'sd_zd') +sd_zd_solut = float(value[ii[0]]) + +; reading solution param values +readcol, ff_astro_solut, junk, junk, param_solut, junk, sigma_solut, junk, $ + format = files_month.calibration.month.astrometry.solution.format_r, /silent + +; deciding if we have to check to update the config file +try_update = (ns_solut ge par.astrometry.min_ns) and (sd_az_solut le par.astrometry.max_sd_az) and $ + (sd_zd_solut le par.astrometry.max_sd_zd) + +; the astrometric solution is not good enough, returning +if ~try_update then begin + + message, 'monthly astrometric solution is not good enough. return:99', /informational + cd, old_dir + return + +endif + +; evaluating difference between param_image initial estimates (from config) and solution +d_image = param_image_solut - par.astrometry.param_image +dn_image = (par.astrometry.tol_image gt 0)*sign(d_image)*floor(abs(d_image/par.astrometry.tol_image)) +en_image = floor(abs(d_image/sigma_image_solut)) gt par.astrometry.min_sigma + +; flag to decide if param_image has to be updated +y_update_image = total((abs(dn_image) gt 0) and en_image) gt 0 + +; evaluating difference between param_daily initial estimates (from config) and solution +d_daily = param_solut - par.astrometry.param_daily +dn_daily = (par.astrometry.tol_daily gt 0)*sign(d_daily)*floor(abs(d_daily/par.astrometry.tol_daily)) +en_daily = floor(abs(d_daily/sigma_solut)) gt par.astrometry.min_sigma + +; flag to decide if param_image has to be updated +y_update_daily = total((abs(dn_daily) gt 0) and en_daily) gt 0 + +; evaluating difference between param_monthly initial estimates (from config) and solution +d_monthly = param_solut - par.astrometry.param_monthly +dn_monthly = (par.astrometry.tol_monthly gt 0)*sign(d_monthly)*floor(abs(d_monthly/par.astrometry.tol_monthly)) +en_monthly = floor(abs(d_monthly/sigma_solut)) gt par.astrometry.min_sigma + +; flag to decide if param_image has to be updated +y_update_monthly = total((abs(dn_monthly) gt 0) and en_monthly) gt 0 + +if ~(y_update_image or y_update_daily or y_update_monthly) then begin + + message, 'no significant changes detected, no need to update the configuration file. return:0', /informational + cd, old_dir + return + +endif + +; new astrometric param starting points +new_param_image = par.astrometry.param_image + y_update_image*en_image*dn_image*par.astrometry.tol_image +new_param_daily = par.astrometry.param_daily + y_update_daily*en_daily*dn_daily*par.astrometry.tol_daily +new_param_monthly = par.astrometry.param_monthly + y_update_monthly*en_monthly*dn_monthly*par.astrometry.tol_monthly + +; formatting new_param_image to be printed on the config file +str_param_image = '[' +for i=0, n_elements(new_param_image)-1 do begin + + if i gt 0 then str_param_image = str_param_image + ', ' + decimals = (-floor(alog10(abs(par.astrometry.tol_image[i])))) > 0 + format = '(f20.' + strtrim(decimals, 2) + ')' + str_param_image = str_param_image + strtrim(string(new_param_image[i], format = format), 2) + +endfor +str_param_image = str_param_image + ']' + +; formatting new_param_daily to be printed on the config file +str_param_daily = '[' +for i=0, n_elements(new_param_daily)-1 do begin + + if i gt 0 then str_param_daily = str_param_daily + ', ' + decimals = (-floor(alog10(abs(par.astrometry.tol_daily[i])))) > 0 + format = '(f20.' + strtrim(decimals, 2) + ')' + str_param_daily = str_param_daily + strtrim(string(new_param_daily[i], format = format), 2) + +endfor +str_param_daily = str_param_daily + ']' + +; formatting new_param_monthly to be printed on the config file +str_param_monthly = '[' +for i=0, n_elements(new_param_monthly)-1 do begin + + if i gt 0 then str_param_monthly = str_param_monthly + ', ' + decimals = (-floor(alog10(abs(par.astrometry.tol_monthly[i])))) > 0 + format = '(f20.' + strtrim(decimals, 2) + ')' + str_param_monthly = str_param_monthly + strtrim(string(new_param_monthly[i], format = format), 2) + +endfor +str_param_monthly = str_param_monthly + ']' + +; entries to be updated +entries = ['param_image', 'param_daily', 'param_monthly'] +values = [str_param_image, str_param_daily, str_param_monthly] + +; going into calibration results directory / camera / month +ckcd, par.config.path.dir_configurations, check = check, old_dir = old_dir +if ~check then return +ckcd, camera, check = check, old_dir = old_dir +if ~check then return + +; searching the config file +ff = myfile_search(par.file) + +; cannot find any configuration file +if ff[0] eq '' then begin + + cd, old_dir + return + +endif + +; length of the entries to be updated +len = strlen(entries) + +; reading every line from the config file +openr, lun, ff[0], /get_lun + +lines = [] & str = '' +while not(eof(lun)) do begin + + readf, lun, str + lines = [lines, strtrim(str, 2)] + +endwhile + +close, lun & free_lun, lun + +for i=0, n_elements(lines)-1 do begin + + for j=0, n_elements(entries)-1 do begin + + ; checking if this line match one entry to be updated + str = strtrim(strmid(lines[i], 0, len[j]), 2) + if str eq entries[j] then lines[i] = entries[j] + ' = ' + values[j] + + endfor + +endfor + +; new config file +yr = fix(strmid(month, 0, 4)) +mn = fix(strmid(month, 4, 2)) + +; new config is valid starting from next month +mn = mn + 1 +if mn gt 12 then begin + + mn = 1 + yr = yr + 1 + +endif + +; formatting date +str_yr = strtrim(fix(yr), 2) +str_mn = strtrim(fix(mn), 2) & if strlen(str_mn) eq 1 then str_mn = '0' + str_mn +next_month = str_yr + str_mn + '00' + +new_config_file = camera + '_' + next_month + '.ini' + +; searching if there is already a config file with this filename +ff_old = file_search(new_config_file) + +if ff_old[0] ne '' then begin + + ; printing an informational message if we are going to delete the current config file + message, 'overwriting ' + ff_old[0] + ' config file.', /informational + + ; deleting the current solution + file_delete, ff_old[0] + +endif + +; printing the new configuration file +openw, lun, new_config_file, /get_lun +for i=0, n_elements(lines)-1 do printf, lun, lines[i] +close, lun & free_lun, lun + +; returning to the original directory +cd, old_dir + +message, camera + '_' + month + ' - finish updating camera config. return:0', /informational + +end \ No newline at end of file diff --git a/code/event/compression_event.pro b/code/event/compression_event.pro index 42d84d2..13287d8 100644 --- a/code/event/compression_event.pro +++ b/code/event/compression_event.pro @@ -46,7 +46,7 @@ sxaddpar, header_eve, 'extend', 'T', ' FITS dataset may contain extensions', /nu sxaddpar, header_eve, 'if_data', 1, ' 1 if there are data, 0 otherwise', /null sxaddpar, header_eve, 'event', event, ' event code', /null sxaddpar, header_eve, 'date', date, ' event date', /null -sxaddpar, header_eve, 'jd', jd0, ' julian date', format = '(f20.6)', /null +sxaddpar, header_eve, 'jd', jd0, ' julian date', format = '(f20.8)', /null sxaddpar, header_eve, 'n', n, ' number of detections in the event', /null ; compress the detection folders into separated tar files @@ -56,19 +56,23 @@ for i=0, n-1 do begin message, detection[i] + ' - start detection compression.', /informational ; counting the number of frames in this detection - cd, detection[i] - ckcd, 'fits2D', check = check + ckcd, detection[i], check = check if check then begin + + ckcd, 'fits2D', check = check + if check then begin - gg = file_search('frame_*.fit*') - if gg[0] ne '' then nframes = n_elements(gg) else nframes = 0 + gg = file_search('frame_*.fit*') + if gg[0] ne '' then nframes = n_elements(gg) else nframes = 0 - cd, '..' + cd, '..' + + endif else nframes = 0 + cd, '..' + endif else nframes = 0 - cd, '..' - ; checking if we have any data in this detection if nframes gt 0 then if_data = 1 else if_data = 0 @@ -83,11 +87,21 @@ for i=0, n-1 do begin tdate = strmid(tdate, 0, 19) tdate = repstr(tdate, 'T', ' ') + ; parameters in the header of each detection + camera = '' + config_file = '' + lat = !values.f_NaN + lon = !values.f_NaN + hgt = !values.f_NaN + if_img = 0 & fimg = '' + ; retrieve code configuration from the config file par = get_par(config, pseudo, jd0, /pseudo, /return0) - + if par.file ne '' then begin - + + camera = par.camera + config_file = par.file lat = par.station.latitude lon = par.station.longitude hgt = par.station.elevation @@ -95,7 +109,6 @@ for i=0, n-1 do begin ; searching for the image thumb from astrometry results files = get_files(par, day, detection = detection[i]) res_path = config.path.dir_results + path_sep() + month + path_sep() + event - if_img = 0 & fimg = '' ; copying image to the temporary event directory timage = myfile_search(res_path, files.detection.media.thumb.name) & timage = timage[0] @@ -105,16 +118,9 @@ for i=0, n-1 do begin if_img = 1 fimg = filename_detection_image[i] - endif - - endif else begin - - lat = !values.f_NaN - lon = !values.f_NaN - hgt = !values.f_NaN - if_img = 0 & fimg = '' + endif - endelse + endif ; printing the FITS header file for detection header = [] @@ -124,16 +130,23 @@ for i=0, n-1 do begin sxaddpar, header, 'extend', 'T', ' FITS dataset may contain extensions', /null sxaddpar, header, 'if_data', if_data, ' 1 if there are data, 0 otherwise', /null sxaddpar, header, 'det', detection[i], ' detection code', /null - sxaddpar, header, 'code', par.camera, ' camera code', /null sxaddpar, header, 'name', pseudo, ' camera name', /null + sxaddpar, header, 'code', camera, ' camera code', /null sxaddpar, header, 'date', tdate, ' detection date', /null - sxaddpar, header, 'jd', tjd, ' julian date', format = '(f20.6)', /null + sxaddpar, header, 'jd', tjd, ' julian date', format = '(f20.8)', /null sxaddpar, header, 'n', nframes, ' number of frames of the detection', /null - sxaddpar, header, 'lat', lat, ' station latitude of the camera [deg]', format = '(f20.6)', /null - sxaddpar, header, 'lon', lon, ' station longitude of the camera [deg]', format = '(f20.6)', /null - sxaddpar, header, 'hgt', hgt, ' station elevation of the camera [m]', format = '(f20.1)', /null - sxaddpar, header, 'if_img', if_img, ' 1 if there is the preview image, 0 otherwise', /null - if if_img then sxaddpar, header, 'fimg', fimg, ' image filename of the detection preview', /null + sxaddpar, header, 'config', config_file, ' configuration file used for processing', /null + + ; if configured, adding metadata + if config_file ne '' then begin + + sxaddpar, header, 'lat', lat, ' station latitude of the camera [deg]', format = '(f20.6)', /null + sxaddpar, header, 'lon', lon, ' station longitude of the camera [deg]', format = '(f20.6)', /null + sxaddpar, header, 'hgt', hgt, ' station elevation of the camera [m]', format = '(f20.1)', /null + sxaddpar, header, 'if_img', if_img, ' 1 if there is the preview image, 0 otherwise', /null + if if_img then sxaddpar, header, 'fimg', fimg, ' image filename of the detection preview', /null + + endif ; writing the detection FITS header to file writefits, filename_detection_summary[i], [], header @@ -169,7 +182,7 @@ for i=0, n-1 do begin ; adding detection information to the event header sxaddpar, header_eve, 'det' + strtrim(i, 2), detection[i], ' ith detection of the event', /null - sxaddpar, header_eve, 'code' + strtrim(i, 2), par.camera, ' camera code of the ith detection', /null + sxaddpar, header_eve, 'code' + strtrim(i, 2), camera, ' camera code of the ith detection', /null sxaddpar, header_eve, 'name' + strtrim(i, 2), pseudo, ' camera name of the ith detection', /null sxaddpar, header_eve, 'ftar' + strtrim(i, 2), ffi, ' tar filename of the ith detection', /null diff --git a/code/event/compression_result.pro b/code/event/compression_result.pro index 33c5e6a..978a6f3 100644 --- a/code/event/compression_result.pro +++ b/code/event/compression_result.pro @@ -55,7 +55,7 @@ sxaddpar, header, 'extend', 'T', ' FITS dataset may contain extensions', /null sxaddpar, header, 'if_data', 0, ' 1 if there are data, 0 otherwise', /null sxaddpar, header, 'event', event, ' event code', /null sxaddpar, header, 'date', date, ' event date', /null -sxaddpar, header, 'jd', jd0, ' julian date', format = '(f20.6)', /null +sxaddpar, header, 'jd', jd0, ' julian date', format = '(f20.8)', /null ; reading the various result folders ff_res = [] @@ -75,7 +75,7 @@ if ff[0] ne '' then begin res_detection = ff n = n_elements(res_detection) - sxaddpar, header, 'if_astr', 1, ' 1 if astrometry is processed, 0 otherwise', /null + sxaddpar, header, 'if_astr', 0, ' 1 if astrometry is processed, 0 otherwise', /null sxaddpar, header, 'n', n, ' number of detections in the event', /null for i=0, n-1 do begin @@ -83,30 +83,129 @@ if ff[0] ne '' then begin ; detection info info = strsplit(res_detection[i], '_', /extract) pseudo = info[0] + + cd, res_detection[i] ; retrieve code configuration from the config file par = get_par(config, pseudo, jd0, /pseudo, /return0) - if par.file ne '' then begin - - lat = par.station.latitude - lon = par.station.longitude - hgt = par.station.elevation + ; parameters in the header of each detection + camera = '' + config_file = '' + lat = !values.f_NaN + lon = !values.f_NaN + hgt = !values.f_NaN + if_astr = 0 + solution = '' + sd_az = !values.f_NaN + sd_zd = !values.f_NaN + sd_mag = !values.f_NaN + C = !values.f_NaN + s_C = !values.f_NaN + k = !values.f_NaN + s_k = !values.f_NaN - endif else begin + if par.file ne '' then begin - lat = !values.f_NaN - lon = !values.f_NaN - hgt = !values.f_NaN + ; camera code + camera = par.camera - endelse + ; checking the _bar result file header + files = get_files(par, day, detection = res_detection[i], event = event) + ff_bar = myfile_search(files.detection.bar.result.name) + + if ff_bar[0] ne '' then begin + + readcol, ff_bar[0], info, junk, value, format = '(a,a,a)', /silent + + ; checking configuration file in header + ii = where(info eq 'config') + if ii[0] ne -1 then config_file = value[ii[0]] + + ; if the config files match, all good + if config_file eq par.file then begin + + lat = par.station.latitude + lon = par.station.longitude + hgt = par.station.elevation + if_astr = 1 + + ; checking metadata from _bar header + ii = where(info eq 'solution') + if ii[0] ne -1 then solution = value[ii[0]] + + ii = where(info eq 'sd_az') + if ii[0] ne -1 then sd_az = float(value[ii[0]]) + + ii = where(info eq 'sd_zd') + if ii[0] ne -1 then sd_zd = float(value[ii[0]]) + + ii = where(info eq 'sd_mag') + if ii[0] ne -1 then sd_mag = float(value[ii[0]]) + + ; reading values with errors + readcol, ff_bar[0], info, junk, value, junk, error, format = '(a,a,a,a,a)', /silent + + ii = where(info eq 'C') + if ii[0] ne -1 then begin + + C = float(value[ii[0]]) + s_C = float(error[ii[0]]) + + endif + + ii = where(info eq 'k') + if ii[0] ne -1 then begin + + k = float(value[ii[0]]) + s_k = float(error[ii[0]]) + + endif + + endif else begin; otherwise, not good...! not assigning metadata to fits header + + config_file = '' + message, 'config from photo_param file and loaded config_file do not match. return:2', /informational + + endelse + + endif + + endif sxaddpar, header, 'det' + strtrim(i, 2), res_detection[i], ' ith detection of the event', /null - sxaddpar, header, 'code' + strtrim(i, 2), par.camera, ' camera code of the ith detection', /null sxaddpar, header, 'name' + strtrim(i, 2), pseudo, ' camera name of the ith detection', /null - sxaddpar, header, 'lat' + strtrim(i, 2), lat, ' station latitude of the ith camera [deg]', format = '(f20.6)', /null - sxaddpar, header, 'lon' + strtrim(i, 2), lon, ' station longitude of the ith camera [deg]', format = '(f20.6)', /null - sxaddpar, header, 'hgt' + strtrim(i, 2), hgt, ' station elevation of the ith camera [m]', format = '(f20.1)', /null + sxaddpar, header, 'code' + strtrim(i, 2), camera, ' camera code of the ith detection', /null + sxaddpar, header, 'config' + strtrim(i, 2), config_file, ' configuration file for the ith camera', /null + + ; if configured, adding metadata + if config_file ne '' then begin + + sxaddpar, header, 'lat' + strtrim(i, 2), lat, ' station latitude of the ith camera [deg]', format = '(f20.6)', /null + sxaddpar, header, 'lon' + strtrim(i, 2), lon, ' station longitude of the ith camera [deg]', format = '(f20.6)', /null + sxaddpar, header, 'hgt' + strtrim(i, 2), hgt, ' station elevation of the ith camera [m]', format = '(f20.1)', /null + sxaddpar, header, 'if_ast' + strtrim(i, 2), if_astr, ' 1 if astrometry is processed, 0 otherwise', /null + + if if_astr then begin + + ; updating general if_astr + sxaddpar, header, 'if_astr', 1, ' astro/photo solution for the ith detection', /null + + ; updating astro/photo data for this detection + sxaddpar, header, 'solut' + strtrim(i, 2), solution, ' astro/photo solution for the ith detection', /null + sxaddpar, header, 'sd_az' + strtrim(i, 2), sd_az, ' stddev of the az resid of solut [amin]', format = '(f20.2)', /null + sxaddpar, header, 'sd_zd' + strtrim(i, 2), sd_az, ' stddev of the zd resid of solut [amin]', format = '(f20.2)', /null + sxaddpar, header, 'sd_mag' + strtrim(i, 2), sd_mag, ' stddev of the mag resid of solut [amin]', format = '(f20.3)', /null + sxaddpar, header, 'C' + strtrim(i, 2), C, ' zero-point magnitude [mag]', format = '(f20.3)', /null + sxaddpar, header, 's_C' + strtrim(i, 2), s_C, ' err on zero-point magnitude of solut [mag]', format = '(f20.3)', /null + sxaddpar, header, 'k' + strtrim(i, 2), k, ' atm extinction coeff of solut [mag/am]', format = '(f20.3)', /null + sxaddpar, header, 's_k' + strtrim(i, 2), s_k, ' err on atm extinction coeff of solut [mag/am]', format = '(f20.3)', /null + + endif + + endif + + cd, '..' endfor diff --git a/code/event/detection_astrometry.pro b/code/event/detection_astrometry.pro index f0364ec..199ea80 100644 --- a/code/event/detection_astrometry.pro +++ b/code/event/detection_astrometry.pro @@ -9,6 +9,7 @@ pro detection_astrometry, config, event, detection, $ extend_frames = extend_frames, $ allow_tilt = allow_tilt, $ report = report, $ + oplot_errors = oplot_errors, $ image = image, $ video = video @@ -39,6 +40,7 @@ if isa(extend_frames) then par.config.detection.extend_frames = extend_frames if isa(snr_min) then par.config.detection.snr_min = snr_min if isa(allow_tilt) then par.config.detection.allow_tilt = allow_tilt if isa(report) then par.config.detection.report = report +if isa(oplot_errors) then par.config.detection.oplot_errors = oplot_errors if isa(image) then par.config.detection.image = image if isa(video) then par.config.detection.video = video @@ -682,7 +684,7 @@ if solution.folder ne '' then begin ; retrieving eff_corr junk = mags_psf - eff_correction, junk, zd_psf, /mag, corr = eff_corr_psf + eff_correction, solution.eff_corr, junk, zd_psf, /mag, corr = eff_corr_psf ; computing RA, DEC coordinates and magnitude with error propagation hor2eq_error, alt_psf*!radeg, s_alt_psf*!radeg, az_psf*!radeg, s_alt_psf*!radeg, julian_date, ra_psf, s_ra_psf, $ @@ -731,7 +733,7 @@ if solution.folder ne '' then begin ; retrieving eff_corr junk = mags_bar - eff_correction, junk, zd_bar, /mag, corr = eff_corr_bar + eff_correction, solution.eff_corr, junk, zd_bar, /mag, corr = eff_corr_bar ; computing RA, DEC coordinates and magnitude with error propagation hor2eq_error, alt_bar*!radeg, s_alt_bar*!radeg, az_bar*!radeg, s_alt_bar*!radeg, julian_date, ra_bar, s_ra_bar, $ @@ -780,13 +782,24 @@ mkcd, detection ; copying the position file to the results directory file_copy, path_posfile, '.', /overwrite +; new header lines with info about astrometric and photometric solution +new_lines = ['2', 'solution = ' + solution.folder, $ + 'ns = ' + strtrim(string(solution.n, format = '(f20.0)'), 2), $ + 'sd_az = ' + strtrim(string(solution.sd_az, format = '(f20.2)'), 2) + ' amin', $ + 'sd_zd = ' + strtrim(string(solution.sd_zd, format = '(f20.2)'), 2) + ' amin', $ + 'sd_mag = ' + strtrim(string(solution.sd_mag, format = '(f20.3)'), 2), $ + 'C = ' + strtrim(string(solution.C, format = '(f20.3)'), 2) + ' ± ' + $ + strtrim(string(solution.s_C, format = '(f20.3)'), 2), $ + 'k = ' + strtrim(string(solution.k, format = '(f20.3)'), 2) + ' ± ' + $ + strtrim(string(solution.s_k, format = '(f20.3)'), 2)] + ; printing headers of result files print_header, files.detection.psf.param print_header, files.detection.psf.sigma -print_header, files.detection.psf.result +print_header, files.detection.psf.result, add_lines = new_lines print_header, files.detection.bar.param print_header, files.detection.bar.sigma -print_header, files.detection.bar.result +print_header, files.detection.bar.result, add_lines = new_lines openw, lun1, files.detection.psf.param.name, /get_lun, /append openw, lun2, files.detection.psf.sigma.name, /get_lun, /append diff --git a/code/event/dynamic_model.pro b/code/event/dynamic_model.pro index 644e5d7..622c748 100644 --- a/code/event/dynamic_model.pro +++ b/code/event/dynamic_model.pro @@ -6,7 +6,9 @@ pro dynamic_model, cconfig, event, detection, $ gamma = gamma, $ rho = rho, $ mu_range = mu_range, $ - report = report + report = report, $ + oplot_errors = oplot_errors, $ + oplot_errorbands = oplot_errorbands compile_opt idl2 @@ -25,6 +27,8 @@ if isa(gamma) then config.dynamic.gamma = gamma if isa(rho) then config.dynamic.rho = rho if isa(mu_range) then config.dynamic.mu_range = mu_range if isa(report) then config.dynamic.report = report +if isa(oplot_errors) then config.dynamic.oplot_errors = oplot_errors +if isa(oplot_errorbands) then config.dynamic.oplot_errorbands = oplot_errorbands ; month of the event month = get_month(event, /event) @@ -183,7 +187,7 @@ if status_grit11_dyn eq 0 then begin covar_dyn = covar_vel sigma_dyn = sigma_vel -endif else begin ; the fit did not converged +endif else begin ; the fit did not converge message, 'Gritsevich2011 (vel) dynamic model fit did not converged. return:6', /informational @@ -248,27 +252,30 @@ fita = [0,0,1,1,1] yfit = mpdyn_fit('Gritsevich2011', x_fit, y_fit, param_mag, measure_errors = me, fita = fita, atmosphere = atmosphere, $ mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, status = status, chisq = chisq_mag, $ sigma = sigma_mag, covar = covar_mag) - -; again with real errors -me = [s_vel*!values.f_NaN, s_mag] - -; invoking fitting function (no fit, only errors estimation) -yfit = mpdyn_fit('Gritsevich2011', x_fit, y_fit, param_mag, measure_errors = me, fita = fita, maxiter = 0, $ - atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, chisq = chisq_mag, $ - sigma = sigma_mag, covar = covar_mag) ; status of the grit11_mag fit status_grit11_mag = status -if status_grit11_mag ne 0 then begin +; the fit converged +if status_grit11_mag eq 0 then begin + + ; again with real errors + me = [s_vel*!values.f_NaN, s_mag] + + ; invoking fitting function (no fit, only errors estimation) + yfit = mpdyn_fit('Gritsevich2011', x_fit, y_fit, param_mag, measure_errors = me, fita = fita, maxiter = 0, $ + atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, chisq = chisq_mag, $ + sigma = sigma_mag, covar = covar_mag) + +endif else begin ; the fit did not converge message, 'Gritsevich2011 (mag) dynamic model fit did not converged. return:6', /informational - + param_mag = param_mag*!values.f_NaN sigma_mag = sigma_mag*!values.f_NaN covar_mag = covar_mag*!values.f_NaN -endif +endelse if debug_dyn then begin @@ -312,16 +319,21 @@ if status_grit11_mag eq 0 then begin yfit = mpdyn_fit('Gritsevich2011', x_fit, y_fit, param_phd, measure_errors = me, fita = fita, atmosphere = atmosphere, $ mu_range = config.dynamic.mu_range, status = status, chisq = chisq_phd, sigma = sigma_phd, covar = covar_phd) - ; again with real errors on magnitude - me = [s_vel, s_mag*fact] - - ; invoking fitting function (no fit, only error estimation) - yfit = mpdyn_fit('Gritsevich2011', x_fit, y_fit, param_phd, measure_errors = me, fita = fita, maxiter = 0, $ - atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, $ - chisq = chisq_phd, sigma = sigma_phd, covar = covar_phd) - ; updating the status of the grit11_phd fit status_grit11_phd = status + + ; the fit converged + if status_grit11_phd eq 0 then begin + + ; again with real errors on magnitude + me = [s_vel, s_mag*fact] + + ; invoking fitting function (no fit, only error estimation) + yfit = mpdyn_fit('Gritsevich2011', x_fit, y_fit, param_phd, measure_errors = me, fita = fita, maxiter = 0, $ + atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, $ + chisq = chisq_phd, sigma = sigma_phd, covar = covar_phd) + + endif endif @@ -363,7 +375,7 @@ grit11_phd = {status:status_grit11_phd, fit:{res:res_phd, err:err_phd, param:par Gritsevich2011_physics, config.path.dir_atmosphere, hgt, grit11_phd, atmosphere = atmosphere, s_hgt = s_hgt ; let's try the dynamic model (Kalenichenko 2006) only if we have the _dyn or _phd version from Gritsevich (2011) -; if neither of these fits converged, let's break +; if neither of these fits converged, let's return if grit11_dyn.status ne 0 and grit11_phd.status ne 0 then begin message, 'Both dynamic and photo-dynamic model fits of Gritsevich (2011) did not converged. return:6', /informational @@ -444,7 +456,7 @@ if status_kale06_dyn ne 0 then begin message, 'Kalenichenko2006 (hgt, vel) dynamic model fit did not converged. return:6', /informational - param_dyn = param_vel1*!values.f_NaN + param_dyn = param_vel*!values.f_NaN covar_dyn = covar_vel1*!values.f_NaN sigma_dyn = sigma_vel1*!values.f_NaN @@ -511,25 +523,28 @@ yfit = mpdyn_fit('Kalenichenko2006', x_fit, y_fit, param_mag, measure_errors = m atmosphere = atmosphere, mu_range = config.dynamic.mu_range, status = status, fdof_vel = fdof_vel, $ chisq = chisq_mag, sigma = sigma_mag, covar = covar_mag) -; again with real errors (no fit, only error estimation) -me = [s_hgt*!values.f_NaN, s_vel*!values.f_NaN, s_mag] - -yfit = mpdyn_fit('Kalenichenko2006', x_fit, y_fit, param_mag, measure_errors = me, fita = fita, maxiter = 0, $ - atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, $ - chisq = chisq_mag, sigma = sigma_mag, covar = covar_mag) - ; status of the kale06_mag fit status_kale06_mag = status -if status_kale06_mag ne 0 then begin +; the fit converged +if status_kale06_mag eq 0 then begin + + ; again with real errors (no fit, only error estimation) + me = [s_hgt*!values.f_NaN, s_vel*!values.f_NaN, s_mag] + + yfit = mpdyn_fit('Kalenichenko2006', x_fit, y_fit, param_mag, measure_errors = me, fita = fita, maxiter = 0, $ + atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, $ + chisq = chisq_mag, sigma = sigma_mag, covar = covar_mag) +endif else begin ; the fit did not converge + message, 'Kalenichenko2006 (hgt, mag) dynamic model fit did not converged. return:6', /informational param_mag = param_mag*!values.f_NaN sigma_mag = sigma_mag*!values.f_NaN covar_mag = covar_mag*!values.f_NaN - -endif + +endelse if debug_dyn then begin @@ -573,37 +588,48 @@ if status_kale06_mag eq 0 then begin atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, status = status, $ chisq = chisq_phd, sigma = sigma_phd1, covar = covar_phd1) - ; again with real errors on magnitude - me = [s_hgt, s_vel, s_mag*fact] - - ; invoking fitting function (no fit, only error estimation) - yfit = mpdyn_fit('Kalenichenko2006', x_fit, y_fit, param_phd, measure_errors = me, fita = fita, maxiter = 0, $ - atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, $ - chisq = chisq_phd, sigma = sigma_phd1, covar = covar_phd1) + ; updating the status of the grit11_phd fit + status_kale06_phd = status - ; fitting only v_ini/v_inf - me = [s_hgt, s_vel, sm_mag*fact] - fita = [0,0,0,0,1,0,0,0,0] - - ; invoking fitting function again - yfit = mpdyn_fit('Kalenichenko2006', x_fit, y_fit, param_phd, measure_errors = me, fita = fita, $ - atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, status = status, $ - chisq = chisq_phd, sigma = sigma_phd2, covar = covar_phd2) + if status_kale06_phd eq 0 then begin - ; again with real errors on magnitude - me = [s_hgt, s_vel, s_mag*fact] - - ; invoking fitting function (no fit, only error estimation) - yfit = mpdyn_fit('Kalenichenko2006', x_fit, y_fit, param_phd, measure_errors = me, fita = fita, maxiter = 0, $ - atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, $ - chisq = chisq_phd, sigma = sigma_phd2, covar = covar_phd2) + ; again with real errors on magnitude + me = [s_hgt, s_vel, s_mag*fact] - ; merging sigma and covar - sigma_phd = sigma_phd1 + sigma_phd2 - covar_phd = covar_phd1 + covar_phd2 + ; invoking fitting function (no fit, only error estimation) + yfit = mpdyn_fit('Kalenichenko2006', x_fit, y_fit, param_phd, measure_errors = me, fita = fita, maxiter = 0, $ + atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, $ + chisq = chisq_phd, sigma = sigma_phd1, covar = covar_phd1) + + ; fitting only v_ini/v_inf + me = [s_hgt, s_vel, sm_mag*fact] + fita = [0,0,0,0,1,0,0,0,0] - ; updating the status of the grit11_phd fit - status_kale06_phd = status + ; invoking fitting function again + yfit = mpdyn_fit('Kalenichenko2006', x_fit, y_fit, param_phd, measure_errors = me, fita = fita, $ + atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, status = status, $ + chisq = chisq_phd, sigma = sigma_phd2, covar = covar_phd2) + + ; updating the status of the grit11_phd fit + status_kale06_phd = status + + if status_kale06_phd eq 0 then begin + + ; again with real errors on magnitude + me = [s_hgt, s_vel, s_mag*fact] + + ; invoking fitting function (no fit, only error estimation) + yfit = mpdyn_fit('Kalenichenko2006', x_fit, y_fit, param_phd, measure_errors = me, fita = fita, maxiter = 0, $ + atmosphere = atmosphere, mu_range = config.dynamic.mu_range, fdof_vel = fdof_vel, $ + chisq = chisq_phd, sigma = sigma_phd2, covar = covar_phd2) + + ; merging sigma and covar + sigma_phd = sigma_phd1 + sigma_phd2 + covar_phd = covar_phd1 + covar_phd2 + + endif + + endif endif diff --git a/code/event/event.pro b/code/event/event.pro index 3db2f38..87c9582 100644 --- a/code/event/event.pro +++ b/code/event/event.pro @@ -14,7 +14,7 @@ compile_opt idl2 useful_vars -if ~isa(event) then event = '20200101T182654_UT' +if ~isa(event) then event = '20240723T193103_UT' ; configuration file path if ~isa(config_file) then config_file = config_path_filename() diff --git a/code/event/orbit.pro b/code/event/orbit.pro index 00e13eb..e4f406e 100644 --- a/code/event/orbit.pro +++ b/code/event/orbit.pro @@ -4,7 +4,8 @@ pro orbit, cconfig, event, detection, $ step_nominal = step_nominal, $ n_ensemble = n_ensemble, $ step_ensemble = step_ensemble, $ - report = report + report = report, $ + oplot_errorbands = oplot_errorbands compile_opt idl2 @@ -18,6 +19,7 @@ if isa(step_nominal) then config.orbit.step_nominal = step_nominal if isa(n_ensemble) then config.orbit.n_ensemble = n_ensemble if isa(step_ensemble) then config.orbit.step_ensemble = step_ensemble if isa(report) then config.orbit.report = report +if isa(oplot_errorbands) then config.orbit.oplot_errorbands = oplot_errorbands ; month of the event month = get_month(event, /event) @@ -162,15 +164,38 @@ covar = covar_eci_a ; nominal orbit nominal = meteor_orbit(jd, coord, speed, covar, step_orbit = config.orbit.step_nominal) +; returning if the computation of the nominal orbit was not successful +if nominal.status ne 0 then return + ; Monte-Carlo bootstrap ensemble = [] for j=0, config.orbit.n_ensemble-1 do begin - rand = float(mrandomn(seed, covar, 1)) - speed_j = speed + rand[*] - orbit_j = meteor_orbit(jd, coord, speed_j, covar, /noerror_orbit, step_orbit = config.orbit.step_ensemble) - ensemble = [ensemble, orbit_j] + count = 0 & count_max = 20 + orbit_j = {status:1} + while orbit_j.status ne 0 and count lt count_max do begin + + rand = float(mrandomn(seed, covar, 1)) + speed_j = speed + rand[*] + orbit_j = meteor_orbit(jd, coord, speed_j, covar, /noerror_orbit, step_orbit = config.orbit.step_ensemble) + count++ + + endwhile + + ; adding jth orbit to the MC ensemble if computation was successful + if orbit_j.status eq 0 then begin + + ensemble = [ensemble, orbit_j] + + endif else begin + + ; aborting, not able to compute MC ensemble after 20 iterations + message, 'not able to compute Monte-Carlo bootstrap iteration n. ' + strtrim(fix(j), 2) + $ + ' after ' + strtrim(fix(count_max), 2) + ' attempts. return:99', /informational + return + + endelse endfor diff --git a/code/event/triangulation.pro b/code/event/triangulation.pro index 2dbf2b4..3a02f4a 100644 --- a/code/event/triangulation.pro +++ b/code/event/triangulation.pro @@ -7,7 +7,8 @@ pro triangulation, cconfig, event, detection, $ kml = kml, $ map = map, $ api_key = api_key, $ - report = report + report = report, $ + oplot_errors = oplot_errors compile_opt idl2 @@ -27,6 +28,7 @@ if isa(kml) then config.triangulation.kml = kml if isa(map) then config.triangulation.map = map if isa(api_key) then config.triangulation.api_key = api_key if isa(report) then config.triangulation.report = report +if isa(oplot_errors) then config.triangulation.oplot_errors = oplot_errors ; number of detections n = n_elements(detection) @@ -743,9 +745,9 @@ endif ; deducing effective DOF for speed ; the effective DOF number is given by the ratio of the original and smoothed series variances -std = medabsdev(vel - vel_fit, /sigma) -std_nf1 = medabsdev(vel_nf1 - vel_fit, /sigma) -fdof_vel = (std_nf1/std)^2 +std = medabsdev(vel - vel_fit, /sigma, /even) +sd_nf1 = medabsdev(vel_nf1 - vel_fit, /sigma, /even) +fdof_vel = (sd_nf1/std)^2 ; DOF ratio (= np/dof_vel) is limited in [1, 2*nf + 1] fdof_vel = (fdof_vel > 1) < (2*max(nf_v) + 1) diff --git a/code/functions/astrometry/astro_model_info.pro b/code/functions/astrometry/astro_model_info.pro index 9b91197..8315822 100644 --- a/code/functions/astrometry/astro_model_info.pro +++ b/code/functions/astrometry/astro_model_info.pro @@ -12,7 +12,7 @@ case strlowcase(model) of names = ['a0', 'xc', 'yc', 'p1', 'p2'] units = ['rad', 'px', 'px', 'rad/px', 'rad^(1/2)/px'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F)' + format_r = '(f,f,f,f,f)' comments = ['dir of the north', $ 'x of the proj center', $ @@ -27,7 +27,7 @@ case strlowcase(model) of names = ['a0', 'xc', 'yc', 'z0', 'f0'] units = ['rad', 'px', 'px', 'rad', 'px'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F)' + format_r = '(f,f,f,f,f)' comments = ['dir of the north', $ 'x of the proj center', $ @@ -42,7 +42,7 @@ case strlowcase(model) of names = ['a0', 'xc', 'yc', 'v', 's', 'd'] units = ['rad', 'px', 'px', 'rad/px', 'rad', '1/px'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F,F)' + format_r = '(f,f,f,f,f,f)' comments = ['dir of the north', $ 'x of the proj center', $ @@ -58,7 +58,7 @@ case strlowcase(model) of names = ['a0', 'xo', 'yo', 'e', 'eps', 'p1', 'p2'] units = ['rad', 'px', 'px', 'rad', 'rad', 'rad/px', 'rad^(1/2)/px'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F,F,F)' + format_r = '(f,f,f,f,f,f,f)' comments = ['dir of the north', $ 'x of the opt center', $ @@ -75,7 +75,7 @@ case strlowcase(model) of names = ['a0', 'xo', 'yo', 'xz', 'yz', 'p1', 'p2'] units = ['rad', 'px', 'px', 'px', 'px', 'rad/px', 'rad^(1/2)/px'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F,F,F)' + format_r = '(f,f,f,f,f,f,f)' comments = ['dir of the north', $ 'x of the opt center', $ @@ -92,7 +92,7 @@ case strlowcase(model) of names = ['a0', 'xo', 'yo', 'e', 'eps', 'v', 's', 'd' ] units = ['rad', 'px', 'px', 'rad', 'rad', 'rad/px', 'rad', '1/px'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F,F,F,F)' + format_r = '(f,f,f,f,f,f,f,f)' comments = ['dir of the north', $ 'x of the opt center', $ @@ -110,7 +110,7 @@ case strlowcase(model) of names = ['a0', 'xo', 'yo', 'xz', 'yz', 'v', 's', 'd' ] units = ['rad', 'px', 'px', 'px', 'px', 'rad/px', 'rad', '1/px'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F,F,F,F)' + format_r = '(f,f,f,f,f,f,f,f)' comments = ['dir of the north', $ 'x of the opt center', $ @@ -128,7 +128,7 @@ case strlowcase(model) of names = ['a0', 'xo', 'yo', 'e', 'eps', 'p1', 'p2', 'j', 'phi'] units = ['rad', 'px', 'px', 'rad', 'rad', 'rad/px', 'rad^(1/2)/px', 'rad', 'rad'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F,F,F,F,F)' + format_r = '(f,f,f,f,f,f,f,f,f)' comments = ['dir of the north', $ 'x of the opt center', $ @@ -147,7 +147,7 @@ case strlowcase(model) of names = ['a0', 'xo', 'yo', 'xz', 'yz', 'p1', 'p2', 'j', 'phi'] units = ['rad', 'px', 'px', 'px', 'px', 'rad/px', 'rad^(1/2)/px', 'rad', 'rad'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F,F,F,F,F)' + format_r = '(f,f,f,f,f,f,f,f,f)' comments = ['dir of the north', $ 'x of the opt center', $ @@ -166,7 +166,7 @@ case strlowcase(model) of names = ['a0', 'xo', 'yo', 'e', 'eps', 'v', 's', 'd', 'j', 'phi'] units = ['rad', 'px', 'px', 'rad', 'rad', 'rad/px', 'rad', '1/px', 'rad', 'rad'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F,F,F,F,F,F)' + format_r = '(f,f,f,f,f,f,f,f,f,f)' comments = ['dir of the north', $ 'x of the opt center', $ @@ -186,7 +186,7 @@ case strlowcase(model) of names = ['a0', 'xo', 'yo', 'xz', 'yz', 'v', 's', 'd', 'j', 'phi'] units = ['rad', 'px', 'px', 'px', 'px', 'rad/px', 'rad', '1/px', 'rad', 'rad'] format_w = '(e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6,e17.6)' - format_r = '(F,F,F,F,F,F,F,F,F,F)' + format_r = '(f,f,f,f,f,f,f,f,f,f)' comments = ['dir of the north', $ 'x of the opt center', $ @@ -211,11 +211,23 @@ units = strlowcase(units) format_w = strcompress(format_w, /remove_all) format_r = strcompress(format_r, /remove_all) +; subdividing formats in vectors with 1 element for each parameter +temp = repstr(format_w, "(", "['(") +temp = repstr(temp, ")", ")']") +temp = repstr(temp, ",", ")','(") +junk = execute('format_wv = ' + temp) + +temp = repstr(format_r, "(", "['(") +temp = repstr(temp, ")", ")']") +temp = repstr(temp, ",", ")','(") +junk = execute('format_rv = ' + temp) + ; adding measurement units to comments for i=0, n_elements(names)-1 do comments[i] = comments[i] + ' [' + units[i] + ']' ; returning structure -retv = {names:names, units:units,Format_w:format_w,Format_r:format_r, comments:comments, nparam:n_elements(names)} +retv = {names:names, units:units, format_w:format_w, format_wv:format_wv, format_r:format_r, format_rv:format_rv, $ + comments:comments, nparam:n_elements(names)} return, retv diff --git a/code/functions/astrometry/astrometry_error.pro b/code/functions/astrometry/astrometry_error.pro index e845d89..277067e 100644 --- a/code/functions/astrometry/astrometry_error.pro +++ b/code/functions/astrometry/astrometry_error.pro @@ -122,8 +122,13 @@ int.az_zd = mean(err_in.az*sin(zd_mat), dimension = 1, /NaN) int.zd_az = mean(err_in.zd, dimension = 2, /NaN) int.zd_zd = mean(err_in.zd, dimension = 1, /NaN) +; computing global std from mad - to be printed on solution files +global = {std:{az:0., zd:0.}} +global.std.az = medabsdev(d_az*sin(var.ZD), /sigma, /even) +global.std.zd = medabsdev(d_zd, /sigma, /even) + ; return structure -retv = {az:az_fbias, zd:zd_fbias, bias:bias, std:std, int:int} +retv = {az:az_fbias, zd:zd_fbias, bias:bias, std:std, int:int, global:global} return, retv diff --git a/code/functions/astrometry/eq2hor_error.pro b/code/functions/astrometry/eq2hor_error.pro index e4e2c6e..6ef8155 100644 --- a/code/functions/astrometry/eq2hor_error.pro +++ b/code/functions/astrometry/eq2hor_error.pro @@ -35,7 +35,7 @@ case n_params() of s_ra = double(ra*0.) dec = double(s_ra1) s_dec = double(dec*0.) - jd = double(dec) + jd = double(dec1) end @@ -46,7 +46,7 @@ case n_params() of s_ra = double(ra*0.) dec = double(s_ra1) s_dec = double(dec*0.) - jd = double(dec) + jd = double(dec1) end diff --git a/code/functions/astrometry/f_astro.pro b/code/functions/astrometry/f_astro.pro index 6f7b595..ce769d6 100644 --- a/code/functions/astrometry/f_astro.pro +++ b/code/functions/astrometry/f_astro.pro @@ -5,6 +5,7 @@ function f_astro, model_image, x, s_x, y, s_y, mags, s_mags, sat, ctlg, res, r_c compile_opt idl2 ; building fit variables +nfound = n_elements(res.match.x) x_fit = [res.match.x, res.match.y] y_fit = [res.match_ctlg.az, res.match_ctlg.zd] param = res.proj.param @@ -17,16 +18,24 @@ yfit = mpastro_fit(model_image, x_fit, y_fit, param, measure_errors = me, status if status eq 0 then begin + ; computing global std from mad + d_az = (res.match_ctlg.az - yfit[0:nfound-1]) + d_zd = (res.match_ctlg.zd - yfit[nfound:2*nfound-1]) + + sd_az = medabsdev(d_az*sin(res.match_ctlg.zd), /sigma, /even) + sd_zd = medabsdev(d_zd, /sigma, /even) + ; computing new projection xy_proj = az2xy(model_image, ctlg.az, ctlg.zd, param) x_proj = xy_proj.x y_proj = xy_proj.y ; invoking list correlation routine - srcor, x_proj, y_proj, x, y, r_corr, ii1, ii2, /silent, option=1 + srcor, x_proj, y_proj, x, y, r_corr, ii1, ii2, /silent, option = 1 + nfound = n_elements(ii1) ; too few associations - if n_elements(ii1) lt 2 then begin + if nfound lt 2 then begin match = {status:1} retv = {match:match} @@ -42,13 +51,16 @@ if status eq 0 then begin ; match sources structure definition match = {status:0, x:x[ii2], s_x:s_x[ii2], y:y[ii2], s_y:s_y[ii2], mags:mags[ii2], s_mags:s_mags[ii2], sat:sat[ii2], $ - eff_corr:mags[ii2]*0+1, n:n_elements(ii2)} + eff_corr:mags[ii2]*0+1, n:nfound} ; projection structure to be input for next iteration proj = {x:x_proj, y:y_proj, param:param, sigma:sigma} + + ; az/zd standard deviations + std = {az:sd_az, zd:sd_zd} ; defining return structure - retv = {match:match, proj:proj, match_ctlg:match_ctlg} + retv = {match:match, proj:proj, match_ctlg:match_ctlg, std:std} return, retv diff --git a/code/functions/astrometry/f_astro0.pro b/code/functions/astrometry/f_astro0.pro index 54673b8..1aa287e 100644 --- a/code/functions/astrometry/f_astro0.pro +++ b/code/functions/astrometry/f_astro0.pro @@ -10,10 +10,11 @@ x_proj = xy_proj.x y_proj = xy_proj.y ; invoking list correlation routine -srcor, x_proj, y_proj, x, y, r_corr, ii1, ii2, /silent, option=1 +srcor, x_proj, y_proj, x, y, r_corr, ii1, ii2, /silent, option = 1 +nfound = n_elements(ii1) ; too few associations -if n_elements(ii1) lt 2 then begin +if nfound lt 2 then begin match = {status:1} retv = {match:match} @@ -22,6 +23,14 @@ if n_elements(ii1) lt 2 then begin endif +; computing global std from mad +az_proj = xy2az(model_image, x[ii2], y[ii2], param_0) +d_az = (ctlg.az[ii1] - az_proj.az) +d_zd = (ctlg.zd[ii1] - az_proj.zd) + +sd_az = medabsdev(d_az*sin(ctlg.zd[ii1]), /sigma, /even) +sd_zd = medabsdev(d_zd, /sigma, /even) + ; match catalog structure definition match_ctlg = {id:ctlg.id[ii1], type:ctlg.type[ii1], spectype:ctlg.spectype[ii1], alpha:ctlg.alpha[ii1], $ delta:ctlg.delta[ii1], az:ctlg.az[ii1], alt:ctlg.alt[ii1], zd:ctlg.zd[ii1], ha:ctlg.ha[ii1], $ @@ -29,13 +38,16 @@ match_ctlg = {id:ctlg.id[ii1], type:ctlg.type[ii1], spectype:ctlg.spectype[ii1], ; match sources structure definition match = {status:0, x:x[ii2], s_x:s_x[ii2], y:y[ii2], s_y:s_y[ii2], mags:mags[ii2], s_mags:s_mags[ii2], sat:sat[ii2], $ - eff_corr:mags[ii2]*0+1, n:n_elements(ii2)} + eff_corr:mags[ii2]*0+1, n:nfound} ; projection structure to be input for next iteration proj = {x:x_proj, y:y_proj, param:param_0, sigma:param_0*0.} +; az/zd standard deviations +std = {az:sd_az, zd:sd_zd} + ; defining return structure -retv = {match:match, proj:proj, match_ctlg:match_ctlg} +retv = {match:match, proj:proj, match_ctlg:match_ctlg, std:std} return, retv diff --git a/code/functions/astrometry/hor2eq_error.pro b/code/functions/astrometry/hor2eq_error.pro index c77d5be..741d6d4 100644 --- a/code/functions/astrometry/hor2eq_error.pro +++ b/code/functions/astrometry/hor2eq_error.pro @@ -35,7 +35,7 @@ case n_params() of s_alt = double(alt*0.) az = double(s_alt1) s_az = double(az*0.) - jd = double(az) + jd = double(az1) end @@ -46,7 +46,7 @@ case n_params() of s_alt = double(alt*0.) az = double(s_alt1) s_az = double(az*0.) - jd = double(az) + jd = double(az1) end diff --git a/code/functions/astrometry/mpastro_fit.pro b/code/functions/astrometry/mpastro_fit.pro index 0276381..9c7cbd0 100644 --- a/code/functions/astrometry/mpastro_fit.pro +++ b/code/functions/astrometry/mpastro_fit.pro @@ -40,6 +40,18 @@ sigma = dblarr(na) + !values.d_NaN covar = dblarr(na,na) + !values.d_NaN chisq = !values.d_NaN +; checking for params before fit, inserting a min shift to avoid being stuck in E = 0 +; that is, if xo = xz and yo = yz, then shifting slightly xo to unstuck +case function_name of + + 'proj_rotz_poly2' : begin & if a[1] eq a[3] and a[2] eq a[4] then a[1] += 0.1 & end + 'proj_rotz_exp1' : begin & if a[1] eq a[3] and a[2] eq a[4] then a[1] += 0.1 & end + 'proj_rotz_poly2_asym' : begin & if a[1] eq a[3] and a[2] eq a[4] then a[1] += 0.1 & end + 'proj_rotz_exp1_asym' : begin & if a[1] eq a[3] and a[2] eq a[4] then a[1] += 0.1 & end + else : + +endcase + ; invoking MPFIT in Least Absolute Value (LAV) mode param = mpfit('MPASTRO_FUNCT', a, functargs = functargs, parinfo = parinfo, autoderivative = 0, maxiter = maxiter, $ status = status, dof = dof, /quiet) diff --git a/code/functions/astrometry/project.pro b/code/functions/astrometry/project.pro index ddecf31..1d8204c 100644 --- a/code/functions/astrometry/project.pro +++ b/code/functions/astrometry/project.pro @@ -69,7 +69,7 @@ if n_params() eq 13 then begin if keyword_set(eff_correction) then begin junk = mags - eff_correction, junk, zd, err = s_mags, /mag, corr = corr + eff_correction, solution.eff_corr, junk, zd, err = s_mags, /mag, corr = corr mags = mag - 2.5*alog10(corr) endif diff --git a/code/functions/astrometry/solve.pro b/code/functions/astrometry/solve.pro index 5de0f40..308d8af 100644 --- a/code/functions/astrometry/solve.pro +++ b/code/functions/astrometry/solve.pro @@ -59,7 +59,7 @@ if n_params() eq 13 then begin ; correcting for radial efficiency if keyword_set(eff_correction) then begin - eff_correction, mags, zd, err = s_mags, /mag + eff_correction, solution.eff_corr, mags, zd, err = s_mags, /mag endif diff --git a/code/functions/common/adjust_font_size.pro b/code/functions/common/adjust_font_size.pro index 5897187..4e6842a 100644 --- a/code/functions/common/adjust_font_size.pro +++ b/code/functions/common/adjust_font_size.pro @@ -9,7 +9,7 @@ pro adjust_font_size, font_size, dpi0, $ compile_opt idl2 ; get screen resolution to adjust graphics size -screen_size = get_screen_size(resolution = resolution) +screen_size = myget_screen_size(resolution = resolution) ; a screen device was found if screen_size[0] ne 0 then begin diff --git a/code/functions/common/closest_metric_prefix.pro b/code/functions/common/closest_metric_prefix.pro new file mode 100644 index 0000000..8094367 --- /dev/null +++ b/code/functions/common/closest_metric_prefix.pro @@ -0,0 +1,19 @@ +; find the closest measure unit prefix + +function closest_metric_prefix, input + +; lists of prefixes and powers of 10 in the SI (excluding da, h and d) +prefixes = ['y', 'z', 'a', 'f', 'p', 'n', 'µ', 'm', 'c', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'] +powers = [-24, -21, -18, -15, -12, -9, -6, -3, -2, 0, 3, 6, 9, 12, 15, 18, 21, 24] + +; finding the closest prefix +power = floor(alog10(input)) +dista = abs(powers - power) +min_dista = min(dista, ii) +ii = ii[0] + +retv = {prefix:prefixes[ii], power:powers[ii]} + +return, retv + +end \ No newline at end of file diff --git a/code/functions/common/img_stddev.pro b/code/functions/common/img_stddev.pro index 539fa65..6cfa8fd 100644 --- a/code/functions/common/img_stddev.pro +++ b/code/functions/common/img_stddev.pro @@ -8,7 +8,7 @@ if ~isa(smooth) then smooth = 100 sm = smooth > 1 ; computing std.dev by median absolute deviation -retv = medabsdev(smooth(img, sm, /nan, /edge_mirror) - img)/0.67449 +retv = medabsdev(smooth(img, sm, /nan, /edge_mirror) - img, /sigma, /even) return, retv diff --git a/code/functions/common/mpfunct_fit/mpfunct_fit.pro b/code/functions/common/mpfunct_fit/mpfunct_fit.pro index c1a5914..d9cb8b2 100644 --- a/code/functions/common/mpfunct_fit/mpfunct_fit.pro +++ b/code/functions/common/mpfunct_fit/mpfunct_fit.pro @@ -5,6 +5,7 @@ function mpfunct_fit, function_name, xIn, yIn, aIn, $ autodiff = autodiff, $ relstep = relstep, $ measure_errors = measure_errors, $ + limit_chi2 = limit_chi2, $ fita = fita, $ maxiter = maxiter, $ status = status, $ @@ -12,6 +13,7 @@ function mpfunct_fit, function_name, xIn, yIn, aIn, $ dof = dof, $ sigma = sigma, $ covar = covar + compile_opt idl2 @@ -34,6 +36,7 @@ if ii[0] ne -1 then me[ii] = 1. if ~isa(LAV) then LAV = [0, 0] if ~isa(autodiff) then autodiff = [1, 1] if ~isa(relstep) then relstep = [0., 0.] +if ~isa(limit_chi2) then limit_chi2 = 0 if n_elements(LAV) ne 2 then LAV = [LAV[0], LAV[0]] if n_elements(autodiff) ne 2 then autodiff = [autodiff[0], autodiff[0]] @@ -102,8 +105,9 @@ if status eq 0 then begin ; computing errors and covariances chisq = total(resid^2, /nan)/dof - sigma = sigma*sqrt(chisq) - covar = covar*chisq + if limit_chi2 then chi2 = chisq > 1 else chi2 = chisq + sigma = sigma*sqrt(chi2) + covar = covar*(chi2) endif diff --git a/code/functions/common/myget_screen_size.pro b/code/functions/common/myget_screen_size.pro new file mode 100644 index 0000000..dfc3bf8 --- /dev/null +++ b/code/functions/common/myget_screen_size.pro @@ -0,0 +1,35 @@ +; my version of the IDL get_screen_size function to fix bug after a Windows bug... + +function myget_screen_size, display_arg, $ + DISPLAY_NAME = display_name, $ + RESOLUTION = resolution + +compile_opt idl2, hidden + +; Set default display name. +if (n_elements(display_arg) eq 0) then begin + + if (n_elements(display_name) eq 0) then inDisplayName = "" $ + else inDisplayName = display_name + +endif else inDisplayName = display_arg + +oMon = Obj_New('IDLsysMonitorInfo', DISPLAY_NAME = inDisplayName) +nMons = oMon->GetNumberOfMonitors() +rects = oMon->GetRectangles() +resolution = oMon->GetResolutions() +primary = oMon->GetPrimaryMonitorIndex() +isExtended = oMon->IsExtendedDesktop() +obj_destroy, oMon + +; overwriting primary if it is an extended display...! +; implemented after a Windows update that introduced the bug. +if isExtended then primary = 0 + +resolution = resolution[*, primary] +screenDims = rects[2:3, primary] + +; Return the screen dimensions. +RETURN, screenDims + +END diff --git a/code/functions/common/myreadcol.pro b/code/functions/common/myreadcol.pro index 7ee7c2d..fdcc0b9 100644 --- a/code/functions/common/myreadcol.pro +++ b/code/functions/common/myreadcol.pro @@ -4,6 +4,7 @@ pro myreadcol, name, v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15, $ v16,v17,v18,v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30, $ v31,v32,v33,v34,v35,v36,v37,v38,v39,v40,v41,v42,v43,v44,v45, $ v46,v47,v48,v49,v50, $ + namelist = namelist, $ _extra = _extra compile_opt idl2 @@ -21,10 +22,12 @@ for i=0, n-1 do begin inp[i] = "v" + strtrim(i + 1, 2) var[i] = "e" + strtrim(i + 1, 2) - res = execute("v" + strtrim(i + 1, 2) + " = []") + res = execute(inp[i] + " = []") endfor +namelist = [] + for j=0, m-1 do begin ; composing the readcol call @@ -42,6 +45,9 @@ for j=0, m-1 do begin ; concatenating vectors for i=0, n-1 do res = execute(inp[i] + " = [" + inp[i] + ", " + var[i] + "]") + ; storing filename list + namelist = [namelist, replicate(name[j], n_elements(e1))] + endfor end \ No newline at end of file diff --git a/code/functions/common/plot_range.pro b/code/functions/common/plot_range.pro index 0797024..107ca89 100644 --- a/code/functions/common/plot_range.pro +++ b/code/functions/common/plot_range.pro @@ -4,6 +4,7 @@ function plot_range, data, $ log = log, $ border = border, $ min0 = min0, $ + minge0 = minge0, $ reverse = reverse, $ error = error, $ err_filter = err_filter, $ @@ -23,6 +24,7 @@ endif if ~isa(log) then log = 0 if ~isa(border) then border = 0.05 if ~isa(min0) then min0 = 0 +if ~isa(minge0) then minge0 = 0 if ~isa(reverse) then reverse = 0 if ~isa(error) then error = data*0 if ~isa(err_filter) then err_filter = 0 @@ -67,6 +69,9 @@ range = massimo - minimo ; defining range retv = [minimo - border*range, massimo + border*range] +; min >= 0 +if minge0 then retv[0] = retv[0] > 0. + ; min = 0 if min0 then retv[0] = 0. diff --git a/code/functions/common/sunrise.pro b/code/functions/common/sunrise.pro new file mode 100644 index 0000000..01552c7 --- /dev/null +++ b/code/functions/common/sunrise.pro @@ -0,0 +1,22 @@ +function sunrise, jd, lat, lon, alt, $ + ref_alt = ref_alt + +if ~isa(ref_alt) then ref_alt = 0. + +; jd fraction of that day +jdv = round(jd[0]) + [0d:0.99d:0.01d] + +; computing sun ephemeris +sunpos, jdv, sun_alpha, sun_delta + +; converting to horizontal coordinates +eq2hor, sun_alpha, sun_delta, jdv, sun_alt, sun_az, sun_ha, lat = lat, lon = lon, altitude = alt, $ + precess_= 0, nutate_ = 0, refract_ = 0, aberration_ = 0 + +; searching sunrise and sunset +retv = zerocrossings(jdv, sun_alt - ref_alt, rising = rising) +retv = retv[sort(1 - rising)] + +return, retv + +end \ No newline at end of file diff --git a/code/functions/configuration/camera_par.pro b/code/functions/configuration/camera_par.pro index c2598ca..8104f38 100644 --- a/code/functions/configuration/camera_par.pro +++ b/code/functions/configuration/camera_par.pro @@ -1,12 +1,12 @@ -; read camera configuration file in dir_config +; read camera configuration file in dir_configurations -function camera_par, dir_config, camera, target, $ +function camera_par, dir_configurations, camera, target, $ return0 = return0 compile_opt idl2 ; going into the configuration / camera directory -ckcd, dir_config, current = old_dir, check = check +ckcd, dir_configurations, current = old_dir, check = check if ~check then begin retv = {file:''} @@ -17,7 +17,6 @@ endif ckcd, camera, check = check, old_dir = old_dir if ~check then begin - cd, old_dir retv = {file:''} if keyword_set(return0) then return, retv else retall @@ -26,7 +25,7 @@ endif ; computing julian date from input ; if target is a month, we will take the last day of the month ; e.g. the camere turned on at the middle of the month, with config change: taking the first day would not be good -jd = target_jd(target, /return0, first = first, last = last, day = -1) +jd = target_jd(target, /return0, first = first, last = last, day = -1, target_str = target_str) if jd[0] eq -1 then begin @@ -50,7 +49,9 @@ if ff[0] eq '' then begin endif ; extracting date from config filename -config_jd = target_jd(strmid(ff, strlen(camera) + 1, 8)) +; if input is a month, then checking for configurations starting from day 00 (from update_config.pro) +if strlen(target) eq 6 then config_jd = target_jd(strmid(ff, strlen(camera) + 1, 8), /check0d) $ + else config_jd = target_jd(strmid(ff, strlen(camera) + 1, 8)) ; identifying which configuration file we have to use based on the julian date ; config_jd are starting dates for the validity of each configuration @@ -59,12 +60,47 @@ ii = value_locate(config_jd, jd) if ii[0] eq -1 then begin cd, old_dir + retv = {file:''} message, 'cannot find ' + camera + ' configuration on date ' + strtrim(target, 2) + '. return:99', /informational if keyword_set(return0) then return, retv else retall endif +; if input is a day, verifying if the day of the selected config file is 00 +; if yes, this is not valid for the last day of the month before +if strlen(target) eq 8 and jd eq config_jd[ii[0]] then begin + + config_date = strmid(ff[ii[0]], strlen(camera) + 1, 8) + config_dd = long(strmid(config_date, 6, 2)) + + ; if it's day 00 + if config_dd eq 0 then begin + + config_mn = long(strmid(config_date, 4, 2)) + target_mn = long(strmid(target_str, 4, 2)) + + ; if this is not the same month, using the previous config + if config_mn ne target_mn then begin + + ii[0] = ii[0] - 1 + + if ii[0] lt 0 then begin + + cd, old_dir + retv = {file:''} + message, 'cannot find ' + camera + ' configuration on date ' + strtrim(target, 2) + '. return:99', /informational + if keyword_set(return0) then return, retv else retall + + endif + + endif + + endif + +endif + ; if target is a month, checking if there was a config change in this month +is_changed = 0 if strlowcase(typename(target)) eq 'string' then begin if strlen(target) eq 6 then begin @@ -72,10 +108,15 @@ if strlowcase(typename(target)) eq 'string' then begin iif = value_locate(config_jd, first) iil = value_locate(config_jd, last) - if iif[0] ne iil[0] then $ + if iif[0] ne iil[0] then begin + + is_changed = 1 + message, 'configuration change detected for ' + camera + ' on ' + strtrim(target, 2) + '. ' + $ - 'Loading configuration for the last day of the month.', /informational - + 'Loading configuration for the last day of the month.', /informational + + endif + endif endif @@ -109,13 +150,21 @@ station = {latitude:latitude, longitude:longitude, elevation:elevation} ; Astrometry model_image = strlowcase(config->get('model_image', section = 'Astrometry')) param_image = float(config->get('param_image', section = 'Astrometry', /extract)) +tol_image = float(config->get('tol_image', section = 'Astrometry', /extract)) model_daily = strlowcase(config->get('model_daily', section = 'Astrometry')) param_daily = float(config->get('param_daily', section = 'Astrometry', /extract)) +tol_daily = float(config->get('tol_daily', section = 'Astrometry', /extract)) model_monthly = strlowcase(config->get('model_monthly', section = 'Astrometry')) param_monthly = float(config->get('param_monthly', section = 'Astrometry', /extract)) +tol_monthly = float(config->get('tol_monthly', section = 'Astrometry', /extract)) +min_ns = float(config->get('min_ns', section = 'Astrometry')) +min_sigma = float(config->get('min_sigma', section = 'Astrometry')) +max_sd_az = float(config->get('max_sd_az', section = 'Astrometry')) +max_sd_zd = float(config->get('max_sd_zd', section = 'Astrometry')) -astrometry = {model_image:model_image, param_image:param_image, model_daily:model_daily, param_daily:param_daily, $ - model_monthly:model_monthly, param_monthly:param_monthly} +astrometry = {model_image:model_image, param_image:param_image, tol_image:tol_image, model_daily:model_daily, param_daily:param_daily, $ + tol_daily:tol_daily, model_monthly:model_monthly, param_monthly:param_monthly, tol_monthly:tol_monthly, min_ns:min_ns, $ + min_sigma:min_sigma, max_sd_az:max_sd_az, max_sd_zd:max_sd_zd} ; Find fwhm = float(config->get('fwhm', section = 'Find')) @@ -137,9 +186,9 @@ alt_lim2 = float(config->get('alt_lim2', section = 'Find'))/!radeg n_min = long(config->get('n_min', section = 'Find')) param_tool = float(config->get('param_tool', section = 'Find')) -find = {fwhm:fwhm, s_x:s_x, s_y:s_y, roundlim:roundlim, sharplim:sharplim, min_iter:min_iter, max_iter:max_iter, $ - switch_iter:switch_iter, h_min1:h_min1, h_min2:h_min2, mag_lim1:mag_lim1, mag_lim2:mag_lim2, $ - r_corr1:r_corr1, r_corr2:r_corr2, alt_lim1:alt_lim1, alt_lim2:alt_lim2, n_min:n_min, param_tool:param_tool} +find = {fwhm:fwhm, s_x:s_x, s_y:s_y, roundlim:roundlim, sharplim:sharplim, min_iter:min_iter, max_iter:max_iter, switch_iter:switch_iter, $ + h_min1:h_min1, h_min2:h_min2, mag_lim1:mag_lim1, mag_lim2:mag_lim2, r_corr1:r_corr1, r_corr2:r_corr2, alt_lim1:alt_lim1, $ + alt_lim2:alt_lim2, n_min:n_min, param_tool:param_tool} ; Ephemeris r_moon_mask = float(config->get('r_moon_mask', section = 'Ephemeris')) @@ -156,11 +205,13 @@ saturation = float(config->get('saturation', section = 'Photometry')) exposure = float(config->get('exposure', section = 'Photometry')) star_aper = long(config->get('star_aper', section = 'Photometry', /extract)) sky_aper = long(config->get('sky_aper', section = 'Photometry', /extract)) +eff_corr = strlowcase(config->get('eff_corr', section = 'Photometry')) C = float(config->get('C', section = 'Photometry')) k = float(config->get('k', section = 'Photometry')) +max_sd_mag = float(config->get('max_sd_mag', section = 'Photometry')) -photometry = {band:band, gain:gain, saturation:saturation, exposure:exposure, star_aper:star_aper, sky_aper:sky_aper, $ - C:C, k:k} +photometry = {band:band, gain:gain, saturation:saturation, exposure:exposure, star_aper:star_aper, sky_aper:sky_aper, eff_corr:eff_corr, $ + C:C, k:k, max_sd_mag:max_sd_mag} ; putting all together in a structure retv = {file:ff[0], fits:fits, station:station, astrometry:astrometry, find:find, ephemeris:ephemeris, $ diff --git a/code/functions/configuration/config_path_filename.pro b/code/functions/configuration/config_path_filename.pro index b9d5900..84c0838 100644 --- a/code/functions/configuration/config_path_filename.pro +++ b/code/functions/configuration/config_path_filename.pro @@ -4,7 +4,7 @@ function config_path_filename compile_opt idl2 -filename = 'C:\Users\dario\Lavoro\IDLWorkspace\PRISMA\settings\configuration.ini' +filename = '/astrometry/workspace/settings/configuration/configuration.ini' return, filename diff --git a/code/functions/configuration/get_config.pro b/code/functions/configuration/get_config.pro index 00ee6bd..5dd8db2 100644 --- a/code/functions/configuration/get_config.pro +++ b/code/functions/configuration/get_config.pro @@ -23,9 +23,9 @@ on_error = fix(config->get('on_error')) except = fix(config->get('except')) ; Path -dir_config = check_path(config->get('dir_config', section = 'Path')) dir_captures = check_path(config->get('dir_captures', section = 'Path')) dir_calibrations = check_path(config->get('dir_calibrations', section = 'Path')) +dir_reports = check_path(config->get('dir_reports', section = 'Path')) dir_events = check_path(config->get('dir_events', section = 'Path')) dir_results = check_path(config->get('dir_results', section = 'Path')) arc_captures = check_path(config->get('arc_captures', section = 'Path')) @@ -33,15 +33,18 @@ arc_calibrations = check_path(config->get('arc_calibrations', section = 'Path')) arc_events = check_path(config->get('arc_events', section = 'Path')) arc_results = check_path(config->get('arc_results', section = 'Path')) dir_atmosphere = check_path(config->get('dir_atmosphere', section = 'Path')) +dir_configurations = check_path(config->get('dir_configurations', section = 'Path')) +dir_solutions = check_path(config->get('dir_solutions', section = 'Path')) solutions = check_path(config->get('solutions', section = 'Path')) catalog = check_path(config->get('catalog', section = 'Path')) logo_black = check_path(config->get('logo_black', section = 'Path')) logo_white = check_path(config->get('logo_white', section = 'Path')) +template_calib = check_path(config->get('template_calib', section = 'Path')) -path = {dir_config:dir_config, dir_captures:dir_captures, dir_calibrations:dir_calibrations, dir_events:dir_events, $ +path = {dir_captures:dir_captures, dir_calibrations:dir_calibrations, dir_reports:dir_reports, dir_events:dir_events, $ dir_results:dir_results, arc_captures:arc_captures, arc_calibrations:arc_calibrations, arc_events:arc_events, $ - arc_results:arc_results, dir_atmosphere:dir_atmosphere, solutions:solutions, catalog:catalog, $ - logo_black:logo_black, logo_white:logo_white} + arc_results:arc_results, dir_atmosphere:dir_atmosphere, dir_configurations:dir_configurations, dir_solutions:dir_solutions, $ + solutions:solutions, catalog:catalog, logo_black:logo_black, logo_white:logo_white, template_calib:template_calib} ; Calibration yplot = str2bool(config->get('yplot', section = 'Calibration')) @@ -50,9 +53,11 @@ stop_iter = str2bool(config->get('stop_iter', section = 'Calibration')) stop_image = str2bool(config->get('stop_image', section = 'Calibration')) report_astro = str2bool(config->get('report_astro', section = 'Calibration')) report_photo = str2bool(config->get('report_photo', section = 'Calibration')) +report_calib = str2bool(config->get('report_calib', section = 'Calibration')) +excel_calib = str2bool(config->get('excel_calib', section = 'Calibration')) calibration = {yplot:yplot, cat_yplot:cat_yplot, stop_iter:stop_iter, stop_image:stop_image, $ - report_astro:report_astro, report_photo:report_photo} + report_astro:report_astro, report_photo:report_photo, report_calib:report_calib, excel_calib:excel_calib} ; Detection positions = config->get('positions', section = 'Detection') @@ -63,11 +68,13 @@ extend_frames = str2bool(config->get('extend_frames', section = 'Detection')) snr_min = float(config->get('snr_min', section = 'Detection')) allow_tilt = str2bool(config->get('allow_tilt', section = 'Detection')) report = str2bool(config->get('report', section = 'Detection')) +oplot_errors = str2bool(config->get('oplot_errors', section = 'Detection')) image1 = str2bool(config->get('image', section = 'Detection')) video = str2bool(config->get('video', section = 'Detection')) detection = {positions:positions, box_bolide:box_bolide, adjust_frames:adjust_frames, fill_frames:fill_frames, $ - extend_frames:extend_frames, snr_min:snr_min, allow_tilt:allow_tilt, report:report, image:image1, video:video} + extend_frames:extend_frames, snr_min:snr_min, allow_tilt:allow_tilt, report:report, oplot_errors:oplot_errors, $ + image:image1, video:video} ; Triangulation time_shift = str2bool(config->get('time_shift', section = 'Triangulation')) @@ -77,9 +84,10 @@ kml = str2bool(config->get('kml', section = 'Triangulation')) map = str2bool(config->get('map', section = 'Triangulation')) api_key = config->get('api_key', section = 'Triangulation') report = str2bool(config->get('report', section = 'Triangulation')) +oplot_errors = str2bool(config->get('oplot_errors', section = 'Triangulation')) -triangulation = {time_shift:time_shift, exclude_bad_camera:exclude_bad_camera, nframe_deriv:nframe_deriv, kml:kml, $ - map:map, api_key:api_key, report:report} +triangulation = {time_shift:time_shift, exclude_bad_camera:exclude_bad_camera, nframe_deriv:nframe_deriv, kml:kml, map:map, $ + api_key:api_key, report:report, oplot_errors:oplot_errors} ; Dynamic atmospheric_model = config->get('atmospheric_model', section = 'Dynamic') @@ -88,17 +96,20 @@ gamma = float(config->get('gamma', section = 'Dynamic', /extract)) rho = float(config->get('rho', section = 'Dynamic', /extract)) mu_range = float(config->get('mu_range', section = 'Dynamic', /extract)) report = str2bool(config->get('report', section = 'Dynamic')) +oplot_errors = str2bool(config->get('oplot_errors', section = 'Dynamic')) +oplot_errorbands = str2bool(config->get('oplot_errorbands', section = 'Dynamic')) -dynamic = {atmospheric_model:atmospheric_model, solar_provider:solar_provider, gamma:gamma, rho:rho, $ - mu_range:mu_range, report:report} +dynamic = {atmospheric_model:atmospheric_model, solar_provider:solar_provider, gamma:gamma, rho:rho, mu_range:mu_range, report:report, $ + oplot_errors:oplot_errors, oplot_errorbands:oplot_errorbands} ; Orbit step_nominal = float(config->get('step_nominal', section = 'Orbit')) n_ensemble = float(config->get('n_ensemble', section = 'Orbit')) step_ensemble = float(config->get('step_ensemble', section = 'Orbit')) report = str2bool(config->get('report', section = 'Orbit')) +oplot_errorbands = str2bool(config->get('oplot_errorbands', section = 'Orbit')) -orbit = {step_nominal:step_nominal, n_ensemble:n_ensemble, step_ensemble:step_ensemble, report:report} +orbit = {step_nominal:step_nominal, n_ensemble:n_ensemble, step_ensemble:step_ensemble, report:report, oplot_errorbands:oplot_errorbands} ; putting all together retv = {file:ff[0], quiet:quiet, on_error:on_error, except:except, path:path, calibration:calibration, $ diff --git a/code/functions/configuration/get_files.pro b/code/functions/configuration/get_files.pro index 14e800f..cc033e9 100644 --- a/code/functions/configuration/get_files.pro +++ b/code/functions/configuration/get_files.pro @@ -1,6 +1,6 @@ ; get filenames for output ; for each file, we define a structure with the following tags: -; name, table header, write format, read format +; name, column names, column units, table header, write format, read format function get_files, par, day, $ detection = detection, $ @@ -46,7 +46,7 @@ header = [par.camera + '_' + day, 'config = ' + par.file, 'model = ' + par.astro string(heads[0,*], format = format_header(format_w)), string(heads[1,*], format = format_header(format_w)), $ trat, ''] -assoc = {name:name, header:header, format_w:format_w, format_r:format_r} +assoc = {name:name, columns:heads[0,*], units:heads[1,*], header:header, format_w:format_w, format_r:format_r} ; PARAM-SIGMA name_param = par.camera + '_' + day + '_astro_param.txt' @@ -55,7 +55,9 @@ name_sigma = par.camera + '_' + day + '_astro_sigma.txt' heads_param = [ $ ['image', '[/]'], $ ['julian_date', '[/]'], $ - ['n', '[/]'] $ + ['ns', '[/]'], $ + ['sd_az', '[amin]'], $ + ['sd_zd', '[amin]'] $ ] heads_sigma = heads_param @@ -63,14 +65,14 @@ heads_sigma = heads_param names = astro_model_info(par.astrometry.model_image) for i=0, n_elements(names.names)-1 do begin - + heads_param = [[heads_param], [names.names[i], '[' + names.units[i] + ']']] heads_sigma = [[heads_sigma], ['s_'+names.names[i], '[' + names.units[i] + ']']] - + endfor -format_w = '(a32,f21.8,f9.0,' + strmid(names.format_w, 1, strlen(names.format_w)-1) -format_r = '(a,d,f,' + strmid(names.format_r, 1, strlen(names.format_r)-1) +format_w = '(a32,f21.8,f9.0,f9.2,f9.2,' + strmid(names.format_w, 1, strlen(names.format_w)-1) +format_r = '(a,d,f,f,f,' + strmid(names.format_r, 1, strlen(names.format_r)-1) trat = strjoin(replicate('-', total(format_length(format_w)))) @@ -82,8 +84,8 @@ header_sigma = [par.camera + '_' + day, 'config = ' + par.file, 'model = ' + par string(heads_sigma[0,*], format = format_header(format_w)), $ string(heads_sigma[1,*], format = format_header(format_w)), trat, ''] -param = {name:name_param, header:header_param, format_w:format_w, format_r:format_r} -sigma = {name:name_sigma, header:header_sigma, format_w:format_w, format_r:format_r} +param = {name:name_param, columns:heads_param[0,*], units:heads_param[1,*], header:header_param, format_w:format_w, format_r:format_r} +sigma = {name:name_sigma, columns:heads_sigma[0,*], units:heads_sigma[1,*], header:header_sigma, format_w:format_w, format_r:format_r} astrometry = {param:param, sigma:sigma, assoc:assoc} @@ -96,7 +98,7 @@ name_sigma = par.camera + '_' + day + '_photo_sigma.txt' heads_param = [ $ ['image', '[/]'], $ ['julian_date', '[/]'], $ - ['n', '[/]'], $ + ['ns', '[/]'], $ ['f', '[/]'], $ ['exp', '[sec]'], $ ['m_ph', '[/]'], $ @@ -108,7 +110,8 @@ heads_param = [ $ ['eff_z', '[/]'], $ ['eff_m', '[/]'], $ ['eff_l', '[/]'], $ - ['c', '[/]'], $ + ['sd_mag', '[/]'], $ + ['C', '[/]'], $ ['k', '[/]'], $ ['z1', '[/]'], $ ['m1', '[/]'], ['m2', '[/]'], ['m3', '[/]'], ['m4', '[/]'], ['m5', '[/]'], $ @@ -121,7 +124,7 @@ heads_param = [ $ heads_sigma = [ $ ['image', '[/]'], $ ['julian_date', '[/]'], $ - ['n', '[/]'], $ + ['ns', '[/]'], $ ['f', '[/]'], $ ['exp', '[sec]'], $ ['m_ph', '[/]'], $ @@ -133,7 +136,8 @@ heads_sigma = [ $ ['eff_z', '[/]'], $ ['eff_m', '[/]'], $ ['eff_l', '[/]'], $ - ['s_c', '[/]'], $ + ['sd_mag', '[/]'], $ + ['s_C', '[/]'], $ ['s_k', '[/]'], $ ['s_z1', '[/]'], $ ['s_m1', '[/]'], ['s_m2', '[/]'], ['s_m3', '[/]'], ['s_m4', '[/]'], ['s_m5', '[/]'], $ @@ -143,9 +147,9 @@ heads_sigma = [ $ ['s_l11', '[/]'], ['s_l12', '[/]'] $ ] -format_w = '(a32,f21.8,f9.0,f7.0,e13.2,f11.4,f11.4,f11.4,f11.4,f11.4,e15.4,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,' + $ - 'F10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3)' -format_r = '(a,d,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f)' +format_w = '(a32,f21.8,f9.0,f7.0,e13.2,f11.4,f11.4,f11.4,f11.4,f11.4,e15.4,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,' + $ + 'f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3)' +format_r = '(a,d,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f)' trat = strjoin(replicate('-', total(format_length(format_w)))) @@ -157,8 +161,8 @@ header_sigma = [par.camera + '_' + day, 'config = ' + par.file, 'model = ' + par string(heads_sigma[0,*], format = format_header(format_w)), $ string(heads_sigma[1,*], format = format_header(format_w)), trat, ''] -param = {name:name_param, header:header_param, format_w:format_w, format_r:format_r} -sigma = {name:name_sigma, header:header_sigma, format_w:format_w, format_r:format_r} +param = {name:name_param, columns:heads_param[0,*], units:heads_param[1,*], header:header_param, format_w:format_w, format_r:format_r} +sigma = {name:name_sigma, columns:heads_sigma[0,*], units:heads_sigma[1,*], header:header_sigma, format_w:format_w, format_r:format_r} photometry = {param:param, sigma:sigma} @@ -175,7 +179,9 @@ name_sigma = par.camera + '_' + month + '_astro_sigma.txt' heads_param = [ $ ['date', '[/]'], $ ['julian_date', '[/]'], $ - ['n', '[/]'] $ + ['ns', '[/]'], $ + ['sd_az', '[amin]'], $ + ['sd_zd', '[amin]'] $ ] heads_sigma = heads_param @@ -189,8 +195,8 @@ for i=0, n_elements(names.names)-1 do begin endfor -format_w = '(a13,f14.1,f10.0,' + strmid(names.format_w, 1, strlen(names.format_w)-1) -format_r = '(a,d,f,' + strmid(names.format_r, 1, strlen(names.format_r)-1) +format_w = '(a13,f14.1,f10.0,f9.2,f9.2,' + strmid(names.format_w, 1, strlen(names.format_w)-1) +format_r = '(a,d,f,f,f,' + strmid(names.format_r, 1, strlen(names.format_r)-1) trat = strjoin(replicate('-', total(format_length(format_w)))) @@ -202,8 +208,8 @@ header_sigma = [par.camera + '_' + month, 'config = ' + par.file, 'model = ' + p string(heads_sigma[0,*], format = format_header(format_w)), $ string(heads_sigma[1,*], format = format_header(format_w)), trat, ''] -param = {name:name_param, header:header_param, format_w:format_w, format_r:format_r} -sigma = {name:name_sigma, header:header_sigma, format_w:format_w, format_r:format_r} +param = {name:name_param, columns:heads_param[0,*], units:heads_param[1,*], header:header_param, format_w:format_w, format_r:format_r} +sigma = {name:name_sigma, columns:heads_sigma[0,*], units:heads_sigma[1,*], header:header_sigma, format_w:format_w, format_r:format_r} ; SOLUTION name = par.camera + '_' + day + '_astro_solution.txt' @@ -215,7 +221,7 @@ trat = strjoin(replicate('-', total(format_length(format_w)) - 1)) header = [par.camera + '_' + day, 'config = ' + par.file, 'model = ' + par.astrometry.model_daily, trat, ''] -solution = {name:name, header:header, format_w:format_w, format_r:format_r} +solution = {name:name, columns:'', units:'', header:header, format_w:format_w, format_r:format_r} ; COVAR name = par.camera + '_' + day + '_astro_covar.txt' @@ -239,7 +245,7 @@ header = [par.camera + '_' + day, 'config = ' + par.file, 'model = ' + par.astro string(heads[0,*], format = format_header(format_w)), string(heads[1,*], format = format_header(format_w)), $ trat, ''] -covar = {name:name, header:header, format_w:format_w, format_r:format_r} +covar = {name:name, columns:heads[0,*], units:heads[1,*], header:header, format_w:format_w, format_r:format_r} ; ERROR name = par.camera + '_' + day + '_astro_error.txt' @@ -247,10 +253,10 @@ name = par.camera + '_' + day + '_astro_error.txt' heads = [ $ ['angle ' , '[rad]'], $ ['bias_az*sin(zd)', '[rad]'], $ - ['std_az*sin(zd)', '[rad]'], $ + ['sd_az*sin(zd)', '[rad]'], $ ['int_az*sin(zd)', '[rad]'], $ ['bias_zd', '[rad]'], $ - ['std_zd', '[rad]'], $ + ['sd_zd', '[rad]'], $ ['int_zd', '[rad]'] $ ] @@ -263,12 +269,12 @@ header = [par.camera + '_' + day, 'config = ' + par.file, 'model = ' + par.astro string(heads[0,*], format = format_header(format_w)), $ string(heads[1,*], format = format_header(format_w)), trat, ''] -error = {name:name, header:header, format_w:format_w, format_r:format_r} +error = {name:name, columns:heads[0,*], units:heads[1,*], header:header, format_w:format_w, format_r:format_r} ; REPORT name = par.camera + '_' + day + '_astro_report.pdf' -report = {name: name, header: 0, format_w: 0, format_r: 0} +report = {name:name, columns:'', units:'', header:0, format_w:0, format_r:0} astrometry = {param:param, sigma:sigma, solution:solution, covar:covar, error:error, report:report} @@ -281,7 +287,7 @@ name_sigma = par.camera + '_' + month + '_photo_sigma.txt' heads_param = [ $ ['date', '[/]'], $ ['julian_date', '[/]'], $ - ['n', '[/]'], $ + ['ns', '[/]'], $ ['f', '[/]'], $ ['exp', '[sec]'], $ ['m_ph', '[/]'], $ @@ -289,8 +295,9 @@ heads_param = [ $ ['scale', '[rad/px]'], $ ['eff_z', '[/]'], $ ['eff_m', '[/]'], $ - ['eff_l', '[/]'], $ - ['c', '[/]'], $ + ['eff_l', '[/]'], $ + ['sd_mag', '[/]'], $ + ['C', '[/]'], $ ['k', '[/]'], $ ['z', '[/]'], $ ['m', '[/]'], $ @@ -300,7 +307,7 @@ heads_param = [ $ heads_sigma = [ $ ['date', '[/]'], $ ['julian_date', '[/]'], $ - ['n', '[/]'], $ + ['ns', '[/]'], $ ['f', '[/]'], $ ['exp', '[sec]'], $ ['m_ph', '[/]'], $ @@ -309,15 +316,16 @@ heads_sigma = [ $ ['eff_z', '[/]'], $ ['eff_m', '[/]'], $ ['eff_l', '[/]'], $ - ['s_c', '[/]'], $ + ['sd_mag', '[/]'], $ + ['s_C', '[/]'], $ ['s_k', '[/]'], $ ['s_z', '[/]'], $ ['s_m', '[/]'], $ ['s_l', '[/]'] $ ] -format_w = '(a13,f14.1,f10.0,f7.0,e13.2,f11.4,f11.4,e15.4,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3)' -format_r = '(a,d,f,f,f,f,f,f,f,f,f,f,f,f,f,f) +format_w = '(a13,f14.1,f10.0,f7.0,e13.2,f11.4,f11.4,e15.4,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3,f10.3)' +format_r = '(a,d,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f) trat = strjoin(replicate('-', total(format_length(format_w)))) @@ -329,8 +337,8 @@ header_sigma = [par.camera + '_' + month, 'config = ' + par.file, 'model = ' + p string(heads_sigma[0,*], format = format_header(format_w)), $ string(heads_sigma[1,*], format = format_header(format_w)), trat, ''] -param = {name:name_param, header:header_param, format_w:format_w, format_r:format_r} -sigma = {name:name_sigma, header:header_sigma, format_w:format_w, format_r:format_r} +param = {name:name_param, columns:heads_param[0,*], units:heads_param[1,*], header:header_param, format_w:format_w, format_r:format_r} +sigma = {name:name_sigma, columns:heads_sigma[0,*], units:heads_sigma[1,*], header:header_sigma, format_w:format_w, format_r:format_r} ; SOLUTION name = par.camera + '_' + day + '_photo_solution.txt' @@ -342,12 +350,12 @@ trat = strjoin(replicate('-', total(format_length(format_w)) - 1)) header = [par.camera + '_' + day, 'config = ' + par.file, trat, ''] -solution = {name:name, header:header, format_w:format_w, format_r:format_r} +solution = {name:name, columns:'', units:'', header:header, format_w:format_w, format_r:format_r} ; REPORT name = par.camera + '_' + day + '_photo_report.pdf' -report = {name:name, header:0, format_w:0, format_r:0} +report = {name:name, columns:'', units:'', header:0, format_w:0, format_r:0} photometry = {param:param, sigma:sigma, solution:solution, report:report} @@ -367,7 +375,7 @@ trat = strjoin(replicate('-', total(format_length(format_w)) - 1)) header = [par.camera + '_' + month, 'config = ' + par.file, 'model = ' + par.astrometry.model_daily, trat, ''] -solution = {name:name, header:header, format_w:format_w, format_r:format_r} +solution = {name:name, columns:'', units:'', header:header, format_w:format_w, format_r:format_r} ; COVAR name = par.camera + '_' + month + '_astro_covar.txt' @@ -391,7 +399,7 @@ header = [par.camera + '_' + month, 'config = ' + par.file, 'model = ' + par.ast string(heads[0,*], format = format_header(format_w)), string(heads[1,*], format = format_header(format_w)), $ trat, ''] -covar = {name:name, header:header, format_w:format_w, format_r:format_r} +covar = {name:name, columns:heads[0,*], units:heads[1,*], header:header, format_w:format_w, format_r:format_r} ; ERROR name = par.camera + '_' + month + '_astro_error.txt' @@ -399,10 +407,10 @@ name = par.camera + '_' + month + '_astro_error.txt' heads = [ $ ['angle ', '[rad]'], $ ['bias_az*sin(zd)', '[rad]'], $ - ['std_az*sin(zd)', '[rad]'], $ + ['sd_az*sin(zd)', '[rad]'], $ ['int_az*sin(zd)', '[rad]'], $ ['bias_zd', '[rad]'], $ - ['std_zd', '[rad]'], $ + ['sd_zd', '[rad]'], $ ['int_zd', '[rad]'] $ ] @@ -411,16 +419,16 @@ format_r = '(f,f,f,f,f,f,f)' trat = strjoin(replicate('-', total(format_length(format_w)))) -header_error = [par.camera + '_' + month, 'config = ' + par.file, 'model = ' + par.astrometry.model_monthly, trat, $ - string(heads[0,*], format = format_header(format_w)), $ - string(heads[1,*], format = format_header(format_w)), trat, ''] +header = [par.camera + '_' + month, 'config = ' + par.file, 'model = ' + par.astrometry.model_monthly, trat, $ + string(heads[0,*], format = format_header(format_w)), $ + string(heads[1,*], format = format_header(format_w)), trat, ''] -error = {name:name, header:header, format_w:format_w, format_r:format_r} +error = {name:name, columns:heads[0,*], units:heads[1,*], header:header, format_w:format_w, format_r:format_r} ; REPORT name = par.camera + '_' + month + '_astro_report.pdf' -report = {name:name, header:0, format_w:0, format_r:0} +report = {name:name, columns:'', units:'', header:0, format_w:0, format_r:0} astrometry = {report:report, solution:solution, error:error, covar:covar} @@ -429,28 +437,69 @@ photometry = 0 monthly = {astrometry:astrometry, photometry:photometry} -calibration = {image:image, day:daily, month:monthly} +; {{REPORTS}} + +; {TXT} +name = 'PRISMA_calibration_report.txt' + +heads = [ $ + ['camera ', '[/]'], $ + ['start', '[/]'], $ + ['end', '[/]'], $ + ['nc', '[/]'], ['s_nc', '[/]'], ['l_nc', '[/]'], $ + ['ns', '[/]'], ['s_ns', '[/]'], ['l_ns', '[/]'], $ + ['sm', '[/]'], ['s_sm', '[/]'], ['l_sm', '[/]'], $ + ['d_C', '[/]'], ['s_C', '[/]'], ['l_C', '[/]'], ['t_C', '[/]'], $ + ['d_k', '[/]'], ['s_k', '[/]'], ['l_k', '[/]'], ['t_k', '[/]'], $ + ['sa', '[amin]'], ['s_sa', '[amin]'], ['l_sa', '[amin]'], $ + ['sz', '[amin]'], ['s_sz', '[amin]'], ['l_sz', '[amin]'], $ + ['d_a0', '[deg]'], ['s_a0', '[deg]'], ['l_a0', '[deg]'], ['t_a0', '[deg]'], $ + ['d_xo', '[px]'], ['s_xo', '[px]'], ['l_xo', '[px]'], ['t_xo', '[px]'], $ + ['d_yo', '[px]'], ['s_yo', '[px]'], ['l_yo', '[px]'], ['t_yo', '[px]'], $ + ['d_xz', '[px]'], ['s_xz', '[px]'], ['l_xz', '[px]'], ['t_xz', '[px]'], $ + ['d_yz', '[px]'], ['s_yz', '[px]'], ['l_yz', '[px]'], ['t_yz', '[px]'], $ + ['d_v', '[am/px]'], ['s_v', '[am/px]'], ['l_v', '[am/px]'], ['t_v', '[am/px]'], $ + ['d_s', '[am]'], ['s_s', '[am]'], ['l_s', '[am]'], ['t_s', '[am]'], $ + ['d_d', '[1e3/px]'], ['s_d', '[1e3/px]'], ['l_d', '[1e3/px]'], ['t_d', '[1e3/px]'], $ + ['d_j', '[am]'], ['s_j', '[am]'], ['l_j', '[am]'], ['t_j', '[am]'], $ + ['d_phi', '[deg]'], ['s_phi', '[deg]'], ['l_phi', '[deg]'], ['t_phi', '[deg]'] $ + ] + +format_w = '(a11,a11,a11,i8,i8,i8,i9,i9,i9,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,' + $ + 'f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,' + $ + 'f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,' + $ + 'f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2,f10.2)' +format_r = '(a,a,a,i,i,i,i,i,i,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,' + $ + 'f,f,f,f,f,f,f,f,f)' + +names = astro_model_info(par.astrometry.model_monthly) + +trat = strjoin(replicate('-', total(format_length(format_w)))) + +header = ['config = ' + par.file, 'model = ' + par.astrometry.model_monthly, trat, $ + string(heads[0,*], format = format_header(format_w)), $ + string(heads[1,*], format = format_header(format_w)), trat, ''] + +txt = {name:name, columns:heads[0,*], units:heads[1,*], header:header, format_w:format_w, format_r:format_r} + +; {XLSX} +name = 'PRISMA_calibration_report.xlsx' + +xlsx = {name:name, columns:'', units:'', header:0, format_w:0, format_r:0} + +; {PDF} +name = par.camera + '_calibration_report.pdf' + +pdf = {name:name, columns:'', units:'', header:0, format_w:0, format_r:0} + +reports = {txt:txt, xlsx:xlsx, pdf:pdf} + +calibration = {image:image, day:daily, month:monthly, reports:reports} retv = {calibration:calibration} if isa(detection) then begin - ; retrieving data from detection code - len = strlen(par.pseudo) + 1 - - yy = long(strmid(detection, len, 4)) - mn = long(strmid(detection, len + 4, 2)) - dd = long(strmid(detection, len + 6, 2)) - hh = double(strmid(detection, len + 9, 2)) - mm = double(strmid(detection, len + 11, 2)) - ss = double(strmid(detection, len + 13, 2)) - - ; computing julian date - jd = julday(mn, dd, yy, hh, mm, ss) - - ; reading solution file from settings - solut = get_solution(par, jd, /return0) - ; {NEWPOSITIONS} name_newpos = 'newpositions.txt' @@ -541,12 +590,7 @@ if isa(detection) then begin trat = strjoin(replicate('-', total(format_length(format_w)))) header = [detection, $ - 'config = ' + par.file, $ - 'solution = ' + solut.folder, $ - 'C = ' + strtrim(string(solut.C, format = '(f20.3)'), 2) + ' ± ' + $ - strtrim(string(solut.s_C, format = '(f20.3)'), 2), $ - 'k = ' + strtrim(string(solut.k, format = '(f20.3)'), 2) + ' ± ' + $ - strtrim(string(solut.s_k, format = '(f20.3)'), 2), trat, $ + 'config = ' + par.file, trat, $ string(heads[0,*], format = format_header(format_w)), $ string(heads[1,*], format = format_header(format_w)), trat, ''] @@ -634,12 +678,7 @@ if isa(detection) then begin trat = strjoin(replicate('-', total(format_length(format_w)))) header = [detection, $ - 'config = ' + par.file, $ - 'solution = ' + solut.folder, $ - 'C = ' + strtrim(string(solut.C, format = '(f20.3)'), 2) + ' ± ' + $ - strtrim(string(solut.s_C, format = '(f20.3)'), 2), $ - 'k = ' + strtrim(string(solut.k, format = '(f20.3)'), 2) + ' ± ' + $ - strtrim(string(solut.s_k, format = '(f20.3)'), 2), trat, $ + 'config = ' + par.file, trat, $ string(heads[0,*], format = format_header(format_w)), $ string(heads[1,*], format = format_header(format_w)), trat, ''] @@ -771,7 +810,7 @@ if isa(event) then begin ['s_azim', '[deg]'] $ ] - format_w = '(i6,a11,a29,f21.8,f10.3,f10.3,f14.6,f13.6,f14.6,f13.6,f13.4,f11.4,f11.3,f10.3,f12.4,f11.4,f10.3,f10.3,f12.4,f11.4,f13.4,f11.4)' + format_w = '(i6,a11,a29,f21.8,f10.3,f10.3,f14.6,f13.6,f15.6,f13.6,f13.4,f11.4,f11.3,f10.3,f12.4,f11.4,f10.3,f10.3,f12.4,f11.4,f13.4,f11.4)' format_r = '(i,a,a,d,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f)' trat = strjoin(replicate('-', total(format_length(format_w)))) diff --git a/code/functions/configuration/get_logo.pro b/code/functions/configuration/get_logo.pro index 0e116ab..ba9328a 100644 --- a/code/functions/configuration/get_logo.pro +++ b/code/functions/configuration/get_logo.pro @@ -1,7 +1,8 @@ ; function that read the logo image and provide transparent background function get_logo, filename, $ - transparent = transparent + transparent = transparent, $ + rescale_dim = rescale_dim compile_opt idl2 @@ -61,6 +62,50 @@ if isa(transparent) then begin endif +; rescaling the logo to the standard dimensions (of original PRISMA logo) +if isa(rescale_dim) then begin + + ; check if the logo has square dimensions + case 1 of + + ; extend along the y dimension if dimx > dimy + dim[1] gt dim[2]: begin + + dy = dim[1] - dim[2] + newlogo = bytarr(4, dim[1], dim[1]) + newlogo[*,*,floor(dy/2.):(floor(dy/2.)+dim[2]-1)] = logo + + end + + ; extend along the x dimension if dimx < dimy + dim[1] lt dim[2]: begin + + dx = dim[2] - dim[1] + newlogo = bytarr(4, dim[2], dim[2]) + newlogo[*,floor(dx/2.):(floor(dx/2.)+dim[1]-1),*] = logo + + end + + ; dimx = dimy, nothing to be done + dim[1] eq dim[2]: newlogo = logo + + endcase + + ; logo is now squared + logo = newlogo + + ; reforming the logo to the required dimension + scaled_logo = bytarr(4, rescale_dim, rescale_dim) + scaled_logo[0,*,*] = frebin(reform(logo[0,*,*]), rescale_dim, rescale_dim) + scaled_logo[1,*,*] = frebin(reform(logo[1,*,*]), rescale_dim, rescale_dim) + scaled_logo[2,*,*] = frebin(reform(logo[2,*,*]), rescale_dim, rescale_dim) + scaled_logo[3,*,*] = frebin(reform(logo[3,*,*]), rescale_dim, rescale_dim) + + ; logo is now scaled + logo = scaled_logo + +endif + return, logo end \ No newline at end of file diff --git a/code/functions/configuration/get_mask.pro b/code/functions/configuration/get_mask.pro index 2b40117..1d02019 100644 --- a/code/functions/configuration/get_mask.pro +++ b/code/functions/configuration/get_mask.pro @@ -9,7 +9,7 @@ function get_mask, par, $ compile_opt idl2 ; going into the configuration / camera directory -ckcd, par.config.path.dir_config, current = old_dir, check = check +ckcd, par.config.path.dir_configurations, current = old_dir, check = check if ~check then retall ckcd, par.camera, check = check, old_dir = old_dir if ~check then retall diff --git a/code/functions/configuration/get_par.pro b/code/functions/configuration/get_par.pro index 698f2a3..33e232f 100644 --- a/code/functions/configuration/get_par.pro +++ b/code/functions/configuration/get_par.pro @@ -77,7 +77,7 @@ endif else begin endelse ; loading camera setting from specified config file -cam_par = camera_par(config.path.dir_config, camera, target, return0 = return0) +cam_par = camera_par(config.path.dir_configurations, camera, target, return0 = return0) ; loading failed if cam_par.file eq '' then begin diff --git a/code/functions/configuration/get_solution.pro b/code/functions/configuration/get_solution.pro index 73e8310..08b6d56 100644 --- a/code/functions/configuration/get_solution.pro +++ b/code/functions/configuration/get_solution.pro @@ -13,7 +13,7 @@ k = !values.f_NaN s_k = !values.f_NaN ; going into the solutions directory -ckcd, par.config.path.dir_config, current = old_dir, check = check +ckcd, par.config.path.dir_solutions, current = old_dir, check = check if ~check then begin retv = {folder:'', C:C, s_C:s_C, k:k, s_k:s_k} @@ -89,9 +89,26 @@ if ff_solut[0] eq '' then begin endif ; reading the solution file header -readcol, ff_solut[0], info, junk, model, format = '(a,a,a)', /silent +readcol, ff_solut[0], info, junk, value, format = '(a,a,a)', /silent + +; astrometric model ii = where(info eq 'model') -model = model[ii[0]] +model = value[ii[0]] + +; number of stars +ii = where(info eq 'ns') +if ii[0] ne -1 then n = value[ii[0]] $ + else n = !values.f_NaN + +; std deviation of az residuals +ii = where(info eq 'sd_az') +if ii[0] ne -1 then sd_az = float(value[ii[0]]) $ + else sd_az = !values.f_NaN + +; std deviation of zd residuals +ii = where(info eq 'sd_zd') +if ii[0] ne -1 then sd_zd = float(value[ii[0]]) $ + else sd_zd = !values.f_NaN ; reading the solution file readcol, ff_solut[0], junk, junk, param, junk, sigma, junk, $ @@ -166,13 +183,13 @@ endif else begin if ff_param[0] ne '' and ff_sigma[0] ne '' then begin ; reading the photometric files - myreadcol, ff_param, junk, jdv, junk, f, junk, junk, junk, junk, junk, junk, junk, Cv, kv, junk, junk, junk, $ + myreadcol, ff_param, junk, jdv, junk, f, junk, junk, junk, junk, junk, junk, junk, sd_magv, Cv, kv, junk, junk, junk, $ format = files.calibration.day.photometry.param.format_r, /silent - myreadcol, ff_sigma, junk, jdv, junk, f, junk, junk, junk, junk, junk, junk, junk, s_Cv, s_kv, junk, junk, junk, $ + myreadcol, ff_sigma, junk, jdv, junk, f, junk, junk, junk, junk, junk, junk, junk, junk, s_Cv, s_kv, junk, junk, junk, $ format = files.calibration.day.photometry.param.format_r, /silent ; f = 1 means that the photometric calibration was performed on that day - ii_ok = where(f eq 1) + ii_ok = where(f eq 1 and sd_magv le par.photometry.max_sd_mag) endif @@ -186,6 +203,7 @@ endif else begin s_Cv = s_Cv[ii_ok] kv = kv[ii_ok] s_kv = s_kv[ii_ok] + sd_magv = sd_magv[ii_ok] ; is the target day included in the table? jdv = round(jdv) - round(jd) @@ -198,6 +216,7 @@ endif else begin s_C = s_Cv[ii_jd[0]] k = kv[ii_jd[0]] s_k = s_kv[ii_jd[0]] + sd_mag = sd_magv[ii_jd[0]] endif else begin ; it's not included, let's use median values @@ -205,6 +224,7 @@ endif else begin s_C = sqrt(median(s_Cv^2, /even) + medabsdev(Cv, /sigma, /even)^2)/sqrt(n_ok) k = median(kv, /even) s_k = sqrt(median(s_kv^2, /even) + medabsdev(kv, /sigma, /even)^2)/sqrt(n_ok) + sd_mag = median(sd_magv, /even) endelse @@ -212,14 +232,15 @@ endif else begin C = [par.photometry.C, 0.] k = [par.photometry.k, 0.] + sd_mag = !values.f_NaN endelse endelse ; return structure -retv = {folder:folder, target:target, model:model, param:param, sigma:sigma, error:error, covar:covar, $ - C:C[0], s_C:s_C[0], k:k[0], s_k:s_k[0]} +retv = {folder:folder, target:target, model:model, n:n, sd_az:sd_az, sd_zd:sd_zd, param:param, sigma:sigma, error:error, covar:covar, $ + eff_corr:par.photometry.eff_corr, sd_mag:sd_mag[0], C:C[0], s_C:s_C[0], k:k[0], s_k:s_k[0]} cd, old_dir return, retv diff --git a/code/functions/configuration/target_jd.pro b/code/functions/configuration/target_jd.pro index 99dd5f1..762c8d8 100644 --- a/code/functions/configuration/target_jd.pro +++ b/code/functions/configuration/target_jd.pro @@ -4,6 +4,8 @@ function target_jd, target, $ day = day, $ first = first, $ last = last, $ + check0d = check0d, $ + target_str = target_str, $ return0 = return0 compile_opt idl2 @@ -52,7 +54,14 @@ case typ of end ; input is YYYYMMDD - 8: jd[i] = julday(mn, dd, yy) + 8: begin + + ; checking is this day is 00 -> moving to 01 + if keyword_set(check0d) then if dd eq 0 then dd = 1 + + jd[i] = julday(mn, dd, yy) + + end else: begin @@ -89,6 +98,14 @@ if n eq 1 then begin endif +; computing string date is target is a jd +if typ ne 'string' then begin + + target_fits = date_conv(target, 'FITS') + target_str = repstr(strmid(target_fits, 0, 10), '-', '') + +endif else target_str = target + return, jd end \ No newline at end of file diff --git a/code/functions/dynamic/kalenichenko2006.pro b/code/functions/dynamic/kalenichenko2006.pro index fd17ec5..9a4942d 100644 --- a/code/functions/dynamic/kalenichenko2006.pro +++ b/code/functions/dynamic/kalenichenko2006.pro @@ -38,12 +38,11 @@ for i=1, nxi-1 do begin ; initial time x0 = xi[i-1] - ; computing atmospheric density at step - rho_i = atmospheric_density(atmosphere, yi[0,i-1]) - rho[i] = rho_i + ; atmospheric density at last step + rho0 = rho[i-1] - ; initial height and speed, adding the atmospheric density and the parameter vector - y0 = [reform(yi[*,i-1]), rho_i, A] + ; initial height and speed, adding the atmospheric density and the parameters vector + y0 = [reform(yi[*,i-1]), rho0, A] ; computing differential dydx = Kalenichenko2006_differential(x0, y0) @@ -51,12 +50,23 @@ for i=1, nxi-1 do begin ; solving by Runge Kutta 4th order result = rk4(y0, dydx, x0, dt, 'Kalenichenko2006_differential', /double) - ; if speed is lower than zero, then clip to zero - if result[1] lt 0 then result[1] = 0. + ; if speed is lower than zero, fixing it + if result[1] lt 0 then begin + + ; speed is clipped to zero + result[1] = 0. + + ; height does not change + retult[0] = y0[0] + + endif ; storing results in yi yi[*,i] = result[0:1] - + + ; computing atmospheric density at new height + rho[i] = atmospheric_density(atmosphere, yi[0,i]) + endfor ; extracting hgt and vel vectors diff --git a/code/functions/geometry3d/eci2geodetic.pro b/code/functions/geometry3d/eci2geodetic.pro index 4592a59..7b85a73 100644 --- a/code/functions/geometry3d/eci2geodetic.pro +++ b/code/functions/geometry3d/eci2geodetic.pro @@ -13,6 +13,11 @@ gcoord = eci2geo(eci, jd) ; geographic to geodetic conversion coord = geo2geodetic(gcoord) +; correcting lon in [-180, 180] deg +lon = reform(coord[1,*]) +closest, lon, /degree +coord[1,*] = lon + ; converting to float if needed if strlowcase(typename(eci)) ne 'double' then coord = float(coord) diff --git a/code/functions/orbit/meteor_orbit.pro b/code/functions/orbit/meteor_orbit.pro index d701ca2..3daa591 100644 --- a/code/functions/orbit/meteor_orbit.pro +++ b/code/functions/orbit/meteor_orbit.pro @@ -11,6 +11,7 @@ compile_opt idl2 ; using default orbit step on eccentric anomaly if ~isa(step_orbit) then step_orbit = 0.1 +if ~isa(covar) then covar = fltarr(3,3) ; initial position (lat, lon, hgt) lat_ini = coord[0] @@ -25,7 +26,7 @@ s_vy_a = sqrt(covar[1,1]) vz_a = speed[2] s_vz_a = sqrt(covar[2,2]) -; covariance matric for apparent radiant computation +; covariance matrix for apparent radiant computation covar_eci_a = covar ; correcting for Earth's rotation if requested @@ -85,8 +86,23 @@ Jaz1_a = [0., 0., 1./!radeg] jacob_hor1_a = transpose([[Jv1_a], [Jzd1_a], [Jaz1_a]]) covar_hor1_a = jacob_hor1_a # covar_hor_a # transpose(jacob_hor1_a) -; computing geocentric meteor speed module -v1_g = sqrt(v1_a^2 - 2.*float(!const.G*!const.M_Earth/(!const.R_Earth + h_ini*1e3))) +; escape speed from the Earth at the meteor initial altitude +v1_e = sqrt(2.*float(!const.G*!const.M_Earth/(!const.R_Earth + h_ini*1e3))) + +; checking if apparent speed is greater than escape speed +if v1_a gt v1_e then begin + + ; computing geocentric meteor speed module + v1_g = sqrt(v1_a^2 - 2.*float(!const.G*!const.M_Earth/(!const.R_Earth + h_ini*1e3))) + +endif else begin + + ; aborting, this is not a meteor! + message, 'the apparent speed of the meteor is lower than the escape speed from the Earth at the meteor initial altitude. return:99', /informational + retv = {status:1} + return, retv + +endelse ; zenith attraction formula zd1_g = zd1_a + 2.*atan2((v1_a - v1_g)*tan(zd1_a/2.), (v1_a + v1_g)) @@ -616,7 +632,7 @@ yz = {sigma1:{inner:{y:y_yz_inn_1s, z:z_yz_inn_1s}, outer:{y:y_yz_out_1s, z:z_yz proj = {xy:xy, xz:xz, yz:yz} -retv = {radiant:radiant, vector:vector, elements:elements, orbit:orbit, proj:proj} +retv = {status:0, radiant:radiant, vector:vector, elements:elements, orbit:orbit, proj:proj} return, retv diff --git a/code/functions/photometry/eff_correction.pro b/code/functions/photometry/eff_correction.pro index 3eba3c2..2977557 100644 --- a/code/functions/photometry/eff_correction.pro +++ b/code/functions/photometry/eff_correction.pro @@ -1,9 +1,9 @@ ; correction for differential radial efficiency -pro eff_correction, var, zd, $ - err = err, $ +pro eff_correction, model, var, zd, $ + err = err, $ flux = flux, $ - mag = mag, $ + mag = mag, $ corr = corr compile_opt idl2 @@ -22,21 +22,35 @@ if ~keyword_set(flux) and ~keyword_set(mag) then begin endif -; PRISMA radial efficiency correction -A0 = 1.04819 -A1 = 0.00483018*!radeg -A2 = 0.04819 -corr = A0 - A1*zd - A2 * exp( - (A1/A2) * zd ) - -;; DMI_SKYCAM -;corr = zd*0. + 1. +; efficiency correction model +case strlowcase(model) of + + ; PRISMA radial efficiency correction (FRIPON cameras) + 'prisma_eff_v0': begin + + A0 = 1.04819 + A1 = 0.00483018*!radeg + A2 = 0.04819 + corr = A0 - A1*zd - A2 * exp( - (A1/A2) * zd ) + + end + + else: begin + + message, 'radial efficiency correction not implemented for ' + strlowcase(model) + '. return:99' + + end + +endcase +; if input (var) if a magnitude if keyword_set(mag) then begin - var = var + 2.5*alog10(corr) + var = var + 2.5*alog10(corr) endif +; if input (var) if a flux if keyword_set(flux) then begin var = var / corr diff --git a/code/functions/report/astrometry_report.pro b/code/functions/report/astrometry_report.pro index d460b24..09cd7e2 100644 --- a/code/functions/report/astrometry_report.pro +++ b/code/functions/report/astrometry_report.pro @@ -57,6 +57,10 @@ range_dzd = [-60., 60.] ; number of found and associated stars ns = n_elements(var.x) +; standard deviation of residuals in az and zd +sd_az = var.err.global.std.az +sd_zd = var.err.global.std.zd + ; frames rotated dimensions rotdim = get_rotdim(par.fits.dim, par.fits.rotate) @@ -116,12 +120,12 @@ if keyword_set(histo) then begin ; histogram plots pa = image(h2D_resaz, loc_h2Dx_resaz, loc_h2Dy_resaz, rgb_table = rgb_mod, current = w1, $ position = [0.16, 0.54, 0.73, 0.86], title = 'azimuth residuals', xtitle = 'a [deg]', $ - ytitle = '$\delta$a$\cdot$sin(z) [arcmin]', axis_style = 2, xrange = range_az, yrange = range_daz, $ + ytitle = '$\delta$a$\cdot$sin(z) [amin]', axis_style = 2, xrange = range_az, yrange = range_daz, $ xminor = 4, yminor = 3, aspect_ratio = 0, font_size = font_size) pz = image(h2D_reszd, loc_h2Dx_reszd, loc_h2Dy_reszd, rgb_table = rgb_mod, current = w1, $ position = [0.16, 0.13, 0.73, 0.45], title = 'zenith distance residuals', xtitle = 'z [deg]', $ - ytitle = '$\delta$z [arcmin]', axis_style = 2, xrange = range_zd, yrange = range_dzd, xminor = 3, $ + ytitle = '$\delta$z [amin]', axis_style = 2, xrange = range_zd, yrange = range_dzd, xminor = 3, $ yminor = 3, aspect_ratio = 0, font_size = font_size) ; 2D histograms @@ -139,23 +143,23 @@ if keyword_set(histo) then begin ; coverage histograms pxy = image(h2D_covXY, loc_h2Dx_covXY, loc_h2Dy_covXY, rgb_table = rgb_mod, current = w2, $ position = [0.40, 0.62, 0.74, 0.86], title = '(x,y) coverage histogram', xtitle = 'a [deg]', $ - ytitle = '$\delta$a$\cdot$sin(z) [arcmin]', axis_style = 2, xrange = range_x, yrange = range_y, $ + ytitle = '$\delta$a$\cdot$sin(z) [amin]', axis_style = 2, xrange = range_x, yrange = range_y, $ xminor = 3, yminor = 3, aspect_ratio = 0, font_size = font_size) paz = image(h2D_covaz, loc_h2Dx_covaz, loc_h2Dy_covaz, rgb_table = rgb_mod, current = w2, $ position = [0.29, 0.22, 0.85, 0.45], title = '(a,z) coverage histogram', xtitle = 'z [deg]', $ - ytitle = '$\delta$z [arcmin]', axis_style = 2, xrange = range_az, yrange = range_zd, xminor = 4, $ + ytitle = '$\delta$z [amin]', axis_style = 2, xrange = range_az, yrange = range_zd, xminor = 4, $ yminor = 3, aspect_ratio = 0, font_size = font_size) endif else begin ; residuals plots pa = plot(var.az*!radeg, d_az*sin(var.zd)*!ramin, '.', current = w1, position = [0.16, 0.54, 0.73, 0.86], $ - title = 'azimuth residuals', xtitle = 'a [deg]', ytitle = '$\delta$a$\cdot$sin(z) [arcmin]', $ + title = 'azimuth residuals', xtitle = 'a [deg]', ytitle = '$\delta$a$\cdot$sin(z) [amin]', $ xrange = range_az, yrange = range_daz, font_size = font_size, xminor = 4, yminor = 3) pz = plot(var.zd*!radeg, d_zd*!ramin, '.', current = w1, position = [0.16, 0.13, 0.73, 0.45], $ - title = 'zenith distance residuals', xtitle = 'z [deg]', ytitle = '$\delta$z [arcmin]', $ + title = 'zenith distance residuals', xtitle = 'z [deg]', ytitle = '$\delta$z [amin]', $ xrange = range_zd, yrange = range_dzd, font_size = font_size, xminor = 3, yminor = 3) ; (x,y) coverage plots @@ -171,8 +175,10 @@ endif else begin endelse ; adding textbox with number of stars and astrometric model -str1 = 'n$_{\ast}$ = ' + strtrim(ns, 2) +str1 = 'n$_{\ast}$ = ' + strtrim(ns, 2) + ', $\sigma_{a}$ = ' + strtrim(string(sd_az*!ramin, format = '(f20.2)'), 2) + ' amin' + $ + ', $\sigma_{z}$ = ' + strtrim(string(sd_zd*!ramin, format = '(f20.2)'), 2) + ' amin' str2 = 'model = ' + strlowcase(res.model) + t1 = text(0.16, 0.92, str1, target = w1, font_size = font_size, vertical_alignment = 0.5) t2 = text(0.16, 0.90, str2, target = w1, font_size = font_size, vertical_alignment = 0.5) @@ -267,11 +273,11 @@ d_zd_proj = abs(proj_base.zd - proj.zd)*mask_r2 ; distorsion maps im1 = image(d_az_proj*sin(proj.zd)*!ramin, xv , yv, rgb_table = rgb, current = w3, layout = [1,2,1], $ - margin = [0.20, 0.10, 0.20, 0.30], title = 'azimuth distorsion [$\Delta$a$\cdot$sin(z), arcmin]', $ + margin = [0.20, 0.10, 0.20, 0.30], title = 'azimuth distorsion [$\Delta$a$\cdot$sin(z), amin]', $ xtitle = 'x [px]', ytitle = 'y [px]', axis_style = 2, xticklen = 0., yticklen = 0., font_size = font_size) im2 = image(d_zd_proj*!ramin, xv, yv, rgb_table = rgb, current = w3, layout = [1,2,2], margin = [0.20, 0.30, 0.20, 0.10], $ - title = 'zenith distance distorsion [$\Delta$z, arcmin]', xtitle = 'x [px]', ytitle = 'y [px]', $ + title = 'zenith distance distorsion [$\Delta$z, amin]', xtitle = 'x [px]', ytitle = 'y [px]', $ axis_style = 2, xticklen = 0., yticklen = 0., font_size = font_size) ; colorbars @@ -290,11 +296,11 @@ s_zd = err.zd*mask_r2 ; error maps im3 = image(s_az*sin(proj.zd)*!ramin, xv, yv, rgb_table = rgb, current = w4, layout = [1,2,1], $ - margin = [0.20, 0.10, 0.20, 0.30], title = 'azimuth projection error [$\sigma_a\cdot$sin(z), arcmin]', $ + margin = [0.20, 0.10, 0.20, 0.30], title = 'azimuth projection error [$\sigma_a\cdot$sin(z), amin]', $ xtitle = 'x [px]', ytitle = 'y [px]', axis_style = 2, xticklen = 0., yticklen = 0., font_size = font_size) im4 = image(s_zd*!ramin, xv, yv, rgb_table = rgb, current = w4, layout = [1,2,2], margin = [0.20, 0.30, 0.20, 0.10], $ - title = 'zenith distance projection error [$\sigma_z$, arcmin]', xtitle = 'x [px]', ytitle = 'y [px]', $ + title = 'zenith distance projection error [$\sigma_z$, amin]', xtitle = 'x [px]', ytitle = 'y [px]', $ axis_style = 2, xticklen = 0., yticklen = 0., xthick = 0.5, ythick = 0.5, font_size = font_size) ; colorbars @@ -318,7 +324,7 @@ range_zd_zd[1] = min([range_zd_zd[1], range_dzd[1]], /nan) ; plotting az bias pb_az_az = errorplot(var.err.az*!radeg, var.err.bias.az_az*!ramin, var.err.std.az_az*!ramin, '.-', $ current = w5, position = [0.16, 0.54, 0.88, 0.86], title = 'azimuth bias', xtitle = 'a [deg]', $ - ytitle = '$\Delta$a$\cdot$sin(z) [arcmin]', xrange = [0, 360], yrange = range_az_az, $ + ytitle = '$\Delta$a$\cdot$sin(z) [amin]', xrange = [0, 360], yrange = range_az_az, $ xminor = 4, yminor = 4, errorbar_capsize = 0, font_size = font_size) ; plotting 1/2/3sigma intrinsic error bands on az @@ -342,7 +348,7 @@ pb_az_az.order, /bring_to_front ; plotting zd bias pb_zd_zd = errorplot(var.err.zd*!radeg, var.err.bias.zd_zd*!ramin, var.err.std.zd_zd*!ramin, '.-', $ current = w5, position = [0.16, 0.13, 0.88, 0.45], title = 'zenith distance bias', $ - xtitle = 'z [deg]', ytitle = '$\Delta$z [arcmin]', xrange = [0,90], yrange = range_zd_zd, $ + xtitle = 'z [deg]', ytitle = '$\Delta$z [amin]', xrange = [0,90], yrange = range_zd_zd, $ xminor = 3, yminor = 4, errorbar_capsize = 0, font_size = font_size) ; plotting 1/2/3sigma intrinsic error bands on zd diff --git a/code/functions/report/detection_report.pro b/code/functions/report/detection_report.pro index b303490..0a594dd 100644 --- a/code/functions/report/detection_report.pro +++ b/code/functions/report/detection_report.pro @@ -60,85 +60,93 @@ s_mag_psf = var.psf.s_mag ii = where(var.psf.s_mag gt 3*var.bar.s_mag) if ii[0] ne -1 then var.psf.s_mag[ii] = !values.f_NaN -yrange = plot_range([var.psf.param[1,*],var.bar.param[1,*]], error = [var.psf.sigma[1,*],var.bar.sigma[1,*]], /min0, rel_filter = 1.) +; suppressing errors if required +if par.config.detection.oplot_errors then f_e = 1. else f_e = !values.f_NaN + +yrange = plot_range([var.psf.param[1,*], var.bar.param[1,*]], error = [var.psf.sigma[1,*], var.bar.sigma[1,*]]*f_e, /min0, rel_filter = 1.) ; plotting psf background -p1 = errorplot(time, var.psf.param[1,*], var.psf.sigma[1,*], '.', current = w1, position = [0.16, 0.68, 0.46, 0.86], $ +p1 = errorplot(time, var.psf.param[1,*], var.psf.sigma[1,*]*f_e, '.', current = w1, position = [0.16, 0.68, 0.46, 0.86], $ title = 'background level', xtitle = 'time [s]', ytitle = 'bkg [ADU]', xminor = 4, yminor = 4, $ xrange = xrange, yrange = yrange, errorbar_capsize = 0., font_size = font_size) p1a = plot(time, var.psf.param[1,*], overplot = p1, color = 'blue', name = 'PSF fitting') -p1b = errorplot(time, var.bar.param[1,*], var.bar.sigma[1,*], '.', errorbar_capsize = 0., overplot = p1) +p1b = errorplot(time, var.bar.param[1,*], var.bar.sigma[1,*]*f_e, '.', errorbar_capsize = 0., overplot = p1) p1c = plot(time, var.bar.param[1,*], overplot = p1, color = 'red', name = 'BAR computation') -leg1 = legend(target = p1a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, position = [0.14, 0.92], $ +leg1 = legend(target = p1a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, position = [0.140, 0.920], $ font_size = font_size) -leg2 = legend(target = p1c, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, position = [0.14, 0.90], $ +leg2 = legend(target = p1c, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, position = [0.140, 0.905], $ font_size = font_size) -yrange = plot_range([var.psf.param[2,*],var.bar.param[2,*]], error = [var.psf.sigma[2,*],var.bar.sigma[2,*]], /min0, $ +yrange = plot_range([var.psf.param[2,*], var.bar.param[2,*]], error = [var.psf.sigma[2,*], var.bar.sigma[2,*]]*f_e, /min0, $ rel_filter = 1.) ; plotting psf height -p2 = errorplot(time, var.psf.param[2,*], var.psf.sigma[2,*], '.', current = w1, position = [0.58, 0.68, 0.88, 0.86], $ +p2 = errorplot(time, var.psf.param[2,*], var.psf.sigma[2,*]*f_e, '.', current = w1, position = [0.58, 0.68, 0.88, 0.86], $ title = 'PSF height', xtitle = 'time [s]', ytitle = 'H [ADU]', xminor = 4, yminor = 4, xrange = xrange, $ yrange = yrange, errorbar_capsize = 0., font_size = font_size) p2a = plot(time, var.psf.param[2,*], overplot = p2, color = 'blue') -p2b = errorplot(time, var.bar.param[2,*], var.bar.sigma[2,*], '.', errorbar_capsize = 0., overplot = p2) +p2b = errorplot(time, var.bar.param[2,*], var.bar.sigma[2,*]*f_e, '.', errorbar_capsize = 0., overplot = p2) p2c = plot(time, var.bar.param[2,*], overplot = p2, color = 'red') -yrange = plot_range([var.psf.param[3,*],var.bar.param[3,*]], error = [var.psf.sigma[3,*],var.bar.sigma[3,*]], $ +yrange = plot_range([var.psf.param[3,*], var.bar.param[3,*]], error = [var.psf.sigma[3,*], var.bar.sigma[3,*]]*f_e, $ rel_filter = 1.) ; plotting psf x centre -p3 = errorplot(time, var.psf.param[3,*], var.psf.sigma[3,*], '.', current = w1, position = [0.16, 0.41, 0.46, 0.59], $ +p3 = errorplot(time, var.psf.param[3,*], var.psf.sigma[3,*]*f_e, '.', current = w1, position = [0.16, 0.41, 0.46, 0.59], $ title = 'x position', xtitle = 'time [s]', ytitle = 'x [px]', xminor = 4, yminor = 4, xrange = xrange, $ yrange = yrange, errorbar_capsize = 0., font_size = font_size) p3a = plot(time, var.psf.param[3,*], overplot = p3, color = 'blue') -p3b = errorplot(time, var.bar.param[3,*], var.bar.sigma[3,*], '.', errorbar_capsize = 0., overplot = p3) +p3b = errorplot(time, var.bar.param[3,*], var.bar.sigma[3,*]*f_e, '.', errorbar_capsize = 0., overplot = p3) p3c = plot(time, var.bar.param[3,*], overplot = p3, color = 'red') -yrange = plot_range([var.psf.param[4,*],var.bar.param[4,*]], error = [var.psf.sigma[4,*],var.bar.sigma[4,*]], rel_filter = 1.) +yrange = plot_range([var.psf.param[4,*], var.bar.param[4,*]], error = [var.psf.sigma[4,*], var.bar.sigma[4,*]]*f_e, rel_filter = 1.) ; plotting psf y centre -p4 = errorplot(time, var.psf.param[4,*], var.psf.sigma[4,*], '.', current = w1, position = [0.58, 0.41, 0.88, 0.59], $ +p4 = errorplot(time, var.psf.param[4,*], var.psf.sigma[4,*]*f_e, '.', current = w1, position = [0.58, 0.41, 0.88, 0.59], $ title = 'y position', xtitle = 'time [s]', ytitle = 'y [px]', xminor = 4, yminor = 4, xrange = xrange, $ yrange = yrange, errorbar_capsize = 0., font_size = font_size) p4a = plot(time, var.psf.param[4,*], overplot = p4, color = 'blue') -p4b = errorplot(time, var.bar.param[4,*], var.bar.sigma[4,*], '.', errorbar_capsize = 0., overplot = p4) +p4b = errorplot(time, var.bar.param[4,*], var.bar.sigma[4,*]*f_e, '.', errorbar_capsize = 0., overplot = p4) p4c = plot(time, var.bar.param[4,*], overplot = p4, color = 'red') -yrange = plot_range([var.psf.param[5,*],var.psf.param[6,*],var.bar.param[5,*],var.bar.param[6,*]], $ - error = [var.psf.sigma[5,*],var.psf.sigma[6,*],var.bar.sigma[5,*],var.bar.sigma[6,*]], rel_filter = 1., /min0) +yrange = plot_range([var.psf.param[5,*], var.psf.param[6,*], var.bar.param[5,*], var.bar.param[6,*]], $ + error = [var.psf.sigma[5,*], var.psf.sigma[6,*], var.bar.sigma[5,*], var.bar.sigma[6,*]]*f_e, rel_filter = 1., /min0) ; plotting psf sigma_x -p5 = errorplot(time, var.psf.param[5,*], var.psf.sigma[5,*], '.', current = w1, position = [0.16, 0.14, 0.46, 0.32], $ +p5 = errorplot(time, var.psf.param[5,*], var.psf.sigma[5,*]*f_e, '.', current = w1, position = [0.16, 0.14, 0.46, 0.32], $ title = 'PSF x-width', xtitle = 'time [s]', ytitle = '$\sigma_x$ [px]', xminor = 4, yminor = 4, $ xrange = xrange, yrange = yrange, errorbar_capsize = 0., font_size = font_size) p5a = plot(time, var.psf.param[5,*], overplot = p5, color = 'blue') -p5b = errorplot(time, var.bar.param[5,*], var.bar.sigma[5,*], '.', errorbar_capsize = 0., overplot = p5) +p5b = errorplot(time, var.bar.param[5,*], var.bar.sigma[5,*]*f_e, '.', errorbar_capsize = 0., overplot = p5) p5c = plot(time, var.bar.param[5,*], overplot = p5, color = 'red') ; plotting psf sigma_y -p6 = errorplot(time, var.psf.param[6,*], var.psf.sigma[6,*], '.', current = w1, position = [0.58, 0.14, 0.88, 0.32], $ +p6 = errorplot(time, var.psf.param[6,*], var.psf.sigma[6,*]*f_e, '.', current = w1, position = [0.58, 0.14, 0.88, 0.32], $ title = 'PSF y-width', xtitle = 'time [s]', ytitle = '$\sigma_y$ [px]', xminor = 4, yminor = 4, $ xrange = xrange, yrange = yrange, errorbar_capsize = 0., font_size = font_size) p6a = plot(time, var.psf.param[6,*], overplot = p6, color = 'blue') -p6b = errorplot(time, var.bar.param[6,*], var.bar.sigma[6,*], '.', errorbar_capsize = 0., overplot = p6) +p6b = errorplot(time, var.bar.param[6,*], var.bar.sigma[6,*]*f_e, '.', errorbar_capsize = 0., overplot = p6) p6c = plot(time, var.bar.param[6,*], overplot = p6, color = 'red') ; window 2 w2 = window(dimensions = dimw, buffer = buffer) -yrange = plot_range([var.psf.param[3,*],var.bar.param[3,*]], error = [var.psf.sigma[3,*],var.bar.sigma[3,*]], rel_filter = 1.) +yrange = plot_range([var.psf.param[3,*], var.bar.param[3,*]], error = [var.psf.sigma[3,*], var.bar.sigma[3,*]]*f_e, rel_filter = 1.) ; plotting x position -px = errorplot(time, var.psf.param[3,*], var.psf.sigma[3,*], '.', current = w2, position = [0.16, 0.67, 0.46, 0.86], $ +px = errorplot(time, var.psf.param[3,*], var.psf.sigma[3,*]*f_e, '.', current = w2, position = [0.16, 0.67, 0.46, 0.86], $ title = 'x position', xtitle = 'time [s]', ytitle = 'x [px]', $ xminor = 4, yminor = 4, xrange = xrange, yrange = yrange, $ errorbar_capsize = 0., font_size = font_size) -pxa = plot(time, var.psf.param[3,*], overplot = px, color = 'blue') -pxb = errorplot(time, var.bar.param[3,*], var.bar.sigma[3,*], '.', errorbar_capsize = 0., overplot = px) -pxc = plot(time, var.bar.param[3,*], overplot = px, color = 'red') +pxa = plot(time, var.psf.param[3,*], overplot = px, color = 'blue', name = 'PSF fitting') +pxb = errorplot(time, var.bar.param[3,*], var.bar.sigma[3,*]*f_e, '.', errorbar_capsize = 0., overplot = px) +pxc = plot(time, var.bar.param[3,*], overplot = px, color = 'red', name = 'BAR computation') + +leg3 = legend(target = pxa, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, position = [0.140, 0.920], $ + font_size = font_size) +leg4 = legend(target = pxc, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, position = [0.140, 0.905], $ + font_size = font_size) dx = var.bar.param[3,*] - var.psf.param[3,*] @@ -148,14 +156,14 @@ pdx = plot(time, dx, current = w2, position = [0.16, 0.54, 0.46, 0.62], xtitle = p0x = plot(time, replicate(0, Ndet), thick = 0.5, linestyle = '--', overplot = pdx) -yrange = plot_range([var.psf.param[4,*],var.bar.param[4,*]], error = [var.psf.sigma[4,*],var.bar.sigma[4,*]], rel_filter = 1.) +yrange = plot_range([var.psf.param[4,*], var.bar.param[4,*]], error = [var.psf.sigma[4,*], var.bar.sigma[4,*]]*f_e, rel_filter = 1.) ; plotting y position -py = errorplot(time, var.psf.param[4,*], var.psf.sigma[4,*], '.', current = w2, position = [0.58, 0.67, 0.88, 0.86], $ +py = errorplot(time, var.psf.param[4,*], var.psf.sigma[4,*]*f_e, '.', current = w2, position = [0.58, 0.67, 0.88, 0.86], $ title = 'y position', xtitle = 'time [s]', ytitle = 'y [px]', xminor = 4, yminor = 4, xrange = xrange, $ yrange = yrange, errorbar_capsize = 0., font_size = font_size) pya = plot(time, var.psf.param[4,*], overplot = py, color = 'blue') -pyb = errorplot(time, var.bar.param[4,*], var.bar.sigma[4,*], '.', errorbar_capsize = 0., overplot = py) +pyb = errorplot(time, var.bar.param[4,*], var.bar.sigma[4,*]*f_e, '.', errorbar_capsize = 0., overplot = py) pyc = plot(time, var.bar.param[4,*], overplot = py, color = 'red') dy = var.bar.param[4,*] - var.psf.param[4,*] @@ -166,14 +174,14 @@ pdy = plot(time, dy, current = w2, position = [0.58, 0.54, 0.88, 0.62], xtitle = p0y = plot(time, replicate(0,Ndet), thick = 0.5, linestyle = '--', overplot = pdy) -yrange = plot_range([var.psf.fwhm,var.bar.fwhm], error = [var.psf.s_fwhm,var.bar.s_fwhm], rel_filter = 1., /min0) +yrange = plot_range([var.psf.fwhm, var.bar.fwhm], error = [var.psf.s_fwhm, var.bar.s_fwhm]*f_e, rel_filter = 1., /min0) ; plotting psf FWHM -pfw = errorplot(time, var.psf.fwhm, var.psf.s_fwhm, '.',current = w2, position = [0.16, 0.26, 0.46, 0.45], $ +pfw = errorplot(time, var.psf.fwhm, var.psf.s_fwhm*f_e, '.',current = w2, position = [0.16, 0.26, 0.46, 0.45], $ title = 'FWHM', xtitle = 'time [s]', ytitle = '$\Gamma$ [px]', xminor = 4, yminor = 4, xrange = xrange, $ yrange = yrange, errorbar_capsize = 0., font_size = font_size) pfwa = plot(time, var.psf.fwhm, overplot = pfw, color = 'blue') -pfwb = errorplot(time, var.bar.fwhm, var.bar.s_fwhm, '.', errorbar_capsize = 0., overplot = pfw) +pfwb = errorplot(time, var.bar.fwhm, var.bar.s_fwhm*f_e, '.', errorbar_capsize = 0., overplot = pfw) pfwc = plot(time, var.bar.fwhm, overplot = pfw, color = 'red') dfw = var.bar.fwhm - var.psf.fwhm @@ -183,14 +191,14 @@ pdfw = plot(time, dfw, current = w2, position = [0.16,0.13,0.46,0.21], xtitle = ytitle = '$\Gamma_{bar}$ - $\Gamma_{psf}$ [/]', xrange = xrange, xminor = 4, yminor = 0, font_size = font_size) p0fw = plot(time, replicate(0,Ndet), linestyle = '--', overplot = pdfw) -yrange = plot_range([var.psf.mag,var.bar.mag], error = [var.psf.s_mag,var.bar.s_mag], /reverse, rel_filter = 1.) +yrange = plot_range([var.psf.mag, var.bar.mag], error = [var.psf.s_mag, var.bar.s_mag]*f_e, /reverse, rel_filter = 1.) ; plotting apparent magnitude -pm = errorplot(time, var.psf.mag, var.psf.s_mag, '.', current = w2, position = [0.58, 0.26, 0.88, 0.45], $ +pm = errorplot(time, var.psf.mag, var.psf.s_mag*f_e, '.', current = w2, position = [0.58, 0.26, 0.88, 0.45], $ title = 'Apparent Magnitude', xtitle = 'time [s]', ytitle = 'm [/]', xminor = 4, yminor = 4, $ xrange = xrange, yrange = yrange, errorbar_capsize = 0., font_size = font_size) pma = plot(time, var.psf.mag, overplot = pm, color = 'blue') -pmb = errorplot(time, var.bar.mag, var.bar.s_mag, '.', errorbar_capsize = 0., overplot = pm) +pmb = errorplot(time, var.bar.mag, var.bar.s_mag*f_e, '.', errorbar_capsize = 0., overplot = pm) pmc = plot(time, var.bar.mag, overplot = pm, color = 'red') dm = var.bar.mag - var.psf.mag @@ -204,15 +212,20 @@ p0m = plot(time, replicate(0,Ndet), linestyle = '--', overplot = pdm) ; window 3 w3 = window(dimensions = dimw, buffer = buffer) -yrange = plot_range([var.psf.az,var.bar.az], error = [var.psf.s_az,var.bar.s_az], rel_filter = 1.) +yrange = plot_range([var.psf.az, var.bar.az], error = [var.psf.s_az, var.bar.s_az]*f_e, rel_filter = 1.) ; plotting az of the bolide -paz = errorplot(time, var.psf.az*!radeg, var.psf.s_az*!radeg, '.', current = w3, position = [0.16, 0.67, 0.46, 0.86], $ +paz = errorplot(time, var.psf.az*!radeg, var.psf.s_az*f_e*!radeg, '.', current = w3, position = [0.16, 0.67, 0.46, 0.86], $ title = 'azimuth', xtitle = 'time [s]', ytitle = 'a [deg]', xminor = 4, yminor = 4, xrange = xrange, $ yrange = yrange*!radeg, errorbar_capsize = 0., font_size = font_size) -paza = plot(time, var.psf.az*!radeg, overplot = paz, color = 'blue') -pazb = errorplot(time, var.bar.az*!radeg, var.bar.s_az*!radeg, '.', errorbar_capsize = 0., overplot = paz) -pazc = plot(time, var.bar.az*!radeg, overplot = paz, color = 'red') +paza = plot(time, var.psf.az*!radeg, overplot = paz, color = 'blue', name = 'PSF fitting') +pazb = errorplot(time, var.bar.az*!radeg, var.bar.s_az*f_e*!radeg, '.', errorbar_capsize = 0., overplot = paz) +pazc = plot(time, var.bar.az*!radeg, overplot = paz, color = 'red', name = 'BAR computation') + +leg5 = legend(target = paza, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, position = [0.140, 0.920], $ + font_size = font_size) +leg6 = legend(target = pazc, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, position = [0.140, 0.905], $ + font_size = font_size) daz = var.bar.az - var.psf.az closest, dAZ @@ -223,14 +236,14 @@ pdaz = plot(time, daz*!ramin, current = w3, position = [0.16, 0.54, 0.46, 0.62], p0az = plot(time, replicate(0,Ndet), linestyle = '--', overplot = pdaz) -yrange = plot_range([var.psf.alt,var.bar.alt], error = [var.psf.s_alt,var.bar.s_alt], rel_filter = 1.) +yrange = plot_range([var.psf.alt, var.bar.alt], error = [var.psf.s_alt, var.bar.s_alt]*f_e, rel_filter = 1.) ; plotting alt of the bolide -palt = errorplot(time, var.psf.alt*!radeg, var.psf.s_alt*!radeg, '.', current = w3, position = [0.58, 0.67, 0.88, 0.86], $ +palt = errorplot(time, var.psf.alt*!radeg, var.psf.s_alt*f_e*!radeg, '.', current = w3, position = [0.58, 0.67, 0.88, 0.86], $ title = 'elevation', xtitle = 'time [s]', ytitle = 'h [deg]', xminor = 4, yminor = 4, xrange = xrange, $ yrange = yrange*!radeg, errorbar_capsize = 0., font_size = font_size) palta = plot(time, var.psf.alt*!radeg, overplot = palt, color = 'blue') -paltb = errorplot(time, var.bar.alt*!radeg, var.bar.s_alt*!radeg, '.', errorbar_capsize = 0., overplot = palt) +paltb = errorplot(time, var.bar.alt*!radeg, var.bar.s_alt*f_e*!radeg, '.', errorbar_capsize = 0., overplot = palt) paltc = plot(time, var.bar.alt*!radeg, overplot = palt, color = 'red') dalt = var.bar.alt - var.psf.alt @@ -241,14 +254,14 @@ pdalt = plot(time, dalt*!ramin, current = w3, position = [0.58, 0.54, 0.88, 0.62 p0alt = plot(time, replicate(0,Ndet), linestyle = '--', overplot = pdalt) -yrange = plot_range([var.psf.ra,var.bar.ra], error = [var.psf.s_ra,var.bar.s_ra], rel_filter = 1.) +yrange = plot_range([var.psf.ra, var.bar.ra], error = [var.psf.s_ra, var.bar.s_ra]*f_e, rel_filter = 1.) ; plotting ra of the bolide -pra = errorplot(time, var.psf.ra*!radeg, var.psf.s_ra*!radeg, '.', current = w3, position = [0.16, 0.26, 0.46, 0.45], $ +pra = errorplot(time, var.psf.ra*!radeg, var.psf.s_ra*f_e*!radeg, '.', current = w3, position = [0.16, 0.26, 0.46, 0.45], $ title = 'right ascension', xtitle = 'time [s]', ytitle = '$\alpha$ [deg]', xminor = 4, yminor = 4, $ xrange = xrange, yrange = yrange*!radeg, errorbar_capsize = 0., font_size = font_size) praa = plot(time, var.psf.ra*!radeg, overplot = pra, color = 'blue') -prab = errorplot(time, var.bar.ra*!radeg, var.bar.s_ra*!radeg, '.', errorbar_capsize = 0., overplot = pra) +prab = errorplot(time, var.bar.ra*!radeg, var.bar.s_ra*f_e*!radeg, '.', errorbar_capsize = 0., overplot = pra) prac = plot(time, var.bar.ra*!radeg, overplot = pra, color = 'red') dra = var.bar.ra - var.psf.ra @@ -259,14 +272,14 @@ pdra = plot(time, dra*!ramin, current = w3, position = [0.16,0.13,0.46,0.21], xt p0ra = plot(time, replicate(0,Ndet), linestyle = '--', overplot = pdra) -yrange = plot_range([var.psf.dec,var.bar.dec], error = [var.psf.s_dec,var.bar.s_dec], rel_filter = 1.) +yrange = plot_range([var.psf.dec, var.bar.dec], error = [var.psf.s_dec, var.bar.s_dec]*f_e, rel_filter = 1.) ; plotting dec of the bolide -pdec = errorplot(time, var.psf.dec*!radeg, var.psf.s_dec*!radeg, '.', current = w3, position = [0.58, 0.26, 0.88, 0.45], $ +pdec = errorplot(time, var.psf.dec*!radeg, var.psf.s_dec*f_e*!radeg, '.', current = w3, position = [0.58, 0.26, 0.88, 0.45], $ title = 'declination ', xtitle = 'time [s]', ytitle = '$\delta$ [deg]', xminor = 4, yminor = 4, $ xrange = xrange, yrange = yrange*!radeg, errorbar_capsize = 0., font_size = font_size) pdeca = plot(time, var.psf.dec*!radeg, overplot = pdec, color = 'blue') -pdecb = errorplot(time, var.bar.dec*!radeg, var.bar.s_dec*!radeg, '.', errorbar_capsize = 0., overplot = pdec) +pdecb = errorplot(time, var.bar.dec*!radeg, var.bar.s_dec*f_e*!radeg, '.', errorbar_capsize = 0., overplot = pdec) pdecc = plot(time, var.bar.dec*!radeg, overplot = pdec, color = 'red') ddec = var.bar.dec - var.psf.dec diff --git a/code/functions/report/dynamic_report.pro b/code/functions/report/dynamic_report.pro index c511ac6..bd3b90b 100644 --- a/code/functions/report/dynamic_report.pro +++ b/code/functions/report/dynamic_report.pro @@ -22,6 +22,10 @@ adjust_font_size, font_size, 96., dpi = dpi ; scale for dpi value of the device, correcting font size scaling issue dimw = roundf(dimw*dpi) +; suppressing errors if required +if config.dynamic.oplot_errors then f_e = 1. else f_e = !values.f_NaN +if config.dynamic.oplot_errorbands then f_b = 1. else f_b = !values.f_NaN + ; window 1 w1 = window(dimensions = dimw, buffer = buffer) @@ -38,8 +42,8 @@ p1a = plot(var.atmosphere.hgt, var.atmosphere.rho_exp, overplot = p1, color = 'b ; plot ranges for t/h/v/M trange = plot_range(var.results.time) hrange = plot_range(var.results.triang.res.hgt, /reverse) -vrange = plot_range(var.results.triang.res.vel, error = var.results.triang.err.vel, rel_filter = 1.) -mrange = plot_range(var.results.triang.res.mag, error = var.results.triang.err.mag, err_filter = 1., /reverse) +vrange = plot_range(var.results.triang.res.vel, error = var.results.triang.err.vel*f_e, rel_filter = 1., /minge0) +mrange = plot_range(var.results.triang.res.mag, error = var.results.triang.err.mag*f_e, err_filter = 1., /reverse) ; sorting for hgt values for fit line plots iih = sort(var.results.triang.res.hgt) @@ -48,13 +52,13 @@ iih = sort(var.results.triang.res.hgt) ; right column : kale06_dyn and _phd ; hgt vs speed -p2 = errorplot(var.results.triang.res.hgt, var.results.triang.res.vel, var.results.triang.err.vel, 'o', current = w1, $ +p2 = errorplot(var.results.triang.res.hgt, var.results.triang.res.vel, var.results.triang.err.vel*f_e, 'o', current = w1, $ position = [0.16, 0.41, 0.46, 0.59], title = 'speed', xtitle = 'H [km]', ytitle = 'V [km/s]', $ xminor = 4, yminor = 4, xrange = hrange, yrange = vrange, font_size = font_size, sym_size = 0.1, $ /sym_filled, errorbar_capsize = 0.02, errorbar_thick = 0.5) ; hgt vs mag -p3 = errorplot(var.results.triang.res.hgt, var.results.triang.res.mag, var.results.triang.err.mag, 'o', current = w1, $ +p3 = errorplot(var.results.triang.res.hgt, var.results.triang.res.mag, var.results.triang.err.mag*f_e, 'o', current = w1, $ position = [0.16, 0.14, 0.46, 0.32], title = 'absolute magnitude', xtitle = 'H [km]', ytitle = 'M [/]', $ xminor = 4, yminor = 4, xrange = hrange, yrange = mrange, font_size = font_size, sym_size = 0.1, $ /sym_filled, errorbar_capsize = 0.02, errorbar_thick = 0.5) @@ -68,19 +72,19 @@ p3b = plot(var.results.triang.res.hgt[iih], var.results.grit11_phd.fit.res.mag[i thick = 2) ; time vs hgt -p4 = errorplot(var.results.time, var.results.triang.res.hgt, var.results.triang.err.hgt, 'o', current = w1, $ +p4 = errorplot(var.results.time, var.results.triang.res.hgt, var.results.triang.err.hgt*f_e, 'o', current = w1, $ position = [0.58, 0.68, 0.88, 0.86], title = 'height above sea level', xtitle = 't [s]', ytitle = 'H [km]', $ xminor = 4, yminor = 4, xrange = trange, yrange = reverse(hrange), font_size = font_size, sym_size = 0.1, $ /sym_filled, errorbar_capsize = 0.02, errorbar_thick = 0.5) ; time vs speed -p5 = errorplot(var.results.time, var.results.triang.res.vel, var.results.triang.err.vel, 'o', current = w1, $ +p5 = errorplot(var.results.time, var.results.triang.res.vel, var.results.triang.err.vel*f_e, 'o', current = w1, $ position = [0.58, 0.41, 0.88, 0.59], title = 'speed', xtitle = 't [s]', ytitle = 'V [km/s]', $ xminor = 4, yminor = 4, xrange = trange, yrange = vrange, font_size = font_size, sym_size = 0.1, $ /sym_filled, errorbar_capsize = 0.02, errorbar_thick = 0.5) ; time vs mag -p6 = errorplot(var.results.time, var.results.triang.res.mag, var.results.triang.err.mag, 'o', current = w1, $ +p6 = errorplot(var.results.time, var.results.triang.res.mag, var.results.triang.err.mag*f_e, 'o', current = w1, $ position = [0.58, 0.14, 0.88, 0.32], title = 'absolute magnitude', xtitle = 't [s]', ytitle = 'M [/]', $ xminor = 4, yminor = 4, xrange = trange, yrange = mrange, font_size = font_size, sym_size = 0.1, $ /sym_filled, errorbar_capsize = 0.02, errorbar_thick = 0.5) @@ -95,43 +99,41 @@ p5b = plot(var.results.time, var.results.kale06_phd.fit.res.vel, overplot = p5, p6a = plot(var.results.time, var.results.kale06_phd.fit.res.mag, overplot = p6, color = 'red', thick = 2) leg1 = legend(target = p2a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ - position = [0.14, 0.92], font_size = font_size) + position = [0.140, 0.920], font_size = font_size) leg2 = legend(target = p2b, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ - position = [0.14, 0.90], font_size = font_size) + position = [0.140, 0.905], font_size = font_size) leg3 = legend(target = p5a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ - position = [0.56, 0.92], font_size = font_size) + position = [0.560, 0.920], font_size = font_size) leg4 = legend(target = p5b, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ - position = [0.56, 0.90], font_size = font_size) + position = [0.560, 0.905], font_size = font_size) ; window 2 w2 = window(dimensions = dimw, buffer = buffer) ; text for assumed drag coefficient and meteoroid density -str1 = '$\Gamma$ = ' + strtrim(string(config.dynamic.gamma[0], format = '(f20.3)'), 2) + ' $\pm$ ' + $ - strtrim(string(config.dynamic.gamma[1], format = '(f20.3)'), 2) -str2 = '$\rho$ = ' + strtrim(string(config.dynamic.rho[0], format = '(f20.1)'), 2) + ' $\pm$ ' + $ - strtrim(string(config.dynamic.rho[1], format = '(f20.1)'), 2) + ' kg/m$^3$' - -t1 = text(0.16, 0.92, str1, target = w2, font_size = font_size, vertical_alignment = 0.5) -t1 = text(0.16, 0.90, str2, target = w2, font_size = font_size, vertical_alignment = 0.5) +str1 = '$\Gamma$ = ' + strtrim(string(config.dynamic.gamma[0], format = '(f20.2)'), 2) + ' $\pm$ ' + $ + strtrim(string(config.dynamic.gamma[1], format = '(f20.2)'), 2) +str2 = '$\rho$ = ' + strtrim(string(config.dynamic.rho[0], format = '(i20)'), 2) + ' $\pm$ ' + $ + strtrim(string(config.dynamic.rho[1], format = '(i20)'), 2) + ' kg/m$^3$' yrange = plot_range([var.results.grit11_dyn.param.D_ini[0], var.results.grit11_phd.fit.res.msr, $ var.results.kale06_dyn.param.D_ini[0], var.results.kale06_phd.fit.res.msr], $ error = [var.results.grit11_dyn.param.D_ini[1]*!values.f_NaN, var.results.grit11_phd.fit.err.msr, $ - var.results.kale06_dyn.param.D_ini[1]*!values.f_NaN, var.results.kale06_phd.fit.err.msr]) + var.results.kale06_dyn.param.D_ini[1]*!values.f_NaN, var.results.kale06_phd.fit.err.msr]*f_b, /minge0) ; hgt vs msr - grit11_dyn and _phd p7 = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.msr[iih], '--', current = w2, $ position = [0.16, 0.68, 0.46, 0.86], title = 'mass-section ratio', xtitle = 'H [km]', ytitle = 'D [kg/m$^2$]', $ - xminor = 4, yminor = 4, xrange = hrange, yrange = yrange, font_size = font_size, color = 'blue', thick = 2) -p7a = plot(var.results.triang.res.hgt[iih], var.results.grit11_phd.fit.res.msr[iih], overplot = p7, color = 'blue', thick = 2) + xminor = 4, yminor = 4, xrange = hrange, yrange = yrange, font_size = font_size, color = 'blue', thick = 2, name = 'grit11_dyn') +p7a = plot(var.results.triang.res.hgt[iih], var.results.grit11_phd.fit.res.msr[iih], overplot = p7, color = 'blue', thick = 2, $ + name = 'grit11_phd') minfp = var.results.grit11_phd.fit.res.msr[iih] - var.results.grit11_phd.fit.err.msr[iih] maxfp = var.results.grit11_phd.fit.res.msr[iih] + var.results.grit11_phd.fit.err.msr[iih] iig = where(finite(minfp) and finite(maxfp)) if n_elements(iig) gt 1 then $ - poly_p7 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p7 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'blue', fill_transparency = 80, linestyle = '', overplot = p7) if isa(poly_p7) then poly_p7.order, /send_to_back @@ -139,31 +141,59 @@ if isa(poly_p7) then poly_p7.order, /send_to_back ; hgt vs msr - kale06_dyn and _phd p10 = plot(var.results.kale06_dyn.fit.res.hgt, var.results.kale06_dyn.fit.res.msr, '--', current = w2, $ position = [0.58, 0.68, 0.88, 0.86], title = 'mass-section ratio', xtitle = 'H [km]', ytitle = 'D [kg/m$^2$]', $ - xminor = 4, yminor = 4, xrange = hrange, yrange = yrange, font_size = font_size, color = 'red', thick = 2) -p10a = plot(var.results.kale06_phd.fit.res.hgt, var.results.kale06_phd.fit.res.msr, overplot = p10, color = 'red', thick = 2) + xminor = 4, yminor = 4, xrange = hrange, yrange = yrange, font_size = font_size, color = 'red', thick = 2, name = 'kale06_dyn') +p10a = plot(var.results.kale06_phd.fit.res.hgt, var.results.kale06_phd.fit.res.msr, overplot = p10, color = 'red', thick = 2, $ + name = 'kale06_phd') minfp = var.results.kale06_phd.fit.res.msr - var.results.kale06_phd.fit.err.msr maxfp = var.results.kale06_phd.fit.res.msr + var.results.kale06_phd.fit.err.msr iig = where(finite(minfp) and finite(maxfp)) if n_elements(iig) gt 1 then $ - poly_p10 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p10 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'red', fill_transparency = 80, linestyle = '', overplot = p10) if isa(poly_p10) then poly_p10.order, /send_to_back ; adding another y-axis with size scale -ct = [0., median(2.*var.results.kale06_phd.fit.res.rad/var.results.kale06_phd.fit.res.msr, /even)] -yaxis = axis('Y', target = p10, location = 'right', title = 'size [m]', coord_transform = ct, $ - yrange = ct[0] + ct[1]*yrange, tickfont_size = font_size, minor = 4) - -; hiding the standard right y-axis of p10 -p10['axis3'].hide = 1 +if var.results.kale06_phd.status eq 0 then begin + + ct = [0., median(2.*var.results.kale06_phd.fit.res.rad/var.results.kale06_phd.fit.res.msr, /even)] + + yrange_size = ct[0] + ct[1]*yrange + + ; deciding the measure unit + uom = closest_metric_prefix(yrange_size[1]) + + ; updating axis range and coord_transform + ct = ct*10.^(-uom.power) + yrange_size = ct[0] + ct[1]*yrange + title = 'size [' + uom.prefix + 'm]' + + yaxis = axis('Y', target = p10, location = 'right', title = title, coord_transform = ct, $ + yrange = yrange_size, tickfont_size = font_size, minor = 4) + + ; hiding the standard right y-axis of p10 + p10['axis3'].hide = 1 + +endif + +leg5 = legend(target = p7, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ + position = [0.140, 0.920], font_size = font_size) +leg6 = legend(target = p7a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ + position = [0.140, 0.905], font_size = font_size) +leg7 = legend(target = p10, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ + position = [0.560, 0.920], font_size = font_size) +leg8 = legend(target = p10a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ + position = [0.560, 0.905], font_size = font_size) + +t1 = text(0.160, 0.090, str1, target = w2, font_size = font_size, vertical_alignment = 0.5) +t2 = text(0.160, 0.075, str2, target = w2, font_size = font_size, vertical_alignment = 0.5) yrange = plot_range([var.results.grit11_dyn.param.M_ini[0], var.results.grit11_phd.fit.res.mass, $ var.results.kale06_dyn.param.M_ini[0], var.results.kale06_phd.fit.res.mass], $ error = [var.results.grit11_dyn.param.M_ini[1]*!values.f_NaN, var.results.grit11_phd.fit.err.mass, $ - var.results.kale06_dyn.param.M_ini[1]*!values.f_NaN, var.results.kale06_phd.fit.err.mass], /log) + var.results.kale06_dyn.param.M_ini[1]*!values.f_NaN, var.results.kale06_phd.fit.err.mass]*f_b, /log) ; hgt vs mass - grit11_dyn and _phd p8 = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.mass[iih], '--', current = w2, /ylog, $ @@ -178,7 +208,7 @@ maxfp = var.results.grit11_phd.fit.res.mass[iih] + var.results.grit11_phd.fit.er iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p8 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p8 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'blue', fill_transparency = 80, linestyle = '', overplot = p8) if isa(poly_p8) then poly_p8.order, /send_to_back @@ -196,7 +226,7 @@ maxfp = var.results.kale06_phd.fit.res.mass + var.results.kale06_phd.fit.err.mas iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p11 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p11 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'red', fill_transparency = 80, linestyle = '', overplot = p11) if isa(poly_p11) then poly_p11.order, /send_to_back @@ -204,7 +234,7 @@ if isa(poly_p11) then poly_p11.order, /send_to_back yrange = plot_range([var.results.grit11_dyn.param.S_ini[0], var.results.grit11_phd.fit.res.sect, $ var.results.kale06_dyn.param.S_ini[0], var.results.kale06_phd.fit.res.sect], $ error = [var.results.grit11_dyn.param.S_ini[1]*!values.f_NaN, var.results.grit11_phd.fit.err.sect, $ - var.results.kale06_dyn.param.S_ini[1]*!values.f_NaN, var.results.kale06_phd.fit.err.sect], /log) + var.results.kale06_dyn.param.S_ini[1]*!values.f_NaN, var.results.kale06_phd.fit.err.sect]*f_b, /log) ; hgt vs section - grit11_dyn and _phd p9 = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.sect[iih], '--', current = w2, /ylog, $ @@ -219,7 +249,7 @@ maxfp = var.results.grit11_phd.fit.res.sect[iih] + var.results.grit11_phd.fit.er iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p9 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p9 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'blue', fill_transparency = 80, linestyle = '', overplot = p9) if isa(poly_p9) then poly_p9.order, /send_to_back @@ -237,7 +267,7 @@ maxfp = var.results.kale06_phd.fit.res.sect + var.results.kale06_phd.fit.err.sec iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p12 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p12 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'red', fill_transparency = 80, linestyle = '', overplot = p12) ; window 3 @@ -250,7 +280,7 @@ yrange = plot_range([var.results.grit11_dyn.fit.res.Re_1*!values.f_NaN, var.resu error = [var.results.grit11_dyn.fit.err.Re_1*!values.f_NaN, var.results.grit11_phd.fit.err.Re_1, $ var.results.kale06_dyn.fit.err.Re_1*!values.f_NaN, var.results.kale06_phd.fit.err.Re_1, $ var.results.grit11_dyn.fit.err.Re_2*!values.f_NaN, var.results.grit11_phd.fit.err.Re_2, $ - var.results.kale06_dyn.fit.err.Re_2*!values.f_NaN, var.results.kale06_phd.fit.err.Re_2], /log) + var.results.kale06_dyn.fit.err.Re_2*!values.f_NaN, var.results.kale06_phd.fit.err.Re_2]*f_b, /log) ; hgt vs Re - grit11_dyn and _phd p13 = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.Re_1[iih], '--', current = w3, /ylog, $ @@ -265,7 +295,7 @@ maxfp = var.results.grit11_phd.fit.res.Re_1[iih] + var.results.grit11_phd.fit.er iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p13 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p13 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'blue', fill_transparency = 80, linestyle = '', overplot = p13) p13b = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.Re_2[iih], '--', overplot = p13, $ @@ -278,7 +308,7 @@ maxfp = var.results.grit11_phd.fit.res.Re_2[iih] + var.results.grit11_phd.fit.er iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p13c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p13c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'cyan', fill_transparency = 80, linestyle = '', overplot = p13) if isa(poly_p13) then poly_p13.order, /send_to_back @@ -297,7 +327,7 @@ maxfp = var.results.kale06_phd.fit.res.Re_1 + var.results.kale06_phd.fit.err.Re_ iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p16 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p16 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'red', fill_transparency = 80, linestyle = '', overplot = p16) p16b = plot(var.results.kale06_dyn.fit.res.hgt, var.results.kale06_dyn.fit.res.Re_2, '--', overplot = p16, $ @@ -310,20 +340,20 @@ maxfp = var.results.kale06_phd.fit.res.Re_2 + var.results.kale06_phd.fit.err.Re_ iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p16c = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p16c = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'light salmon', fill_transparency = 80, linestyle = '', overplot = p16) if isa(poly_p16) then poly_p16.order, /send_to_back if isa(poly_p16c) then poly_p16c.order, /send_to_back leg5 = legend(target = p13a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ - position = [0.14, 0.92], font_size = font_size) + position = [0.140, 0.920], font_size = font_size) leg6 = legend(target = p13c, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ - position = [0.14, 0.90], font_size = font_size) + position = [0.140, 0.905], font_size = font_size) leg7 = legend(target = p16a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ - position = [0.56, 0.92], font_size = font_size) + position = [0.560, 0.920], font_size = font_size) leg8 = legend(target = p16c, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ - position = [0.56, 0.90], font_size = font_size) + position = [0.560, 0.905], font_size = font_size) yrange = plot_range([var.results.grit11_dyn.fit.res.Kn_1*!values.f_NaN, var.results.grit11_phd.fit.res.Kn_1, $ var.results.kale06_dyn.fit.res.Kn_1*!values.f_NaN, var.results.kale06_phd.fit.res.Kn_1, $ @@ -340,7 +370,7 @@ yrange = plot_range([var.results.grit11_dyn.fit.res.Kn_1*!values.f_NaN, var.resu var.results.grit11_dyn.fit.err.Knr_1*!values.f_NaN, var.results.grit11_phd.fit.err.Knr_1, $ var.results.kale06_dyn.fit.err.Knr_1*!values.f_NaN, var.results.kale06_phd.fit.err.Knr_1, $ var.results.grit11_dyn.fit.err.Knr_2*!values.f_NaN, var.results.grit11_phd.fit.err.Knr_2, $ - var.results.kale06_dyn.fit.err.Knr_2*!values.f_NaN, var.results.kale06_phd.fit.err.Knr_2], /log) + var.results.kale06_dyn.fit.err.Knr_2*!values.f_NaN, var.results.kale06_phd.fit.err.Knr_2]*f_b, /log) ; hgt vs Kn - grit11_dyn and _phd p14 = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.Kn_1[iih], '--', current = w3, /ylog, $ @@ -355,7 +385,7 @@ maxfp = var.results.grit11_phd.fit.res.Kn_1[iih] + var.results.grit11_phd.fit.er iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p14 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p14 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'blue', fill_transparency = 80, linestyle = '', overplot = p14) p14b = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.Kn_2[iih], '--', overplot = p14, $ @@ -368,7 +398,7 @@ maxfp = var.results.grit11_phd.fit.res.Kn_2[iih] + var.results.grit11_phd.fit.er iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p14c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p14c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'cyan', fill_transparency = 80, linestyle = '', overplot = p14) if isa(poly_p14) then poly_p14.order, /send_to_back @@ -386,7 +416,7 @@ maxfp = var.results.kale06_phd.fit.res.Kn_1 + var.results.kale06_phd.fit.err.Kn_ iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p17 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p17 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'red', fill_transparency = 80, linestyle = '', overplot = p17) p17b = plot(var.results.kale06_dyn.fit.res.hgt, var.results.kale06_dyn.fit.res.Kn_2, '--', overplot = p17, $ @@ -399,7 +429,7 @@ maxfp = var.results.kale06_phd.fit.res.Kn_2 + var.results.kale06_phd.fit.err.Kn_ iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p17c = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p17c = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'light salmon', fill_transparency = 80, linestyle = '', overplot = p17) if isa(poly_p17) then poly_p17.order, /send_to_back @@ -418,7 +448,7 @@ maxfp = var.results.grit11_phd.fit.res.Knr_1[iih] + var.results.grit11_phd.fit.e iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p15 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p15 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'blue', fill_transparency = 80, linestyle = '', overplot = p15) p15b = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.Knr_2[iih], '--', overplot = p15, $ @@ -431,7 +461,7 @@ maxfp = var.results.grit11_phd.fit.res.Knr_2[iih] + var.results.grit11_phd.fit.e iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p15c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p15c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'cyan', fill_transparency = 80, linestyle = '', overplot = p15) if isa(poly_p15) then poly_p15.order, /send_to_back @@ -449,7 +479,7 @@ maxfp = var.results.kale06_phd.fit.res.Knr_1 + var.results.kale06_phd.fit.err.Kn iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p18 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p18 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'red', fill_transparency = 80, linestyle = '', overplot = p18) p18b = plot(var.results.kale06_dyn.fit.res.hgt, var.results.kale06_dyn.fit.res.Knr_2, '--', overplot = p18, $ @@ -462,7 +492,7 @@ maxfp = var.results.kale06_phd.fit.res.Knr_2 + var.results.kale06_phd.fit.err.Kn iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p18c = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p18c = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'light salmon', fill_transparency = 80, linestyle = '', overplot = p18) if isa(poly_p18) then poly_p18.order, /send_to_back @@ -478,7 +508,7 @@ yrange = plot_range([var.results.grit11_dyn.fit.res.pdyn_1*!values.f_NaN, var.re error = [var.results.grit11_dyn.fit.err.pdyn_1*!values.f_NaN, var.results.grit11_phd.fit.err.pdyn_1, $ var.results.kale06_dyn.fit.err.pdyn_1*!values.f_NaN, var.results.kale06_phd.fit.err.pdyn_1, $ var.results.grit11_dyn.fit.err.pdyn_2*!values.f_NaN, var.results.grit11_phd.fit.err.pdyn_2, $ - var.results.kale06_dyn.fit.err.pdyn_2*!values.f_NaN, var.results.kale06_phd.fit.err.pdyn_2], /log) + var.results.kale06_dyn.fit.err.pdyn_2*!values.f_NaN, var.results.kale06_phd.fit.err.pdyn_2]*f_b, /log) ; hgt vs Pdyn - grit11_dyn and _phd p19 = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.pdyn_1[iih], '--', current = w4, /ylog, $ @@ -486,27 +516,27 @@ p19 = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.pdyn_ xminor = 4, yminor = 4, xrange = hrange, yrange = yrange, font_size = font_size, color = 'blue', thick = 2, $ ytickunits = 'exponent') p19a = plot(var.results.triang.res.hgt[iih], var.results.grit11_phd.fit.res.pdyn_1[iih], overplot = p19, $ - color = 'blue', thick = 2) + color = 'blue', thick = 2, name = 'grit11 - atmosphere') minfp = var.results.grit11_phd.fit.res.pdyn_1[iih] - var.results.grit11_phd.fit.err.pdyn_1[iih] maxfp = var.results.grit11_phd.fit.res.pdyn_1[iih] + var.results.grit11_phd.fit.err.pdyn_1[iih] iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p19 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p19 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'blue', fill_transparency = 80, linestyle = '', overplot = p19) p19b = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.pdyn_2[iih], '--', overplot = p19, $ color = 'cyan', thick = 2) p19c = plot(var.results.triang.res.hgt[iih], var.results.grit11_phd.fit.res.pdyn_2[iih], overplot = p19, $ - color = 'cyan', thick = 2) + color = 'cyan', thick = 2, name = 'grit11 - shock') minfp = var.results.grit11_phd.fit.res.pdyn_2[iih] - var.results.grit11_phd.fit.err.pdyn_2[iih] maxfp = var.results.grit11_phd.fit.res.pdyn_2[iih] + var.results.grit11_phd.fit.err.pdyn_2[iih] iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p19 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p19 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'cyan', fill_transparency = 80, linestyle = '', overplot = p19) if isa(poly_p19) then poly_p19.order, /send_to_back @@ -517,32 +547,42 @@ p22 = plot(var.results.kale06_dyn.fit.res.hgt, var.results.kale06_dyn.fit.res.pd position = [0.58, 0.68, 0.88, 0.86], title = 'dynamic pressure', xtitle = 'H [km]', ytitle = 'P$_{dyn}$ [Pa]', $ xminor = 4, yminor = 4, xrange = hrange, yrange = yrange, font_size = font_size, color = 'red', thick = 2, $ ytickunits = 'exponent') -p22a = plot(var.results.kale06_phd.fit.res.hgt, var.results.kale06_phd.fit.res.pdyn_1, overplot = p22, color = 'red', thick = 2) +p22a = plot(var.results.kale06_phd.fit.res.hgt, var.results.kale06_phd.fit.res.pdyn_1, overplot = p22, color = 'red', thick = 2, $ + name = 'kale06 - atmosphere') minfp = var.results.kale06_phd.fit.res.pdyn_1 - var.results.kale06_phd.fit.err.pdyn_1 maxfp = var.results.kale06_phd.fit.res.pdyn_1 + var.results.kale06_phd.fit.err.pdyn_1 iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p22 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p22 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'red', fill_transparency = 80, linestyle = '', overplot = p22) p22b = plot(var.results.kale06_dyn.fit.res.hgt, var.results.kale06_dyn.fit.res.pdyn_2, '--', overplot = p22, $ color = 'light salmon', thick = 2) p22c = plot(var.results.kale06_phd.fit.res.hgt, var.results.kale06_phd.fit.res.pdyn_2, overplot = p22, $ - color = 'light salmon', thick = 2) + color = 'light salmon', thick = 2, name = 'kale06 - shock') minfp = var.results.kale06_phd.fit.res.pdyn_2 - var.results.kale06_phd.fit.err.pdyn_2 maxfp = var.results.kale06_phd.fit.res.pdyn_2 + var.results.kale06_phd.fit.err.pdyn_2 iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p22c = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p22c = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'light salmon', fill_transparency = 80, linestyle = '', overplot = p22) if isa(poly_p22) then poly_p22.order, /send_to_back if isa(poly_p22c) then poly_p22c.order, /send_to_back +leg9 = legend(target = p19a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ + position = [0.140, 0.920], font_size = font_size) +leg10 = legend(target = p19c, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ + position = [0.140, 0.905], font_size = font_size) +leg11 = legend(target = p22a, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ + position = [0.560, 0.920], font_size = font_size) +leg12 = legend(target = p22c, linestyle = '', vertical_alignment = 0.5, horizontal_alignment = 0, sample_width = 0.08, $ + position = [0.560, 0.905], font_size = font_size) + yrange = plot_range([var.results.grit11_dyn.fit.res.temp_1*!values.f_NaN, var.results.grit11_phd.fit.res.temp_1, $ var.results.kale06_dyn.fit.res.temp_1*!values.f_NaN, var.results.kale06_phd.fit.res.temp_1, $ var.results.grit11_dyn.fit.res.temp_2*!values.f_NaN, var.results.grit11_phd.fit.res.temp_2, $ @@ -550,7 +590,7 @@ yrange = plot_range([var.results.grit11_dyn.fit.res.temp_1*!values.f_NaN, var.re error = [var.results.grit11_dyn.fit.err.temp_1*!values.f_NaN, var.results.grit11_phd.fit.err.temp_1, $ var.results.kale06_dyn.fit.err.temp_1*!values.f_NaN, var.results.kale06_phd.fit.err.temp_1, $ var.results.grit11_dyn.fit.err.temp_2*!values.f_NaN, var.results.grit11_phd.fit.err.temp_2, $ - var.results.kale06_dyn.fit.err.temp_2*!values.f_NaN, var.results.kale06_phd.fit.err.temp_2], /log) + var.results.kale06_dyn.fit.err.temp_2*!values.f_NaN, var.results.kale06_phd.fit.err.temp_2]*f_b, /log) ; hgt vs temp - grit11_dyn and _phd p20 = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.temp_1[iih], '--', current = w4, /ylog, $ @@ -565,7 +605,7 @@ maxfp = var.results.grit11_phd.fit.res.temp_1[iih] + var.results.grit11_phd.fit. iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p20 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p20 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'blue', fill_transparency = 80, linestyle = '', overplot = p20) p20b = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.temp_2[iih], '--', overplot = p20, $ @@ -578,7 +618,7 @@ maxfp = var.results.grit11_phd.fit.res.temp_2[iih] + var.results.grit11_phd.fit. iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p20c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p20c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'cyan', fill_transparency = 80, linestyle = '', overplot = p20) if isa(poly_p20) then poly_p20.order, /send_to_back @@ -596,7 +636,7 @@ maxfp = var.results.kale06_phd.fit.res.temp_1 + var.results.kale06_phd.fit.err.t iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p23 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p23 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'red', fill_transparency = 80, linestyle = '', overplot = p23) p23b = plot(var.results.kale06_dyn.fit.res.hgt, var.results.kale06_dyn.fit.res.temp_2, '--', overplot = p23, $ @@ -609,7 +649,7 @@ maxfp = var.results.kale06_phd.fit.res.temp_2 + var.results.kale06_phd.fit.err.t iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p23 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p23 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'light salmon', fill_transparency = 80, linestyle = '', overplot = p23) if isa(poly_p23) then poly_p23.order, /send_to_back @@ -622,7 +662,7 @@ yrange = plot_range([var.results.grit11_dyn.fit.res.mu_1*!values.f_NaN, var.resu error = [var.results.grit11_dyn.fit.err.mu_1*!values.f_NaN, var.results.grit11_phd.fit.err.mu_1, $ var.results.kale06_dyn.fit.err.mu_1*!values.f_NaN, var.results.kale06_phd.fit.err.mu_1, $ var.results.grit11_dyn.fit.err.mu_2*!values.f_NaN, var.results.grit11_phd.fit.err.mu_2, $ - var.results.kale06_dyn.fit.err.mu_2*!values.f_NaN, var.results.kale06_phd.fit.err.mu_2], /log) + var.results.kale06_dyn.fit.err.mu_2*!values.f_NaN, var.results.kale06_phd.fit.err.mu_2]*f_b, /log) ; hgt vs mu - grit11_dyn and _phd p21 = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.mu_1[iih], '--', current = w4, /ylog, $ @@ -637,7 +677,7 @@ maxfp = var.results.grit11_phd.fit.res.mu_1[iih] + var.results.grit11_phd.fit.er iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p21 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p21 = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'blue', fill_transparency = 80, linestyle = '', overplot = p21) p21b = plot(var.results.triang.res.hgt[iih], var.results.grit11_dyn.fit.res.mu_2[iih], '--', overplot = p21, $ @@ -650,7 +690,7 @@ maxfp = var.results.grit11_phd.fit.res.mu_2[iih] + var.results.grit11_phd.fit.er iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p21c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p21c = fillplot(var.results.triang.res.hgt[iih[iig]], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'cyan', fill_transparency = 80, linestyle = '', overplot = p21) if isa(poly_p21) then poly_p21.order, /send_to_back @@ -668,7 +708,7 @@ maxfp = var.results.kale06_phd.fit.res.mu_1 + var.results.kale06_phd.fit.err.mu_ iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p24 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p24 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'red', fill_transparency = 80, linestyle = '', overplot = p24) p24b = plot(var.results.kale06_dyn.fit.res.hgt, var.results.kale06_dyn.fit.res.mu_2, '--', overplot = p24, $ @@ -681,7 +721,7 @@ maxfp = var.results.kale06_phd.fit.res.mu_2 + var.results.kale06_phd.fit.err.mu_ iig = where(finite(minfp) and finite(maxfp) and (minfp gt 0) and (maxfp gt 0)) if n_elements(iig) gt 1 then $ - poly_p24 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]], /fill_background, $ + poly_p24 = fillplot(var.results.kale06_phd.fit.res.hgt[iig], [[minfp[iig]], [maxfp[iig]]]*f_b, /fill_background, $ fill_color = 'light salmon', fill_transparency = 80, linestyle = '', overplot = p24) if isa(poly_p24) then poly_p24.order, /send_to_back diff --git a/code/functions/report/export_detection_media.pro b/code/functions/report/export_detection_media.pro index 2d8295c..19f711a 100644 --- a/code/functions/report/export_detection_media.pro +++ b/code/functions/report/export_detection_media.pro @@ -241,9 +241,11 @@ if par.config.detection.image then begin w2 = window(dimensions = par.fits.dim, buffer = buffer) image1 = image(image_bolide, current = w2, min_value = min_value, max_value = max_value, margin = 0.) + + ; logo overlay image2 = image(logo, current = w2, position = pos_logo) - ; informative overlat (station code, name and data) + ; informative overlay (station code, name and data) text1 = text(pos_station[0], pos_station[1], text_station, target = w2, font_color = 'white', font_size = font_size_1, $ vertical_alignment = 1.0) text2 = text(pos_data[0], pos_data[1], text_data, target = w2, font_color = 'white', font_size = font_size_2, $ diff --git a/code/functions/report/orbit_report.pro b/code/functions/report/orbit_report.pro index a9e4221..7bb82b4 100644 --- a/code/functions/report/orbit_report.pro +++ b/code/functions/report/orbit_report.pro @@ -56,6 +56,9 @@ is_open = 0 ii_open = where(e_v ge 1) if ii_open[0] ne -1 or ((e + 3.*s_e) ge 1) then is_open = 1 +; suppressing errors if required +if config.orbit.oplot_errorbands then f_b = 1. else f_b = !values.f_NaN + ; window 1 w1 = window(dimensions = dimw, buffer = buffer) @@ -93,7 +96,7 @@ pmar2 = plot([var.planets.mars.x[0], var.planets.mars.x[0]], [var.planets.mars.y 'o', overplot = p1, sym_size = plan_size, /sym_filled, color = 'dark orange') pbelt = polygon([var.planets.main_belt.inner.x, reverse(var.planets.main_belt.outer.x)], $ - [var.planets.main_belt.inner.y, reverse(var.planets.main_belt.outer.y)], target = p1, /data, $ + [var.planets.main_belt.inner.y, reverse(var.planets.main_belt.outer.y)]*f_b, target = p1, /data, $ /fill_background, fill_color = 'grey', fill_transparency = 90, linestyle = 'none') pjup1 = plot(var.planets.jupiter.x, var.planets.jupiter.y, overplot = p1, color = 'saddle brown') @@ -119,15 +122,15 @@ psun = plot([0., 0.], [0., 0.], 'o', overplot = p1, sym_size = plan_size, /sym_f if ~is_open then begin p3sig = polygon([var.nominal.proj.xy.sigma3.inner.x, reverse(var.nominal.proj.xy.sigma3.outer.x)], $ - [var.nominal.proj.xy.sigma3.inner.y, reverse(var.nominal.proj.xy.sigma3.outer.y)], target = p1, /data, $ + [var.nominal.proj.xy.sigma3.inner.y, reverse(var.nominal.proj.xy.sigma3.outer.y)]*f_b, target = p1, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') p2sig = polygon([var.nominal.proj.xy.sigma2.inner.x, reverse(var.nominal.proj.xy.sigma2.outer.x)], $ - [var.nominal.proj.xy.sigma2.inner.y, reverse(var.nominal.proj.xy.sigma2.outer.y)], target = p1, /data, $ + [var.nominal.proj.xy.sigma2.inner.y, reverse(var.nominal.proj.xy.sigma2.outer.y)]*f_b, target = p1, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') p1sig = polygon([var.nominal.proj.xy.sigma1.inner.x, reverse(var.nominal.proj.xy.sigma1.outer.x)], $ - [var.nominal.proj.xy.sigma1.inner.y, reverse(var.nominal.proj.xy.sigma1.outer.y)], target = p1, /data, $ + [var.nominal.proj.xy.sigma1.inner.y, reverse(var.nominal.proj.xy.sigma1.outer.y)]*f_b, target = p1, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') endif @@ -140,9 +143,9 @@ pmet2 = plot(var.nominal.orbit.x, var.nominal.orbit.y, overplot = p1, color = 'b ; legend for nominal orbit leg1 = legend(target = pmet1, linestyle = '', label = 'closed nominal orbit', vertical_alignment = 0.5, transparency = 100., $ - horizontal_alignment = 0, sample_width = 0.08, position = [0.14, 0.92], font_size = font_size) + horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.920], font_size = font_size) leg2 = legend(target = pmet2, linestyle = '', label = 'open nominal orbit', vertical_alignment = 0.5, transparency = 100., $ - horizontal_alignment = 0, sample_width = 0.08, position = [0.14, 0.90], font_size = font_size) + horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.905], font_size = font_size) ; bringing the nominal orbit plot in front p1.order, /bring_to_front @@ -172,7 +175,7 @@ pmar2 = plot([var.planets.mars.x[0], var.planets.mars.x[0]], [var.planets.mars.y 'o', overplot = p2, sym_size = plan_size, /sym_filled, color = 'dark orange') pbelt = polygon([var.planets.main_belt.inner.x, reverse(var.planets.main_belt.outer.x)], $ - [var.planets.main_belt.inner.y, reverse(var.planets.main_belt.outer.y)], target = p2, /data, $ + [var.planets.main_belt.inner.y, reverse(var.planets.main_belt.outer.y)]*f_b, target = p2, /data, $ /fill_background, fill_color = 'grey', fill_transparency = 90, linestyle = 'none') pjup1 = plot(var.planets.jupiter.x, var.planets.jupiter.y, overplot = p2, color = 'saddle brown') @@ -200,9 +203,9 @@ pmc2 = plot(var.ensemble[0].orbit.x, var.ensemble[0].orbit.y, overplot = p2, col ; legend for Monte Carlo replicas orbit leg3 = legend(target = pmc1, linestyle = '', label = 'closed MC orbit', vertical_alignment = 0.5, transparency = 100., $ - horizontal_alignment = 0, sample_width = 0.08, position = [0.14, 0.508], font_size = font_size) + horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.508], font_size = font_size) leg4 = legend(target = pmc2, linestyle = '', label = 'open MC orbit', vertical_alignment = 0.5, transparency = 100., $ - horizontal_alignment = 0, sample_width = 0.08, position = [0.14, 0.488], font_size = font_size) + horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.493], font_size = font_size) ; disabling refresh to speed up the overplot p2.refresh, /disable @@ -248,7 +251,7 @@ pven = plot(var.planets.venus.x, var.planets.venus.y, overplot = p3, color = 'go pear = plot(var.planets.earth.x, var.planets.earth.y, overplot = p3, color = 'royal blue') pmar = plot(var.planets.mars.x, var.planets.mars.y, overplot = p3, color = 'dark orange') pbelt = polygon([var.planets.main_belt.inner.x, reverse(var.planets.main_belt.outer.x)], $ - [var.planets.main_belt.inner.y, reverse(var.planets.main_belt.outer.y)], target = p3, /data, $ + [var.planets.main_belt.inner.y, reverse(var.planets.main_belt.outer.y)]*f_b, target = p3, /data, $ /fill_background, fill_color = 'grey', fill_transparency = 90, linestyle = 'none') pjup = plot(var.planets.jupiter.x, var.planets.jupiter.y, overplot = p3, color = 'saddle brown') psat = plot(var.planets.saturn.x, var.planets.saturn.y, overplot = p3, color = 'goldenrod') @@ -260,15 +263,15 @@ psun = plot([0., 0.], [0., 0.], 'o', overplot = p3, sym_size = plan_size, /sym_f if ~is_open then begin p3sig = polygon([var.nominal.proj.xy.sigma3.inner.x, reverse(var.nominal.proj.xy.sigma3.outer.x)], $ - [var.nominal.proj.xy.sigma3.inner.y, reverse(var.nominal.proj.xy.sigma3.outer.y)], target = p3, /data, $ + [var.nominal.proj.xy.sigma3.inner.y, reverse(var.nominal.proj.xy.sigma3.outer.y)]*f_b, target = p3, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') p2sig = polygon([var.nominal.proj.xy.sigma2.inner.x, reverse(var.nominal.proj.xy.sigma2.outer.x)], $ - [var.nominal.proj.xy.sigma2.inner.y, reverse(var.nominal.proj.xy.sigma2.outer.y)], target = p3, /data, $ + [var.nominal.proj.xy.sigma2.inner.y, reverse(var.nominal.proj.xy.sigma2.outer.y)]*f_b, target = p3, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') p1sig = polygon([var.nominal.proj.xy.sigma1.inner.x, reverse(var.nominal.proj.xy.sigma1.outer.x)], $ - [var.nominal.proj.xy.sigma1.inner.y, reverse(var.nominal.proj.xy.sigma1.outer.y)], target = p3, /data, $ + [var.nominal.proj.xy.sigma1.inner.y, reverse(var.nominal.proj.xy.sigma1.outer.y)]*f_b, target = p3, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') endif @@ -276,6 +279,18 @@ endif ; bringing the nominal orbit plot in front p3.order, /bring_to_front +; nominal orbit of the meteoroid +pmet3 = plot(var.nominal.orbit.x, var.nominal.orbit.y, overplot = p3, color = 'black', thick = 1.5, $ + linestyle = linestyle_closed, /hide) +pmet4 = plot(var.nominal.orbit.x, var.nominal.orbit.y, overplot = p3, color = 'black', thick = 1.5, $ + linestyle = linestyle_open, /hide) + +; legend for nominal orbit +leg5 = legend(target = pmet3, linestyle = '', label = 'closed nominal orbit', vertical_alignment = 0.5, transparency = 100., $ + horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.920], font_size = font_size) +leg6 = legend(target = pmet4, linestyle = '', label = 'open nominal orbit', vertical_alignment = 0.5, transparency = 100., $ + horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.905], font_size = font_size) + ; linestyle for closed or open nominal orbit if e lt 1 then linestyle = linestyle_closed else linestyle = linestyle_open @@ -290,7 +305,7 @@ pven = plot(var.planets.venus.x, var.planets.venus.y, overplot = p4, color = 'go pear = plot(var.planets.earth.x, var.planets.earth.y, overplot = p4, color = 'royal blue') pmar = plot(var.planets.mars.x, var.planets.mars.y, overplot = p4, color = 'dark orange') pbelt = polygon([var.planets.main_belt.inner.x, reverse(var.planets.main_belt.outer.x)], $ - [var.planets.main_belt.inner.y, reverse(var.planets.main_belt.outer.y)], target = p4, /data, $ + [var.planets.main_belt.inner.y, reverse(var.planets.main_belt.outer.y)]*f_b, target = p4, /data, $ /fill_background, fill_color = 'grey', fill_transparency = 90, linestyle = 'none') pjup = plot(var.planets.jupiter.x, var.planets.jupiter.y, overplot = p4, color = 'saddle brown') psat = plot(var.planets.saturn.x, var.planets.saturn.y, overplot = p4, color = 'goldenrod') @@ -317,6 +332,16 @@ p4.refresh ; bringing the nominal orbit plot in front p4.order, /bring_to_front +; first replica, to plot the legend +pmc3 = plot(var.ensemble[0].orbit.x, var.ensemble[0].orbit.y, overplot = p4, color = color_closed, /hide) +pmc4 = plot(var.ensemble[0].orbit.x, var.ensemble[0].orbit.y, overplot = p4, color = color_open, /hide) + +; legend for Monte Carlo replicas orbit +leg7 = legend(target = pmc3, linestyle = '', label = 'closed MC orbit', vertical_alignment = 0.5, transparency = 100., $ + horizontal_alignment = 0, sample_width = 0.08, position = [0.560, 0.920], font_size = font_size) +leg8 = legend(target = pmc4, linestyle = '', label = 'open MC orbit', vertical_alignment = 0.5, transparency = 100., $ + horizontal_alignment = 0, sample_width = 0.08, position = [0.560, 0.905], font_size = font_size) + ; linestyle for closed or open nominal orbit if e lt 1 then linestyle = linestyle_closed else linestyle = linestyle_open @@ -333,15 +358,15 @@ psun = plot([0., 0.], [0., 0.], 'o', overplot = p5, sym_size = plan_size, /sym_f if ~is_open then begin p3sig = polygon([var.nominal.proj.xz.sigma3.inner.x, reverse(var.nominal.proj.xz.sigma3.outer.x)], $ - [var.nominal.proj.xz.sigma3.inner.z, reverse(var.nominal.proj.xz.sigma3.outer.z)], target = p5, /data, $ + [var.nominal.proj.xz.sigma3.inner.z, reverse(var.nominal.proj.xz.sigma3.outer.z)]*f_b, target = p5, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') p2sig = polygon([var.nominal.proj.xz.sigma2.inner.x, reverse(var.nominal.proj.xz.sigma2.outer.x)], $ - [var.nominal.proj.xz.sigma2.inner.z, reverse(var.nominal.proj.xz.sigma2.outer.z)], target = p5, /data, $ + [var.nominal.proj.xz.sigma2.inner.z, reverse(var.nominal.proj.xz.sigma2.outer.z)]*f_b, target = p5, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') p1sig = polygon([var.nominal.proj.xz.sigma1.inner.x, reverse(var.nominal.proj.xz.sigma1.outer.x)], $ - [var.nominal.proj.xz.sigma1.inner.z, reverse(var.nominal.proj.xz.sigma1.outer.z)], target = p5, /data, $ + [var.nominal.proj.xz.sigma1.inner.z, reverse(var.nominal.proj.xz.sigma1.outer.z)]*f_b, target = p5, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') endif @@ -396,15 +421,15 @@ psun = plot([0., 0.], [0., 0.], 'o', overplot = p7, sym_size = plan_size, /sym_f if ~is_open then begin p3sig = polygon([var.nominal.proj.yz.sigma3.inner.y, reverse(var.nominal.proj.yz.sigma3.outer.y)], $ - [var.nominal.proj.yz.sigma3.inner.z, reverse(var.nominal.proj.yz.sigma3.outer.z)], target = p7, /data, $ + [var.nominal.proj.yz.sigma3.inner.z, reverse(var.nominal.proj.yz.sigma3.outer.z)]*f_b, target = p7, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') p2sig = polygon([var.nominal.proj.yz.sigma2.inner.y, reverse(var.nominal.proj.yz.sigma2.outer.y)], $ - [var.nominal.proj.yz.sigma2.inner.z, reverse(var.nominal.proj.yz.sigma2.outer.z)], target = p7, /data, $ + [var.nominal.proj.yz.sigma2.inner.z, reverse(var.nominal.proj.yz.sigma2.outer.z)]*f_b, target = p7, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') p1sig = polygon([var.nominal.proj.yz.sigma1.inner.y, reverse(var.nominal.proj.yz.sigma1.outer.y)], $ - [var.nominal.proj.yz.sigma1.inner.z, reverse(var.nominal.proj.yz.sigma1.outer.z)], target = p7, /data, $ + [var.nominal.proj.yz.sigma1.inner.z, reverse(var.nominal.proj.yz.sigma1.outer.z)]*f_b, target = p7, /data, $ /fill_background, fill_color = 'red', fill_transparency = 70, linestyle = 'none') endif @@ -535,10 +560,10 @@ ph2 = plot([h, h] + bin1_h/2., [0., max(g1_h)], overplot = ph, thick = 1.5) ; legend for histograms ph0 = plot(loc_h, h_h, /histogram, overplot = ph, color = 'cornflower', thick = 1.5, /hide) -leg5 = legend(target = ph1, linestyle = '', label = 'nominal elements distribution', vertical_alignment = 0.5, $ - transparency = 100., horizontal_alignment = 0, sample_width = 0.08, position = [0.14, 0.92], font_size = font_size) -leg6 = legend(target = ph0, linestyle = '', label = 'MC elements distribution', vertical_alignment = 0.5, $ - transparency = 100., horizontal_alignment = 0, sample_width = 0.08, position = [0.14, 0.90], font_size = font_size) +leg9 = legend(target = ph1, linestyle = '', label = 'nominal elements distribution', vertical_alignment = 0.5, $ + transparency = 100., horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.920], font_size = font_size) +leg10 = legend(target = ph0, linestyle = '', label = 'MC elements distribution', vertical_alignment = 0.5, $ + transparency = 100., horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.905], font_size = font_size) xrange = plot_range([loc_e, loc1_e], border = 0.2) + bin_e/2. yrange = plot_range([h_e, g1_e], border = 0.2, /min0) @@ -560,7 +585,7 @@ xrange = plot_range([loc_lon, loc1_lon], border = 0.2) + bin_lon/2. yrange = plot_range([h_lon, g1_lon], border = 0.2, /min0) plon = plot(loc_lon, h_lon, /histogram, current = w3, position = [0.58, 0.41, 0.88, 0.59], title = 'longitude of the ascending node', $ xtitle = '$\Omega$ [deg]', ytitle = '% occurrences', xrange = xrange, yrange = yrange, fill_background = 1, $ - linestyle = '', fill_color = 'cornflower', font_size = font_size, xminor = 4, yminor = 4, xtickformat = '(f6.2)') + linestyle = '', fill_color = 'cornflower', font_size = font_size, xmajor = 4, xminor = 4, yminor = 4, xtickformat = '(f8.4)') plon1 = plot(loc1_lon + bin1_lon/2., g1_lon, overplot = plon, thick = 1.5) plon2 = plot([lon, lon] + bin1_lon/2., [0., max(g1_lon)], overplot = plon, thick = 1.5) @@ -630,10 +655,10 @@ phe4 = plot(h_z[0:1], e_z[0:1], '.', overplot = phe, sym_size = 3.0, sym_color = phe5 = plot(h_z[0:1], e_z[0:1], overplot = phe, thick = 1.5, color = 'black', /hide) ; legend for the correlation plot -leg7 = legend(target = phe5, linestyle = '', label = 'nominal elements correlation ellipse', vertical_alignment = 0.5, $ - transparency = 100., horizontal_alignment = 0, sample_width = 0.08, position = [0.14, 0.92], font_size = font_size) -leg8 = legend(target = phe4, linestyle = '', label = 'MC elements correlation plot', vertical_alignment = 0.5, $ - transparency = 100., horizontal_alignment = 0, sample_width = 0.08, position = [0.14, 0.90], font_size = font_size) +leg11 = legend(target = phe5, linestyle = '', label = 'nominal elements correlation ellipse', vertical_alignment = 0.5, $ + transparency = 100., horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.920], font_size = font_size) +leg12 = legend(target = phe4, linestyle = '', label = 'MC elements correlation plot', vertical_alignment = 0.5, $ + transparency = 100., horizontal_alignment = 0, sample_width = 0.08, position = [0.140, 0.905], font_size = font_size) phi = plot(h_z, i_z, '.', current = w4, position = [0.415, 0.76, 0.585, 0.88], xrange = range_x, yrange = range_y, $ xtitle = 'h', ytitle = 'i', font_size = font_size, sym_size = 0.5, $ diff --git a/code/functions/report/photometry_report.pro b/code/functions/report/photometry_report.pro index a3a963c..8827203 100644 --- a/code/functions/report/photometry_report.pro +++ b/code/functions/report/photometry_report.pro @@ -34,6 +34,9 @@ if var.fm then begin ; number of found and associated stars ns = n_elements(var.am) + ; standard deviation of mag residuals + sd_mag = var.sd_mag + ; airmass and mag ranges xrange = [1, 6] yrange = plot_range(var.dm, error = var.me, err_filter = 1.) @@ -51,8 +54,8 @@ if var.fm then begin ; defining binning to have square bins in the image bin_am = 0.05 - N_am = round((xrange[1]-xrange[0]) / bin_am) - N_dm = round(N_am * dimw[1]/dimw[0] * (pos_h2D[3]-pos_h2D[1])/(pos_h2D[2]-pos_h2D[0])) + N_am = round((xrange[1] - xrange[0]) / bin_am) + N_dm = round(N_am * dimw[1]/dimw[0] * (pos_h2D[3] - pos_h2D[1])/(pos_h2D[2] - pos_h2D[0])) bin_dm = (yrange[1] - yrange[0]) / N_dm ; 2D histograms @@ -117,7 +120,7 @@ if var.fm then begin endif ; adding textbox with number of stars - str1 = 'n$_{\ast}$ = ' + strtrim(ns, 2) + str1 = 'n$_{\ast}$ = ' + strtrim(ns, 2) + ', $\sigma_m$ = ' + strtrim(string(sd_mag, format = '(f20.3)'), 2) str2 = 'C = ' + strtrim(string(var.Cm, format = '(f20.3)'), 2) + ' $\pm$ ' + $ strtrim(string(var.s_Cm, format = '(f20.3)'), 2) + ', k = ' + $ strtrim(string(var.Km, format = '(f20.3)'), 2) + ' $\pm$ ' + $ diff --git a/code/functions/report/triangulation_report.pro b/code/functions/report/triangulation_report.pro index ca90034..d2037e3 100644 --- a/code/functions/report/triangulation_report.pro +++ b/code/functions/report/triangulation_report.pro @@ -65,6 +65,9 @@ ii = where(var.results.index eq ind) dH = var.results.LoS.coord.hgt - var.results.trajectory.coord.hgt dD = signum(dH)*abs(var.borovicka.points.dD) +; suppressing errors if required +if config.triangulation.oplot_errors then f_e = 1. else f_e = !values.f_NaN + ; x ranges trange = plot_range(var.results.time) hrange = plot_range(var.results.trajectory.coord.hgt, /reverse) @@ -98,29 +101,29 @@ pL[0] = plot(var.results.time[ii], var.results.trajectory.eci.dist[ii], 'o', cur xminor = 4, yminor = 4, xrange = trange, yrange = yrange, font_size = font_size, $ color = colors_cam[*,ind], sym_size = 0.1, /sym_filled) -yrange = plot_range(var.results.trajectory.speed.v, error = var.results.trajectory.speed.s_v, rel_filter = 1.) +yrange = plot_range(var.results.trajectory.speed.v, error = var.results.trajectory.speed.s_v*f_e, rel_filter = 1.) ; plot time vs speed pvel[0] = errorplot(var.results.trajectory.coord.hgt[ii], var.results.trajectory.speed.v[ii], $ - var.results.trajectory.speed.s_v[ii], 'o', current = w1, position = [0.58, 0.68, 0.88, 0.86], $ + var.results.trajectory.speed.s_v[ii]*f_e, 'o', current = w1, position = [0.58, 0.68, 0.88, 0.86], $ title = 'speed', xtitle = 'H [km]', ytitle = 'V [km/s]', xminor = 4, yminor = 4, xrange = hrange, $ yrange = yrange, font_size = font_size, sym_size = 0.1, /sym_filled, errorbar_capsize = 0.02, $ errorbar_thick = 0.5) -yrange = plot_range(var.results.trajectory.speed.a, error = var.results.trajectory.speed.s_a, rel_filter = 1.) +yrange = plot_range(var.results.trajectory.speed.a, error = var.results.trajectory.speed.s_a*f_e, rel_filter = 1.) ; plot time vs acceleration pacc[0] = errorplot(var.results.trajectory.coord.hgt[ii], var.results.trajectory.speed.a[ii], $ - var.results.trajectory.speed.a[ii], 'o', current = w1, position = [0.58, 0.41, 0.88, 0.59], $ + var.results.trajectory.speed.a[ii]*f_e, 'o', current = w1, position = [0.58, 0.41, 0.88, 0.59], $ title = 'acceleration', xtitle = 'H [km]', ytitle = 'a [km/s$^2$]', xminor = 4, yminor = 4, $ xrange = hrange, yrange = yrange, font_size = font_size, sym_size = 0.1, /sym_filled, $ errorbar_capsize = 0.02, errorbar_thick = 0.5) -yrange = plot_range(var.results.trajectory.mag.amag, error = var.results.trajectory.mag.s_amag, /reverse, err_filter = 1.) +yrange = plot_range(var.results.trajectory.mag.amag, error = var.results.trajectory.mag.s_amag*f_e, /reverse, err_filter = 1.) ; plot time vs magnitude pmag[0] = errorplot(var.results.trajectory.coord.hgt[ii], var.results.trajectory.mag.amag[ii], $ - var.results.trajectory.mag.s_amag[ii], 'o', current = w1, position = [0.58, 0.14, 0.88, 0.32], $ + var.results.trajectory.mag.s_amag[ii]*f_e, 'o', current = w1, position = [0.58, 0.14, 0.88, 0.32], $ title = 'absolute magnitude', xtitle = 'H [km]', ytitle = 'M [/]', xminor = 4, yminor = 4, $ xrange = hrange, yrange = yrange, color = colors_cam[*,ind], font_size = font_size, $ sym_size = 0.1, /sym_filled, errorbar_capsize = 0.02, errorbar_thick = 0.5) @@ -144,15 +147,15 @@ for i=1, n-1 do begin color = colors_cam[*,ind], sym_size = 0.1, /sym_filled) pvel[i] = errorplot(var.results.trajectory.coord.hgt[ii], var.results.trajectory.speed.v[ii], $ - var.results.trajectory.speed.s_v[ii], 'o', overplot = pvel[0], sym_size = 0.1, /sym_filled, $ + var.results.trajectory.speed.s_v[ii]*f_e, 'o', overplot = pvel[0], sym_size = 0.1, /sym_filled, $ errorbar_capsize = 0.02, errorbar_thick = 0.5) pacc[i] = errorplot(var.results.trajectory.coord.hgt[ii], var.results.trajectory.speed.a[ii], $ - var.results.trajectory.speed.s_a[ii], 'o', overplot = pacc[0], sym_size = 0.1, $ + var.results.trajectory.speed.s_a[ii]*f_e, 'o', overplot = pacc[0], sym_size = 0.1, $ /sym_filled, errorbar_capsize = 0.02, errorbar_thick = 0.5) pmag[i] = errorplot(var.results.trajectory.coord.hgt[ii], var.results.trajectory.mag.amag[ii], $ - var.results.trajectory.mag.s_amag[ii], 'o', overplot = pmag[0], color = colors_cam[*,ind], $ + var.results.trajectory.mag.s_amag[ii]*f_e, 'o', overplot = pmag[0], color = colors_cam[*,ind], $ sym_size = 0.1, /sym_filled, errorbar_capsize = 0.02, errorbar_thick = 0.5) endfor @@ -374,18 +377,18 @@ endfor ; legend for ceplecha/borovicka legc = legend(target = pyz_mean, font_size = font_size, horizontal_alignment = 0, vertical_alignment = 0.5, $ - position = [0.58, 0.48], linestyle = '') + position = [0.580, 0.480], linestyle = '') legb = legend(target = pyz_boro, font_size = font_size, horizontal_alignment = 0, vertical_alignment = 0.5, $ - position = [0.58, 0.46], linestyle = '') + position = [0.580, 0.465], linestyle = '') ; legends for names of the cameras nleg = (norig < 16) -spacing = 0.02 +spacing = 0.015 leg_cam = objarr(nleg) for i=0, nleg-1 do leg_cam[i] = legend(target = pcam[i], font_size = font_size, horizontal_alignment = 0, $ - vertical_alignment = 0.5, position = [0.58, 0.42-i*spacing], linestyle = '') + vertical_alignment = 0.5, position = [0.580, 0.420-i*spacing], linestyle = '') ; window 3 w3 = window(dimensions = dimw, buffer = buffer) diff --git a/code/pwwidget/PRISMAwidget.pro b/code/pwwidget/PRISMAwidget.pro deleted file mode 100644 index 5d22e9e..0000000 --- a/code/pwwidget/PRISMAwidget.pro +++ /dev/null @@ -1,207 +0,0 @@ -; This widget is used to interactively visualize the PRISMA data -; (both detections and captures) and allows to produce animated gif -; and images, e.g. for meteors detections. - -pro PRISMAwidget - -; in order to produce the runtime distribution the value of "runtime" has to be set to 1 -runtime = 0 - -cd, current = basedir - -; custom path (for runtime=0,1) -if runtime then solutions = basedir + path_sep() + 'PRISMAcamera.txt' $ - else solutions = 'C:\Users\dario\Lavoro\IDLWorkspace\PRISMA\settings\solutions.ini' - -if runtime then path_black = basedir + path_sep() + 'PRISMAlogo_black.png' $ - else path_black = 'C:\Users\dario\Lavoro\IDLWorkspace\PRISMA\settings\logo_black.png' - -if runtime then path_white = basedir + path_sep() + 'PRISMAlogo_white.png' $ - else path_white = 'C:\Users\dario\Lavoro\IDLWorkspace\PRISMA\settings\logo_white.png' - -; read the black/white logos -logo_black = get_logo(path_black, transparent = 'black') -logo_white = get_logo(path_white, transparent = 'white') - -; read the solutions file -readcol, solutions, list_camera, list_pseudo, format = '(A,A)', /silent - -list_camera = strupcase(list_camera) -list_pseudo = strupcase(list_pseudo) - -; scaling factor for widget dimensions -; 1 for HD and FHD screens -; 2 for QHD, UHD and 4K screens -wscale = round(mean(get_screen_size()/[1920., 1080.])) -wscale = (wscale > 1) < 2 - -; creating the various components of the widget -tlb = widget_base(title = 'PRISMA Widget', /column, mbar = mbar) -button_file = widget_button(mbar, value = 'File', /menu, event_pro = 'PWwidget_file') -button_detection = widget_button(button_file, value = 'Open Detection') -button_capture = widget_button(button_file, value = 'Open Capture') -button_exit = widget_button(button_file, value = 'Exit') - -button_pos = widget_button(mbar, value = 'Positions', /menu, event_pro = 'PWwidget_positions', sensitive = 0) -button_loadpos = widget_button(button_pos, value = 'Load', /checked_menu, sensitive = 0) -button_autopos = widget_button(button_pos, value = 'Auto-centre', /checked_menu, sensitive = 0) -button_showbox = widget_button(button_pos, value = 'Show Box', /checked_menu, sensitive = 0) - -base1 = widget_base(tlb, /row) -list_mode = widget_droplist(base1, value = ['Detection','Capture'], /dynamic_resize, event_pro = 'PWwidget_modelist') -label = widget_label(base1, value = ' Image filename:', /dynamic_resize) -text_filename = widget_text(base1, xsize = 144, ysize = 1, value = '', /editable, event_pro = 'PWwidget_filename') -button_previmage = widget_button(base1, value = '<<', event_pro = 'PWwidget_prevnextimage', sensitive = 0) -button_nextimage = widget_button(base1, value = '>>', event_pro = 'PWwidget_prevnextimage', sensitive = 0) -label = widget_label(base1, value = ' Movie:', /dynamic_resize) -text_nframe = widget_text(base1, xsize = 6, ysize = 1, value = '', /editable, sensitive = 0) -button_playmovie = widget_button(base1, value = 'Play', event_pro = 'PWwidget_playmovie', sensitive = 0) -button_savemovie = widget_button(base1, value = 'Save', event_pro = 'PWwidget_playmovie', sensitive = 0) - -base2 = widget_base(tlb, /row) -draw_big = widget_draw(base2, xsize = 640*wscale, ysize=480*wscale, /motion_events, /frame, /button_events, $ - event_pro = 'PWwidget_draw', sensitive = 0) -draw_zoom = widget_draw(base2, xsize = 480*wscale, ysize = 480*wscale, /motion_events, /button_events, /frame, $ - event_pro = 'PWwidget_zoom', sensitive = 0) -table_pos = widget_table(base2, value = ['','','',''], xsize = 4, ysize = 25, scr_xsize = 310*wscale, scr_ysize = 487*wscale, $ - /scroll, alignment = 2, column_width = [36, 70, 150, 36]*wscale, /no_row_headers, $ - column_labels = ['#', '(X;Y)', 'TIME UTC', 'BOX'], sensitive = 0) - -base3 = widget_base(tlb, /row) -base31 = widget_base(base3, /row, /frame) -label = widget_label(base31, value = ' Image Cuts Min ') -slider_min = widget_slider(base31, xsize = 380*wscale, minimum = 0, maximum = 4095, value = 0, $ - event_pro = 'PWwidget_slider_minmax', sensitive = 0) -label = widget_label(base31, value = ' Max ') -slider_max = widget_slider(base31, xsize = 380*wscale, minimum = 0, maximum = 4095, value = 4095, $ - event_pro = 'PWwidget_slider_minmax', sensitive = 0) - -base32 = widget_base(base3, /row, /frame) -label = widget_label(base32, value = ' Zoom Scale ') -slider_zoom = widget_slider(base32, xsize = 118*wscale, minimum = 0, maximum = 5, value = 5, $ - event_pro = 'PWwidget_slider_zoom', sensitive = 0) - -base33 = widget_base(base3, /row, /frame) -label = widget_label(base33, value = ' Centering Box Dim ') -slider_box = widget_slider(base33, xsize = 143*wscale, minimum = 2, maximum = 20, value = 8, $ - event_pro = 'PWwidget_slider_box', sensitive = 0) -base37 = widget_base(base33, /column, /nonexclusive) -button_fixbox = widget_button(base37, value = ' Fix', sensitive = 0) - -base4 = widget_base(tlb, /row) -base41 = widget_base(base4, /row, /frame) -label = widget_label(base41, value = ' Pixel ') -label = widget_label(base41, value = ' X ', xsize = 17*wscale) -text_xpos = widget_text(base41, scr_xsize = 40*wscale, sensitive = 0) -label = widget_label(base41, value = ' Y ', xsize = 17*wscale) -text_ypos = widget_text(base41, scr_xsize = 40*wscale, sensitive = 0) - -base42 = widget_base(base4, /row, /frame) -label = widget_label(base42, value = ' Pixel Value ') -text_imgvalue = widget_text(base42, scr_xsize = 40*wscale, sensitive = 0) - -base43 = widget_base(base4, /row, /frame) -label = widget_label(base43, value = ' Zoom Centre ') -label = widget_label(base43, value = ' Xc ', xsize = 17*wscale) -text_zoomxc = widget_text(base43, scr_xsize = 40*wscale, sensitive = 0) -label = widget_label(base43, value = ' Yc ', xsize = 17*wscale) -text_zoomyc = widget_text(base43, scr_xsize = 40*wscale, sensitive = 0) - -base44 = widget_base(base4, /row, /frame, /nonexclusive) -button_negative = widget_button(base44, value = ' Negative', event_pro = 'PWwidget_negative', sensitive = 0) -button_logscale = widget_button(base44, value = ' Log Scale', event_pro = 'PWwidget_logscale', sensitive = 0) -button_interpol = widget_button(base44, value = ' Interpolation', event_pro = 'PWwidget_interpolation', sensitive = 0) - -base45 = widget_base(base4, /row, /frame) -label = widget_label(base45, value = ' SNR ') -text_snrvalue = widget_text(base45, scr_xsize = 40*wscale, sensitive = 0) -label = widget_label(base45, value = ' Min ') -text_minvalue = widget_text(base45, scr_xsize = 40*wscale, /editable, sensitive = 0, value = '6.0') - -base46 = widget_base(base4, /column, /base_align_right, xsize = 511*wscale) -label = widget_label(base46, value = 'Authors: Dario Barghini and Daniele Gardiol (for the PRISMA collaboration)') -label = widget_label(base46, value = 'INAF Osservatorio Astrofisico di Torino - 23/12/2019') - -animation = '..' + path_sep() + 'animation.gif' -track = '..' + path_sep() + 'track.png' - -; variable structure -var = { $ - RUNTIME:runtime, $ ; boolean for runtime distribution - BASEDIR:basedir, $ ; base directory - SOLUTIONS:solutions, $ ; solutions file - LIST_CAMERA:list_camera, $ ; list of cameras - LIST_PSEUDO:list_pseudo, $ ; list of pseudos - LOGO_BLACK:logo_black, $ ; black background logo image - LOGO_WHITE:logo_white, $ ; white background logo image - WSCALE:wscale, $ ; scaling factor for widget dimensions - ANIMATION:animation, $ ; filename of gif animation - TRACK:track $ ; filename of png track - } - -; structure to store tlb uvalue -pwwidget = { $ - TLB:tlb, $ ; main window - BUTTON_FILE:button_file, $ ; file button - TEXT_FILENAME:text_filename, $ ; filename text - BUTTON_PREVIMAGE:button_previmage, $ ; button to select previous image (if exists) - BUTTON_NEXTIMAGE:button_nextimage, $ ; button to select next image (if exists) - TEXT_NFRAME:text_nframe, $ ; text widget for custom movie of n frames starting from current image - BUTTON_PLAYMOVIE:button_playmovie, $ ; button to play custom movie - BUTTON_SAVEMOVIE:button_savemovie, $ ; button to save of custom movie after play - LIST_MODE:list_mode, $ ; droplist for detection and capture mode selection - DRAW_BIG:draw_big, $ ; draw widget (big) - DRAW_ZOOM:draw_zoom, $ ; draw widget (small, zoom window) - TABLE_POS:table_pos, $ ; table widget for position file visualization - TEXT_XPOS:text_XPOS, $ ; text for current xpos cursor - TEXT_YPOS:text_YPOS, $ ; text for current ypos cursor - TEXT_IMGVALUE:text_imgvalue, $ ; text for current imgvalue cursor - TEXT_ZOOMXC:text_zoomxc, $ ; text for xcentre zoom box - TEXT_ZOOMYC:text_zoomyc, $ ; text for ycentre zoom box - SLIDER_MIN:slider_min, $ ; slider for min image curt value - SLIDER_MAX:slider_max, $ ; slider for max image cut value - SLIDER_ZOOM:slider_zoom, $ ; slider for zoom window dim - SLIDER_BOX:slider_box, $ ; slider for box auto-centre - BUTTON_FIXBOX:button_fixbox, $ ; fix box button - BUTTON_POS:button_pos, $ ; position menu - BUTTON_LOADPOS:button_loadpos, $ ; load position button - BUTTON_AUTOPOS:button_autopos, $ ; load position button - BUTTON_SHOWBOX:button_showbox, $ ; show box button - BUTTON_NEGATIVE:button_negative, $ ; button for negative colorscale control - BUTTON_LOGSCALE:button_logscale, $ ; button for log-scale control - BUTTON_INTERPOL:button_interpol, $ ; button for rebin interpolation control - TEXT_SNRVALUE:text_snrvalue, $ ; text for SNR value in autopos - TEXT_MINVALUE:text_minvalue, $ ; text for Min SNR value in autopos - VAR:var $ - } - -; realize the widgets -widget_control, tlb, /realize -widget_control, tlb, set_uvalue = pwwidget - -; initializing uvalues -img = {IMAGE:fltarr(1280,960), XSIZE:1280, YSIZE:960, FRAMENUM:0, DATA:'', CAMERA:'', PSEUDO:''} -widget_control, draw_big, set_uvalue = img - -imgzoom = {IMAGE:fltarr(480*wscale, 480*wscale), SCALE:5, XSIZE:480*wscale, YSIZE:480*wscale, $ - XCN:640, YCN:480, XCOORD:lonarr(480*wscale),YCOORD:lonarr(480*wscale)} -widget_control, draw_zoom, set_uvalue = imgzoom - -posfile = '..' + path_sep() + 'newpositions.txt' -freeture = '..' + path_sep() + 'positions.txt' - -position = {DEFINED:0, POSFILE:posfile, FREETURE:freeture, NDET:0, frame:0, XPOS:0, YPOS:0, STRCOORD:'', DATA:'', BOX:8} -widget_control, button_pos, set_uvalue = position - -widget_control, button_file, set_uvalue = basedir -widget_control, list_mode, set_uvalue = 'detection' -widget_control, text_filename, set_uvalue = '' - -widget_control, table_pos, set_table_view = [0, 0], set_table_select=[-1, -1, -1, -1] - -; launching the event manager -xmanager, 'PWwidget', tlb, /no_block, cleanup = 'PWwidget_cleanup' - -device, /decompose - -end \ No newline at end of file diff --git a/code/pwwidget/PW_draw_image.pro b/code/pwwidget/PW_draw_image.pro deleted file mode 100644 index f756b8d..0000000 --- a/code/pwwidget/PW_draw_image.pro +++ /dev/null @@ -1,168 +0,0 @@ -; This procedure manages the drawing of the current image on both the big and -; zoom windows of PRISMAwigdget - -pro PW_draw_image, pwwidget - -compile_opt idl2 - -; retrieve images -widget_control, pwwidget.draw_big, get_uvalue = img -widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom -widget_control, pwwidget.text_filename, get_value = filename - -; scaling factor of the widget -wscale = pwwidget.var.wscale - -if filename ne '' then begin - - ; display image in draw_big - s = size(img.image) - - ; image is defined - if s[1] ne 0 then begin - - ; display image in main draw window - widget_control, pwwidget.draw_big, get_value = dWin - wset, dWin - erase - - ; retrieve slider values - widget_control, pwwidget.slider_min, get_value = minimo - widget_control, pwwidget.slider_max, get_value = massimo - - ; if log-scale option is selecred - if widget_info(pwwidget.button_logscale, /button_set) then begin - - tvima = bytscl(alog10(img.image + 1), alog10(minimo + 1), alog10(massimo + 1)) - - endif else begin - - tvima = bytscl(img.image, minimo, massimo) - - endelse - - ; if button_negative option is selected - if widget_info(pwwidget.button_negative, /button_set) then begin - - tv, 255-rebin(tvima, 640*wscale, 480*wscale, sample = ~widget_info(pwwidget.button_interpol, /button_set)) - - endif else begin - - tv, rebin(tvima, 640*wscale, 480*wscale, sample = ~widget_info(pwwidget.button_interpol, /button_set)) - - endelse - - ; draw blue box for zoom region - boxdim = long(15*2^imgzoom.scale) - tvbox, boxdim*wscale, imgzoom.xcn/2*wscale, imgzoom.ycn/2*wscale, color = 'blue' - - ; if positions is selected - if widget_info(pwwidget.button_loadpos, /button_set) then begin - - widget_control, pwwidget.button_pos, get_uvalue = position - - ; if framenum is listed in position - if position.defined then begin - - ii = where(position.frame eq img.framenum) - - if ii[0] ne -1 then begin - - ii = ii[0] - - ; draw red circle - tvcircle, 5*wscale, position.xpos[ii]/2*wscale, position.ypos[ii]/2*wscale, color = 'red',thick = 2 - - endif - - endif - - endif - - endif - - ; display image in draw_zoom - s = size(imgzoom.image) - - ; image is defined - if s[1] ne 0 then begin - - ; display image in main draw window - widget_control, pwwidget.draw_zoom, get_value = dWin - wset, dWin - erase - - ; retrieve slider values - widget_control, pwwidget.slider_min, get_value = minimo - widget_control, pwwidget.slider_max, get_value = massimo - - ; if log-scale option is selected - if widget_info(pwwidget.button_logscale, /button_set) then begin - - tvimazoom = bytscl(alog10(imgzoom.image + 1), alog10(minimo + 1), alog10(massimo + 1)) - - endif else begin - - tvimazoom = bytscl(imgzoom.image, minimo, massimo) - - endelse - - ; if button_negative option is selected - if widget_info(pwwidget.button_negative, /button_set) then begin - - tv, 255 - tvimazoom - - endif else begin - - tv, tvimazoom - - endelse - - ; draw position if available - if widget_info(pwwidget.button_loadpos, /button_set) then begin - - widget_control, pwwidget.button_pos, get_uvalue = position - - ; if framenum is listed in position - if position.defined then begin - - ii = where(position.frame eq img.framenum) - - if ii[0] ne -1 then begin - - ii = ii[0] - - if position.xpos[ii] ge min(imgzoom.xcoord) and position.xpos[ii] le max(imgzoom.xcoord) and $ - position.ypos[ii] ge min(imgzoom.ycoord) and position.ypos[ii] le max(imgzoom.ycoord) then begin - - dx = abs(imgzoom.xcoord - position.xpos[ii]) - dy = abs(imgzoom.ycoord - position.ypos[ii]) - - jx = where(abs(dx) eq min(dx)) - jy = where(abs(dy) eq min(dy)) - - jx = median(jx) - jy = median(jy) - - ; draw green box - tvcircle, 5*wscale, jx, jy, color = 'red',thick=2 - - if widget_info(pwwidget.button_showbox, /button_set) then begin - - tvbox, 2^(4 - imgzoom.scale)*(2*position.box[ii] + 1)*wscale, jx, jy, color = 'green', thick = 2, /device - - endif - - endif - - endif - - endif - - endif - - endif - -endif - -end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_cleanup.pro b/code/pwwidget/PWwidget_cleanup.pro deleted file mode 100644 index 2c03640..0000000 --- a/code/pwwidget/PWwidget_cleanup.pro +++ /dev/null @@ -1,13 +0,0 @@ -; This procedure managed the action to be performed when the -; PRISMAwidget is closed or die - -pro PWwidget_cleanup, widgetid - -compile_opt idl2 - -; go to the initial directory and destroy the widget -widget_control, widgetid, get_uvalue = pwwidget -cd, pwwidget.var.basedir -widget_control, widgetid, /destroy - -end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_draw.pro b/code/pwwidget/PWwidget_draw.pro deleted file mode 100644 index 58728e6..0000000 --- a/code/pwwidget/PWwidget_draw.pro +++ /dev/null @@ -1,75 +0,0 @@ -; This procedure manages the events on the draw widget big (main) window -; of PRISMAwidget - -pro PWwidget_draw, event - -compile_opt idl2 - -widget_control, event.top, get_uvalue = pwwidget -widget_control, pwwidget.text_filename, get_value = filename - -; scaling factor of the widget -wscale = pwwidget.var.wscale - -; if there is a loaded image on the widget -if filename ne '' then begin - - case event.type of - - ; moving mouse on image - 2: begin - widget_control, pwwidget.TEXT_XPOS, set_value = strtrim(event.x*2/wscale, 2) - widget_control, pwwidget.TEXT_YPOS, set_value = strtrim(event.y*2/wscale, 2) - - end - - ; button released - 1: begin - - ; right click - if event.release eq 4 then begin - - ;left click - endif else begin - - ; update window centre coordinates - widget_control, pwwidget.draw_big, get_uvalue = img - widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom - imgzoom.xcn = event.x*2/wscale - imgzoom.ycn = event.y*2/wscale - ds = long(15*2^imgzoom.scale) - - ; correct for border effects - if imgzoom.xcn lt ds then imgzoom.xcn = ds - if imgzoom.xcn gt img.xsize - ds then imgzoom.xcn = img.xsize - ds - if imgzoom.ycn lt ds then imgzoom.ycn = ds - if imgzoom.ycn gt img.ysize-ds then imgzoom.ycn = img.ysize - ds - - widget_control, pwwidget.TEXT_ZOOMXC, set_value = strtrim(imgzoom.xcn, 2) - widget_control, pwwidget.TEXT_ZOOMYC, set_value = strtrim(imgzoom.ycn, 2) - - xcoord = imgzoom.xcn - ds + indgen(2*ds) - ycoord = imgzoom.ycn - ds + indgen(2*ds) - imgzoom.xcoord = rebin(xcoord, 480*wscale) - imgzoom.ycoord = rebin(ycoord, 480*wscale) - - imgtmp = img.image[imgzoom.xcn - ds:imgzoom.xcn + ds - 1, imgzoom.ycn - ds:imgzoom.ycn + ds - 1] - imgzoom.image = rebin(imgtmp, 480*wscale, 480*wscale, sample = ~widget_info(pwwidget.button_interpol, /button_set)) - widget_control, pwwidget.draw_zoom, set_uvalue = imgzoom - - PW_draw_image, pwwidget - - endelse - - end - - ; no action to be performed - else: begin - - end - - endcase - -endif - -end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_interpolation.pro b/code/pwwidget/PWwidget_interpolation.pro deleted file mode 100644 index 622a900..0000000 --- a/code/pwwidget/PWwidget_interpolation.pro +++ /dev/null @@ -1,25 +0,0 @@ -; This procedure manages the event of button_interpol button of PRISMAwidget - -pro PWwidget_interpolation, event - -compile_opt idl2 - -widget_control, event.top, get_uvalue = pwwidget -widget_control, pwwidget.draw_big, get_uvalue = img -widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom - -ds=long(15*2^imgzoom.scale) - -imgtmp = img.image[imgzoom.xcn - ds:imgzoom.xcn + ds - 1, imgzoom.ycn - ds:imgzoom.ycn + ds - 1] -xcoord=imgzoom.xcn - ds + indgen(2*ds) -ycoord=imgzoom.ycn - ds + indgen(2*ds) - -imgzoom.xcoord = rebin(xcoord, imgzoom.xsize) -imgzoom.ycoord = rebin(ycoord, imgzoom.ysize) -imgzoom.image = rebin(imgtmp, imgzoom.xsize, imgzoom.ysize, sample = ~widget_info(pwwidget.button_interpol, /button_set)) - -widget_control, pwwidget.draw_zoom, set_uvalue = imgzoom - -PW_draw_image, pwwidget - -end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_playmovie.pro b/code/pwwidget/PWwidget_playmovie.pro deleted file mode 100644 index ac78af7..0000000 --- a/code/pwwidget/PWwidget_playmovie.pro +++ /dev/null @@ -1,219 +0,0 @@ -; This procedure manages the play and save movie function of PRISMAwidget - -pro PWwidget_playmovie, event - -compile_opt idl2 - -widget_control, /hourglass - -widget_control, event.top, get_uvalue = pwwidget - -; verify if the input is valid -widget_control, pwwidget.text_nframe, get_value = value - -split = strsplit(value, ',', /extract) - -case n_elements(split) of - - 0: begin - - error = dialog_message('Specify a non-zero number of frames', /error) - return - - end - - 1: begin - - nframe = long(split[0]) - delay = long(15) - - end - - 2: begin - - nframe = long(split[0]) - delay = long(split[1]) - - end - - else: begin - - error = dialog_message('specify a non-zero number of frames and optionally the desired delay time' + $ - 'of the movie in 1/100 seconds units, in the format nframe, delay', /error) - return - - end - -endcase - -direction = signum(nframe) -nframe = abs(nframe) - -; not a valid frame number -if nframe eq 0 then begin - - error = dialog_message('specify a non-zero number of frames', /error) - return - -endif - -; not a valid delay time -if delay lt 1 then begin - - error = dialog_message('specify a delay time of at least 1 (= 1/100 seconds)', /error) - return - -endif - -; retrieve current image name -widget_control, pwwidget.text_filename, get_value = filename -current = filename[0] - -; scaling factor of the widget -wscale = pwwidget.var.wscale - -charsize1 = 3.0*wscale -charsize2 = 2.0*wscale - -; correction for screen resolution scaling issue -adjust_font_size, charsize1, 96. -adjust_font_size, charsize2, 96. - -if event.id eq pwwidget.button_savemovie then begin - - ; loading the appropriate logo for the background - if widget_info(pwwidget.button_negative, /button_set) then begin - - logo = pwwidget.var.logo_white - text_color = 'black' - - endif else begin - - logo = pwwidget.var.logo_black - text_color = 'white' - - endelse - - ; retrieving imgzoom - widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom - - ; binning the logo to a nice dimension - logo = rebin(logo[*,1:528,1:528], 4, 132, 132) - imgstack = bytarr(nframe, imgzoom.xsize, imgzoom.ysize) - imgsum = lonarr(3, imgzoom.xsize, imgzoom.ysize) - r = bytarr(nframe, 256) - g = bytarr(nframe, 256) - b = bytarr(nframe, 256) - timestart = '' - -endif - -; iterating on the images -for i=0, nframe-1 do begin - - if i eq 0 then begin - - status = 0 - PW_draw_image, pwwidget - - endif else begin - - case direction of - - 1: widget_control, pwwidget.button_nextimage, get_uvalue = filename - -1: widget_control, pwwidget.button_previmage, get_uvalue = filename - - endcase - - ; reaching the end of the file list - if filename eq '' then begin - - if event.id eq pwwidget.button_savemovie then imgstack = imgstack[0:i-1,*,*] - nframe = i - break - - endif - - ; open the image - widget_control, pwwidget.text_filename, set_value = filename - - PW_open_image, pwwidget, status = status - - endelse - - if status then begin - - widget_control, pwwidget.text_filename, set_value = current - PW_open_image, pwwidget - return - - endif - - widget_control, pwwidget.draw_big, get_uvalue = img - - if event.id eq pwwidget.button_savemovie then begin - - ; snapshot of the current zoom window - snapshot = tvrd(/true) - imgsum = imgsum + long(snapshot) - - ; overplot the logo - cgimage, logo, alphafgposition = [(479. - 132.)/480., 5./480., 1., (5. + 132.)/480.] - camera = img.camera + ' - ' + img.pseudo - time = repstr(strmid(img.data, 0, 22), 'T', ' @ ') + ' UT' - - cgtext, 10./480., 450./480., camera, color = text_color, charsize = charsize1, /font, tt_font = 'DejaVuSans Bold' - cgtext, 10./480., 425./480., time, color = text_color, charsize = charsize2, /font, tt_font = 'DejaVuSans Bold' - - ; saving start time (first frame) - if i eq 0 then begin - - camera_start = camera - time_start = time - - endif - - ; getting the RGB decomposition and converting for gif format - tvlct, r0, g0, b0, /get - snapshot = tvrd(/true) - imgstack[i,*,*] = color_quan(snapshot, 1, r0, g0, b0, colors = 256, dither = 0) - r[i,*] = r0 - g[i,*] = g0 - b[i,*] = b0 - - endif - - wait, delay/100. - -endfor - -if event.id eq pwwidget.button_savemovie then begin - - ; save the gif animation - for i=0, nframe-1 do $ - write_gif, pwwidget.var.animation, reform(imgstack[i,*,*]), reform(r[i,*]), reform(g[i,*]), reform(b[i,*]), $ - /multiple, repeat_count = 0, delay_time = delay - write_gif, pwwidget.var.animation, reform(imgstack[0,*,*]), reform(r[0,*]), reform(g[0,*]), reform(b[0,*]), /close - - ; display the summed image - tvscl, imgsum, /true - - ; overplot the logo - cgimage, logo, alphafgposition = [(479. - 132.)/480., 5./480., 1., (5. + 132.)/480.] - - cgtext, 10./480., 450./480., camera_start, color = text_color, charsize = charsize1, /font, tt_font = 'DejaVuSans Bold' - cgtext, 10./480., 425./480., time_start, color = text_color, charsize = charsize2, /font, tt_font = 'DejaVuSans Bold' - - ; save the png track - snapshot = tvrd(/true) - write_png, pwwidget.var.track, snapshot - - wait, 3 - -endif - -; reaload the initial image -widget_control, pwwidget.text_filename, set_value = current -PW_open_image, pwwidget - -end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_positions.pro b/code/pwwidget/PWwidget_positions.pro deleted file mode 100644 index fbf133a..0000000 --- a/code/pwwidget/PWwidget_positions.pro +++ /dev/null @@ -1,98 +0,0 @@ -; This procedure manages the Position menu events of PRISMAwidget - -pro PWwidget_positions, event - -compile_opt idl2 - -widget_control, event.top, get_uvalue = pwwidget -widget_control, event.id, get_value = value -widget_control, pwwidget.button_pos, get_uvalue = position - -; case for different buttons -case value of - - 'Load': begin - - widget_control, pwwidget.button_loadpos, set_button = ~widget_info(pwwidget.button_loadpos, /button_set) - - ; load position file - if widget_info(pwwidget.button_loadpos, /button_set) then begin - - widget_control, pwwidget.table_pos, sensitive = 1 - widget_control, pwwidget.slider_box, sensitive = 1 - widget_control, pwwidget.button_fixbox, sensitive = 1 - widget_control, pwwidget.text_snrvalue, set_value = '', sensitive = 1 - widget_control, pwwidget.text_minvalue, sensitive = 1 - - PW_loadpos, pwwidget - PW_draw_image, pwwidget - - ; clear position - endif else begin - - widget_control, pwwidget.slider_box, get_value=dbox - - position = {DEFINED:0, POSFILE:position.posfile, FREETURE:position.freeture, NDET:0, frame:0, XPOS:0, YPOS:0, $ - STRCOORD:'', DATA:'', BOX:dbox} - widget_control,pwwidget.button_pos,set_uvalue = position - - widget_control, pwwidget.button_autopos, set_button = 0 - widget_control, pwwidget.button_showbox, set_button = 0 - widget_control, pwwidget.table_pos, sensitive = 0, table_ysize = 25, alignment = 2, set_value = ['', '', '', ''], $ - set_table_view = [0,0], set_table_select = [-1, -1, -1, -1] - widget_control, pwwidget.slider_box, sensitive = 0 - widget_control, pwwidget.button_fixbox, set_button = 0, sensitive = 0 - widget_control, pwwidget.text_snrvalue, set_value = '', sensitive = 0 - widget_control, pwwidget.text_minvalue, sensitive = 0 - - PW_draw_image, pwwidget - - endelse - - end - - 'Auto-centre': begin - - widget_control,pwwidget.button_autopos, set_button = ~widget_info(pwwidget.button_autopos, /button_set) - - if widget_info(pwwidget.button_autopos, /button_set) and widget_info(pwwidget.button_loadpos, /button_set) then begin - - ; check for fix-box button - button_fixbox = widget_info(pwwidget.button_fixbox, /button_set) - - if ~button_fixbox then begin - - widget_control, pwwidget.draw_big, get_uvalue=img - kk = where(position.frame eq img.framenum) - kk = kk[0] - - if kk ne -1 then widget_control, pwwidget.slider_box, set_value = position.box[kk] - - endif - - widget_control, pwwidget.text_snrvalue, set_value = '', sensitive = 1 - widget_control, pwwidget.text_minvalue, sensitive = 1 - - PW_autopos, pwwidget - PW_draw_image, pwwidget - - endif else begin - - widget_control, pwwidget.text_snrvalue, set_value = '', sensitive = 0 - widget_control, pwwidget.text_minvalue, sensitive = 0 - - endelse - - end - - 'Show Box': begin - - widget_control, pwwidget.button_showbox, set_button = ~widget_info(pwwidget.button_showbox, /button_set) - - PW_draw_image, pwwidget - - end - -endcase - -end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_slider_box.pro b/code/pwwidget/PWwidget_slider_box.pro deleted file mode 100644 index 1cd4455..0000000 --- a/code/pwwidget/PWwidget_slider_box.pro +++ /dev/null @@ -1,26 +0,0 @@ -; This procedure manages the events on the box dim slider of PRISMAwidget - -pro PWwidget_slider_box, event - -compile_opt idl2 - -widget_control, event.top, get_uvalue = pwwidget -widget_control, pwwidget.draw_big, get_uvalue = img -widget_control, pwwidget.button_pos, get_uvalue = position -widget_control, pwwidget.slider_box, get_value = box - -if widget_info(pwwidget.button_loadpos, /button_set) and widget_info(pwwidget.button_autopos, /button_set) then begin - - kk = where(position.frame eq img.framenum) - kk = kk[0] - - if kk ne -1 then position.box[kk] = box - - widget_control, pwwidget.button_pos, set_uvalue = position - - PW_autopos, pwwidget - PW_draw_image, pwwidget - -endif - -end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_slider_zoom.pro b/code/pwwidget/PWwidget_slider_zoom.pro deleted file mode 100644 index eff04ed..0000000 --- a/code/pwwidget/PWwidget_slider_zoom.pro +++ /dev/null @@ -1,38 +0,0 @@ -; This procedures manages the event on the zoom slider of PRISMAwidget - -pro PWwidget_slider_zoom, event - -compile_opt idl2 - -widget_control, event.top, get_uvalue = pwwidget -widget_control, pwwidget.slider_zoom, get_value = scala -widget_control, pwwidget.draw_big, get_uvalue = img -widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom - -; scaling factor of the widget -wscale = pwwidget.var.wscale - -imgzoom.scale = scala -ds = long(15*2^imgzoom.scale) - -; adjust border effects -if imgzoom.xcn lt ds then imgzoom.xcn = ds -if imgzoom.xcn gt img.xsize - ds then imgzoom.xcn = img.xsize - ds -if imgzoom.ycn lt ds then imgzoom.ycn = ds -if imgzoom.ycn gt img.ysize - ds then imgzoom.ycn = img.ysize - ds - -widget_control, pwwidget.TEXT_ZOOMXC, set_value = strtrim(imgzoom.xcn, 2) -widget_control, pwwidget.TEXT_ZOOMYC, set_value = strtrim(imgzoom.ycn, 2) - -xcoord = imgzoom.xcn - ds + indgen(2*ds) -ycoord = imgzoom.ycn - ds + indgen(2*ds) -imgzoom.xcoord = rebin(xcoord, 480*wscale) -imgzoom.ycoord = rebin(ycoord, 480*wscale) - -imgtmp = img.image[imgzoom.xcn - ds:imgzoom.xcn + ds - 1, imgzoom.ycn - ds:imgzoom.ycn + ds - 1] -imgzoom.image=rebin(imgtmp, 480*wscale, 480*wscale, sample = ~widget_info(pwwidget.button_interpol, /button_set)) - -widget_control, pwwidget.draw_zoom, set_uvalue = imgzoom -PW_draw_image, pwwidget - -end \ No newline at end of file diff --git a/code/pwwidget/PWwidget_zoom.pro b/code/pwwidget/PWwidget_zoom.pro deleted file mode 100644 index d52d1a0..0000000 --- a/code/pwwidget/PWwidget_zoom.pro +++ /dev/null @@ -1,229 +0,0 @@ -; This procedure manages the events on the zoom draw window of PRISMAwidget - -pro PWwidget_zoom, event - -compile_opt idl2 - -widget_control, event.top, get_uvalue = pwwidget -widget_control, pwwidget.text_filename, get_value = filename - -; scaling factor of the widget -wscale = pwwidget.var.wscale - -if filename ne '' then begin - - ; case for different event types - case event.type of - - ; moving mouse on image - 2: begin - - widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom - widget_control, pwwidget.text_xpos, set_value = strtrim(imgzoom.xcoord[event.x], 2) - widget_control, pwwidget.text_ypos, set_value = strtrim(imgzoom.ycoord[event.y], 2) - widget_control, pwwidget.text_imgvalue, set_value = strtrim(fix(imgzoom.image[event.x,event.y]), 2) - - end - - ; button released - 1: begin - - ; retrieve images - widget_control, pwwidget.draw_big, get_uvalue = img - widget_control, pwwidget.draw_zoom, get_uvalue = imgzoom - - ; retrieve mouse position in image coordinates - imgzoom.xcn = imgzoom.xcoord[event.x] - imgzoom.ycn = imgzoom.ycoord[event.y] - - ; right click - save current position in position.txt - if event.release eq 4 then begin - - if widget_info(pwwidget.button_loadpos, /button_set) then begin - - widget_control, pwwidget.button_pos, get_uvalue = position - widget_control, pwwidget.slider_box, get_value = dbox - - defined = position.defined - Ndet = position.Ndet - posfile = position.posfile - freeture = position.freeture - frame = position.frame - xpos = position.xpos - ypos = position.ypos - strcoord = position.strcoord - data = position.data - box = position.box - - if defined then begin - - ; looking if the current image is already listed in position - ii = where(frame eq img.framenum, complement = ii0) - - ; if listed - if ii[0] ne -1 then begin - - id = ii[0] - - ; if the selected pixel is the same already saved - if xpos[id] eq imgzoom.xcn and ypos[id] eq imgzoom.ycn then begin - - ; remove from the list - if ii0[0] ne -1 then begin - - Ndet = Ndet - 1 - frame = frame[ii0] - xpos = xpos[ii0] - ypos = ypos[ii0] - strcoord = strcoord[ii0] - data = data[ii0] - box = box[ii0] - - ; it was the last one, undefine position - endif else begin - - defined = 0 - Ndet = 0 - frame = 0 - xpos = 0 - ypos = 0 - strcoord = '' - data = '' - box = dbox - - endelse - - ; replace the value in position - endif else begin - - xpos[id] = imgzoom.xcn - ypos[id] = imgzoom.ycn - strcoord[id] = '('+strtrim(imgzoom.xcn, 2) + ';' + strtrim(imgzoom.ycn, 2) + ')' - data[id] = img.data - box[id] = dbox - - endelse - - ; add to the list - endif else begin - - Ndet = Ndet + 1 - frame = [frame, img.framenum] - xpos = [xpos, imgzoom.xcn] - ypos = [ypos, imgzoom.ycn] - strcoord = [strcoord, '(' + strtrim(imgzoom.xcn, 2) + ';' + strtrim(imgzoom.ycn,2) + ')'] - data = [data, img.data] - box = [box, dbox] - - jj = sort(frame) - - frame = frame[jj] - xpos = xpos[jj] - ypos = ypos[jj] - strcoord = strcoord[jj] - data = data[jj] - box = box[jj] - - endelse - - ; it is the first value inserted, define position - endif else begin - - defined = 1 - Ndet = 1 - frame = [img.framenum] - xpos = [imgzoom.xcn] - ypos = [imgzoom.ycn] - strcoord = ['(' + strtrim(imgzoom.xcn, 2) + ';' + strtrim(imgzoom.ycn, 2) + ')'] - data = [img.data] - box = dbox - - endelse - - position = {defined:defined, posfile:posfile, freeture:freeture, Ndet:Ndet, frame:frame, xpos:xpos, ypos:ypos, $ - strcoord:strcoord, data:data, box:box} - - widget_control, pwwidget.button_pos, set_uvalue = position - - nl = n_elements(xpos) - openw, lun, posfile, /get_lun - if defined then for i=0, nl-1 do printf, lun, frame[i], strcoord[i], data[i], box[i], format = '(I7,A15,A30,I7)' - close, lun & free_lun, lun - - ; print position to widget table - if defined then begin - - str = transpose([[string(fix(frame))], [string(strcoord)], [string(data)], [string(box)]]) - - endif else begin - - str = ['', '', '', ''] - - endelse - - widget_control, pwwidget.table_pos, table_ysize = Ndet > 25, alignment = 2, set_value = str - PW_draw_image, pwwidget - - ; compute the box limits - minx = max([0, imgzoom.xcn - dbox]) - maxx = min([img.xsize-1, imgzoom.xcn + dbox]) - miny = max([0, imgzoom.ycn - dbox]) - maxy = min([img.ysize-1, imgzoom.ycn + dbox]) - - bocs = img.image[minx:maxx, miny:maxy] - - ; median filtering - mediana = median(bocs, /even) - sigma = sqrt(mean((bocs - mediana)^2)) - jj = where(bocs gt mediana + 3*sigma, njj, complement = jj0) - - ; evaluation of signal-to-noise ratio - if jj[0] ne -1 then begin - - signal = total(float(bocs[jj])) - mediana*njj - noise = sqrt(mean((bocs[jj0] - mediana)^2)) - SNR = signal/(noise*sqrt(njj)) - - endif else SNR = 0. - - widget_control, pwwidget.text_snrvalue, set_value = strtrim(string(SNR, format = '(f10.1)'), 2) - - endif - - ; left click - re-centre zoom box - endif else begin - - ; update window centre coordinates - ds = long(15*2^imgzoom.scale) - - ; correct for border effects - if imgzoom.xcn lt ds then imgzoom.xcn = ds - if imgzoom.xcn gt img.xsize-ds then imgzoom.xcn = img.xsize - ds - if imgzoom.ycn lt ds then imgzoom.ycn = ds - if imgzoom.ycn gt img.ysize-ds then imgzoom.ycn = img.ysize - ds - widget_control, pwwidget.text_zoomxc, set_value = strtrim(imgzoom.xcn, 2) - widget_control, pwwidget.text_zoomyc, set_value = strtrim(imgzoom.ycn, 2) - xcoord = imgzoom.xcn - ds + indgen(2*ds) - ycoord = imgzoom.ycn - ds + indgen(2*ds) - imgzoom.xcoord = rebin(xcoord, 480*wscale) - imgzoom.ycoord = rebin(ycoord, 480*wscale) - imgtmp = img.image[imgzoom.xcn - ds:imgzoom.xcn + ds - 1, imgzoom.ycn - ds:imgzoom.ycn + ds - 1] - imgzoom.image = rebin(imgtmp, 480*wscale, 480*wscale, sample = ~widget_info(pwwidget.button_interpol, /button_set)) - widget_control, pwwidget.draw_zoom, set_uvalue = imgzoom - - PW_draw_image, pwwidget - - endelse - - end - - ; nothing to do in the other case - else: begin - - end - - endcase - -endif - -end \ No newline at end of file -- GitLab