-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tesscorr.py
77 lines (63 loc) · 3.26 KB
/
run_tesscorr.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
# -*- coding: utf-8 -*-
"""
Command-line utility to run TESS detrend correction from command-line.
Note:
This file is intended as an addition to the code
`tess_detrend` by Derek Buzasi <[email protected]>
It allows for small tests of single target inputs from
a variety of formats, including FITS and text files,
and provides an option for debugging and maintenance
Structure inspired by `tessphot` by Rasmus Handberg <[email protected]>
"""
# photometry runs under Python 2, so compatibility is an issue without this
from __future__ import with_statement, print_function
import os
import argparse
import fnmatch
import logging
import functools
#------------------------------------------------------------------------------
if __name__ == '__main__':
# list of files to run through
fitsfiles = []
# allowing for the option of running on a single star/folder
# command line parameters (input, output, format, ...)
parser = argparse.ArgumentParser(description='Run detrending correction for a single target from the TESS Photometry pipeline')
parser.add_argument('-i', '--input', help='input folder, default local: ' + os.getcwd(), default=os.getcwd())
parser.add_argument('-o', '--output', help='output path, default local: ' + os.getcwd(), default=os.getcwd())
parser.add_argument('-d', '--debug', help='Print debug messages.', action='store_true')
parser.add_argument('-q', '--quiet', help='Only report warnings and errors.', action='store_true')
parser.add_argument('-f', '--format', help='use alternate output format, default tab-delimited', nargs='?', const='latex', default='tab')
# probably don't want a latex default, but it's an okay placeholder for now
args = parser.parse_args()
# Make sure appropriate settings are supplied, or that defaults are acceptable (print/log)
# Set logging level - keeps consistency with logging in run_tessphot
logging_level = logging.INFO
if args.quiet:
logging_level = logging.WARNING
elif args.debug:
logging_level = logging.DEBUG
# Setup logging
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
console = logging.StreamHandler()
console.setFormatter(formatter)
logger = logging.getLogger(__name__)
logger.addHandler(console)
logger.setLevel(logging_level)
logger_parent = logging.getLogger('correction')
logger_parent.addHandler(console)
logger_parent.setLevel(logging_level)
# run_tessphot uses environment variables to set in/out folders, can use for defaults
test_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), 'test', 'input'))
if args.test:
input_foler = test_folder
else:
input_folder = os.environ.get('TESSCORR_INPUT', test_folder)
output_folder = os.environ.get('TESSCORR_OUTPUT', os.path.abspath('.'))
logger.info("Loading input data from '%s'", input_folder)
logger.info("Putting output data in '%s'", output_folder)
# "Create partial function of tessphot, setting the common keywords:"
# f = functools.partial(tessphot, input_folder=input_folder, output_folder=output_folder, plot=args.plot)
###### TODO: figure out what that means - how does functools.partial() work? ########
# Run the program
# Write out results