Files
GridBased/scripts/rerun_star_column_masked.sh
T
xie_x1andClaude Opus 5.5 0f9a3f496f Initial commit: grid-based multi-photon reconstruction
Code, configs, charge LUTs, best.pth and evaluation records for each
training run, the knife-edge / Siemens-star / XRF notebooks with
outputs, and the overnight run reports. Epoch checkpoints, inference
results and HTML exports stay local (see .gitignore).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 07:36:49 +02:00

84 lines
3.3 KiB
Bash

#!/usr/bin/env bash
# Siemens star again with the masked column common mode (2026-09-28).
# The 09-27 run used the plain column median, which the ~5 % occupancy of the
# star pulls up: the 15 keV line came out at 14.47 keV. Outputs carry the tag
# _poly2to20_cmmasked, next to the old _poly2to20 ones.
#
# setsid nohup bash scripts/rerun_star_column_masked.sh \
# >> Results/overnight_poly2to20keV_Moench040/driver.log 2>&1 < /dev/null &
#
# After parts 0-1 (half of the 20 M frames) the notebook is executed on them and
# kept as SiemensStar_poly2to20keV_15keV_50pct.ipynb (+ HTML, summary json), so
# a result exists even if the rest does not finish; after all four parts the
# main notebook is executed in place.
set -u
cd /home/xie_x1/MLXID/GridBased
ENV_BIN=/home/xie_x1/software/miniforge3/envs/pytorch_nightly/bin
PY=$ENV_BIN/python
BASE=Results/overnight_poly2to20keV_Moench040
LOG=$BASE/logs
STATE=$BASE/state
STATUS=$BASE/status.md
REPORT=$BASE/report
STAR=Configs/infer_measurement_poly_Moench040_star.yaml
TAG=poly2to20_cmmasked
experiment=$(cat "$STATE/experiment")
checkpoint=$experiment/Models/best.pth
export OMP_NUM_THREADS=4 MKL_NUM_THREADS=4
export PATH=$ENV_BIN:$PATH GRID_POLY_TAG=$TAG
NOTEBOOK=Notebooks/SiemensStar_poly2to20keV_15keV
note() {
echo "- $(date '+%m-%d %H:%M:%S') $*" >> "$STATUS"
echo "$(date '+%m-%d %H:%M:%S') $*"
}
run() {
local name=$1; shift
if [ -f "$STATE/$name.done" ]; then
note "$name: already done, skipped"; return 0
fi
note "$name: started"
local started=$(date +%s)
"$@" > "$LOG/$name.log" 2>&1
local status=$?
local minutes=$(( ($(date +%s) - started) / 60 ))
if [ $status -eq 0 ]; then
touch "$STATE/$name.done"
note "$name: done (${minutes} min) $(grep -o '([0-9]* frame/s)' "$LOG/$name.log" | tail -1)"
else
note "$name: **FAILED** (exit $status after ${minutes} min), see logs/$name.log"
fi
return $status
}
snapshot() { # executed copy of the notebook on the first two parts
GRID_STAR_RUNS=SiemensStar_15keV_part0,SiemensStar_15keV_part1 \
GRID_STAR_SUMMARY=siemens_star_poly2to20keV_summary_50pct.json \
jupyter nbconvert --to notebook --execute --ExecutePreprocessor.timeout=3600 \
--ExecutePreprocessor.kernel_name=python3 \
--output SiemensStar_poly2to20keV_15keV_50pct.ipynb "$NOTEBOOK.ipynb" && \
jupyter nbconvert --to html --output-dir "$REPORT" "${NOTEBOOK}_50pct.ipynb"
}
full() {
jupyter nbconvert --to notebook --execute --inplace --ExecutePreprocessor.timeout=3600 \
--ExecutePreprocessor.kernel_name=python3 "$NOTEBOOK.ipynb" && \
jupyter nbconvert --to html --output-dir "$REPORT" "$NOTEBOOK.ipynb"
}
note "=== Siemens star rerun, column_masked (pid $$), tag $TAG ==="
for part in 0 1; do
run infer_star_cmmasked_part$part $PY scripts/05_infer_measurement.py --config $STAR \
--run SiemensStar_15keV_part$part --checkpoint "$checkpoint" --tag $TAG
done
run notebook_star_cmmasked_50pct snapshot
for part in 2 3; do
run infer_star_cmmasked_part$part $PY scripts/05_infer_measurement.py --config $STAR \
--run SiemensStar_15keV_part$part --checkpoint "$checkpoint" --tag $TAG
done
rm -f "$STATE/notebook_star_cmmasked.done"
run notebook_star_cmmasked full
note "=== Siemens star rerun finished ==="