Skip to content

Commit

Permalink
Merge pull request #286 from LCOGT/issue-266
Browse files Browse the repository at this point in the history
Issue 266 (Don't update with old elements after find_orb refit)
  • Loading branch information
jchate6 authored Mar 7, 2019
2 parents 636e497 + 7a0e7ef commit cebbeac
Show file tree
Hide file tree
Showing 25 changed files with 67,025 additions and 284 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Portal for scheduling observations of NEOs using Las Cumbres Observatory.

## History

### 2.7.11
Allow for automatic updating of targets.
* Update observations from MPC daily.
* Update orbits with FindOrb or from MPC daily.
* Be smarter about when and how FindOrb updates an orbit.
* Update taxonomy daily.
* Update external spectroscopy weekly.

### 2.7.10
Several bug fixes
* Allow Download for all Programs
Expand Down
3 changes: 2 additions & 1 deletion docker/var/spool/cron/root
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
30 0,4,8,12,16,20 * * * source /var/www/apps/neoexchange/cronwrapper; python3 /var/www/apps/neoexchange/manage.py update_crossids
*/20 * * * * source /var/www/apps/neoexchange/cronwrapper; python3 /var/www/apps/neoexchange/manage.py update_blocks
30 */6 * * * source /var/www/apps/neoexchange/cronwrapper; python3 /var/www/apps/neoexchange/manage.py zoo_mtd_confirm
10 7 * * 0 source /var/www/apps/neoexchange/cronwrapper; python3 /var/www/apps/neoexchange/manage.py update_taxonomy_data
10 7 * * * source /var/www/apps/neoexchange/cronwrapper; python3 /var/www/apps/neoexchange/manage.py update_taxonomy_data
03 03 * * * source /var/www/apps/neoexchange/cronwrapper; python3 /var/www/apps/neoexchange/manage.py update_targets
30 7 * * 0 source /var/www/apps/neoexchange/cronwrapper; python3 /var/www/apps/neoexchange/manage.py update_external_spectroscopy_data -a
30 19,22 * * * source ~/download_FLOYDS_data_cron "$(date --date '1 day ago' +\%Y\%m\%d)"
11 changes: 8 additions & 3 deletions neoexchange/astrometrics/ephem_subs.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def compute_ephem(d, orbelems, sitecode, dbg=False, perturb=True, display=False,
# 0 1 2 3 4 5 6 7
emp_line = (d, ra, dec, mag, total_motion, alt_deg, spd, sky_pa)
if detailed:
return emp_line, mag_dot, separation
return emp_line, mag_dot, separation, delta

return emp_line

Expand Down Expand Up @@ -605,7 +605,12 @@ def read_findorb_ephem(empfile):
# Read main ephemeris
line = line.strip()
chunks = line.split()
emp_datetime = datetime(int(chunks[0]), int(chunks[1]), int(chunks[2]), int(chunks[3][0:2]), int(chunks[3][3:5]))
try:
emp_datetime = datetime(int(chunks[0]), int(chunks[1]), int(chunks[2]), int(chunks[3][0:2]), int(chunks[3][3:5]))
except ValueError:
logger.error("Couldn't parse line:")
logger.error(line)
raise ValueError("Error converting to datetime")
emp_ra, status = S.sla_dtf2r(chunks[4], chunks[5], chunks[6])
if status != 0:
logger.error("Error converting RA value")
Expand Down Expand Up @@ -1199,7 +1204,7 @@ def get_sitepos(site_code, dbg=False):
name or a MPC sitecode (FTN, FTS and SQA currently defined).
Be *REALLY* careful over longitude sign conventions..."""

site_code = site_code.upper()
site_code = str(site_code).upper()
if site_code == 'F65' or site_code == 'FTN':
# MPC code for FTN. Positions from JPL HORIZONS, longitude converted from 203d 44' 32.6" East
# 156d 15' 27.4" W
Expand Down
82 changes: 41 additions & 41 deletions neoexchange/astrometrics/sources_subs.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,10 @@ def parse_mpcobs(line):
prov_or_temp = str(line[5:12])

if len(number.strip()) != 0 and len(prov_or_temp.strip()) != 0:
# Number and provisional/temp. desigination
# Number and provisional/temp. designation
body = number
elif len(number.strip()) == 0 or len(prov_or_temp.strip()) != 0:
# No number but provisional/temp. desigination
# No number but provisional/temp. designation
body = prov_or_temp
else:
body = number
Expand Down Expand Up @@ -630,6 +630,9 @@ def parse_mpcobs(line):
elif obs_type.upper() == 'R':
# Radar observations, skip
logger.debug("Found radar observation, skipping")
elif obs_type.upper() == 'M':
# Micrometer observations, skip
logger.debug("Found micrometer observation, skipping")
elif obs_type == 's':
# Second line of satellite-based observation, stuff whole line into
# 'extrainfo' and parse what we can (so we can identify the corresponding
Expand Down Expand Up @@ -1829,64 +1832,61 @@ def parse_binzel_data(tax_text=None):
def parse_taxonomy_data(tax_text=None):
"""Parses the online taxonomy database for targets and pulls a list
of these targets back.
PDS table has 125 characters/line (chunks = 16 once names/notes removed)
SDSS table has 117 characters/line (chunks = 6 once names/extra removed)
"""

tax_text = str(tax_text).replace("\r", '\n').split("\n")
tax_text = list(filter(None, tax_text))
# print(len(tax_text))

tax_scheme = ['T',
'Ba',
'Td',
'H',
'S',
'B',
'3T/3B',
['3T', '3B'],
'BD',
]
tax_table = []
if len(tax_text[0]) == 117:
offset = -1
else:
offset = 0
for line in tax_text:
name = line[8:25]
end = line[103:]
line = line[:8]+line[26:104]
number = line[:8+offset].strip()
name = line[8+offset:25+offset].strip()
prov = line[25+offset:37+offset].strip()
end = line[103+offset*44:].strip()
line = line[36+offset:103+offset*44]
chunks = line.split(' ')
chunks = list(filter(None, chunks))
if chunks[0] != '':
if chunks[1] != '-':
chunks[1] = chunks[1]+' '+chunks[2]
del chunks[2]
chunks.insert(1, name)
if ',' in chunks[18]:
chunks[18] = chunks[18][:2]
chunks.insert(19, chunks[18][3:])
# print(chunks[0],len(chunks))
# parse Object ID=Object Number or Provisional designation if no number
if chunks[0] != '0':
obj_id = (chunks[0])
else:
obj_id = (chunks[2])
# Build Taxonomy reference table. This is clunky. Better to search table for matching values first?
index = range(1, 7)
index = [2*x+1 for x in index]+[17]
# parse Object ID=Object Number or Provisional designation if no number
if number != '0':
obj_id = number
else:
obj_id = prov
# Build Taxonomy reference table.
if len(chunks) == 6:
out = '{}|{}|{}'.format(chunks[1], chunks[2], chunks[5])
row = [obj_id, chunks[0], 'Sd', "SDSS", out]
tax_table.append(row)
elif len(chunks) == 16:
index = range(0, 8)
index = [2*x for x in index]+[13]
for i in index:
out = ' '
if chunks[i] != '-':
if end[0] != '-':
chunks[i+1] = chunks[i+1] + "|" + end
row = [obj_id, chunks[i], tax_scheme[(i-1)//2-1], "PDS6", chunks[i+1]]
if i == 12 or i == 13:
scheme = tax_scheme[6][i-12]
else:
if end[0] != '-':
out = chunks[i+1] + "|" + end
else:
out = chunks[i+1]
scheme = tax_scheme[i//2]
row = [obj_id, chunks[i], scheme, "PDS6", out]
tax_table.append(row)
if chunks[15] != '-':
if end[0] != '-':
out = end
else:
out = ' '
row = [obj_id, chunks[15], "3T", "PDS6", out]
tax_table.append(row)
if chunks[16] != '-':
if end[0] != '-':
out = end
else:
out = ' '
row = [obj_id, chunks[16], "3B", "PDS6", out]
tax_table.append(row)
return tax_table


Expand Down
106 changes: 47 additions & 59 deletions neoexchange/astrometrics/tests/test_albedo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
NEO exchange: NEO observing portal for Las Cumbres Observatory
Copyright (C) 2017-2019 LCO
Expand All @@ -11,116 +11,104 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
'''
"""

from datetime import datetime, timedelta
from django.test import TestCase

#Import module to test
# Import module to test
from astrometrics.albedo import *


class TestAsteroidDiameter(TestCase):
'''Unit tests for asteroid_diameter'''
"""Unit tests for asteroid_diameter"""

def test_big_bright(self):
expected_diameter = 375.0075

albedo = 0.5
H_mag = 18.5
diameter = asteroid_diameter(albedo, H_mag)
h_mag = 18.5

diameter = asteroid_diameter(albedo, h_mag)
self.assertAlmostEqual(expected_diameter, diameter, 4)



def test_small_shiny(self):
expected_diameter = 83.6556

albedo = 0.4
H_mag = 22.0
diameter = asteroid_diameter(albedo, H_mag)
h_mag = 22.0

diameter = asteroid_diameter(albedo, h_mag)
self.assertAlmostEqual(expected_diameter, diameter, 4)

def test_large_dim(self):
expected_diameter = 4825.3073

albedo = 0.1
H_mag = 14.7
diameter = asteroid_diameter(albedo, H_mag)
h_mag = 14.7

diameter = asteroid_diameter(albedo, h_mag)
self.assertAlmostEqual(expected_diameter, diameter, 4)

def test_tiny_not_shiny(self):
expected_diameter = 57.8755

albedo = 0.04
H_mag = 25.3
diameter = asteroid_diameter(albedo, H_mag)
h_mag = 25.3

diameter = asteroid_diameter(albedo, h_mag)
self.assertAlmostEqual(expected_diameter, diameter, 4)

def test_negative_albedo(self):
expected_diameter = False

albedo = -0.3
H_mag = 17.1
diameter = asteroid_diameter(albedo, H_mag)
h_mag = 17.1
diameter = asteroid_diameter(albedo, h_mag)
self.assertEqual(expected_diameter, diameter)


class TestAsteroidAlbedoDistribution(TestCase):
'''Unit test for albedo_distribution'''
"""Unit test for albedo_distribution"""

def test_large_albedo(self):
expected_distribution = 0.009661

albedo = 0.65
distribution = albedo_distribution(a = albedo)
distribution = albedo_distribution(a=albedo)
self.assertAlmostEqual(expected_distribution, distribution, 4)

def test_small_albedo(self):
expected_distribution = 5.651816

albedo = 0.04
distribution = albedo_distribution(a = albedo)
distribution = albedo_distribution(a=albedo)
self.assertAlmostEqual(expected_distribution, distribution, 4)

def test_zero_albedo(self):
expected_distribution = 0.00

albedo = 0.00
distribution = albedo_distribution(a = albedo)
distribution = albedo_distribution(a=albedo)
self.assertAlmostEqual(expected_distribution, distribution, 4)

def test_negative_albedo(self):
expected_distribution = False

albedo = -0.20
distribution = albedo_distribution(a = albedo)
distribution = albedo_distribution(a=albedo)
self.assertAlmostEqual(expected_distribution, distribution, 4)

def test_albedo_equal_to_one(self):
expected_distribution = 0.0000

albedo = 1.00
distribution = albedo_distribution(a = albedo)
distribution = albedo_distribution(a=albedo)
self.assertAlmostEqual(expected_distribution, distribution, 4)

def test_not_in_albedo_range(self):
expected_distribution = False

albedo = 5.20
distribution = albedo_distribution(a = albedo)
distribution = albedo_distribution(a=albedo)
self.assertEqual(expected_distribution, distribution)












10 changes: 8 additions & 2 deletions neoexchange/astrometrics/tests/test_mpcobs_13553.dat
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
13553J92J00E 3A1992 06 03.22714 14 26 02.07 -00 57 45.2 17.3 20399675
13553J92J00E 3A1992 06 03.27431 14 26 00.15 -00 57 17.1 20399675
13553J92J00E 3A1992 06 05.25035 14 25 00.69 -00 37 10.6 20399675
13553J92J00E A1994 06 05.27986 14 24 59.76 -00 36 53.4 20399675
13553J92J00E C1998 02 21.09248 10 31 21.78 +03 20 23.2 20.1 V a0516557
13553J92J00E C1999 11 03.45997 06 13 10.05 +16 08 58.4 za7240711
13553J92J00E C1999 11 03.47716 06 13 09.46 +16 08 56.3 za7240711
Expand All @@ -6,8 +10,8 @@
13553J92J00E C2000 01 09.24057 05 03 40.47 +14 29 53.7 za9780711
13553 C2002 09 05.41325 04 21 34.50 +19 16 32.7 19.3 cg2118704
13553 C2002 09 05.42767 04 21 35.37 +19 16 30.5 19.6 cg2118704
13553 C2002 09 05.44192 04 21 36.27 +19 16 28.0 20.1 cg2118704
13553 C2002 09 05.45624 04 21 37.03 +19 16 26.8 20.1 cg2118704
13553 A2002 09 05.44192 04 21 36.27 +19 16 28.0 20.1 cg2118704
13553 A2002 09 05.45624 04 21 37.03 +19 16 26.8 20.1 cg2118704
13553 C2002 09 05.47055 04 21 38.04 +19 16 24.8 20.1 cg2118704
13553 C2002 09 25.61649 04 34 29.34 +18 06 44.2 19.0 Rt~2Z96608
13553 C2002 09 25.62684 04 34 29.48 +18 06 42.2 19.6 Rt~2Z96608
Expand All @@ -21,3 +25,5 @@
13553 KC2018 07 10.13271 20 24 37.81 +16 22 12.2 15.0 VqEN036W34
13553 KC2018 07 10.14118 20 24 39.26 +16 22 22.8 15.0 VqEN036W34
13553 KC2018 07 10.14982 20 24 40.73 +16 22 33.6 15.0 VqEN036W34
13553 S2018 12 04.87785 00 25 08.24 -01 10 38.1 19 RL~2raDC51
13553 s2018 12 04.87785 1 + 6752.8346 + 1167.9174 + 308.3567 ~2raDC51
25 changes: 25 additions & 0 deletions neoexchange/astrometrics/tests/test_sdss_tax_page.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
166 Rhodope - C 78 1 0 0 - s394c9 09.89 2.6859 0.1759 0.2005 02.6887 0.2101 12.0189
183 Istria - S 00 1 0 0 - seef1c 09.68 0.0000 0.0000 0.0000 02.7926 0.3502 26.3823
208 Lacrimosa - S 85 1 0 0 - s458db 08.96 2.8929 0.0450 0.0372 02.8929 0.0152 01.7489
220 Stephania - X 65 1 0 0 - s03bbc 11.00 2.3486 0.2037 0.1545 02.3483 0.2578 07.5865
227 Philosophia - C 92 1 0 0 - sced0d 08.70 3.1443 0.2209 0.1846 03.1534 0.1981 09.1453
232 Russia - CX 66 2 0 0 CX s3c2e8 10.25 2.5531 0.2227 0.0966 02.5505 0.1776 06.0703
251 Sophia - L 96 2 1 0 LS s3936f 10.00 3.0949 0.0966 0.1735 03.0913 0.1053 10.5277
962 Aslog - S 96 4 1 0 CLSQ sd764f 11.52 2.9057 0.0624 0.0351 02.9036 0.1021 02.6025
60682 - 2000 GU31 C 20 1 0 1 - sefb43 15.20 3.1955 0.1530 0.0228 03.2003 0.1646 01.9041
60683 - 2000 GL33 L 42 2 0 1 LS sb7856 16.30 2.1553 0.1604 0.1310 02.1550 0.1315 07.1249
60688 - 2000 GY35 S 86 2 0 1 LS s1ff81 15.00 2.9605 0.0811 0.0400 02.9603 0.1054 01.1886
1067 Lunaria 1926 RG LS 65 1 0 0 - s0c09f 10.99 2.8710 0.1567 0.2047 02.8754 0.1903 10.5569
1072 Malva 1926 TA C 82 1 0 0 - sf32a3 10.50 3.1763 0.2160 0.1304 03.1600 0.2432 08.0292
60690 - 2000 GD38 V 15 1 0 1 - sb424d 15.90 2.2580 0.1222 0.1244 02.2577 0.1132 07.0135
60694 - 2000 GG41 S 50 1 0 1 - s2192f 15.80 2.5632 0.2504 0.0960 02.5638 0.2517 04.8728
60700 - 2000 GL50 S 57 3 0 1 SQ se2f68 16.20 2.3220 0.1842 0.0042 02.3233 0.1456 00.8801
60707 - 2000 GP56 DL 8 1 0 1 - s22ccd 15.10 2.9964 0.0749 0.0321 02.9947 0.0495 01.7026
0 - 2000 QN68 C 25 1 0 1 - s08795 16.15 3.1594 0.1549 0.0893 03.1557 0.1899 04.0325
0 - 2000 QN8 D 14 1 0 1 - sf2cfe 14.67 3.0737 0.2685 0.2297 03.0663 0.3071 13.8602
0 - 2000 QO122 S 20 1 0 1 - s0ac3b 16.34 2.6164 0.2871 0.1264 02.6166 0.3423 06.4734
0 - 2000 QO192 C 10 1 0 1 - s19c59 15.17 0.0000 0.0000 0.0000 02.7212 0.1491 16.8995
0 - 2000 QO200 LS 45 1 0 1 - s08a40 16.49 2.6209 0.1774 0.0511 02.6208 0.2229 03.3663
0 - 2000 QO205 XL 9 1 0 1 - s09d32 16.54 0.0000 0.0000 0.0000 02.2125 0.1348 07.1674
0 - 3184 T-3 D 6 1 0 1 - s41ae4 13.33 0.0000 0.0000 0.0000 05.2069 0.1451 17.0825
0 - 3191 T-2 C 6 1 0 1 - s230a9 16.63 2.3509 0.1983 0.1558 02.3504 0.2399 09.6241
Loading

0 comments on commit cebbeac

Please sign in to comment.