-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprep-and-download-for-MAO-proc.sh
142 lines (119 loc) · 4.51 KB
/
prep-and-download-for-MAO-proc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
#
# prep-and-download-for-MAO-proc.sh
#
#
# 26 Nov 2023
# 12 Nov 2023
# 28 Aug 2023 (prep-for-MAO-proc.sh)
#
# Script to create sub-directories under AstronomyData/MAO and under AAVSO Reports/MAO
# that correspond to input specifying (year month date var), e.g., 2023 12 25 M Crux.
#
# If both sub-directories exist, then script states that they already exist
#
# Then (instead of downloading from MAO Drive in browser) access Google Drive (H)
# and get corresponding images from H:\ drive and copy to AstronomyData/MAO
#
# If input is in form "<year> <month> <date> AutoFlat <temperature>" then B and V flats are retrieve
# from $MAO_AUTOFLAT
#
# Verify that maoDir is in correct format (e.g., 2023 12 25 M Crux)
if [ $# -eq 0 ] || [ $# -eq 1 ]; then
echo \
"Enter MAO sub-directory for parameters, e.g., 2023 12 25 M Crux
Script to create sub-directories under AstronomyData/MAO and under AAVSO Reports/MAO\
that correspond to input specifying (year month date var), e.g., 2023 12 25 M Crux.\
If both sub-directories exist, then script states that they already exist, then exits."
echo ""
exit
elif [ $# -ne 5 ]; then
echo "Incorrect MAO sub-directory format (e.g., 2023 12 25 M Crux)"
exit
fi
if [ $4 != 'AutoFlat' ]; then
# then (e.g., 2023 12 25 M Crux)
maoDir=`echo "$1 $2 $3 $4 $5" | sed 's/\r//g'`
varName=`echo "$4 $5" | sed 's/\r//g'`
maoDate=`echo "$1$2$3" | sed 's/\r//g'`
MAO_YEAR="$1"
BASE_DATA_DIR="$HOME/AstronomyData/MAO"
BASE_AAVSO_DIR="$HOME/AAVSO Reports/MAO"
#Create directories
if [ -e "$BASE_DATA_DIR/$MAO_YEAR/$maoDir/PIData" -a -e "$BASE_AAVSO_DIR/$MAO_YEAR/$maoDir" ];
then
echo "Directories exist, continuing"
elif [ ! -e "$BASE_DATA_DIR/$MAO_YEAR/$maoDir/PIData" ];
then
# Create BASE_DATA_DIR and its PIData
mkdir "$BASE_DATA_DIR/$MAO_YEAR" 2>/dev/null
mkdir "$BASE_DATA_DIR/$MAO_YEAR/$maoDir"
mkdir "$BASE_DATA_DIR/$MAO_YEAR/$maoDir/PIData"
fi
if [ ! -e "$BASE_AAVSO_DIR/$MAO_YEAR/$maoDir" ];
then
mkdir "$BASE_AAVSO_DIR/$MAO_YEAR" 2>/dev/null
mkdir "$BASE_AAVSO_DIR/$MAO_YEAR/$maoDir"
fi
#Copy corresponding MAO Drive folder to the newly created directory
#(Before this, we downloaded manually from browser and unzipped file)
#The source is either in the ~/MAO-Pete or ~/MAO-Pierre directory.
# (Why 2 different choices? "Don't ask!")
# Example: Given parameters "2023 12 25 M Crux", the source folder is
# ~/MAO-Pierre/M Crux/M Crux-20231225/
# or
# ~/MAO-Pete/M Crux/M Crux-20231225/
# Finding the folder then, it is copied to "~/AstronomyData/MAO/2023/2023 12 25 M Crux/"
#
#
MAO_PETE="$HOME/MAO-Pete"
MAO_PIERRE="$HOME/MAO-Pierre"
if [ -e "$MAO_PIERRE/$varName" ];
then
echo "copying $MAO_PIERRE/$varName/$varName-$maoDate"
cp -r "$MAO_PIERRE/$varName/$varName-$maoDate" "$BASE_DATA_DIR/$MAO_YEAR/$maoDir"
elif [ -e "$MAO_PETE/$varName" ];
then
echo "copying $MAO_PETE/$varName/$varName-$maoDate"
cp -r "$MAO_PETE/$varName/$varName-$maoDate" "$BASE_DATA_DIR/$MAO_YEAR/$maoDir"
else
echo "Cannot find $varName on MAO Drive"
exit 1
fi
echo "Finished $maoDir"
exit 0
else
# then (e.g., 2023 12 25 AutoFlat 20)
maoDriveDir=`echo "$1$2$3-sky" | sed 's/\r//g'`
maoDataDir=`echo "$1 $2 $3" | sed 's/\r//g'`
celsius_temp=`echo "$5" | sed 's/\r//g'`
BASE_DATA_DIR="$HOME/AstronomyData/MAO/00CalibrationFiles/Flats/minus $celsius_temp"
#Create directories
if [ -e "$BASE_DATA_DIR/$maoDataDir" ];
then
echo "Directories exist, continuing"
elif [ ! -e "$BASE_DATA_DIR" ];
then
# Create BASE_DATA_DIR
mkdir "$BASE_DATA_DIR" 2>/dev/null
fi
if [ ! -e "$BASE_DATA_DIR/$maoDataDir" ];
then
mkdir "$BASE_DATA_DIR/$maoDataDir" 2>/dev/null
fi
#Copy corresponding MAO Drive folders for B and V only to the newly created directory
MAO_AUTOFLAT="$HOME/MAO-AutoFlat"
if [ -e "$MAO_AUTOFLAT/$maoDriveDir" ] && \
[ -e "$MAO_AUTOFLAT/$maoDriveDir/Flat-sky-V" ] && \
[ -e "$MAO_AUTOFLAT/$maoDriveDir/Flat-sky-B" ];
then
echo "copying $MAO_AUTOFLAT/$maoDriveDir"
cp -r "$MAO_AUTOFLAT/$maoDriveDir/Flat-sky-V" "$BASE_DATA_DIR/$maoDataDir"
cp -r "$MAO_AUTOFLAT/$maoDriveDir/Flat-sky-B" "$BASE_DATA_DIR/$maoDataDir"
else
echo "Cannot find $maoDriveDir on MAO Drive"
exit 1
fi
echo "Finished $maoDir"
exit 0
fi