Created
June 11, 2015 10:03
-
-
Save vterron/b43718dd04913effd8b4 to your computer and use it in GitHub Desktop.
Print the coordinates of all the astronomical objects in a LEMON database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" Take a LEMONdB file and print to standard output the right ascension and | |
declination of all the astronomical objects. """ | |
# Author: Victor Terron (c) 2015 | |
# Email: `echo vt2rron1iaa32s | tr 132 @.e` | |
# License: GNU GPLv3 | |
from __future__ import division | |
from __future__ import print_function | |
from __future__ import absolute_import | |
from __future__ import unicode_literals | |
import argparse | |
import os.path | |
import sys | |
# Fix until LEMON is installed system-wide | |
LEMON_DIR = os.path.expanduser("~/lemon/") | |
sys.path.insert(0, LEMON_DIR) | |
# LEMON modules | |
import database | |
if __name__ == "__main__": | |
# https://stackoverflow.com/a/12151325/184363 | |
parser = argparse.ArgumentParser( | |
description='Export coordinates of objects in a LEMON database', | |
) | |
parser.add_argument('db_path', metavar='LEMON_DB', type=str, | |
help="the LEMON database") | |
args = parser.parse_args() | |
if not os.path.exists(args.db_path): | |
msg = "Error: input LEMONdB does not exist" | |
sys.exit(msg) | |
db = database.LEMONdB(args.db_path) | |
print("Stars: {0}".format(len(db))) | |
# Export all light curves | |
star_ids = db.star_ids | |
for star_id in star_ids: | |
ra, dec = db.get_star(star_id)[2:4] | |
print("{0:.12}\t{1:.12}".format(ra, dec)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment