Commit 8e9def7d authored by Zhang, Yuanpeng's avatar Zhang, Yuanpeng
Browse files

calib doctor support

parent a7265190
Loading
Loading
Loading
Loading
+27 −9
Original line number Diff line number Diff line
{
    "Diamond": "/SNS/PG3/IPTS-32378/nexus/PG3_62140.nxs.h5",
    "Diamond": "/SNS/PG3/IPTS-32378/nexus/PG3_62295.nxs.h5",
    "RunCycle": "2026-1_11A_CAL",
    "Instrument": "PG3",
    "Date": "2026-03-05",
    "Date": "2026-03-25",
    "SampleEnv": "PAC",
    "Notes": "",
    "OutputDir": "/SNS/PG3/shared/CALIBRATION/autoreduce",
@@ -20,32 +20,50 @@
    "ManualMaskFile": "2022-2_11A_CAL/Masks/PG3_43095_manual_mask.xml",
    "Diagnostics": {
        "PAC": {
            "NumMasks": [3790, 200],
            "NumMasks": [
                3790,
                200
            ],
            "NumBadUnmasked": 50,
            "NumOutliers": 20
        },
        "MAG": {
            "NumMasks": [10400, 250],
            "NumMasks": [
                10400,
                250
            ],
            "NumBadUnmasked": 300,
            "NumOutliers": 20
        },
        "OC": {
            "NumMasks": [4340, 200],
            "NumMasks": [
                4340,
                200
            ],
            "NumBadUnmasked": 50,
            "NumOutliers": 20
        },
        "MICAS": {
            "NumMasks": [3250, 200],
            "NumMasks": [
                3250,
                200
            ],
            "NumBadUnmasked": 350,
            "NumOutliers": 20
        },
        "LTJANIS": {
            "NumMasks": [4050, 200],
            "NumMasks": [
                4050,
                200
            ],
            "NumBadUnmasked": 50,
            "NumOutliers": 20
        },
        "JANISGAS": {
            "NumMasks": [3600, 200],
            "NumMasks": [
                3600,
                200
            ],
            "NumBadUnmasked": 30,
            "NumOutliers": 20
        }
+11 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import glob
import urllib
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import shutil
sys.path.append("/SNS/users/y8z/miniconda/envs/slack/lib/python3.13/site-packages/")
from slack_sdk import WebClient

@@ -528,9 +529,19 @@ def pg3_calib_doctor(run_num, cal_file, manual_mask, out_dir, diag_dict):
    print("[Info] # of masked good pixels: ", len(good_pixels_masked))
    print("[Info] # of unmasked bad pxiels: ", len(bad_pixels_unmasked))

    def clear_directory(dir_path):
        for item in os.listdir(dir_path):
            item_path = os.path.join(dir_path, item)
            if os.path.isfile(item_path) or os.path.islink(item_path):
                os.remove(item_path)
            elif os.path.isdir(item_path):
                shutil.rmtree(item_path)

    run_out_dir = os.path.join(out_dir, f"{run_num}")
    if not os.path.exists(run_out_dir):
        os.makedirs(run_out_dir)
    else:
        clear_directory(run_out_dir)

    if len(bad_pixels_unmasked) > 0:
        ExtractSpectra(