Commit 2e70b477 authored by Zhang, Yuanpeng's avatar Zhang, Yuanpeng
Browse files

debug the calib routine

parent f1f4f393
Loading
Loading
Loading
Loading
−4.64 KiB (370 KiB)

File changed.

No diff preview for this file type.

−4.64 KiB (370 KiB)

File changed.

No diff preview for this file type.

+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
    "Instrument": "PG3",
    "Date": "2023-02-14",
    "SampleEnv": "MAG-He3",
    "Notes": "ZYP",
    "Notes": "",
    "OutputDir": "/SNS/PG3/shared/CALIBRATION/autoreduce",
    "PDCalibration": {
        "TofBinningFirst": "300,-0.0008,16667",
+28 −19
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ PDCalibration(InputWorkspace=wksp,
              PeakWidthPercent=peak_width_perct,
              TZEROrange=tzero_range,
              OutputCalibrationTable='PDCalib',
              MaskWorkspace="PDCalib_mask",
              DiagnosticWorkspaces='diag')
RenameWorkspace(InputWorkspace='PDCalib_mask',
                OutputWorkspace='PG3_mask')
@@ -147,6 +148,7 @@ PDCalibration(InputWorkspace=wksp,
              PeakWidthPercent=peak_width_perct_sec,
              TZEROrange=tzero_range,
              OutputCalibrationTable='PDCalib',
              MaskWorkspace="PDCalib_mask",
              DiagnosticWorkspaces='diag')
PDCalibration(InputWorkspace=wksp,
              TofBinning=tof_bin_third,
@@ -158,6 +160,7 @@ PDCalibration(InputWorkspace=wksp,
              PeakWidthPercent=peak_width_perct_sec,
              TZEROrange=tzero_range,
              OutputCalibrationTable='PDCalib',
              MaskWorkspace="PDCalib_mask",
              DiagnosticWorkspaces='diag')

# Merge in the manual mask
@@ -324,30 +327,36 @@ if post_image:
    html_tmp += '<img src=\'data:image/png;base64,{}\'>'.format(encoded)
    html = "<div>{}</div>".format(html_tmp)

    request = publish_plot(instr_name, dia_run_num, files={"file": html})

print("\n======================")
print("Done with calibration.")
print("======================")

# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#                      |||||      Diagnostics-2      |||||
#                      vvvvv  Calib versus Engineer  vvvvv
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

fig, ax = diagnostics.difc_plot2d("_cal", "_cal_eng", instr_ws="_group",
                                  mask="_mask", vrange=(0, 5))

diag_file_name = cal_file_name.replace(".h5", "_diag_2.png")
diag_file_1 = os.path.join(diag_dir_1, diag_file_name)
fig.savefig(diag_file_1, format='png', dpi=300)
diag_file_2 = os.path.join(diag_dir_2, diag_file_name)
fig.savefig(diag_file_2, format='png', dpi=300)

if post_image:
    tmpfile = BytesIO()
    fig.savefig(tmpfile, format='png', dpi=200)
    encoded = base64.b64encode(tmpfile.getvalue()).decode('utf-8')
    
    html_tmp = '<h4>Calibrated vs. Engineering calibration constant</h4>'
    html_tmp += '<img src=\'data:image/png;base64,{}\'>'.format(encoded)
    html += "<div>{}</div>".format(html_tmp)
    
    request = publish_plot(instr_name, dia_run_num, files={"file": html})
# fig, ax = diagnostics.difc_plot2d("_cal", "_cal_eng", instr_ws="_group",
#                                   mask="_mask", vrange=(0, 5))
# 
# diag_file_name = cal_file_name.replace(".h5", "_diag_2.png")
# diag_file_1 = os.path.join(diag_dir_1, diag_file_name)
# fig.savefig(diag_file_1, format='png', dpi=300)
# diag_file_2 = os.path.join(diag_dir_2, diag_file_name)
# fig.savefig(diag_file_2, format='png', dpi=300)
# 
# if post_image:
#     tmpfile = BytesIO()
#     fig.savefig(tmpfile, format='png', dpi=200)
#     encoded = base64.b64encode(tmpfile.getvalue()).decode('utf-8')
#     
#     html_tmp = '<h4>Calibrated vs. Engineering calibration constant</h4>'
#     html_tmp += '<img src=\'data:image/png;base64,{}\'>'.format(encoded)
#     html += "<div>{}</div>".format(html_tmp)
#     
#     request = publish_plot(instr_name, dia_run_num, files={"file": html})

# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# Done with calibration diagnostics plots publishing