From 09e0ce8b152e7a6043ba5cb78c65582058fdff63 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Wed, 4 Mar 2020 11:20:35 -0500 Subject: [PATCH 1/2] Make test_get_aimpoint work without being on VPN --- chandra_aca/tests/test_all.py | 50 ++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/chandra_aca/tests/test_all.py b/chandra_aca/tests/test_all.py index 8e23784..a9e0e48 100644 --- a/chandra_aca/tests/test_all.py +++ b/chandra_aca/tests/test_all.py @@ -4,6 +4,7 @@ import os import pytest +import requests import numpy as np from astropy.io import ascii from astropy.table import Table @@ -25,6 +26,45 @@ [-3.3742E-4, 1.0, 0.0], [-2.7344E-4, 0.0, 1.0]]).transpose() +# Use this for testing in case the icxc version is not available. +ZERO_OFFSET_TABLE = """ +# Table of zero-offset aimpoints +# Last updated: 15 November 2018 +date_effective cycle_effective detector chipx chipy chip_id obsvis_cal +2012-12-15 15 ACIS-I 941.0 988.0 3 1.6 +2012-12-15 15 ACIS-S 224.0 490.0 7 1.6 +2012-12-15 15 HRC-I 7615.0 7862.0 0 1.6 +2012-12-15 15 HRC-S 2075.0 8984.0 2 1.6 +2013-12-15 16 ACIS-I 932.0 1009.0 3 1.7 +2013-12-15 16 ACIS-S 205.0 480.0 7 1.7 +2013-12-15 16 HRC-I 7606.0 7941.0 0 1.7 +2013-12-15 16 HRC-S 2050.0 9023.0 2 1.7 +2014-12-15 17 ACIS-I 930.2 1009.6 3 1.8a +2014-12-15 17 ACIS-S 200.7 476.9 7 1.8a +2014-12-15 17 HRC-I 7591.0 7936.1 0 1.8a +2014-12-15 17 HRC-S 2041.0 9062.7 2 1.8a +2015-12-15 18 ACIS-I 970.0 975.0 3 1.9 +2015-12-15 18 ACIS-S 210.0 520.0 7 1.9 +2015-12-15 18 HRC-I 7590.0 7745.0 0 1.9 +2015-12-15 18 HRC-S 2195.0 8915.0 2 1.9 +2016-12-15 19 ACIS-I 970.0 975.0 3 1.10 +2016-12-15 19 ACIS-S 210.0 520.0 7 1.10 +2016-12-15 19 HRC-I 7590.0 7745.0 0 1.10 +2016-12-15 19 HRC-S 2195.0 8915.0 2 1.10 +2017-12-15 20 ACIS-I 970.0 975.0 3 1.11 +2017-12-15 20 ACIS-S 210.0 520.0 7 1.11 +2017-12-15 20 HRC-I 7590.0 7745.0 0 1.11 +2017-12-15 20 HRC-S 2195.0 8915.0 2 1.11 +2018-11-07 17 ACIS-S 182.3 468.1 7 1.8a +2018-11-07 18 ACIS-S 191.6 511.2 7 1.9 +2018-11-07 19 ACIS-S 191.6 511.2 7 1.10 +2018-11-07 20 ACIS-S 191.6 511.2 7 1.11 +2018-11-16 17 ACIS-S 200.7 476.9 7 1.8a +2018-11-16 18 ACIS-S 210.0 520.0 7 1.9 +2018-11-16 19 ACIS-S 210.0 520.0 7 1.10 +2018-11-16 20 ACIS-S 210.0 520.0 7 1.11 +""" + def test_edge_checking(): """Test row/col edge checking""" @@ -190,8 +230,16 @@ def test_get_aimpoint(): answers = [(224.0, 490.0, 7), (7606.0, 7941.0, 0), (970.0, 975.0, 3)] + try: + r = requests.head("https://icxc.harvard.edu/mp/html/aimpoint_table/zero_offset_aimpoints.txt", + timeout=5) + assert r.status_code == 200 + zot = None + except Exception: + zot = Table.read(ZERO_OFFSET_TABLE, format='ascii') + for obstest, answer in zip(obstests, answers): - chipx, chipy, chip_id = drift.get_target_aimpoint(*obstest) + chipx, chipy, chip_id = drift.get_target_aimpoint(*obstest, zero_offset_table=zot) assert chipx == answer[0] assert chipy == answer[1] assert chip_id == answer[2] From c8139e19e08b791ffd3a7926b9b37fe7dbf4df2a Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Wed, 4 Mar 2020 11:24:46 -0500 Subject: [PATCH 2/2] Fix flake8 --- chandra_aca/tests/test_all.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chandra_aca/tests/test_all.py b/chandra_aca/tests/test_all.py index a9e0e48..6b71342 100644 --- a/chandra_aca/tests/test_all.py +++ b/chandra_aca/tests/test_all.py @@ -231,8 +231,9 @@ def test_get_aimpoint(): (7606.0, 7941.0, 0), (970.0, 975.0, 3)] try: - r = requests.head("https://icxc.harvard.edu/mp/html/aimpoint_table/zero_offset_aimpoints.txt", - timeout=5) + r = requests.head( + "https://icxc.harvard.edu/mp/html/aimpoint_table/zero_offset_aimpoints.txt", + timeout=5) assert r.status_code == 200 zot = None except Exception: