コード例 #1
0
 def test_parallax_factors_independent_of_reference_epoch(self):
     astron = Astrometry('Hip1', '27321', 'htof/test/data_for_tests/Hip1', central_epoch_ra=2000,
                        central_epoch_dec=2000, format='jyear', fit_degree=1, use_parallax=True,
                        central_ra=self.cntr_ra, central_dec=self.cntr_dec)
     ra_motionn = astron.fitter.parallactic_pertubations['ra_plx']
     dec_motionn = astron.fitter.parallactic_pertubations['dec_plx']
     assert np.allclose(to_along_scan_basis(self.ra_motion, self.dec_motion, self.scan_angle),
                        to_along_scan_basis(ra_motionn, dec_motionn, self.scan_angle))
コード例 #2
0
ファイル: test_main.py プロジェクト: gmbrandt/HTOF
def test_Hip2_fit_to_hip27321():
    # Hip 27321 parameters from the Hipparcos 21 IAD
    cntr_ra, cntr_dec = Angle(86.82118073, 'degree'), Angle(-51.06671341, 'degree')
    plx = 51.44  # mas
    pmRA = 4.65  # mas/year
    pmDec = 83.10  # mas/year
    # generate fitter and parse intermediate data
    for datadir in ['Hip2', 'Hip21']:
        # trying fits with a fresh computation of the parallax factors and without
        astro = Astrometry('hip2or21', '27321', f'htof/test/data_for_tests/{datadir}', central_epoch_ra=1991.25,
                           central_epoch_dec=1991.25, format='jyear', fit_degree=1, use_parallax=True,
                           central_ra=cntr_ra, central_dec=cntr_dec,
                           use_catalog_parallax_factors=True)
        chisq = np.sum(astro.data.residuals ** 2 / astro.data.along_scan_errs ** 2)
        # generate ra and dec for each observation.
        year_epochs = Time(astro.data.julian_day_epoch(), format='jd', scale='tcb').jyear - \
                      Time(1991.25, format='decimalyear').jyear
        ra_motion = astro.fitter.parallactic_pertubations['ra_plx']
        dec_motion = astro.fitter.parallactic_pertubations['dec_plx']
        ra = Angle(ra_motion * plx + pmRA * year_epochs, unit='mas')
        dec = Angle(dec_motion * plx + pmDec * year_epochs, unit='mas')
        # add residuals
        ra += Angle(astro.data.residuals.values * np.sin(astro.data.scan_angle.values), unit='mas')
        dec += Angle(astro.data.residuals.values * np.cos(astro.data.scan_angle.values), unit='mas')
        #
        coeffs, errors, chisq_found, residuals = astro.fit(ra.mas, dec.mas, return_all=True)
        residuals = to_along_scan_basis(residuals[:, 0], residuals[:, 1], astro.data.scan_angle.values)
        assert np.isclose(chisq, chisq_found, atol=1E-3)
        assert np.allclose([pmRA, pmDec], np.array([coeffs[3], coeffs[4]]).round(2))
        assert np.isclose(plx, coeffs[0].round(2), atol=0.01)
        assert np.allclose(errors.round(2), np.array([0.12, 0.10, 0.11, 0.11, 0.15]), atol=0.01)
        assert np.allclose(residuals, astro.data.residuals.values, atol=0.02)
コード例 #3
0
ファイル: test_main.py プロジェクト: gmbrandt/HTOF
def test_Gaia_fit_to_hip27321():
    # Hip 27321 central ra and dec from the gost data file.
    cntr_ra, cntr_dec = Angle(1.5153157780177544, 'radian'), Angle(-0.8912787619608181, 'radian')
    #
    plx = 51.87  # mas
    pmRA = 4.65  # mas/year
    pmDec = 81.96  # mas/year
    # generate fitter and parse intermediate data
    for use_catalog_parallax_factors in [False, True]:
        print('not '* (not use_catalog_parallax_factors) + 'using catalog parallax factors.')
        # trying fits with a fresh computation of the parallax factors and without
        astro = Astrometry('GaiaEDR3', '27321', 'htof/test/data_for_tests/GaiaeDR3',
                           central_epoch_ra=2016, central_epoch_dec=2016,
                           format='jyear', fit_degree=1, use_parallax=True,
                           central_ra=cntr_ra, central_dec=cntr_dec,
                           use_catalog_parallax_factors=use_catalog_parallax_factors)
        chisq = np.sum(astro.data.residuals ** 2 / astro.data.along_scan_errs ** 2)
        # generate ra and dec for each observation.
        year_epochs = Time(astro.data.julian_day_epoch(), format='jd', scale='tcb').jyear - \
                      Time(2016, format='decimalyear').jyear
        ra_motion = astro.fitter.parallactic_pertubations['ra_plx']
        dec_motion = astro.fitter.parallactic_pertubations['dec_plx']
        ra = Angle(ra_motion * plx + pmRA * year_epochs, unit='mas')
        dec = Angle(dec_motion * plx + pmDec * year_epochs, unit='mas')
        #
        coeffs, errors, chisq_found, residuals = astro.fit(ra.mas, dec.mas, return_all=True)
        residuals = to_along_scan_basis(residuals[:, 0], residuals[:, 1], astro.data.scan_angle.values)
        assert np.isclose(chisq, chisq_found, atol=1E-3)
        assert np.allclose([pmRA, pmDec], np.array([coeffs[3], coeffs[4]]).round(2))
        assert np.isclose(plx, coeffs[0].round(2), atol=0.01)
コード例 #4
0
 def test_parallax_factors_backward_transform(self):
     # note that this is redundant with test_basis_change_consistency()
     ra_motion, dec_motion = to_ra_dec_basis(self.along_scan_parallax_factors, self.scan_angle)
     # convert the calculated parallax factors to the along-scan basis and back to null out the AC component.
     al_parallax_factor = to_along_scan_basis(self.ra_motion, self.dec_motion, self.scan_angle)
     ra_motion_acnull, dec_motion_acnull = to_ra_dec_basis(al_parallax_factor, self.scan_angle)
     assert np.allclose(ra_motion, ra_motion_acnull, atol=0.03)
     assert np.allclose(dec_motion, dec_motion_acnull, atol=0.03)
コード例 #5
0
def test_basis_change_consistency():
    """
    Tests that to_ra_dec_basis() and to_along_scan_basis() are inverse transforms in the case where
    the data being transformed has a zero across-scan component.

    Note that these two functions are NOT inverse transforms if the data has a non-zero across scan component.
    """
    al_value = np.array([-5, 0, 1, 5, 10] * 100)  # [-5, 0, 1, 5, 10, -5, 0, 1, 5, 10, -5, 0,...]
    scan_angle = np.array([[i]*5 for i in np.linspace(-2*np.pi, 2*np.pi, 100)]).flatten()
    ra_val, dec_val = to_ra_dec_basis(al_value, scan_angle)
    al_value_check = to_along_scan_basis(ra_val, dec_val, scan_angle)
    assert np.allclose(al_value_check, al_value)
コード例 #6
0
 def test_new_computed_parallax_factors_agree_with_catalog(self):
     assert np.allclose(self.along_scan_parallax_factors,
                        to_along_scan_basis(self.ra_motion, self.dec_motion, self.scan_angle), atol=0.03)
コード例 #7
0
 def test_new_computed_parallax_factors_agree_with_scanninglaw(self):
     # test that the newly computed parallax factors agree with
     # parallaxFactorAlongScan from the GOST data.
     assert np.allclose(self.along_scan_parallax_factors,
                        to_along_scan_basis(self.ra_motion, self.dec_motion, self.scan_angle), atol=0.03)