Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/local/bin/python
2# encoding: utf-8
3"""
4*The classification block for the object ticket*
6:Author:
7 David Young
8"""
9import sys
10import os
11import re
12import datetime
13from fundamentals import times
14import khufu
15from marshall_webapp.templates.commonelements import commonutils as cu
17def classification_block(
18 log,
19 request,
20 discoveryDataDictionary):
21 """get ticket classification block
23 **Key Arguments**
25 - ``log`` -- logger
26 - ``request`` -- the pyramid request
27 - ``discoveryDataDictionary`` -- a dictionary of the discovery data for this transient.
30 **Return**
32 - ``classification_block`` -- the ticket identity block for the pesssto object
34 """
35 log.debug('starting the ``classification_block`` function')
37 if not discoveryDataDictionary["recentClassification"]:
38 return None
40 title = cu.block_title(
41 log,
42 title="spectral classification"
43 )
45 # classification
46 label = cu.little_label(
47 text="classification:",
48 )
50 if len(discoveryDataDictionary["recentClassification"]) and discoveryDataDictionary["recentClassification"][0] == "I":
51 discoveryDataDictionary["recentClassification"] = "SN " + \
52 discoveryDataDictionary["recentClassification"]
53 text = khufu.coloredText(
54 text=discoveryDataDictionary["recentClassification"],
55 color="magenta",
56 size=6
57 )
58 spectralType = khufu.grid_row(
59 responsive=True,
60 columns="""%s %s""" % (label, text,),
61 )
63 # classifcation survey
64 label = cu.little_label(
65 text="classifcation survey:",
66 )
67 text = khufu.coloredText(
68 text=discoveryDataDictionary["classificationSurvey"],
69 color="green",
70 size=5
71 )
72 classificationSurvey = khufu.grid_row(
73 responsive=True,
74 columns="""%s %s""" % (label, text,),
75 )
77 # classification date
78 label = cu.little_label(
79 text="classification date:",
80 )
81 text = khufu.coloredText(
82 text=str(discoveryDataDictionary["classificationDate"])[0:10],
83 color="orange",
84 size=4
85 )
87 daysPast = discoveryDataDictionary["classificationDate"]
88 if daysPast:
90 daysPast = times.datetime_relative_to_now(daysPast)[1:]
91 if "just" not in daysPast:
92 daysPast = daysPast[1:]
93 if daysPast[-1] == "d":
94 daysPast = "(%s days ago)" % (daysPast[0:-1],)
95 elif "just" not in daysPast:
96 daysPast = "(+%s)" % (daysPast,)
97 else:
98 daysPast = "(%s)" % (daysPast,)
99 daysPast = khufu.coloredText(
100 text="<br>        %(daysPast)s" % locals(
101 ),
102 color="violet"
103 )
104 else:
105 daysPast = ""
106 classificationDate = khufu.grid_row(
107 responsive=True,
108 columns="""%s %s %s""" % (label, text, daysPast),
109 )
111 # classifcation survey
112 label = cu.little_label(
113 text="classification phase:",
114 )
115 classificationWRTMax = discoveryDataDictionary["classificationWRTMax"]
116 classificationPhase = discoveryDataDictionary["classificationPhase"]
118 if classificationWRTMax is None:
119 classificationWRTMax = "not set"
121 if classificationPhase:
122 if classificationWRTMax == "pre-max":
123 classificationWRTMax = "-%(classificationPhase)sd" % locals()
124 elif classificationWRTMax == "post-max":
125 classificationWRTMax = "+%(classificationPhase)sd" % locals()
126 classificationWRTMax = "  %(classificationWRTMax)s" % locals()
128 if "unknown" in classificationWRTMax:
129 size = 4
130 else:
131 size = 5
132 text = khufu.coloredText(
133 text="""%(classificationWRTMax)s""" % locals(),
134 color="blue",
135 size=size
136 )
137 classificationPhase = khufu.grid_row(
138 responsive=True,
139 columns="""%s %s""" % (label, text,),
140 )
142 # redshift
143 label = cu.little_label(
144 text="redshift:",
145 )
147 redshift = ""
148 if discoveryDataDictionary["best_redshift"]:
149 text = khufu.coloredText(
150 text="%6.4f" % (discoveryDataDictionary["best_redshift"]),
151 color="yellow",
152 size=6
153 )
154 else:
155 text = khufu.coloredText(
156 text="unknown",
157 color="yellow",
158 size=4
159 )
160 redshift = khufu.grid_row(
161 responsive=True,
162 columns="""%s %s""" % (label, text,),
163 )
165 # distance
166 label = cu.little_label(
167 text="distance:",
168 )
170 distanceMpc = ""
171 if discoveryDataDictionary["distanceMpc"]:
172 text = khufu.coloredText(
173 text="%10.2f Mpc" % (discoveryDataDictionary["distanceMpc"]),
174 color="blue",
175 size=6
176 )
177 distanceMpc = khufu.grid_row(
178 responsive=True,
179 columns="""%s %s""" % (label, text,),
180 )
182 return "%(title)s %(spectralType)s %(classificationSurvey)s %(classificationDate)s %(classificationPhase)s %(redshift)s %(distanceMpc)s" % locals()