From 558be796853e8c2d4553768673127750f144133d Mon Sep 17 00:00:00 2001 From: Tim Lister Date: Mon, 29 Jun 2015 17:03:33 -0700 Subject: [PATCH] Allow LCOGT to be a source of asteroids and allow for discoveries. Change default TAG to 'LCOGT' (from 'LCO') --- neoexchange/core/models.py | 26 +++++++++++++++++------- neoexchange/core/tests/test_views.py | 30 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/neoexchange/core/models.py b/neoexchange/core/models.py index 83b2a1868..7f15427e6 100644 --- a/neoexchange/core/models.py +++ b/neoexchange/core/models.py @@ -27,7 +27,8 @@ ('T','Trojan'), ('U','Unknown/NEO Candidate'), ('X','Did not exist'), - ('W','Was not interesting') + ('W','Was not interesting'), + ('D','Discovery, non NEO'), ) ELEMENTS_TYPES = (('MPC_MINOR_PLANET','MPC Minor Planet'),('MPC_COMET','MPC Comet')) @@ -38,7 +39,8 @@ ('S','Spaceguard'), ('D','NEODSYS'), ('G','Goldstone'), - ('A','Arecibo') + ('A','Arecibo'), + ('L','LCOGT') ) TELESCOPE_CHOICES = ( @@ -74,7 +76,7 @@ class Proposal(models.Model): code = models.CharField(max_length=20) title = models.CharField(max_length=255) pi = models.CharField(max_length=50, default='') - tag = models.CharField(max_length=10, default='LCO') + tag = models.CharField(max_length=10, default='LCOGT') class Meta: db_table = 'ingest_proposal' @@ -111,12 +113,22 @@ class Body(models.Model): ingest = models.DateTimeField(default=now) def epochofel_mjd(self): - t = Time(self.epochofel.isoformat(), format='isot', scale='tt') - return t.mjd + mjd = None + try: + t = Time(self.epochofel.isoformat(), format='isot', scale='tt') + mjd = t.mjd + except: + pass + return mjd def epochofperih_mjd(self): - t = Time(self.epochofperih.isoformat(), format='isot', scale='tt') - return t.mjd + mjd = None + try: + t = Time(self.epochofperih.isoformat(), format='isot', scale='tt') + mjd = t.mjd + except: + pass + return mjd def current_name(self): if self.name: diff --git a/neoexchange/core/tests/test_views.py b/neoexchange/core/tests/test_views.py index 0def91d36..3441dde08 100644 --- a/neoexchange/core/tests/test_views.py +++ b/neoexchange/core/tests/test_views.py @@ -134,6 +134,36 @@ def test_update_MPC_duplicate(self): obj_id ='N007riz' update_MPC_orbit(obj_id) + def test_create_discovered_object(self): + obj_id ='LSCTLF8' + elements = { 'abs_mag' : 16.2, + 'slope' : 0.15, + 'epochofel' : datetime(2015, 6, 23, 0, 0, 0), + 'meananom' : 333.70614, + 'argofperih' : 40.75306, + 'longascnode' : 287.97838, + 'orbinc' : 23.61657, + 'eccentricity': 0.1186953, + 'meandist' : 2.7874893, + 'elements_type': 'MPC_MINOR_PLANET', + 'origin' : 'L', + 'source_type' : 'D', + 'active' : True + } + body, created = Body.objects.get_or_create(provisional_name=obj_id) + # We are creating this object + self.assertEqual(True,created) + resp = save_and_make_revision(body,elements) + # Need to call full_clean() to validate the fields as this is not + # done on save() (called by get_or_create() or save_and_make_revision()) + body.full_clean() + # We are saving all the detailing elements + self.assertEqual(True,resp) + + # Test it came from LCOGT as a discovery + self.assertEqual('L', body.origin) + self.assertEqual('D', body.source_type) + class HomePageTest(TestCase):