blob: ecf0593a8ed54ec21a71ac86542f79c18ac7b46e (
plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
#!/bin/sh
# Shell script to stack the data from multiple EKOS sessions.
# It is intended to be used on data from a cooled camera,
# and uses a common set of darks and biases for all sessions.
#
# It assumes dithering and uses the drizzle algorithm.
#
# Required directory structure:
#
# [Working Directory]
#
# \ Master Master dark and bias frames, if they already exists, they take precedence over dark and bias frames.
# If the masters are absent, they are created from the dark end bias frames.
# \ Dark Dark calibration frames, used for all sessions
# \ Bias Biases calibration frames, used for all sessions
#
# \ Session[name]
# \ Flat Flat frames for this sessions
# \ Light Light frames for this session
# \ Master (optional) Master dark and bias frames for this session,
# if found they take precendence over the global masters.
#
# Output:
#
# \ Process
# \ Calibrated Calibrated light frames created from all sessions
# \ Session[name] Per-session preprocessed files
#
# result_xxx.fits Stacked output
# ------------------------------------------------------------------
# CONFIGURATION
# Directory names
LIGHTDIR=Light
FLATDIR=Flat
DARKDIR=Dark
BIASDIR=Bias
MASTERDIR=Master
CALIBRATEDDIR=Calibrated
PROCESSDIR=Process
# Output file names
MASTERDARK=master_dark
MASTERBIAS=master_bias
MASTERFLAT=master_flat
# Framing style
# --framing=[cog|max|min]
OPT_FRAMING=min
# ------------------------------------------------------------------
# COMMAND LINE OPTIONS
while [ ! -z "$1" ]; do
case "$1" in
-f | --framing)
shift
OPT_FRAMING=$1
echo "Framing ${OPT_FRAMING}"
shift
;;
*)
echo "Invalid option $1"
exit 1;
;;
esac
done
# ------------------------------------------------------------------
# SAFETY CHECK
if [ -d "${PROCESSDIR}" ]; then
echo "${PROCESSDIR} directory already exists!"
exit 1
fi
# ------------------------------------------------------------------
# CREATE MASTER DARK
masterdarkdir="${MASTERDIR}/${DARKDIR}"
masterdarkfile="${MASTERDIR}/${MASTERDARK}.fits"
echo "------------------------------------------------------------------"
if [ -r "${masterdarkfile}" ]; then
echo "Using master dark ${masterdarkfile}"
else
if [ ! -d "${masterdarkdir}" ]; then
echo "Couldn't find ${masterdarkdir}";
exit 1
fi
echo "Creating master dark ${masterdarkfile}"
#notify-send "${NOTIFICATIONTITLE}" "Creating master dark ${masterdarkfile}"
siril-cli -d . -s - <<ENDSIRILDARK
requires 1.2.0
# Convert Dark Frames to .fit files
cd ${masterdarkdir}
convert dark -out=../../${PROCESSDIR}
cd ../../${PROCESSDIR}
# Stack Dark Frames to master_dark.fit
stack dark rej 3 3 -nonorm -out=../${MASTERDIR}/${MASTERDARK}
cd ..
close
ENDSIRILDARK
fi
# ------------------------------------------------------------------
# CREATE MASTER BIAS
masterbiasdir="${MASTERDIR}/${BIASDIR}"
masterbiasfile="${MASTERDIR}/${MASTERBIAS}.fits"
echo "------------------------------------------------------------------"
if [ -r "${masterbiasfile}" ]; then
echo "Using master bias ${masterbiasfile}"
else
if [ ! -d "${masterbiasdir}" ]; then
echo "Couldn't find ${masterbiasdir}";
exit 1
fi
echo "Creating master bias ${masterbiasfile}"
#notify-send "${NOTIFICATIONTITLE}" "Creating master bias ${masterbiasfile}"
siril-cli -d . -s - <<ENDSIRILBIAS
requires 1.2.0
# Convert Bias Frames to .fit files
cd ${masterbiasdir}
convert bias -out=../../${PROCESSDIR}
cd ../../${PROCESSDIR}
# Stack Bias Frames to master_bias.fit
stack bias rej 3 3 -nonorm -out=../${MASTERDIR}/${MASTERBIAS}
cd ..
close
ENDSIRILBIAS
fi
# ------------------------------------------------------------------
# CREATE OUTPUT DIRECTORY
mkdir -p "${PROCESSDIR}/${CALIBRATEDDIR}"
# ------------------------------------------------------------------
# CREATE SESSION FLAT
# CALIBRATE SESSIONS LIGHTS
# Create calibrated light frames for each session
for session in `find -maxdepth 1 -type d -iname "session*"`; do
sessionname=`basename "${session}"`
echo "------------------------------------------------------------------"
echo "Preprocessing session ${sessionname}"
#notify-send "${NOTIFICATIONTITLE}" "Preprocessing session ${sessionname}"
sessionlightdir="${sessionname}/${LIGHTDIR}"
sessionflatdir="${sessionname}/${LIGHTDIR}"
if [ ! -d "${sessionlightdir}" ]; then
echo "Couldn't find ${sessionlightdir}"
exit 1;
fi
if [ ! -d "${sessionflatdir}" ]; then
echo "Couldn't find ${sessionflatdir}"
exit 1;
fi
cd "${sessionname}"
SESSIONDARK="${MASTERDIR}/${MASTERDARK}"
if [ -r "${SESSIONDARK}.fits" ]; then
SESSIONDARK="../../${sessionname}/${SESSIONDARK}"
echo "Using session master dark for ${sessionname}"
else
SESSIONDARK="../../${MASTERDIR}/${MASTERDARK}"
fi
SESSIONBIAS="${MASTERDIR}/${MASTERBIAS}"
if [ -r "${SESSIONBIAS}.fits" ]; then
SESSIONBIAS="../../${sessionname}/${SESSIONBIAS}"
echo "Using session master bias for ${sessionname}"
else
SESSIONBIAS="../../${MASTERDIR}/${MASTERBIAS}"
fi
SESSIONFLAT="${MASTERDIR}/${MASTERFLAT}"
if [ -r "${SESSIONFLAT}.fits" ]; then
SESSIONFLAT="../../${sessionname}/${SESSIONFLAT}"
echo "Using session master flat for ${sessionname}"
else
echo "------------------------------------------------------------------"
echo "Creating master flat for session ${sessionname}"
siril-cli -d . -s - <<ENDSIRILFLAT
requires 1.2.0
# Convert Flat Frames to .fit files
cd ${FLATDIR}
convert flat -out=../../${PROCESSDIR}/${sessionname}
cd ../../${PROCESSDIR}/${sessionname}
# Pre-process Flat Frames
calibrate flat -bias=${SESSIONBIAS}
# Stack Flat Frames to session_flat.fits
stack pp_flat rej 3 3 -norm=mul -out=${MASTERFLAT}
cd ../../${sessionname}
close
ENDSIRILFLAT
SESSIONFLAT="../../${sessionname}/${SESSIONFLAT}"
if [ ! -d "${MASTERDIR}" ]; then
mkdir "${MASTERDIR}"
fi
cp -v "../${PROCESSDIR}/${sessionname}/${MASTERFLAT}.fits" "${MASTERDIR}"
fi
echo "------------------------------------------------------------------"
echo "Calibrating lights for session ${sessionname}"
siril-cli -d . -s - <<ENDSIRILLIGHT
requires 1.2.0
# Convert Light Frames to .fit files
cd ${LIGHTDIR}
convert light -out=../../${PROCESSDIR}/${sessionname}
cd ../../${PROCESSDIR}/${sessionname}
# Calibrate light frames
calibrate light -dark=${SESSIONDARK} -flat=${SESSIONFLAT} -cfa -cc=dark -equalize_cfa -prefix=${sessionname}_pp_
cd ../../${sessionname}
close
ENDSIRILLIGHT
# move calibrated files
echo "------------------------------------------------------------------"
cd ..
mv -v ${PROCESSDIR}/${sessionname}/${sessionname}_pp_*.fits ${PROCESSDIR}/${CALIBRATEDDIR}/
done
# ------------------------------------------------------------------
# REGISTER LIGHTS
echo "------------------------------------------------------------------"
echo "Registering calibrated lights"
#notify-send "${NOTIFICATIONTITLE}" "Registering calibrated lights"
siril-cli -d . -s - <<ENDSIRILREGISTER
requires 1.2.0
# Convert Light Frames to .fit files
cd ${PROCESSDIR}/${CALIBRATEDDIR}
convert preprocess -out=../
cd ../
# Register lights
# extra options: -2pass -nostarlist (find reference image)
register preprocess -drizzle -2pass -nostarlist
# extra options --framing=[cog|max|min]
seqapplyreg preprocess -drizzle -framing=${OPT_FRAMING}
cd ..
close
ENDSIRILREGISTER
# ------------------------------------------------------------------
# STACK LIGHTS
echo "------------------------------------------------------------------"
echo "Stacking calibrated lights"
#notify-send "${NOTIFICATIONTITLE}" "Stacking calibrated lights"
siril-cli -d . -s - <<ENDSIRILSTACK
requires 1.2.0
cd ${PROCESSDIR}
# Stack calibrated lights to result.fits
stack r_preprocess rej 3 3 -norm=addscale -output_norm -rgb_equal -out=result
# mirror the result
load result
mirrorx -bottomup
save ../result_drizzle_${OPT_FRAMING}_\$LIVETIME:%d\$s
cd ..
close
ENDSIRILSTACK
notify-send -a "Siril" "Stacking (Finished)"
|