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 master lightcurve block for the object ticket*
6:Author:
7 David Young
8"""
9import sys
10import os
11import re
12import datetime as datetime
13import khufu
14from marshall_webapp.templates.commonelements import commonutils as cu
17def master_lightcurve_block(
18 log,
19 request,
20 discoveryDataDictionary,
21 lightcurveData,
22 objectAkas,
23 displayTitle=True):
24 """get ticket lightcurve block
26 **Key Arguments**
28 - ``log`` -- logger
29 - ``request`` -- the pyramid request
30 - ``discoveryDataDictionary`` -- a dictionary of the discovery data for this transient.
31 - ``lightcurveData`` -- the lightcurve data for the objects displayed on the webpage
32 - ``objectAkas`` -- the transient object akas
33 - ``displayTitle`` -- display the title for this block?
36 **Return**
38 - ``master_lightcurve_block`` -- the ticket identity block for the pesssto object
40 """
41 log.debug('starting the ``master_lightcurve_block`` function')
43 lsqExists = False
44 if displayTitle:
45 title = cu.block_title(
46 log,
47 title="master lightcurve"
48 )
49 else:
50 title = ""
52 name = discoveryDataDictionary["masterName"]
54 if discoveryDataDictionary["master_pessto_lightcurve"]:
55 dlightCurveImage = 'caches/transients/%s/master_lightcurve.png' % (
56 discoveryDataDictionary["transientBucketId"],)
57 lightCurveImage = request.static_url(f'marshall_webapp:{dlightCurveImage}')
59 else:
60 lightCurveImage = ''
61 dlightCurveImage = ''
63 # Override for LSQ lightcurves
64 lightcurveSwitchAttempt = True
65 transientBucketId = discoveryDataDictionary["transientBucketId"]
66 for row in lightcurveData:
67 if row["transientBucketId"] == discoveryDataDictionary["transientBucketId"] and row["survey"] and "lsq-disc" in row["survey"].lower():
68 lightcurveSwitchAttempt = False
70 if lightcurveSwitchAttempt == True:
71 filePath = request.registry.settings[
72 "cache-directory"] + "/transients/%(transientBucketId)s/lsq_lightcurve.gif" % locals()
73 lsqExists = os.path.exists(filePath)
75 if lsqExists:
76 transientBucketId = discoveryDataDictionary["transientBucketId"]
77 dlightCurveImage = 'caches/transients/%(transientBucketId)s/lsq_lightcurve.gif' % locals(
78 )
79 lightCurveImage = request.static_url(f'marshall_webapp:{dlightCurveImage}')
81 if len(lightCurveImage):
82 href = request.route_path(
83 'download', _query={'url': dlightCurveImage, "webapp": "marshall_webapp", "filename": "%(name)s_master_lightcurve" % locals()})
84 lightCurveImage = khufu.imagingModal(
85 log=log,
86 imagePath=lightCurveImage,
87 display="polaroid", # [ rounded | circle | polaroid | False ]
88 modalHeaderContent="Lightcurve for %(name)s" % locals(),
89 modalFooterContent="",
90 stampWidth=False,
91 modalImageWidth=False,
92 downloadLink=href)
93 lightCurveImage = lightCurveImage.get()
94 else:
95 lightCurveImage = khufu.image(
96 # [ industrial | gray | social ]
97 src="""holder.js/190x190/auto/industrial/text:master lightcurve not ready""",
98 display="rounded", # [ rounded | circle | polaroid | False ]
99 )
101 return "%(title)s %(lightCurveImage)s" % locals()