diff --git a/neoexchange/core/models/frame.py b/neoexchange/core/models/frame.py index e251782c9..0db501f1f 100644 --- a/neoexchange/core/models/frame.py +++ b/neoexchange/core/models/frame.py @@ -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, diff --git a/neoexchange/core/models/sources.py b/neoexchange/core/models/sources.py index 197ef2b4d..0ac0df3c9 100644 --- a/neoexchange/core/models/sources.py +++ b/neoexchange/core/models/sources.py @@ -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 @@ -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 diff --git a/neoexchange/core/tests/test_models.py b/neoexchange/core/tests/test_models.py index 268904e56..b8af13219 100644 --- a/neoexchange/core/tests/test_models.py +++ b/neoexchange/core/tests/test_models.py @@ -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, @@ -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, diff --git a/neoexchange/core/tests/test_mpc_submit.py b/neoexchange/core/tests/test_mpc_submit.py index 7b5b76776..46c9d626d 100644 --- a/neoexchange/core/tests/test_mpc_submit.py +++ b/neoexchange/core/tests/test_mpc_submit.py @@ -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, @@ -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' @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/neoexchange/core/tests/test_views.py b/neoexchange/core/tests/test_views.py index 2fc3c61e2..2ff8f4ad2 100644 --- a/neoexchange/core/tests/test_views.py +++ b/neoexchange/core/tests/test_views.py @@ -7316,6 +7316,169 @@ def test_FTS_no_match(self): self.assertEqual(expected_list, close_std_list) +class TestDownloadMeasurementsFile(TestCase): + + def setUp(self): + self.ades_template = get_template('core/mpc_ades_psv_outputfile.txt') + self.mpc_template = get_template('core/mpc_outputfile.txt') + + body_params = { + 'provisional_name': 'C1HDFQ2', + 'provisional_packed': None, + 'name': '2019 XS', + 'origin': 'G', + 'source_type': 'N', + 'source_subtype_1': '', + 'source_subtype_2': None, + 'elements_type': 'MPC_MINOR_PLANET', + 'active': True, + 'fast_moving': True, + 'urgency': None, + 'epochofel': datetime(2021, 11, 10, 0, 0), + 'orbit_rms': 0.33, + 'orbinc': 4.4386, + 'longascnode': 49.49322, + 'argofperih': 250.25583, + 'eccentricity': 0.3277499, + 'meandist': 1.0048339, + 'meananom': 69.71659, + 'perihdist': 0.0815255040820201, + 'epochofperih': datetime(2019, 9, 30, 19, 58, 17), + 'abs_mag': 23.86, + 'slope': 0.15, + 'score': 96, + 'discovery_date': datetime(2012, 12, 22, 0, 0), + 'num_obs': 72, + 'arc_length': 6210.0, + 'not_seen': 334.05341602897, + 'updated': True, + 'ingest': datetime(2019, 12, 2, 7, 20, 38), + 'update_time': datetime(2021, 11, 9, 1, 16, 55, 144878) + } + self.test_body, created = Body.objects.get_or_create(**body_params) + + test_proposal, created = Proposal.objects.get_or_create(code='LCOTesting', title='LCOTesting') + + sblock_params = { + 'cadence': False, + 'body': self.test_body, + 'calibsource': None, + 'proposal': test_proposal, + 'block_start': datetime(2021, 11, 10, 3, 40), + 'block_end': datetime(2021, 11, 10, 9, 22), + 'groupid': '2019 XS_V37-20211110', + 'tracking_number': '1335839', + 'timeused': 883.0, + 'active': False + } + + self.test_sblock, created = SuperBlock.objects.get_or_create(**sblock_params) + + block_params = { + 'telclass': '1m0', + 'site': 'elp', + 'body': self.test_body, + 'calibsource': None, + 'superblock': self.test_sblock, + 'obstype': 0, + 'block_start': datetime(2021, 11, 10, 3, 40), + 'block_end': datetime(2021, 11, 10, 9, 22), + 'request_number': '2704510', + 'num_exposures': 26, + 'exp_length': 2.0, + 'num_observed': 1, + 'when_observed': datetime(2021, 11, 10, 4, 47, 22), + 'active': False, + 'reported': True, + 'when_reported': datetime(2021, 11, 12, 1, 30, 32, 830720) + } + self.test_block, created = Block.objects.get_or_create(**block_params) + + frame_params = { + 'sitecode': 'V37', + 'instrument': 'fa05', + 'filter': 'w', + 'filename': 'elp1m008-fa05-20211109-0177-e91.fits', + 'exptime': 2.028, + 'midpoint': datetime(2021, 11, 10, 4, 47, 23, 867000), + 'block': self.test_block, + 'quality': ' ', + 'zeropoint': 25.197377268962, + 'zeropoint_err': 0.0819936287107206, + 'fwhm': 1.7449277159035, + 'frametype': 91, + 'extrainfo': None, + 'rms_of_fit': 0.283035, + 'nstars_in_fit': 45.0, + 'time_uncertainty': None, + 'frameid': 46146456, + 'astrometric_catalog': 'GAIA-DR2', + 'photometric_catalog': 'GAIA-DR2' + } + self.test_frame, created = Frame.objects.get_or_create(**frame_params) + + sm_params = { + 'body': self.test_body, + 'frame': self.test_frame, + 'obs_ra': 41.7905144822113, + 'obs_dec': -4.34047400302277, + 'obs_mag': 14.3134813308716, + 'err_obs_ra': 2.39723807836075e-06, + 'err_obs_dec': 2.48654937873956e-06, + 'err_obs_mag': 0.0827159211039543, + 'astrometric_catalog': 'GAIA-DR2', + 'photometric_catalog': 'GAIA-DR2', + 'aperture_size': 3.0, + 'snr': 12.0895709877091, + 'flags': ' '} + self.test_sm, created = SourceMeasurement.objects.get_or_create(**sm_params) + + self.psv_header = 'permID |provID |trkSub |mode|stn |obsTime |ra |dec |rmsRA|rmsDec|astCat |mag |rmsMag|band|photCat |photAp|logSNR|seeing|notes|remarks' + + self.maxDiff = None + + def test_V37_ades(self): + expected_response = '\n'.join([self.psv_header, + ' |2019 XS | | CCD|V37 |2021-11-10T04:47:23.87Z| 41.790514 | -4.340474 | 0.28| 0.28| Gaia2|14.3 |0.083 | G| Gaia2| 3.00|1.0824|1.7449| |', '','']) + + request = '' + response = download_measurements_file(self.ades_template, self.test_body, '.psv', request) + + self.assertEqual(expected_response, response.content.decode()) + + def test_V37_mpc(self): + expected_response = ' K19X00S C2021 11 10.19958202 47 09.72 -04 20 25.7 14.3 G V37' + '\n\n' + + request = '' + response = download_measurements_file(self.mpc_template, self.test_body, '.psv', request) + + self.assertEqual(expected_response, response.content.decode()) + + def test_V39_ades(self): + expected_response = '\n'.join([self.psv_header,' |2019 XS | | CCD|V39 |2021-11-10T04:47:23.87Z| 41.790514 | -4.340474 | 0.28| 0.28| Gaia2|14.3 |0.083 | G| Gaia2| 3.00|1.0824|1.7449| |', '','']) + + self.test_frame.sitecode = 'V39' + self.test_frame.instrument = 'fa07' + self.test_frame.save() + + request = '' + response = download_measurements_file(self.ades_template, self.test_body, '.psv', request) + + self.assertEqual(expected_response, response.content.decode()) + + def test_V39_mpc(self): + expected_response = ' K19X00S C2021 11 10.19958202 47 09.72 -04 20 25.7 14.3 G V39' + '\n\n' + + self.test_frame.sitecode = 'V39' + self.test_frame.instrument = 'fa07' + self.test_frame.save() + + request = '' + response = download_measurements_file(self.mpc_template, self.test_body, '.psv', request) + + self.assertEqual(expected_response, response.content.decode()) + + class TestExportMeasurements(TestCase): def setUp(self): diff --git a/neoexchange/neox/tests/test_measurements.py b/neoexchange/neox/tests/test_measurements.py index df9a0f5f7..24f14a356 100644 --- a/neoexchange/neox/tests/test_measurements.py +++ b/neoexchange/neox/tests/test_measurements.py @@ -435,7 +435,7 @@ def test_display_ADES_measurements(self): # He sees that there is a table in which are the original # discovery observations from PanSTARRS (obs. code F51) and from # the LCOGT follow-up network. - testlines = [ 'permID |provID |trkSub |mode|stn |obsTime |ra |dec | astCat|mag |band| photCat|notes|remarks', + testlines = [ 'permID |provID |trkSub |mode|stn |obsTime |ra |dec |astCat |mag |band|photCat |notes|remarks', ' | | N999r0q| CCD|F51 |2015-03-21T06:00:00.00Z| 62.200000 |-11.050000 | |21.5 | r| | |', ' | | N999r0q| CCD|K91 |2015-04-20T18:00:00.00Z| 42.100000 |-30.050000 | |21.1 | R| | |', ] @@ -483,7 +483,7 @@ def test_display_ADES_measurements_withRMS(self): # He sees that there is a table in which are the original # discovery observations from PanSTARRS (obs. code F51) and from # the LCOGT follow-up network. - testlines = [ 'permID |provID |trkSub |mode|stn |obsTime | ra| dec|rmsRA|rmsDec| astCat|mag |rmsMag|band| photCat|photAp|logSNR|seeing|notes|remarks', + testlines = [ 'permID |provID |trkSub |mode|stn |obsTime |ra |dec |rmsRA|rmsDec|astCat |mag |rmsMag|band|photCat |photAp|logSNR|seeing|notes|remarks', ' | | N999r0q| CCD|F51 |2015-03-21T06:00:00.00Z| 62.200000 |-11.050000 |0.090| 0.090| 2MASS|21.5 |0.010 | r| 2MASS| | | | |', ' | | N999r0q| CCD|K91 |2015-04-20T18:00:00.00Z| 42.100000 |-30.050000 | 0.30| 0.28| UCAC4|21.1 |0.030 | R| UCAC4| | | | |', ' | | N999r0q| CCD|K91 |2015-04-21T18:00:00.00Z| 42.200000 |-31.050000 | 0.30| 0.28| PPMXL|20.9 |0.028 | R| PPMXL| 1.56|1.3945|1.6000| |', diff --git a/neoexchange/photometrics/tests/test_spectraplot.py b/neoexchange/photometrics/tests/test_spectraplot.py index 7a1369bda..f91e07afd 100644 --- a/neoexchange/photometrics/tests/test_spectraplot.py +++ b/neoexchange/photometrics/tests/test_spectraplot.py @@ -209,6 +209,7 @@ def setUp(self): files_to_copy = [self.fitsfile, self.analogfile] self.tolerance = 1 + self.precision = 7 self.test_dir = tempfile.mkdtemp(prefix='tmp_neox_') for test_file in files_to_copy: @@ -248,8 +249,8 @@ def test_spectrum_plot(self): self.assertEqual(expected_label, label) self.assertGreater(wav_range[1], max(wavelength)) self.assertLess(wav_range[0], min(wavelength)) - self.assertEqual(np.mean(flux), expected_flux_mean) - self.assertEqual(np.mean(error).value, expected_error_mean) + self.assertAlmostEqual(np.mean(flux), expected_flux_mean, self.precision) + self.assertAlmostEqual(np.mean(error).value, expected_error_mean, self.precision) def test_reflectance_plot(self): expected_label = '455432 -- HD 196164 -- 20190727' @@ -263,7 +264,7 @@ def test_reflectance_plot(self): self.assertEqual(expected_label, label) self.assertGreater(wav_range[1], max(wavelength)) self.assertLess(wav_range[0], min(wavelength)) - self.assertEqual(np.mean(flux), expected_flux_mean) - self.assertEqual(np.mean(error), expected_error_mean) + self.assertAlmostEqual(np.mean(flux), expected_flux_mean, self.precision) + self.assertAlmostEqual(np.mean(error), expected_error_mean, self.precision)