Skip to content

Commit adbbd8d

Browse files
Merge pull request #15 from cdunn314/main
Foil analysis
2 parents 5278d71 + 8f6ce6d commit adbbd8d

File tree

9 files changed

+1235
-18
lines changed

9 files changed

+1235
-18
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ jobs:
2424
python openmc_model.py
2525
jupyter-nbconvert --to notebook postprocessing.ipynb --execute
2626
27+
- name: Run foil analysis
28+
shell: bash -l {0}
29+
working-directory: analysis/neutron
30+
run: |
31+
papermill foil_analysis.ipynb temp.ipynb -p download_from_raw False
32+
jupyter-nbconvert --to notebook --execute temp.ipynb
33+
2734
- name: Run tritium model
2835
shell: bash -l {0}
2936
working-directory: analysis/tritium

.github/workflows/process.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ jobs:
3131
python openmc_model.py
3232
jupyter-nbconvert --to notebook postprocessing.ipynb --execute
3333
34+
- name: Run foil analysis
35+
shell: bash -l {0}
36+
working-directory: analysis/neutron
37+
run: |
38+
papermill foil_analysis.ipynb temp.ipynb -p download_from_raw False
39+
jupyter-nbconvert --to notebook --execute temp.ipynb
40+
3441
- name: Run tritium model
3542
shell: bash -l {0}
3643
working-directory: analysis/tritium
37-
run: |
38-
python tritium_model.py
39-
jupyter-nbconvert --to notebook tritium_model.ipynb --execute
44+
run: jupyter-nbconvert --to notebook tritium_model.ipynb --execute
4045

4146
- name: Commit and Push Changes
4247
run: |
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from pathlib import Path
2+
import zipfile
3+
import requests
4+
5+
6+
def download_and_extract_foil_data(url: str, extracted_path: Path):
7+
8+
output_filepath = Path("../../data/neutron_detection/foil_data.zip")
9+
10+
if extracted_path.exists():
11+
print(f"Directory already exists: {extracted_path}")
12+
else:
13+
# URL of the file
14+
15+
# Download the file
16+
print(f"Downloading data from {url}...")
17+
response = requests.get(url)
18+
if response.status_code == 200:
19+
print("Download successful!")
20+
# Save the file to the specified directory
21+
with open(output_filepath, "wb") as f:
22+
f.write(response.content)
23+
print(f"File saved to: {output_filepath}")
24+
else:
25+
print(f"Failed to download file. HTTP Status Code: {response.status_code}")
26+
27+
# Extract the zip file
28+
29+
# Ensure the extraction directory exists
30+
extracted_path.mkdir(parents=True, exist_ok=True)
31+
32+
# Unzip the file
33+
with zipfile.ZipFile(output_filepath, "r") as zip_ref:
34+
zip_ref.extractall(extracted_path)
35+
print(f"Files extracted to: {extracted_path}")
36+
37+
# Delete the zip file after extraction
38+
output_filepath.unlink(missing_ok=True)
39+

analysis/neutron/foil_analysis.ipynb

Lines changed: 596 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)