Skip to content

Instantly share code, notes, and snippets.

@vterron
Created August 4, 2015 14:12
Show Gist options
  • Save vterron/55ec57cf0aaa72433583 to your computer and use it in GitHub Desktop.
Save vterron/55ec57cf0aaa72433583 to your computer and use it in GitHub Desktop.
List the stars and (if any) the standard deviations of the astronomical objects in a LEMONdB
#! /usr/bin/env python
# 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
description = """
Take a LEMONdB file and, for each astronomical object export its ID, celestial
coordinates, instrumental magnitude and (if any) standard deviation of the
light curves in the different photometric filters.
"""
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
import methods
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=description)
parser.add_argument('db_path', metavar='LEMON_DB', type=str,
help="the input LEMON database")
args = parser.parse_args()
db = database.LEMONdB(args.db_path)
pfilters = [str(p) for p in db.pfilters]
print('# ' + '\t'.join(['ID', 'alpha', 'delta', 'mag'] + pfilters))
for star_id in db.star_ids:
star_info = db.get_star(star_id)
ra, dec = star_info[2:4]
imag = star_info[-1]
row = [star_id, ra, dec, imag]
for pfilter in db.pfilters:
curve = db.get_light_curve(star_id, pfilter)
if curve is None:
row.append('')
else:
row.append(curve.stdev)
print('\t'.join(str(x) for x in row))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment