diff --git a/GWalarm_screens.kv b/GWalarm_screens.kv index 2418d07f1ccc3d89a380e2846c72798c3315b7e9..1a1fea525110c93bcc3fa53a96574524080ae8bd 100644 --- a/GWalarm_screens.kv +++ b/GWalarm_screens.kv @@ -848,10 +848,24 @@ pos:self.pos size:self.size - +: + text1:'torep' + text2:'torep' + cols:2 + InfoLabel: + size_hint_x:0.5 + text:'[b]'+root.text1+'[/b]' + markup:True + halign:'center' + InfoLabel: + size_hint_x:0.5 + text:root.text2 + halign:'left' + text_size:root.width/2,None + : bg_col:(0,0,0,0) - color:(1,1,1,1) + color:(0,0,0,1) canvas.before: Color: rgba:self.bg_col @@ -961,6 +975,13 @@ font_size: dp(20) color:0,0,0,1 markup:True + canvas.before: + Color: + rgba:.4,.4,.4,1 + Line: + width:1 + points:self.x+self.width*0.05,self.y,self.x+self.width*0.95,self.y + GridLayout: rows:2 size_hint:1,0.3 @@ -1025,21 +1046,21 @@ Line: width:1 rectangle:self.x,self.y,self.width,self.height - InfoLabel: - text:root.part2info[1] + ':' + root.rowdict[root.part2info[1]].replace('+-',u'\xb1') - color:0,0,0,1 - InfoLabel: - text: root.part2info[2] + ':' + root.rowdict[root.part2info[2]] - color:0,0,0,1 - InfoLabel: - text:root.part2info[3] + ':' + root.rowdict[root.part2info[3]] - color:0,0,0,1 - InfoLabel: - text: root.part2info[4] + ':' + root.rowdict[root.part2info[4]] - color:0,0,0,1 - InfoLabel: - text: root.part2info[5] + ':' + root.rowdict[root.part2info[5]] - color:0,0,0,1 + InfoContainer: + text1:root.part2info[1] + text2:root.rowdict[root.part2info[1]].replace('+-',u'\xb1') + InfoContainer: + text1: root.part2info[2] + text2:root.rowdict[root.part2info[2]] + InfoContainer: + text1:root.part2info[3] + text2:root.rowdict[root.part2info[3]] + InfoContainer: + text1: root.part2info[4] + text2:root.rowdict[root.part2info[4]] + InfoContainer: + text1: root.part2info[5] + text2:root.rowdict[root.part2info[5]] GridLayout: size_hint_y:0.4 rows: len(root.part3info) @@ -1052,18 +1073,24 @@ InfoLabel: text:root.part3info[0] + ':' + root.rowdict[root.part3info[0]] bg_col:(44/255,160/255,44/255,1) + color:1,1,1,1 InfoLabel: text:root.part3info[1] + ':' + root.rowdict[root.part3info[1]] bg_col:(31/255,119/255,180/255,1) + color:1,1,1,1 + InfoLabel: text: root.part3info[2] + ':' + root.rowdict[root.part3info[2]] bg_col:(1,127/255,14/255,1) + color:1,1,1,1 InfoLabel: text:root.part3info[3] + ':' + root.rowdict[root.part3info[3]] bg_col:(214/255,39/255,40/255,1) + color:1,1,1,1 InfoLabel: text: root.part3info[4] + ':' + root.rowdict[root.part3info[4]] bg_col:(148/255,103/255,189/255,1) + color:1,1,1,1 GridLayout: rows:2 @@ -1193,7 +1220,7 @@ padding:(3,10) spacing:(0,3) - text:'[b][u]'+self.nom+'[/b][/u] \n' + self.desc + text:'[size=16dp][b][u]'+self.nom+'[/b][/u][/size] \n' + self.desc valign:'top' size_hint_y:None text_size: root.width, None @@ -1202,10 +1229,16 @@ font_size:dp(12) line_height:1 markup:True + color:0,0,0,1 viewclass: 'GlossDefLabel' - + canvas.before: + Color: + rgba:0.9,0.9,0.9,1 + Rectangle: + pos:self.pos + size:self.size RecycleBoxLayout: default_size:None,dp(56) default_size_hint:1,None @@ -1213,6 +1246,7 @@ height:self.minimum_height orientation:'vertical' padding:[0,20] + : color:0,0,0,1 diff --git a/GWalarm_screens.py b/GWalarm_screens.py index 466e7273dbe94868212738c8061cbe8140ba57bc..278a32ab7d735e8022253fd665e1b045a79490df 100644 --- a/GWalarm_screens.py +++ b/GWalarm_screens.py @@ -204,11 +204,13 @@ class EventInfoHeader(GridLayout): processType = 'MassGap event' elif ev_type == 'NSBH': processType = 'Neutron Star Black Hole merger' - - far = self.paramdict['FAR'].split() - far[2] = "{0:.0f}".format(float(far[2])) - far = " ".join(far) + far = self.paramdict['FAR'].split() + if len(far) != 1: + far[2] = "{0:.0f}".format(float(far[2])) + far = " ".join(far) + else: + far = far[0] dist = float(self.paramdict['Distance'].split()[0]) # distly = (2/3/72000)*(1-1/(1+72000*dist/scipy.constants.c)**1.5) distly = dist*3.262e+6 @@ -230,14 +232,19 @@ class EventInfoHeader(GridLayout): insts_formed+= ' and '+ elem else: insts_formed+= elem+',' - + date = datetime.datetime.strptime(self.paramdict['DetectionTime'].split()[0],'%Y-%m-%d') ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(n//10%10!=1)*(n%10<4)*n%10::4]) dayname = calendar.day_name[date.weekday()] month = calendar.month_name[date.month] dayno = ordinal(date.day) DateToken = dayname + ' the ' + dayno + ' of ' + str(month) + ' ' + str(date.year) - InitialToken = 'This event was detected by '+insts_formed+' on '+ DateToken + ' . ' + if len(self.children) == 4: + #This is a new event popup + NewOrNotToken = 'A new event has been' + else: + NewOrNotToken = 'This event was' + InitialToken = NewOrNotToken+ ' detected by '+insts_formed+' on '+ DateToken + ' . ' EventTypeToken = 'The event is most likely to be a ' + processType + ', with a probability of ' + "{0:.0f}".format(float(self.paramdict[ev_type][:-1])-1) + ' percent. ' FalseAlarmToken = 'The false alarm rate of the event is ' + far +'. ' DistanceLookBackToken = 'It is approximately ' + oom_to_words(dist,'Megaparsecs',tts='on') + ' away, which is equivalent to a lookback time of '+ oom_to_words(distly,'years',tts='on')+'. ' @@ -280,7 +287,9 @@ class EventInfoHeader(GridLayout): print('Speech thread closing...') def read_aloud(self): self.speaker_color=[0.8,0.8,0.8,0.4] - self.speak='1' + self.var=0 + self.speak=1 + def speaker_back(self): self.speaker_color=[0,0,0,0] @@ -381,15 +390,13 @@ def oom_to_words(inputval,unit,tts='off'): return return_string def process_FAR(FAR,tts='off'): + if type(FAR) is not float: + FAR = float(FAR) per_yr = FAR*scipy.constants.year if per_yr <= 1: oneinyr = 1/per_yr else: oneinyr = per_yr -# if len(str(oneinyr).split('.')[0]) >= 5 or 'e' in str(oneinyr): -# val = "One every "+str("{0:.2e}".format(oneinyr))+" yrs" -# else: -# val = "One every "+str("{0:.3f}".format(oneinyr))+" yrs" val = 'One every ' + oom_to_words(oneinyr,'years',tts) return val @@ -467,7 +474,6 @@ def historyUpdatev2(rv,names,specialnames,lookoutfor,backcolors,sorttype='Time D elif 'Instruments' in sorttype: sort_vars.append(row['Instruments'].decode()) if sort_vars != []: - print(sort_vars) if 'Descending' in sorttype: try: tables = [x for _,x in reversed(sorted(zip(sort_vars,tables)),key=len[0])] @@ -623,14 +629,13 @@ class InfoPop(Screen): pop.open() def on_pre_enter(self): - self.var = '0' - self.speak ='0' - + self.var = 0 + self.speak =0 def on_leave(self): if len(App.get_running_app().root.get_screen('historypop').ids.header.children) == 4: App.get_running_app().root.get_screen('historypop').ids.header.remove_widget(App.get_running_app().root.get_screen('historypop').ids.header.children[0]) App.get_running_app().root.get_screen('historypop').ids.header.do_layout() - self.var = '1' + self.var = 1 App.get_running_app().root.transition = SlideTransition() class GlossDefLabel(Label): @@ -875,12 +880,6 @@ class MainScreenv2(Screen): #check for the flag once per minute (same rate the file is polled) if newevent_flag == 1: #skip a level up to execute the rest of the loop, then back to waiting. - if buzzPin is not None: - buzzthread = threading.Thread(target=buzz,args=(3,1)) - buzzthread.start() - if pixels: - notifthread = threading.Thread(target=self.notifier) - notifthread.start() print('New event has been detected!!') break if main_flag == 1: @@ -927,8 +926,12 @@ class MainScreenv2(Screen): new_event_row = new_event_table[-1] orderedrow = [] for key in namelist: - orderedrow.append(new_event_row[key].decode()) - name_row_dict = dict(zip(namelist,orderedrow)) + if key == 'FAR': + v=process_FAR(new_event_row[key].decode()) + orderedrow.append(v) + else: + orderedrow.append(new_event_row[key].decode()) +# name_row_dict = dict(zip(namelist,orderedrow)) stats = [] lookoutfor = ['BBH','BNS','NSBH','MassGap','Terrestrial'] @@ -939,14 +942,12 @@ class MainScreenv2(Screen): t = threading.Thread(target=type_notif,args=(winner,'on')) t.start() - speech_thread = threading.Thread(target=self.read_event_params,args=(name_row_dict,winner)) - speech_thread.start() - if eventid == 'EventSimulation': h5file.remove_node("/events",'EventSimulation') h5file.close() newevent_flag=0 + App.get_running_app().root.get_screen('historypop').namelist = namelist App.get_running_app().root.get_screen('historypop').row = orderedrow extralabel = Label(text='[b]NEW EVENT[/b]',markup=True,font_size=20,halign='left',color=[0,0,0,1],size_hint_x=0.2) @@ -954,8 +955,17 @@ class MainScreenv2(Screen): if pixels: App.get_running_app().root.get_screen('historypop').ids.but1.bind(on_press=self.notif_off) App.get_running_app().root.get_screen('historypop').ids.but2.bind(on_press=self.notif_off) - App.get_running_app().root.current = 'historypop' + '''Now that we're ready, sound the alarms''' + if buzzPin is not None: + buzzthread = threading.Thread(target=buzz,args=(3,1)) + buzzthread.start() + if pixels: + notifthread = threading.Thread(target=self.notifier) + notifthread.start() + + App.get_running_app().root.current = 'historypop' + App.get_running_app().root.get_screen('historypop').ids.header.speak = 1 def notifier(self): self.notif_light_var=1