Skip to content

Commit e4db021

Browse files
committed
Track tarball version of stellar_models in LFS and update build script
1 parent bdf598a commit e4db021

File tree

2 files changed

+66
-8
lines changed

2 files changed

+66
-8
lines changed

.gitattributes

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ docs/source/assets/zams_z2m2_y28_patched.data filter=lfs diff=lfs merge=lfs -tex
1313
neu/test/test_output filter=lfs diff=lfs merge=lfs -text
1414

1515

16-
# Track all data files for colors with LFS
17-
colors/data/stellar_models/Kurucz2003all/** filter=lfs diff=lfs merge=lfs -text
18-
colors/data/stellar_models/vega** filter=lfs diff=lfs merge=lfs -text
16+
# Track data file for colors with LFS
17+
colors/data/colors_data.txz filter=lfs diff=lfs merge=lfs -text
1918

2019

2120

colors/build_data_and_export

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,74 @@
11
#!/bin/bash
22

3+
set -e # Immediately exit on error
4+
35
function check_okay {
4-
if [ $? -ne 0 ]
5-
then
6+
if [ $? -ne 0 ]; then
67
echo "Error in colors data build process"
78
exit 1
89
fi
910
}
1011

11-
# Create necessary directories
12+
# Create working directory
1213
mkdir -p data
13-
check_okay
1414
cd data
15-
check_okay
15+
16+
# Variables
17+
ARCHIVE_NAME="colors_data.txz"
18+
EXTRACTED_FLAG=".extraction_complete"
19+
TARGET_DIR="../data/colors_data"
20+
21+
# Validate archive
22+
validate_archive() {
23+
tar -tJf "$ARCHIVE_NAME" > /dev/null 2>&1
24+
}
25+
26+
# If not extracted yet
27+
if [ ! -f "$EXTRACTED_FLAG" ]; then
28+
29+
# If the archive is missing
30+
if [ ! -f "$ARCHIVE_NAME" ]; then
31+
echo "Archive $ARCHIVE_NAME is missing."
32+
echo "Please ensure it is downloaded or available in this directory."
33+
# it should now auto-download from a LFS pointer... i think?
34+
35+
exit 1
36+
fi
37+
38+
# Validate it
39+
if ! validate_archive; then
40+
echo "Archive $ARCHIVE_NAME is invalid."
41+
# try again to download or something?
42+
43+
# Validate it
44+
if ! validate_archive; then
45+
echo "Archive $ARCHIVE_NAME is invalid."
46+
exit 1
47+
fi
48+
fi
49+
50+
echo "Extracting colors data..."
51+
mkdir -p filters stellar_models
52+
tar -xJf "$ARCHIVE_NAME" --strip-components=1
53+
touch "$EXTRACTED_FLAG"
54+
rm "$ARCHIVE_NAME"
55+
56+
else
57+
echo "Colors data already extracted."
58+
fi
59+
60+
61+
cd ..
62+
63+
64+
# Export to MESA data dir
65+
mkdir -p "$TARGET_DIR"
66+
67+
for SUBDIR in filters stellar_models; do
68+
if [ -d "data/$SUBDIR" ]; then
69+
cp -r "data/$SUBDIR" "$TARGET_DIR/"
70+
check_okay
71+
fi
72+
done
73+
74+
echo "Colors data has been successfully built and exported."

0 commit comments

Comments
 (0)