-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPPP.py
82 lines (64 loc) · 2.89 KB
/
PPP.py
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
# %%
# This is the Pre-Process Pipeline for calibrating, solving, and aligning cubes
# Input: raw data cubes in folder; super dark, bias, flats (multiple if filtered)
# Output: aligned frames with WCS headers
# !!! Use astroconda environment (python 3.7) for this pipeline !!!
# alipy3-header version needs to be installed in the environment
import os
from essentials import *
from glob import glob1
# Input data directory here
directory = '/Volumes/TMO_Data_4TB/cb_data/C01+13/20221106_newflat'
cubelist = sorted(glob1(directory, '*.fits'))
# Input super calibs directory here
cali_dir='/Users/TMObserver/Documents/CALIBS_20221106'
# %%
# Calibrate cubes with dark, bias, and colored flats
for cubename in cubelist:
calibrate_cube(directory=directory, cubename=cubename,
cali_dir=cali_dir,
darkbiasname='Master_DarkBias.fits',
darkexptime=10.0,
mode='multicolor',
Cflat='Master_Flat_C_norm.fits',
gflat='Master_Flat_g_norm.fits',
rflat='Master_Flat_r_norm.fits',
iflat='Master_Flat_i_norm.fits',
out_dir=os.path.join(directory, 'reduced_cubes'))
# for cubename in cubelist:
# calibrate_cube(directory=directory, cubename=cubename,
# cali_dir=cali_dir,
# darkbiasname='Master_DarkBias.fits',
# darkexptime=10.0,
# mode='monocolor',
# flatname='Master_Flat_C_norm.fits',
# out_dir=os.path.join(directory, 'reduced_cubes'))
# %%
# Slice cubes and increment timestamps
redu_cubelist = sorted(glob1(directory+'/reduced_cubes', '*.fits'))
for cubename in redu_cubelist:
slice_cube(directory=os.path.join(directory, 'reduced_cubes'),
cubename=cubename,
out_dir=os.path.join(directory, 'sliced'))
# %%
# Alipy source detection on all images
ref_image, identifications = alipy_ident(directory=os.path.join(directory, 'sliced'))
# %%
# Align all images to ref img, preserve headers
alipy_align(ref_image, identifications, out_dir=os.path.join(directory, 'aligned'))
# %%
# Solve frame and migrate WCS headers
solve_and_migrate_header(directory=os.path.join(directory, 'aligned'))
# %%
# ------------------------------------ LEGACY FUNCTIONS ------------------------------------
"""
reduced_cubelist = sorted(glob1(os.path.join(directory, 'reduced_cubes'), '*_reduced.fits'))
for cubename in reduced_cubelist:
solve_and_align(directory=os.path.join(directory, 'reduced_cubes'),
cubename=cubename,
out_dir=os.path.join(directory, 'aligned_cubes'))
batch_solve_and_align(directory=os.path.join(directory, 'reduced_cubes'),
out_dir=os.path.join(directory, 'aligned_cubes'),
do_convolve=False)
"""
# %%