Beispiel #1
0
def test_change_engdb_url():
    """Test changing the engineering database by call for success.

    The given time and database should not find any values.
    """
    with pytest.raises(ValueError):
        stp.get_pointing(STARTTIME.mjd,
                         ENDTIME.mjd,
                         engdb_url=engdb_tools.ENGDB_BASE_URL)
Beispiel #2
0
def test_get_pointing_with_zeros(eng_db_ngas):
    (q, j2fgs_matrix, fsmcorr,
     obstime) = stp.get_pointing(ZEROTIME_START.mjd,
                                 ENDTIME.mjd,
                                 reduce_func=stp.first_pointing)
    assert j2fgs_matrix.any()
    (q_desired, j2fgs_matrix_desired, fsmcorr_desired,
     obstime) = stp.get_pointing(STARTTIME.mjd, ENDTIME.mjd)
    assert np.array_equal(q, q_desired)
    assert np.array_equal(j2fgs_matrix, j2fgs_matrix_desired)
    assert np.array_equal(fsmcorr, fsmcorr_desired)
Beispiel #3
0
def test_get_pointing_with_zeros(eng_db_ngas):
    (q, j2fgs_matrix, fsmcorr, obstime, gs_commanded, fgsid,
     gs_position) = stp.get_pointing(ZEROTIME_START.mjd,
                                     ENDTIME.mjd,
                                     reduce_func=stp.first_pointing,
                                     engdb_url='http://localhost')
    assert j2fgs_matrix.any()
    (q_desired, j2fgs_matrix_desired, fsmcorr_desired, obstime, gs_commanded,
     fgsid, gs_position) = stp.get_pointing(STARTTIME.mjd,
                                            ENDTIME.mjd,
                                            engdb_url='http://localhost')
    assert np.array_equal(q, q_desired)
    assert np.array_equal(j2fgs_matrix, j2fgs_matrix_desired)
    assert np.array_equal(fsmcorr, fsmcorr_desired)
Beispiel #4
0
def test_logging(eng_db_ngas, caplog):
    (q, j2fgs_matrix, fsmcorr,
     obstime) = stp.get_pointing(STARTTIME.mjd, ENDTIME.mjd)
    assert 'Determining pointing between observations times' in caplog.text
    assert 'Telemetry search tolerance' in caplog.text
    assert 'Reduction function' in caplog.text
    assert 'Querying engineering DB' in caplog.text
Beispiel #5
0
def test_get_pointing(eng_db_ngas):
    (q, j2fgs_matrix, fsmcorr,
     obstime) = stp.get_pointing(STARTTIME.mjd, ENDTIME.mjd)
    assert np.isclose(q, Q_EXPECTED).all()
    assert np.isclose(j2fgs_matrix, J2FGS_MATRIX_EXPECTED).all()
    assert np.isclose(fsmcorr, FSMCORR_EXPECTED).all()
    assert STARTTIME <= obstime <= ENDTIME
Beispiel #6
0
def test_pointing_averaging(eng_db_jw703):
    """Ensure that the averaging works."""
    q_exp = np.array([0.62383733, 0.53552715, -0.49252283, 0.28541008])
    j2fgs_exp = np.array([
        -1.00962794e-03, 9.99999464e-01, 3.41404261e-06, 3.38429719e-03,
        2.85793453e-09, 9.99994300e-01, 9.99993742e-01, 1.00963370e-03,
        -3.38429548e-03
    ])
    j2fgs_exp = np.array([
        -1.00962794e-03, 3.38429719e-03, 9.99993742e-01, 9.99999464e-01,
        2.85793453e-09, 1.00963370e-03, 3.41404261e-06, 9.99994300e-01,
        -3.38429548e-03
    ])
    fsmcorr_exp = np.array([-0.02558673, -0.00200601])
    obstime_exp = Time(1559582740.4880004, format='unix')

    (q, j2fgs_matrix, fsmcorr, obstime) = stp.get_pointing(
        Time('2019-06-03T17:25:40', format='isot').mjd,
        Time('2019-06-03T17:25:56', format='isot').mjd,
    )

    assert np.allclose(q, q_exp)
    assert np.allclose(j2fgs_matrix, j2fgs_exp)
    assert np.allclose(fsmcorr, fsmcorr_exp)
    assert np.isclose(obstime.value, obstime_exp.value)
Beispiel #7
0
def test_logging(eng_db_ngas, caplog):
    (q, j2fgs_matrix, fsmcorr, obstime, gs_commanded, fgsid,
     gs_position) = stp.get_pointing(STARTTIME.mjd,
                                     ENDTIME.mjd,
                                     engdb_url='http://localhost')
    assert 'Determining pointing between observations times' in caplog.text
    assert 'Telemetry search tolerance' in caplog.text
    assert 'Reduction function' in caplog.text
    assert 'Querying engineering DB' in caplog.text
Beispiel #8
0
def test_get_pointing(eng_db_ngas):
    (q, j2fgs_matrix, fsmcorr, obstime, gs_commanded, fgsid,
     gs_position) = stp.get_pointing(STARTTIME.mjd,
                                     ENDTIME.mjd,
                                     engdb_url='http://localhost')
    assert np.isclose(q, Q_EXPECTED).all()
    assert np.isclose(j2fgs_matrix, J2FGS_MATRIX_EXPECTED).all()
    assert np.isclose(fsmcorr, FSMCORR_EXPECTED).all()
    assert STARTTIME <= obstime <= ENDTIME
Beispiel #9
0
def test_get_pointing_list(eng_db_ngas):
    results = stp.get_pointing(STARTTIME.mjd,
                               ENDTIME.mjd,
                               reduce_func=stp.all_pointings)
    assert isinstance(results, list)
    assert len(results) > 0
    assert np.isclose(results[0].q, Q_EXPECTED).all()
    assert np.isclose(results[0].j2fgs_matrix, J2FGS_MATRIX_EXPECTED).all()
    assert np.isclose(results[0].fsmcorr, FSMCORR_EXPECTED).all()
    assert STARTTIME <= results[0].obstime <= ENDTIME
Beispiel #10
0
def test_get_pointing_fail():
    with pytest.raises(Exception):
        q, j2fgs_matrix, fmscorr, obstime = stp.get_pointing(47892.0, 48256.0)
Beispiel #11
0
def test_change_engdb_url_fail():
    """Test changing the engineering database by call"""
    with pytest.raises(Exception):
        stp.get_pointing(Time('2019-06-03T17:25:40', format='isot').mjd,
                         Time('2019-06-03T17:25:56', format='isot').mjd,
                         engdb_url='http://nonexistant.fake')