Skip to content

Commit

Permalink
Merge branch 'issue-578'. Closes Issue #578
Browse files Browse the repository at this point in the history
  • Loading branch information
talister committed Nov 17, 2021
2 parents 537f4d3 + c90d2d0 commit b94c7b6
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 22 deletions.
3 changes: 3 additions & 0 deletions neoexchange/core/models/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ def return_tel_string(self):
'W86' : onem_dict,
'W87' : onem_dict,
'V37' : onem_dict,
'V39' : onem_dict,
'Z31' : onem_dict,
'Z24' : onem_dict,
'Z21' : point4m_dict,
'Z17' : point4m_dict,
'Q58' : point4m_dict,
Expand Down
8 changes: 5 additions & 3 deletions neoexchange/core/models/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def format_mpc_line(self, include_catcode=False):

microday = True

if self.frame.extrainfo:
valid_MPC_notes = ['A', 'P', 'e', 'C', 'B', 'T', 'M', 'V', 'v', 'R', 'r', 'S', 's',\
'c', 'E', 'O', 'H', 'N', 'n', 'D', 'Z', 'W', 'w', 'Q', 'q', 'T', 't']
if self.frame.extrainfo in valid_MPC_notes:
obs_type = self.frame.extrainfo
if obs_type == 'A':
microday = False
Expand Down Expand Up @@ -140,12 +142,12 @@ def format_psv_header(self):
rms_available = False
if self.err_obs_ra and self.err_obs_dec and self.err_obs_mag:
rms_available = True
rms_tbl_fmt = '%7s|%-11s|%8s|%4s|%-4s|%-23s|%11s|%11s|%5s|%6s|%8s|%-5s|%6s|%4s|%8s|%6s|%6s|%6s|%-5s|%-s'
rms_tbl_fmt = '%-7s|%-11s|%-8s|%-4s|%-4s|%-23s|%-11s|%-11s|%-5s|%-6s|%-8s|%-5s|%-6s|%-4s|%-8s|%-6s|%-6s|%-6s|%-5s|%-s'
tbl_hdr = rms_tbl_fmt % ('permID ', 'provID', 'trkSub ', 'mode', 'stn', 'obsTime', \
'ra', 'dec', 'rmsRA', 'rmsDec', 'astCat', 'mag', 'rmsMag', 'band', 'photCat', \
'photAp', 'logSNR', 'seeing', 'notes', 'remarks')
else:
tbl_fmt = '%7s|%-11s|%8s|%4s|%-4s|%-23s|%11s|%11s|%8s|%-5s|%4s|%8s|%-5s|%-s'
tbl_fmt = '%-7s|%-11s|%-8s|%-4s|%-4s|%-23s|%-11s|%-11s|%-8s|%-5s|%-4s|%-8s|%-5s|%-s'
tbl_hdr = tbl_fmt % ('permID ', 'provID', 'trkSub ', 'mode', 'stn', 'obsTime', \
'ra'.ljust(11), 'dec'.ljust(11), 'astCat', 'mag', 'band', 'photCat', 'notes', 'remarks')
return tbl_hdr
Expand Down
27 changes: 27 additions & 0 deletions neoexchange/core/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,18 @@ def setUp(self):
}
self.test_frame_stack = Frame.objects.create(**frame_params)

frame_params = { 'sitecode' : 'F65',
'instrument' : 'ep02',
'filter' : 'rp',
'frametype' : Frame.BANZAI_RED_FRAMETYPE,
'extrainfo' : 'MUSCAT_FAST',
'midpoint' : datetime(2021, 11,12, 6, 10, 49, int(0.9*1e6)),
'block' : self.test_block,
'astrometric_catalog' : "GAIA-DR2",
'photometric_catalog' : "GAIA-DR2",
}
self.test_frame_extrainfo = Frame.objects.create(**frame_params)

