-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_make_todo.py
81 lines (67 loc) · 3.12 KB
/
run_make_todo.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Create the TODO list which is used by the pipeline to keep track of the
targets that needs to be processed.
Example:
In order to create to TODO list for the directory in the ``TESSPHOT_INPUT``
environment variable simply run the program without any further input:
>>> python run_make_todo.py
This will create the file ``todo.sqlite`` in the directory defined in the
``TESSPHOT_INPUT`` environment variable.
Example:
If you want to create the TODO file for a specific directory (ignoring the
``TESSPHOT_INPUT`` environment variable), you can simply call the script
with the directory you want to process:
>>> python run_make_todo.py /where/ever/you/want/
Note:
This program assumes that the directory already contains "catalog" files for
the given sector. These can be create using the :func:`run_make_catalog`
utility.
.. codeauthor:: Rasmus Handberg <[email protected]>
"""
import argparse
import logging
import os.path
from photometry.todolist import make_todo
#------------------------------------------------------------------------------
def main():
# Parse command line arguments:
parser = argparse.ArgumentParser(description='Create TODO file for TESS Photometry.')
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('-o', '--overwrite', help='Overwrite existing TODO file.', action='store_true')
group = parser.add_argument_group('Filter which targets to include')
group.add_argument('--sector', type=int, default=None, action='append', help='TESS Sector. Default is to run all sectors.')
group.add_argument('--camera', type=int, choices=(1,2,3,4), default=None, action='append', help='TESS Camera. Default is to run all cameras.')
group.add_argument('--ccd', type=int, choices=(1,2,3,4), default=None, action='append', help='TESS CCD. Default is to run all CCDs.')
parser.add_argument('input_folder', type=str, help='TESSPhot input directory to create TODO file in.', nargs='?', default=None)
args = parser.parse_args()
# Set logging level:
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('photometry')
logger_parent.addHandler(console)
logger_parent.setLevel(logging_level)
# Check that the given input directory is indeed a directory:
if args.input_folder is not None and not os.path.isdir(args.input_folder):
parser.error("The given path does not exist or is not a directory")
# Run the program:
make_todo(args.input_folder,
sectors=args.sector,
cameras=args.camera,
ccds=args.ccd,
overwrite=args.overwrite)
#--------------------------------------------------------------------------------------------------
if __name__ == '__main__':
main()