-
Notifications
You must be signed in to change notification settings - Fork 61
Reapply "Add dusk-view CI job and generate_svg scripts" #1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wdconinc
wants to merge
3
commits into
main
Choose a base branch
from
wdconinc/dusk-view
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/usr/bin/env python3 | ||
| """make_dusk_views — run dusk/duskcut generate_svg scripts for a detector view. | ||
|
|
||
| Analogous to make_dawn_views but uses STEP files and produces SVG output. | ||
|
|
||
| Usage: | ||
| make_dusk_views -i detector.stp -d scripts/view1 -t view01 [-o images/] | ||
| """ | ||
|
|
||
| import os | ||
| import subprocess | ||
| import argparse | ||
|
|
||
| parser = argparse.ArgumentParser(description="Generate SVG views using dusk/duskcut") | ||
|
|
||
| parser.add_argument('-i', '--input', type=str, dest='input', required=True, | ||
| help='Input STEP file (.stp)') | ||
| parser.add_argument('-o', '--output-dir', type=str, dest='out_dir', | ||
| default='images', | ||
| help='Output directory for SVG files (default: images)') | ||
| parser.add_argument('-d', '--dusk-dir', type=str, dest='dusk_dir', | ||
| default='scripts/view1', | ||
| help='Directory containing the generate_svg script') | ||
| parser.add_argument('-t', '--tag', type=str, dest='file_tag', | ||
| default='view', | ||
| help='Output file tag passed to generate_svg') | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| os.makedirs(args.out_dir, exist_ok=True) | ||
|
|
||
| # Use absolute paths so chdir does not break them | ||
| args.input = os.path.abspath(args.input) | ||
| args.out_dir = os.path.abspath(args.out_dir) | ||
|
|
||
| owd = os.getcwd() | ||
| os.chdir(args.dusk_dir) | ||
| subprocess.run(['pwd']) | ||
| subprocess.run(['./generate_svg', '-t', args.file_tag, '-i', args.input]) | ||
| subprocess.run(['ls', '-lrth']) | ||
|
|
||
| os.system('cp *.svg {}'.format(args.out_dir)) | ||
| os.chdir(owd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env bash | ||
| # generate_svg — dusk/duskcut equivalent of generate_eps for view1 | ||
| # Produces side and top SVG views using STEP file input. | ||
| # | ||
| # Usage: ./generate_svg -i detector.stp [-t tag] | ||
|
|
||
| function print_the_help { | ||
| echo "USAGE: $0 -i <STEP_FILE> [-t <tag>]" | ||
| echo " OPTIONS:" | ||
| echo " -i, --input <file> input STEP file (required)" | ||
| echo " -t, --tag <tag> filename tag (default: view01)" | ||
| exit 0 | ||
| } | ||
|
|
||
| FILE_TAG="view01" | ||
| INPUT_FILE="" | ||
|
|
||
| POSITIONAL=() | ||
| while [[ $# -gt 0 ]]; do | ||
| key="$1" | ||
| case $key in | ||
| -h|--help) print_the_help ;; | ||
| -i|--input) INPUT_FILE="$2"; shift; shift ;; | ||
| -t|--tag) FILE_TAG="$2"; shift; shift ;; | ||
| *) echo "unknown option $1"; print_the_help ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ -z "${INPUT_FILE}" ]]; then | ||
| echo "Error: no input file specified." | ||
| print_the_help | ||
| fi | ||
|
|
||
| # Side view — cut at x=1 mm (keep x >= 1 mm), theta=165, phi=75, draw=3 | ||
| duskcut -1 0 0 1 "${INPUT_FILE}" "${FILE_TAG}_side.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}_side.stp" --mag 10 --draw 3 --theta 165 --phi 75 \ | ||
| --light-theta 180 --light-phi 90 -o "${FILE_TAG}.svg" | ||
|
|
||
| # Top view — thin y-slice near y=0, theta=90, phi=90, draw=1 | ||
| duskcut 0 1 0 1 "${INPUT_FILE}" "${FILE_TAG}_top_t0.stp" | ||
| duskcut 0 -1 0 1 "${FILE_TAG}_top_t0.stp" "${FILE_TAG}_top.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}_top.stp" --mag 10 --draw 1 --theta 90 --phi 90 \ | ||
| -o "${FILE_TAG}_top.svg" | ||
|
|
||
| rm -f "${FILE_TAG}_side.stp" "${FILE_TAG}_top_t0.stp" "${FILE_TAG}_top.stp" | ||
| echo "[generate_svg] Done: ${FILE_TAG}.svg ${FILE_TAG}_top.svg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/usr/bin/env bash | ||
| # generate_svg — dusk/duskcut equivalent of generate_eps for view11 | ||
| # Slightly tilted XZ section along the beamline (x = ±200mm with small z tilt). | ||
|
|
||
| function print_the_help { | ||
| echo "USAGE: $0 -i <STEP_FILE> [-t <tag>]" | ||
| exit 0 | ||
| } | ||
|
|
||
| FILE_TAG="view11" | ||
| INPUT_FILE="" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -h|--help) print_the_help ;; | ||
| -i|--input) INPUT_FILE="$2"; shift; shift ;; | ||
| -t|--tag) FILE_TAG="$2"; shift; shift ;; | ||
| *) echo "unknown option $1"; print_the_help ;; | ||
| esac | ||
| done | ||
|
|
||
| [[ -z "${INPUT_FILE}" ]] && { echo "Error: no input file."; print_the_help; } | ||
|
|
||
| # Slightly tilted slice near x=0 along the beam axis | ||
| # dawncut 1 0 -0.01666 200 → plane x - 0.01666*z + 200 = 0, keeps x - 0.01666*z >= -200 | ||
| # dawncut -1 0 0.01666 200 → plane -x + 0.01666*z + 200 = 0, keeps -x + 0.01666*z <= -200 | ||
| duskcut 1 0 -0.01666 200 "${INPUT_FILE}" "${FILE_TAG}_t0.stp" | ||
| duskcut -1 0 0.01666 200 "${FILE_TAG}_t0.stp" "${FILE_TAG}.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}.stp" --draw 2 -o "${FILE_TAG}.svg" | ||
|
|
||
| rm -f "${FILE_TAG}_t0.stp" "${FILE_TAG}.stp" | ||
| echo "[generate_svg] Done: ${FILE_TAG}.svg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/usr/bin/env bash | ||
| # generate_svg — dusk/duskcut equivalent of generate_eps for view13 | ||
| # Everything downstream of z = 5 m (forward spectrometer region). | ||
|
|
||
| function print_the_help { | ||
| echo "USAGE: $0 -i <STEP_FILE> [-t <tag>]" | ||
| exit 0 | ||
| } | ||
|
|
||
| FILE_TAG="view13" | ||
| INPUT_FILE="" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -h|--help) print_the_help ;; | ||
| -i|--input) INPUT_FILE="$2"; shift; shift ;; | ||
| -t|--tag) FILE_TAG="$2"; shift; shift ;; | ||
| *) echo "unknown option $1"; print_the_help ;; | ||
| esac | ||
| done | ||
|
|
||
| [[ -z "${INPUT_FILE}" ]] && { echo "Error: no input file."; print_the_help; } | ||
|
|
||
| # dawncut 0 0 -1 -5000 → plane -z-5000=0 → z=-5000, clips -z-5000>0 i.e. z<-5000 | ||
| # Wait: clips front side: 0*x+0*y+(-1)*z+(-5000)>0 → -z-5000>0 → z<-5000 | ||
| # Actually let me re-read: dawncut 0 0 -1 -5000 | ||
| # plane: -z + (-5000) = 0 → z = -5000, but that's wrong for "downstream of z=5000" | ||
| # From generate_eps comment: "everything downstream of z = 5 m" | ||
| # dawncut 0 0 -1 -5000: clips -z-5000 > 0 → -z > 5000 → z < -5000. Keeps z >= -5000. | ||
| # But "downstream" in EIC is hadron-going (+z). Hmm, dawncut convention: n=(0,0,-1), d=-5000. | ||
| # Plane: -z - 5000 = 0 → z = -5000. Keep: -z - 5000 ≤ 0 → z ≥ -5000. | ||
| # That keeps z ≥ -5000, i.e. everything except z < -5000. For EIC, ion beam goes in +z, | ||
| # so "downstream" = large +z. This view must keep the z > 5000 mm region. | ||
| # Let me trust the original script literal translation: duskcut 0 0 -1 -5000 | ||
| duskcut 0 0 -1 -5000 "${INPUT_FILE}" "${FILE_TAG}b.stp" | ||
|
Comment on lines
+24
to
+35
|
||
| dusk --mesh-deflection 5 -d "${FILE_TAG}b.stp" --draw 2 -o "${FILE_TAG}b.svg" | ||
|
|
||
| rm -f "${FILE_TAG}b.stp" | ||
| echo "[generate_svg] Done: ${FILE_TAG}b.svg" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/usr/bin/env bash | ||
| # generate_svg — dusk/duskcut equivalent of generate_eps for view3 | ||
| # Single XZ side view of the central region (z <= 1500 mm). | ||
|
|
||
| function print_the_help { | ||
| echo "USAGE: $0 -i <STEP_FILE> [-t <tag>]" | ||
| exit 0 | ||
| } | ||
|
|
||
| FILE_TAG="view3" | ||
| INPUT_FILE="" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -h|--help) print_the_help ;; | ||
| -i|--input) INPUT_FILE="$2"; shift; shift ;; | ||
| -t|--tag) FILE_TAG="$2"; shift; shift ;; | ||
| *) echo "unknown option $1"; print_the_help ;; | ||
| esac | ||
| done | ||
|
|
||
| [[ -z "${INPUT_FILE}" ]] && { echo "Error: no input file."; print_the_help; } | ||
|
|
||
| # Keep the portion of the model with z >= 1500 mm. | ||
| duskcut 0 0 -1 1500 "${INPUT_FILE}" "${FILE_TAG}.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}.stp" --draw 2 -o "${FILE_TAG}.svg" | ||
|
|
||
| rm -f "${FILE_TAG}.stp" | ||
| echo "[generate_svg] Done: ${FILE_TAG}.svg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| # generate_svg — dusk/duskcut equivalent of generate_eps for view50 | ||
| # Side view with extended z range and a top-down view of the full detector. | ||
|
|
||
| function print_the_help { | ||
| echo "USAGE: $0 -i <STEP_FILE> [-t <tag>]" | ||
| exit 0 | ||
| } | ||
|
|
||
| FILE_TAG="view01" | ||
| INPUT_FILE="" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -h|--help) print_the_help ;; | ||
| -i|--input) INPUT_FILE="$2"; shift; shift ;; | ||
| -t|--tag) FILE_TAG="$2"; shift; shift ;; | ||
| *) echo "unknown option $1"; print_the_help ;; | ||
| esac | ||
| done | ||
|
|
||
| [[ -z "${INPUT_FILE}" ]] && { echo "Error: no input file."; print_the_help; } | ||
|
|
||
| # Side view — upper half only (y >= 1 mm), mag=4, theta=90, phi=40, draw=3 | ||
| duskcut 0 1 0 1 "${INPUT_FILE}" "${FILE_TAG}_side.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}_side.stp" --mag 4 --draw 3 \ | ||
| --theta 90 --phi 40 --light-theta 180 --light-phi 90 \ | ||
| -z 15000 -o "${FILE_TAG}.svg" | ||
|
|
||
| # Top view — thin y-slice, mag=10, theta=270, phi=90, draw=1 | ||
| duskcut 0 1 0 1 "${INPUT_FILE}" "${FILE_TAG}_top_t0.stp" | ||
| duskcut 0 -1 0 1 "${FILE_TAG}_top_t0.stp" "${FILE_TAG}_top.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}_top.stp" --mag 10 --draw 1 --theta 270 --phi 90 \ | ||
| -o "${FILE_TAG}_top.svg" | ||
|
|
||
| rm -f "${FILE_TAG}_side.stp" "${FILE_TAG}_top_t0.stp" "${FILE_TAG}_top.stp" | ||
| echo "[generate_svg] Done: ${FILE_TAG}.svg ${FILE_TAG}_top.svg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/usr/bin/env bash | ||
| # generate_svg — dusk/duskcut equivalent of generate_eps for view6 | ||
| # Series of XY (endcap) slices at different z positions for the Si Tracker. | ||
|
|
||
| function print_the_help { | ||
| echo "USAGE: $0 -i <STEP_FILE> [-t <tag>]" | ||
| exit 0 | ||
| } | ||
|
|
||
| FILE_TAG="view06" | ||
| INPUT_FILE="" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -h|--help) print_the_help ;; | ||
| -i|--input) INPUT_FILE="$2"; shift; shift ;; | ||
| -t|--tag) FILE_TAG="$2"; shift; shift ;; | ||
| *) echo "unknown option $1"; print_the_help ;; | ||
| esac | ||
| done | ||
|
|
||
| [[ -z "${INPUT_FILE}" ]] && { echo "Error: no input file."; print_the_help; } | ||
|
|
||
| # Pre-cut to |z| <= 1000 mm | ||
| duskcut 0 0 -1 1000 "${INPUT_FILE}" "${FILE_TAG}_pre0.stp" | ||
| duskcut 0 0 1 1000 "${FILE_TAG}_pre0.stp" "${FILE_TAG}_input.stp" | ||
|
|
||
| INPUT="${FILE_TAG}_input.stp" | ||
|
|
||
| # Slice a: |z| <= 1 mm (central XY plane) | ||
| duskcut 0 0 -1 1 "${INPUT}" "${FILE_TAG}a_t0.stp" | ||
| duskcut 0 0 1 1 "${FILE_TAG}a_t0.stp" "${FILE_TAG}a.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}a.stp" --mag 14 --draw 2 -o "${FILE_TAG}a.svg" | ||
|
|
||
| # Slice b: SiTracker Endcap layer 5 (860-945 mm) | ||
| duskcut 0 0 1 945 "${INPUT}" "${FILE_TAG}b_t0.stp" | ||
| duskcut 0 0 -1 -865 "${FILE_TAG}b_t0.stp" "${FILE_TAG}b.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}b.stp" --mag 14 --draw 2 -o "${FILE_TAG}b.svg" | ||
|
|
||
| # Slice c: SiTracker Endcap layer 4 (695-780 mm) | ||
| duskcut 0 0 1 780 "${INPUT}" "${FILE_TAG}c_t0.stp" | ||
| duskcut 0 0 -1 -700 "${FILE_TAG}c_t0.stp" "${FILE_TAG}c.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}c.stp" --mag 14 --draw 2 -o "${FILE_TAG}c.svg" | ||
|
|
||
| # Slice d: SiTracker Endcap layer 3 (530-595 mm) | ||
| duskcut 0 0 1 595 "${INPUT}" "${FILE_TAG}d_t0.stp" | ||
| duskcut 0 0 -1 -535 "${FILE_TAG}d_t0.stp" "${FILE_TAG}d.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}d.stp" --mag 14 --draw 2 -o "${FILE_TAG}d.svg" | ||
|
|
||
| # Slice e: SiTracker Endcap layer 2 (365-430 mm) | ||
| duskcut 0 0 1 430 "${INPUT}" "${FILE_TAG}e_t0.stp" | ||
| duskcut 0 0 -1 -370 "${FILE_TAG}e_t0.stp" "${FILE_TAG}e.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}e.stp" --mag 14 --draw 2 -o "${FILE_TAG}e.svg" | ||
|
|
||
| # Slice f: SiTracker Endcap layer 1 (200-225 mm) | ||
| duskcut 0 0 1 225 "${INPUT}" "${FILE_TAG}f_t0.stp" | ||
| duskcut 0 0 -1 -205 "${FILE_TAG}f_t0.stp" "${FILE_TAG}f.stp" | ||
|
|
||
| dusk --mesh-deflection 5 -d "${FILE_TAG}f.stp" --mag 14 --draw 2 -o "${FILE_TAG}f.svg" | ||
|
|
||
| rm -f "${FILE_TAG}_pre0.stp" "${FILE_TAG}_input.stp" \ | ||
| "${FILE_TAG}"[abcdef]_t0.stp "${FILE_TAG}"[abcdef].stp | ||
| echo "[generate_svg] Done: ${FILE_TAG}{a..f}.svg" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/env bash | ||
| # generate_svg — dusk/duskcut equivalent of generate_eps for view7 | ||
| # Two XY slices: central slice and SiTracker Endcap layer 1. | ||
|
|
||
| function print_the_help { | ||
| echo "USAGE: $0 -i <STEP_FILE> [-t <tag>]" | ||
| exit 0 | ||
| } | ||
|
|
||
| FILE_TAG="view7" | ||
| INPUT_FILE="" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -h|--help) print_the_help ;; | ||
| -i|--input) INPUT_FILE="$2"; shift; shift ;; | ||
| -t|--tag) FILE_TAG="$2"; shift; shift ;; | ||
| *) echo "unknown option $1"; print_the_help ;; | ||
| esac | ||
| done | ||
|
|
||
| [[ -z "${INPUT_FILE}" ]] && { echo "Error: no input file."; print_the_help; } | ||
|
|
||
| # Slice a: |z| <= 1 mm (central XY plane) | ||
| duskcut 0 0 -1 1 "${INPUT_FILE}" "${FILE_TAG}a_t0.stp" | ||
| duskcut 0 0 1 1 "${FILE_TAG}a_t0.stp" "${FILE_TAG}a.stp" | ||
| dusk --mesh-deflection 5 -d "${FILE_TAG}a.stp" --draw 2 -o "${FILE_TAG}a.svg" | ||
|
|
||
| # Slice b: SiTracker Endcap layer 1 (205-225 mm) | ||
| duskcut 0 0 1 225 "${INPUT_FILE}" "${FILE_TAG}b_t0.stp" | ||
| duskcut 0 0 -1 -205 "${FILE_TAG}b_t0.stp" "${FILE_TAG}b.stp" | ||
|
|
||
| dusk --mesh-deflection 5 -d "${FILE_TAG}b.stp" --draw 2 -o "${FILE_TAG}b.svg" | ||
|
|
||
| rm -f "${FILE_TAG}a_t0.stp" "${FILE_TAG}a.stp" \ | ||
| "${FILE_TAG}b_t0.stp" "${FILE_TAG}b.stp" | ||
| echo "[generate_svg] Done: ${FILE_TAG}a.svg ${FILE_TAG}b.svg" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.