frame_params = { 'sitecode' : 'C51',
'filter' : 'R',
'frametype' : Frame.SATELLITE_FRAMETYPE,
Expand Down Expand Up @@ -2017,6 +2029,21 @@ def test_mpc_4(self):
mpc_line = measure.format_mpc_line(include_catcode=True)
self.assertEqual(expected_mpcline, mpc_line)

def test_mpc_extrainfo(self):
measure_params = { 'body' : self.body,
'frame' : self.test_frame_extrainfo,
'obs_ra' : 7.5,
'obs_dec' : -00.5,
'obs_mag' : 21.5,
'astrometric_catalog' : "GAIA-DR2",
'photometric_catalog' : "GAIA-DR2",
}

measure = SourceMeasurement.objects.create(**measure_params)
expected_mpcline = ' N999r0q C2021 11 12.25752200 30 00.00 -00 30 00.0 21.5 GV F65'
mpc_line = measure.format_mpc_line(include_catcode=True)
self.assertEqual(expected_mpcline, mpc_line)

def test_mpc_F51_no_filter_mapping(self):
measure_params = { 'body' : self.body,
'frame' : self.test_frame_nonLCO_F51,
Expand Down
179 changes: 166 additions & 13 deletions neoexchange/core/tests/test_mpc_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def setUp(self):
'obs_mag' : 20.7,
}

measure = SourceMeasurement.objects.create(**measure_params)
self.measure_twom = SourceMeasurement.objects.create(**measure_params)

measure_params = { 'body' : self.body,
'frame' : self.test_frame_gaia,
Expand Down Expand Up @@ -548,6 +548,42 @@ def test_F65(self):

self.assertEqual(expected_message, message)

def test_F65_MuSCAT(self):

self.test_frame_twom.instrument = 'ep02'
self.test_frame_twom.filter = 'rp'
self.test_frame_twom.extrainfo = 'MUSCAT_FAST'
self.test_frame_twom.astrometric_catalog = 'GAIA-DR2'
self.test_frame_twom.photometric_catalog = 'GAIA-DR2'
self.test_frame_twom.save()

self.measure_twom.astrometric_catalog = 'GAIA-DR2'
self.measure_twom.photometric_catalog = 'GAIA-DR2'
self.measure_twom.save()

expected_message = (u'COD F65\n'
u'CON LCO, 6740 Cortona Drive Suite 102, Goleta, CA 93117\n'
u'CON [tlister@lco.global]\n'
u'OBS T. Lister, J. Chatelain, S. Greenstreet, E. Gomez\n'
u'MEA T. Lister\n'
u'TEL 2.0-m f/10 Ritchey-Chretien + CCD\n'
u'ACK NEOx_2015 XS54_F65_ep02\n'
u'COM LCO OGG Node 2m0 FTN at Haleakala, Maui\n'
u'AC2 tlister@lco.global,sgreenstreet@lco.global,jchatelain@lco.global\n'
u'NET GAIA-DR2\n'
u'BND G\n'
u' K15X54S C2015 12 05.41028900 30 24.00 +32 45 18.0 20.7 G F65\n')
message = generate_message(self.test_block4.id, self.test_block4.body.id)

i = 0
expected_lines = expected_message.split('\n')
message_lines = message.split('\n')
while i < len(expected_lines):
self.assertEqual(expected_lines[i], message_lines[i])
i += 1

self.assertEqual(expected_message, message)

def test_K93_gaia(self):

expected_message = (u'COD K93\n'
Expand Down Expand Up @@ -971,7 +1007,7 @@ def test_K93(self):
'! aperture 1.0\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' | | N999r0q| CCD|K93 |2015-07-13T21:09:51.00Z|157.500000 |-32.750000 | UCAC4|21.5 | R| UCAC4| |\n')

message = generate_ades_psv_message(self.test_block.id, self.test_block.body.id)
Expand Down Expand Up @@ -1005,7 +1041,7 @@ def test_W86(self):
'! aperture 1.0\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' |2015 XS54 | | CCD|W86 |2015-12-05T01:10:49.90Z|157.500000 | 0.660000 | 2MASS|21.5 | R| 2MASS|K |\n')

message = generate_ades_psv_message(self.test_block2.id, self.test_block2.body.id)
Expand Down Expand Up @@ -1039,7 +1075,7 @@ def test_Z21(self):
'! aperture 0.4\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' |2015 XS54 | | CCD|Z21 |2015-12-05T01:10:49.90Z| 7.600000 | 32.755000 | 2MASS|20.5 | R| 2MASS| |\n')

message = generate_ades_psv_message(self.test_block3.id, self.test_block3.body.id)
Expand Down Expand Up @@ -1080,7 +1116,7 @@ def test_W89(self):
'! aperture 0.4\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' |2015 XS54 | | CCD|W89 |2015-12-05T01:10:49.90Z| 7.600000 | 32.755000 | 2MASS|20.5 | R| 2MASS| |\n')

message = generate_ades_psv_message(self.test_block3.id, self.test_block3.body.id)
Expand Down Expand Up @@ -1121,7 +1157,7 @@ def test_W79(self):
'! aperture 0.4\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' |2015 XS54 | | CCD|W79 |2015-12-05T01:10:49.90Z| 7.600000 | 32.755000 | 2MASS|20.5 | R| 2MASS| |\n')

message = generate_ades_psv_message(self.test_block3.id, self.test_block3.body.id)
Expand Down Expand Up @@ -1162,7 +1198,7 @@ def test_V38(self):
'! aperture 0.4\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' |2015 XS54 | | CCD|V38 |2015-12-05T01:10:49.90Z| 7.600000 | 32.755000 | 2MASS|20.5 | R| 2MASS| |\n')

message = generate_ades_psv_message(self.test_block3.id, self.test_block3.body.id)
Expand Down Expand Up @@ -1203,7 +1239,7 @@ def test_L09(self):
'! aperture 0.4\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' |2015 XS54 | | CCD|L09 |2015-12-05T01:10:49.90Z| 7.600000 | 32.755000 | 2MASS|20.5 | R| 2MASS| |\n')

message = generate_ades_psv_message(self.test_block3.id, self.test_block3.body.id)
Expand Down Expand Up @@ -1238,7 +1274,7 @@ def test_F65(self):
'! aperture 2.0\n'
'! detector CCD\n'
'! fRatio 10.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' |2015 XS54 | | CCD|F65 |2015-12-05T09:50:49.00Z| 7.600000 | 32.755000 | PPMXL|20.7 | R| PPMXL| |\n')

message = generate_ades_psv_message(self.test_block4.id, self.test_block4.body.id)
Expand Down Expand Up @@ -1273,7 +1309,7 @@ def test_K93_gaia(self):
'! aperture 1.0\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' | | N999r0q| CCD|K93 |2015-07-13T21:09:51.00Z| 15.500000 | -3.750000 | Gaia1|21.6 | G| Gaia1| |\n')

message = generate_ades_psv_message(self.test_block_gaia.id, self.test_block_gaia.body.id)
Expand Down Expand Up @@ -1308,7 +1344,7 @@ def test_W86_QL(self):
'! aperture 1.0\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' |2015 XS54 | | CCD|W86 |2015-12-05T01:10:49.90Z| 15.500000 | -3.750000 | 2MASS|21.6 | V| PPMXL| |\n')

message = generate_ades_psv_message(self.test_block2ql.id, self.test_block2ql.body.id)
Expand Down Expand Up @@ -1348,7 +1384,7 @@ def test_K93_discovery(self):
'! aperture 1.0\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' | | N999r0q| CCD|K93 |2015-07-13T21:09:51.00Z|157.500000 |-32.750000 | UCAC4|21.5 | R| UCAC4|* |\n')

message = generate_ades_psv_message(self.test_block.id, self.test_block.body.id)
Expand Down Expand Up @@ -1383,7 +1419,7 @@ def test_K93_gaiadr2(self):
'! aperture 1.0\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' | | N999r0q| CCD|K93 |2015-07-13T21:09:51.00Z| 15.500000 | -3.750000 | Gaia2|21.6 | G| Gaia2| |\n')

message = generate_ades_psv_message(self.test_block_gaiadr2.id, self.test_block_gaiadr2.body.id)
Expand All @@ -1396,3 +1432,120 @@ def test_K93_gaiadr2(self):
i += 1

self.assertEqual(exp_msg, message)

def test_V39_gaiadr2(self):

self.test_frame_gaiadr2.sitecode = 'V39'
self.test_frame_gaiadr2.instrument = 'fa07'
self.test_frame_gaiadr2.save()

exp_msg = ( '# version=2017\n'
'# observatory\n'
'! mpcCode V39\n'
'# submitter\n'
'! name T. Lister\n'
'! institution LCO, 6740 Cortona Drive Suite 102, Goleta, CA 93117\n'
'# observers\n'
'! name T. Lister\n'
'! name E. Gomez\n'
'! name J. Chatelain\n'
'! name S. Greenstreet\n'
'# measurers\n'
'! name T. Lister\n'
'# telescope\n'
'! name LCO ELP Node 1m0 Dome B at McDonald Observatory, Texas\n'
'! design Ritchey-Chretien\n'
'! aperture 1.0\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' | | N999r0q| CCD|V39 |2015-07-13T21:09:51.00Z| 15.500000 | -3.750000 | Gaia2|21.6 | G| Gaia2| |\n')

message = generate_ades_psv_message(self.test_block_gaiadr2.id, self.test_block_gaiadr2.body.id)

i = 0
expected_lines = exp_msg.split('\n')
message_lines = message.split('\n')
while i < len(expected_lines):
self.assertEqual(expected_lines[i], message_lines[i])
i += 1

self.assertEqual(exp_msg, message)

def test_Z24_gaiadr2(self):

self.test_frame_gaiadr2.sitecode = 'Z24'
self.test_frame_gaiadr2.instrument = 'fa20'
self.test_frame_gaiadr2.save()

exp_msg = ( '# version=2017\n'
'# observatory\n'
'! mpcCode Z24\n'
'# submitter\n'
'! name T. Lister\n'
'! institution LCO, 6740 Cortona Drive Suite 102, Goleta, CA 93117\n'
'# observers\n'
'! name T. Lister\n'
'! name E. Gomez\n'
'! name J. Chatelain\n'
'! name S. Greenstreet\n'
'# measurers\n'
'! name T. Lister\n'
'# telescope\n'
'! name LCO TFN Node 1m0 Dome B at Tenerife, Spain\n'
'! design Ritchey-Chretien\n'
'! aperture 1.0\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' | | N999r0q| CCD|Z24 |2015-07-13T21:09:51.00Z| 15.500000 | -3.750000 | Gaia2|21.6 | G| Gaia2| |\n')

message = generate_ades_psv_message(self.test_block_gaiadr2.id, self.test_block_gaiadr2.body.id)

i = 0
expected_lines = exp_msg.split('\n')
message_lines = message.split('\n')
while i < len(expected_lines):
self.assertEqual(expected_lines[i], message_lines[i])
i += 1

self.assertEqual(exp_msg, message)

def test_Z31_gaiadr2(self):

self.test_frame_gaiadr2.sitecode = 'Z31'
self.test_frame_gaiadr2.instrument = 'fa11'
self.test_frame_gaiadr2.save()

exp_msg = ( '# version=2017\n'
'# observatory\n'
'! mpcCode Z31\n'
'# submitter\n'
'! name T. Lister\n'
'! institution LCO, 6740 Cortona Drive Suite 102, Goleta, CA 93117\n'
'# observers\n'
'! name T. Lister\n'
'! name E. Gomez\n'
'! name J. Chatelain\n'
'! name S. Greenstreet\n'
'# measurers\n'
'! name T. Lister\n'
'# telescope\n'
'! name LCO TFN Node 1m0 Dome A at Tenerife, Spain\n'
'! design Ritchey-Chretien\n'
'! aperture 1.0\n'
'! detector CCD\n'
'! fRatio 8.0\n'
'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks\n'
' | | N999r0q| CCD|Z31 |2015-07-13T21:09:51.00Z| 15.500000 | -3.750000 | Gaia2|21.6 | G| Gaia2| |\n')

message = generate_ades_psv_message(self.test_block_gaiadr2.id, self.test_block_gaiadr2.body.id)

i = 0
expected_lines = exp_msg.split('\n')
message_lines = message.split('\n')
while i < len(expected_lines):
self.assertEqual(expected_lines[i], message_lines[i])
i += 1

self.assertEqual(exp_msg, message)
Loading

0 comments on commit b94c7b6

Please sign in to comment.