def execute_after_save(sender, instance, created, *args, **kwargs): if created: print("Transient Created: %s" % instance.name) print("Internal Survey: %s" % instance.internal_survey) is_k2_C16_validated, C16_msg = IsK2Pixel(instance.ra, instance.dec, "16") is_k2_C17_validated, C17_msg = IsK2Pixel(instance.ra, instance.dec, "17") print("K2 C16 Val: %s; K2 Val Msg: %s" % (is_k2_C16_validated, C16_msg)) print("K2 C17 Val: %s; K2 Val Msg: %s" % (is_k2_C17_validated, C17_msg)) if is_k2_C16_validated: k2c16tag = TransientTag.objects.get(name='K2 C16') instance.k2_validated = True instance.k2_msg = C16_msg instance.tags.add(k2c16tag) elif is_k2_C17_validated: k2c17tag = TransientTag.objects.get(name='K2 C17') instance.k2_validated = True instance.k2_msg = C17_msg instance.tags.add(k2c17tag) instance.save() if is_k2_C17_validated: # coord_string = GetSexigesimalString(instance.ra, instance.dec) coord_string = instance.CoordString() SendTransientAlert(instance.id, instance.name, coord_string[0], coord_string[1])
def execute_after_save(sender, instance, created, *args, **kwargs): tag_K2 = False if created: print("Transient Created: %s" % instance.name) print("Internal Survey: %s" % instance.internal_survey) if tag_K2: is_k2_C16_validated, C16_msg = IsK2Pixel(instance.ra, instance.dec, "16") is_k2_C17_validated, C17_msg = IsK2Pixel(instance.ra, instance.dec, "17") is_k2_C19_validated, C19_msg = IsK2Pixel(instance.ra, instance.dec, "19") print("K2 C16 Val: %s; K2 Val Msg: %s" % (is_k2_C16_validated, C16_msg)) print("K2 C17 Val: %s; K2 Val Msg: %s" % (is_k2_C17_validated, C17_msg)) print("K2 C19 Val: %s; K2 Val Msg: %s" % (is_k2_C19_validated, C19_msg)) if is_k2_C16_validated: k2c16tag = TransientTag.objects.get(name='K2 C16') instance.k2_validated = True instance.k2_msg = C16_msg instance.tags.add(k2c16tag) elif is_k2_C17_validated: k2c17tag = TransientTag.objects.get(name='K2 C17') instance.k2_validated = True instance.k2_msg = C17_msg instance.tags.add(k2c17tag) elif is_k2_C19_validated: k2c19tag = TransientTag.objects.get(name='K2 C19') instance.k2_validated = True instance.k2_msg = C19_msg instance.tags.add(k2c19tag) print('Checking TESS') if instance.disc_date: TESSFlag = tess_obs(instance.ra,instance.dec,date_to_mjd(instance.disc_date)+2400000.5) if TESSFlag: try: tesstag = TransientTag.objects.get(name='TESS') instance.tags.add(tesstag) except: pass else: TESSFlag = tess_obs(instance.ra,instance.dec,date_to_mjd(instance.modified_date)+2400000.5) if TESSFlag: try: tesstag = TransientTag.objects.get(name='TESS') instance.tags.add(tesstag) except: pass print('Checking Thacher') if thacher_transient_search(instance.ra,instance.dec): try: thachertag = TransientTag.objects.get(name='Thacher') instance.tags.add(thachertag) except: pass instance.save()
def do(self, tag_K2=False): try: nowdate = datetime.datetime.utcnow() - datetime.timedelta(1) transients = Transient.objects.filter(created_date__gt=nowdate) for t in transients: print('checking transient %s' % t) if tag_K2: is_k2_C16_validated, C16_msg = IsK2Pixel(t.ra, t.dec, "16") is_k2_C17_validated, C17_msg = IsK2Pixel(t.ra, t.dec, "17") is_k2_C19_validated, C19_msg = IsK2Pixel(t.ra, t.dec, "19") print("K2 C16 Val: %s; K2 Val Msg: %s" % (is_k2_C16_validated, C16_msg)) print("K2 C17 Val: %s; K2 Val Msg: %s" % (is_k2_C17_validated, C17_msg)) print("K2 C19 Val: %s; K2 Val Msg: %s" % (is_k2_C19_validated, C19_msg)) if is_k2_C16_validated: k2c16tag = TransientTag.objects.get(name='K2 C16') t.k2_validated = True t.k2_msg = C16_msg t.tags.add(k2c16tag) elif is_k2_C17_validated: k2c17tag = TransientTag.objects.get(name='K2 C17') t.k2_validated = True t.k2_msg = C17_msg t.tags.add(k2c17tag) elif is_k2_C19_validated: k2c19tag = TransientTag.objects.get(name='K2 C19') t.k2_validated = True t.k2_msg = C19_msg t.tags.add(k2c19tag) tag_TESS, tag_Thacher = True, True #False,False print('Checking TESS') if tag_TESS and t.disc_date: TESSFlag = tess_obs(t.ra, t.dec, date_to_mjd(t.disc_date) + 2400000.5) if TESSFlag: print('tagging %s' % t) try: tesstag = TransientTag.objects.get(name='TESS') t.tags.add(tesstag) except: pass else: TESSFlag = tess_obs( t.ra, t.dec, date_to_mjd(t.modified_date) + 2400000.5) if TESSFlag: print('tagging %s' % t) try: tesstag = TransientTag.objects.get(name='TESS') t.tags.add(tesstag) except: pass print('Checking Thacher') if tag_Thacher and thacher_transient_search(t.ra, t.dec): try: thachertag = TransientTag.objects.get(name='Thacher') t.tags.add(thachertag) except: pass t.save() except Exception as e: print(e)