|
#!/usr/local/bin/python |
|
# encoding: utf-8 |
|
""" |
|
gsc-bright-star-associations.py |
|
=============================== |
|
:Summary: |
|
Plot the transients associated within 5 arcmin of GSC stars brighter than V = 16 mag |
|
|
|
:Author: |
|
David Young |
|
|
|
:Date Created: |
|
February 14, 2017 |
|
|
|
Usage: |
|
gsc-bright-star-associations |
|
|
|
Options: |
|
-h, --help show this help message |
|
-v, --version show version |
|
-s, --settings the settings file |
|
""" |
|
## USER DEFINED VARIABLES - ONLY PLACE THIS SCRIPT NEEDS MODIFIED ## |
|
|
|
|
|
################# GLOBAL IMPORTS #################### |
|
import sys |
|
import os |
|
os.environ['TERM'] = 'vt100' |
|
import readline |
|
import glob |
|
import docopt |
|
import math |
|
from fundamentals import tools, times |
|
import unicodecsv as csv |
|
|
|
|
|
def main(arguments=None): |
|
""" |
|
The main function used when ``gsc-bright-star-associations.py`` is run as a single script from the cl, or when installed as a cl command |
|
""" |
|
|
|
# setup the command-line util settings |
|
su = tools( |
|
arguments=arguments, |
|
docString=__doc__, |
|
logLevel="DEBUG", |
|
options_first=False, |
|
projectName=False |
|
) |
|
arguments, settings, log, dbConn = su.setup() |
|
|
|
import numpy as np |
|
import matplotlib.pyplot as plt |
|
|
|
moduleDirectory = os.path.dirname(__file__) |
|
dataFile = moduleDirectory + "./gsc_mag_vs_mean_separation.csv" |
|
print dataFile |
|
|
|
with open(dataFile, 'rb') as csvFile: |
|
csvReader = csv.DictReader(csvFile, dialect='excel', |
|
delimiter=',', quotechar='"') |
|
csvReader = list(csvReader) |
|
|
|
x = [] |
|
x[:] = [c['V'] for c in csvReader] |
|
y = [] |
|
y[:] = [c["mean_sep"] for c in csvReader] |
|
|
|
csvFile.close() |
|
|
|
print len(x), len(y) |
|
|
|
line = plt.figure() |
|
x = np.array(x) |
|
y = np.array(y) |
|
|
|
ax = plt.gca() |
|
ax.invert_xaxis() |
|
ax.set_yscale("log", nonposy='clip') |
|
|
|
ax.set_ylim(0.4, 305) |
|
ax.set_xlim(16.5, 1) |
|
|
|
ax.set_xlabel("GSC V-Magnitude") |
|
ax.set_ylabel("mean separation (arcsec)") |
|
|
|
plt.plot(x, y, "o", ms=3) |
|
|
|
# draw vertical line from (70,100) to (70, 250) |
|
m = -0.2 |
|
c = 3.7 |
|
plt.plot([18, 5], [10**(m * 18 + c), 10**(m * 5 + c)], 'k-', lw=2) |
|
|
|
# # draw vertical line from (70,100) to (70, 250) |
|
# plt.plot([70, 70], [100, 250], 'k-', lw=2) |
|
|
|
# # draw diagonal line from (70, 90) to (90, 200) |
|
#plt.plot([70, 90], [90, 200], 'k-') |
|
|
|
plt.savefig("gsc_mag_vs_mean_separation.png", dpi=300) |
|
plt.clf() # clear figure |
|
return |
|
|
|
if __name__ == '__main__': |
|
main() |