def model_ecliptic_to_equatorial(model, force=False): r"""Converts Astrometry model component, Ecliptic to Equatorial Parameters ---------- model: `pint.models.TimingModel` object current model with AstrometryEcliptic component force: boolean, optional will force conversion even if an equatorial component is already present Returns ------- model new model with AstrometryEquatorial component """ if not ("AstrometryEquatorial" in model.components) or force: if "AstrometryEquatorial" in model.components: log.warning( "Equatorial coordinates already present but re-calculating anyway" ) if "AstrometryEcliptic" in model.components: c = model.coords_as_ICRS() a = AstrometryEquatorial() a.POSEPOCH = model.POSEPOCH a.PX = model.PX a.RAJ.quantity = c.ra a.DECJ.quantity = c.dec a.PMRA.quantity = c.pm_ra_cosdec a.PMDEC.quantity = c.pm_dec model.add_component(a) model.remove_component("AstrometryEcliptic") model.setup() model.validate() else: raise AttributeError( "Requested conversion to equatorial coordinates, but no alternate coordinates found" ) else: log.warning( "Equatorial coordinates already present; not re-calculating") return model
def test_simple_manual(): tm = TimingModel( name="test_manual", components=[AstrometryEquatorial(), Spindown()] ) tm.setup() assert "F0" in tm.phase_deriv_funcs.keys() assert "F1" in tm.phase_deriv_funcs.keys() assert "RAJ" in tm.delay_deriv_funcs.keys() assert "DECJ" in tm.delay_deriv_funcs.keys() with pytest.raises(MissingParameter): # No RA and DEC input tm.validate() tm.RAJ.value = "19:59:48" tm.DECJ.value = "20:48:36" tm.F0.value = 622.122030511927 * u.Hz tm.validate() # This should work.
def test_simple_manual(): tm = TimingModel( name="test_manual", components=[AstrometryEquatorial(), Spindown()] ) tm.setup() assert "F0" in tm.phase_deriv_funcs.keys() assert "RAJ" in tm.delay_deriv_funcs.keys() assert "DECJ" in tm.delay_deriv_funcs.keys() with pytest.raises(MissingParameter): # No RA and DEC input tm.validate() tm.RAJ.value = "19:59:48" tm.DECJ.value = "20:48:36" tm.F0.quantity = 622.122030511927 * u.Hz tm.PEPOCH.value = 48196.0 tm.validate() # This should work. # When there is no POSEPOCH set, it should just be unset assert tm.POSEPOCH.value is None
from pint.models.binary_dd import BinaryDD from pint.models.binary_ddk import BinaryDDK from pint.models.binary_ell1 import BinaryELL1, BinaryELL1H from pint.models.dispersion_model import DispersionDM, DispersionDMX from pint.models.frequency_dependent import FD from pint.models.glitch import Glitch from pint.models.jump import DelayJump, PhaseJump from pint.models.model_builder import get_model from pint.models.noise_model import EcorrNoise, PLRedNoise, ScaleToaError from pint.models.solar_system_shapiro import SolarSystemShapiro from pint.models.solar_wind_dispersion import SolarWindDispersion from pint.models.spindown import Spindown # Import the main timing model classes from pint.models.timing_model import TimingModel, DEFAULT_ORDER from pint.models.wave import Wave from pint.models.ifunc import IFunc # Define a standard basic model StandardTimingModel = TimingModel( "StandardTimingModel", [AstrometryEquatorial(), Spindown(), DispersionDM(), SolarSystemShapiro()], ) # BTTimingModel = generate_timing_model("BTTimingModel", # (Astrometry, Spindown, Dispersion, SolarSystemShapiro, BT)) # DDTimingModel = generate_timing_model("DDTimingModel", # (Astrometry, Spindown, Dispersion, SolarSystemShapiro, DD))
def model(): """Make a simple model.""" return TimingModel( components=[AstrometryEquatorial(), DispersionDM(), DispersionDMX()] )
def test_forgot_name(): """Check argument validation in case 'name' is forgotten.""" with pytest.raises(ValueError): TimingModel(AstrometryEquatorial()) with pytest.raises(ValueError): TimingModel([AstrometryEquatorial(), DispersionDM()])
# Import all standard model components here from pint.models.astrometry import AstrometryEcliptic, AstrometryEquatorial from pint.models.binary_bt import BinaryBT from pint.models.binary_dd import BinaryDD from pint.models.binary_ddk import BinaryDDK from pint.models.binary_ell1 import BinaryELL1, BinaryELL1H from pint.models.dispersion_model import DispersionDM, DispersionDMX from pint.models.frequency_dependent import FD from pint.models.glitch import Glitch from pint.models.jump import DelayJump, PhaseJump from pint.models.model_builder import get_model from pint.models.noise_model import EcorrNoise, PLRedNoise, ScaleToaError from pint.models.solar_system_shapiro import SolarSystemShapiro from pint.models.solar_wind_dispersion import SolarWindDispersion from pint.models.spindown import Spindown # Import the main timing model classes from pint.models.timing_model import TimingModel from pint.models.wave import Wave from pint.models.ifunc import IFunc # Define a standard basic model StandardTimingModel = TimingModel( "StandardTimingModel", (AstrometryEquatorial(), Spindown(), DispersionDM(), SolarSystemShapiro()), ) # BTTimingModel = generate_timing_model("BTTimingModel", # (Astrometry, Spindown, Dispersion, SolarSystemShapiro, BT)) # DDTimingModel = generate_timing_model("DDTimingModel", # (Astrometry, Spindown, Dispersion, SolarSystemShapiro, DD))