Guest User

Untitled

a guest
Jan 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.21 KB | None | 0 0
  1. #!/usr/local/bin/python
  2. # encoding: utf-8
  3. """
  4. april2016-march2017-pessto-stats-plots.py
  5. =========================================
  6. :Summary:
  7. PESSTO Stat Plots
  8.  
  9. :Author:
  10. David Young
  11.  
  12. :Date Created:
  13. March 6, 2017
  14.  
  15. Usage:
  16. april2016-march2017-pessto-stats-plots
  17.  
  18. Options:
  19. -h, --help show this help message
  20. -v, --version show version
  21. -s, --settings the settings file
  22.  
  23. ..todo::
  24.  
  25. @review: when complete pull all general functions and classes into dryxPython
  26. """
  27. ## USER DEFINED VARIABLES - ONLY PLACE THIS SCRIPT NEEDS MODIFIED ##
  28.  
  29.  
  30. ################# GLOBAL IMPORTS ####################
  31. import sys
  32. import os
  33. os.environ['TERM'] = 'vt100'
  34. import readline
  35. import glob
  36. import docopt
  37. from fundamentals import tools, times
  38.  
  39.  
  40. def main(arguments=None):
  41. """
  42. The main function used when ``april2016-march2017-pessto-stats-plots.py`` is run as a single script from the cl, or when installed as a cl command
  43. """
  44.  
  45. # setup the command-line util settings
  46. su = tools(
  47. arguments=arguments,
  48. docString=__doc__,
  49. logLevel="DEBUG",
  50. options_first=False,
  51. projectName=False
  52. )
  53. arguments, settings, log, dbConn = su.setup()
  54.  
  55. import numpy as np
  56. import matplotlib.pyplot as plt
  57. import pylab as P
  58.  
  59. # # # CLASSIFICATION PHASE DAYS
  60. # x = (0, 0, 0, 0, 0, 10, 20, 20, 10, 0, 0, 0, 10, 0, 0, 0, 0, 14, -10, 14, -7, -7, 0, -7, 7, 3, -7, 8, -3, 7, 4, 8, -7, 10, -3, 2, 30, -8, 7, 0, 8, 0, -2, 20, 0, -5, 0, 0, 6, 36, 2, 7, 4, 1, 6, 10, -4, 3, 10, 21, -1, 2, 4, 0, 7, 8, 12, 4, 0, -5, -6, -8, 14, 18, 5, -2, -5, 14, 20, 0, 7, 0, 0, 0, 0, 0, 4, -6, -7, 0, 0, 0, 4, 20, 4, 4, -4, 0, 0, 5,
  61. # 20, -5, 50, 0, 0, -7, 0, -5, 32, 11, 0, 0, -6, -8, 0, 0, 0, 0, 0, 4, -4,
  62. # 4, -10, 5, 0, 1, -1, -2, 26, 1, 30, 11, 3, -6, 7, 12, 6, -9, 6, 0, 0, 0,
  63. # 6, -4, 9, 11, 5, -3, 0, 15, 8, -5, 0, 8, -2, -4, 0, 0, -7, 4, 0, 0, 4,
  64. # 8, 20, 0, -10, 0, 20, -7, -7, -7, -3, 0, 8, 8, 20, 0, 0, -7, -7, 0, 20,
  65. # 20, -7, -3, -3, 8, -10, -3, 12, 8, 4, 28, 36, 72, 5, -5, -6)
  66.  
  67. # bins = [-13, -10, -7, -4, -1, 2, 5, 8, 11, 15, 18, 21, 24, 27, 30, 33]
  68. # # the histogram of the data with histtype='step'
  69. # n, bins, patches = P.hist(x, bins, histtype='bar', rwidth=0.8)
  70.  
  71. # P.xlabel("Classification Phase Relative to Peak")
  72. # P.ylabel("# Supernovae")
  73. # P.figure()
  74. # P.show()
  75.  
  76. # #
  77.  
  78. # n_groups = 4
  79.  
  80. # x = (63, 57, 99, 57)
  81. # fig, ax = plt.subplots()
  82. # index = np.arange(n_groups)
  83. # bar_width = 0.9
  84. # opacity = 1.0
  85.  
  86. # rects1 = plt.bar(index, x, bar_width,
  87. # alpha=opacity,
  88. # color='r')
  89.  
  90. # plt.xlabel('Classification Phase')
  91. # plt.ylabel('# Supernovae')
  92. # plt.xticks(index + bar_width / 2, ('pre max',
  93. # 'at max', 'post max', 'unknown'))
  94.  
  95. # ax = plt.gca()
  96. # ax.set_ylim(0, 120)
  97. # ax.set_xlim(-1, 5)
  98. # # plt.tight_layout()
  99. # plt.show()
  100.  
  101. import collections
  102. surveyDict = {}
  103. surveyDict = collections.OrderedDict(sorted(surveyDict.items()))
  104.  
  105. surveyDict['Gaia'] = 72
  106. surveyDict['ATLAS'] = 67
  107. surveyDict['PS1'] = 33
  108. surveyDict['OGLE'] = 31
  109.  
  110. surveyDict['ASASSN'] = 28
  111. surveyDict['SkyMapper'] = 9
  112. surveyDict['MASTER'] = 4
  113. surveyDict['BOSS'] = 4
  114. surveyDict['POSS'] = 4
  115. surveyDict['PTSS'] = 3
  116. surveyDict['CRTS'] = 3
  117. surveyDict['DES'] = 3
  118. surveyDict['LSQ'] = 3
  119. surveyDict['ISSP'] = 2
  120. surveyDict['DLT40'] = 2
  121. surveyDict['Monard'] = 1
  122. surveyDict['LOSS'] = 1
  123. surveyDict['SNHunt'] = 1
  124. surveyDict['TAROT'] = 1
  125.  
  126. x = surveyDict.values()
  127. labels = surveyDict.keys()
  128.  
  129. n_groups = len(surveyDict)
  130. fig, ax = plt.subplots()
  131. index = np.arange(n_groups)
  132. bar_width = 0.9
  133. opacity = 1.0
  134.  
  135. rects1 = plt.bar(index, x, bar_width,
  136. alpha=opacity,
  137. color='r')
  138.  
  139. plt.xlabel('Discovery Survey')
  140. plt.ylabel('# Supernovae')
  141. plt.xticks(index + bar_width / 2, labels, rotation=60)
  142.  
  143. ax = plt.gca()
  144. # ax.set_ylim(0, 120)
  145. ax.set_xlim(-1, n_groups + 1)
  146. # plt.tight_layout()
  147. plt.show()
  148.  
  149. # import collections
  150. # transientDict = {}
  151. # transientDict = collections.OrderedDict(sorted(transientDict.items()))
  152.  
  153. # transientDict['SN'] = 220
  154. # transientDict['Variable star'] = 28
  155. # transientDict['unknown'] = 13
  156. # transientDict['CV'] = 9
  157. # transientDict['AGN'] = 4
  158. # transientDict['SLSN'] = 3
  159. # transientDict['Galaxy'] = 2
  160. # transientDict['Impostor'] = 1
  161.  
  162. # x = transientDict.values()
  163. # labels = transientDict.keys()
  164.  
  165. # n_groups = len(transientDict)
  166. # fig, ax = plt.subplots()
  167. # index = np.arange(n_groups)
  168. # bar_width = 0.9
  169. # opacity = 1.0
  170.  
  171. # rects1 = plt.bar(index, x, bar_width,
  172. # alpha=opacity,
  173. # color='r')
  174.  
  175. # plt.xlabel('Spectral Classification')
  176. # plt.ylabel('# Transients')
  177. # plt.xticks(index + bar_width / 2, labels, rotation=60)
  178.  
  179. # ax = plt.gca()
  180. # # ax.set_ylim(0, 120)
  181. # ax.set_xlim(-1, n_groups + 1)
  182. # # plt.tight_layout()
  183. # plt.show()
  184.  
  185. # import collections
  186. # transientDict = {}
  187. # transientDict = collections.OrderedDict(sorted(transientDict.items()))
  188.  
  189. # transientDict['SN Ia'] = 159
  190. # transientDict['SN II'] = 37
  191. # transientDict['SN Ic'] = 7
  192. # transientDict['SN IIb'] = 6
  193. # transientDict['SN IIn'] = 6
  194. # transientDict['SLSN Ic'] = 2
  195. # transientDict['SN Ibc'] = 2
  196. # transientDict['SN IIP'] = 1
  197. # transientDict['SLSN II'] = 1
  198. # transientDict['SN I'] = 1
  199. # transientDict['SN Ib'] = 1
  200.  
  201. # x = transientDict.values()
  202. # labels = transientDict.keys()
  203.  
  204. # n_groups = len(transientDict)
  205. # fig, ax = plt.subplots()
  206. # index = np.arange(n_groups)
  207. # bar_width = 0.9
  208. # opacity = 1.0
  209.  
  210. # rects1 = plt.bar(index, x, bar_width,
  211. # alpha=opacity,
  212. # color='r')
  213.  
  214. # plt.xlabel('Spectral Classification')
  215. # plt.ylabel('# Supernovae')
  216. # plt.xticks(index + bar_width / 2, labels, rotation=60)
  217.  
  218. # ax = plt.gca()
  219. # ax.set_ylim(0, 170)
  220. # ax.set_xlim(-1, n_groups + 1)
  221. # # plt.tight_layout()
  222. # plt.show()
  223.  
  224. return
  225.  
  226. if __name__ == '__main__':
  227. main()
Add Comment
Please, Sign In to add comment