Skip to content

Commit

Permalink
Allow LCOGT to be a source of asteroids and allow for discoveries. Ch…
Browse files Browse the repository at this point in the history
…ange default TAG to 'LCOGT' (from 'LCO')
  • Loading branch information
talister committed Jun 30, 2015
1 parent 7f76dff commit 558be79
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
26 changes: 19 additions & 7 deletions neoexchange/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -38,7 +39,8 @@
('S','Spaceguard'),
('D','NEODSYS'),
('G','Goldstone'),
('A','Arecibo')
('A','Arecibo'),
('L','LCOGT')
)

TELESCOPE_CHOICES = (
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down
30 changes: 30 additions & 0 deletions neoexchange/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit 558be79

Please sign in to comment.