Skip to content

Commit 65b72a8

Browse files
committed
Foil analysis added
1 parent d1526e1 commit 65b72a8

5 files changed

Lines changed: 1143 additions & 107 deletions

File tree

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: 609 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)