This repository has been archived by the owner on Oct 26, 2022. It is now read-only.
/
lemon
executable file
·117 lines (93 loc) · 3.56 KB
/
lemon
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
#! /usr/bin/env python
# Copyright (c) 2012 Victor Terron. All rights reserved.
# Institute of Astrophysics of Andalusia, IAA-CSIC
#
# This file is part of LEMON.
#
# LEMON is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Use import hooks, which are added to sys.meta_path, to enforce
# a minimum version of the modules defined in requirements.txt.
import check_versions
import atexit
import difflib
import logging
import os.path
import requests
import sys
API_QUERY_TIMEOUT = 2 # seconds
LEMON_COMMANDS = [
"annuli",
"astrometry",
"diffphot",
"export",
"import",
"juicer",
"mosaic",
"offsets",
"photometry",
"seeing",
]
def show_help(name):
""" Help message, listing all commands, that looks like Git's """
print "usage: %s [--help] [--version] [--update] COMMAND [ARGS]" % name
print
print "The essential commands are:"
print " astrometry Calibrate the images astrometrically"
print " mosaic Assemble the images into a mosaic"
print " photometry Perform aperture photometry"
print " diffphot Generate light curves"
print " juicer LEMONdB browser and variability analyzer"
print " export Print the light curve of an object"
print
print "The auxiliary, not-always-necessary commands are:"
print " import Group the images of an observing campaign"
print " seeing Discard images with bad seeing or elongated"
print " annuli Find optimal parameters for photometry"
print
print "See '%s COMMAND' for more information on a specific command." % name
if __name__ == "__main__":
name = os.path.basename(sys.argv[0])
if len(sys.argv) == 1 or "--help" in sys.argv:
show_help(name)
sys.exit(0)
command = sys.argv[1]
args = sys.argv[2:]
if command not in LEMON_COMMANDS:
msg = "%s: '%s' is not a lemon command. See 'lemon --help'."
print msg % (name, command)
# Show suggestions, if any, when the command does not exist
matches = difflib.get_close_matches(command, LEMON_COMMANDS)
if matches:
print
print "Did you mean",
print len(matches) == 1 and "this?" or "one of these?"
for match in matches:
print " " * 8 + match
sys.exit(1)
elif command == "juicer":
import juicer.main
kwargs = {}
if args:
kwargs["db_path"] = args[0]
juicer.main.main(**kwargs)
else:
# Add the name of the command to the script name so that the brief
# summary of the imported script options includes it (for example,
# "lemon photometry" instead of just "lemon".
sys.argv[0] = "%s %s" % (name, command)
# The 'import' statement cannot be used as the name of the module
# is only known at runtime. We need to manually invoke __import__
# to import the module by name and then run its main() function.
module = __import__(command)
module.main(args)