How to use the pint.models.timing_model.MissingParameter function in Pint

To help you get started, we’ve selected a few Pint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nanograv / PINT / tests / test_model_manual.py View on Github external
def test_compare_get_model_new_and_old_all_parfiles(parfile):
    if basename(parfile) in bad_trouble:
        pytest.skip("This parfile is unclear")
    try:
        m_old = get_model(parfile)
    except (IOError, MissingParameter) as e:
        pytest.skip("Existing code raised an exception {}".format(e))
    m_new = get_model_new(parfile)

    assert set(m_new.components.keys()) == set(m_old.components.keys())
    assert set(m_new.get_params_mapping().keys()) == set(
        m_old.get_params_mapping().keys()
    )
github nanograv / PINT / src / pint / models / binary_bt.py View on Github external
super(BinaryBT, self).setup()
        # If any necessary parameter is missing, raise MissingParameter.
        # This will probably be updated after ELL1 model is added.
        for p in ("T0", "A1"):
            if getattr(self, p).value is None:
                raise MissingParameter("BT", p, "%s is required for BT" % p)

        # If any *DOT is set, we need T0
        for p in ("PBDOT", "OMDOT", "EDOT", "A1DOT"):
            if getattr(self, p).value is None:
                getattr(self, p).set("0")
                getattr(self, p).frozen = True

            if getattr(self, p).value is not None:
                if self.T0.value is None:
                    raise MissingParameter("BT", "T0", "T0 is required if *DOT is set")

        if self.GAMMA.value is None:
            self.GAMMA.set("0")
            self.GAMMA.frozen = True
github nanograv / PINT / pint / models / pulsar_binary.py View on Github external
def check_required_params(self, required_params):
        # seach for all the possible to get the parameters.
        for p in required_params:
            par = getattr(self, p)
            if par.value is None:
                # try to search if there is any class method that computes it
                method_name = p.lower() + "_func"
                try:
                    par_method = getattr(self.binary_instance, method_name)
                    _ = par_method()
                except:
                    raise MissingParameter(self.binary_model_name, p + \
                                           " is required for '%s'." %
                                           self.binary_model_name)
github nanograv / PINT / src / pint / models / spindown.py View on Github external
def validate(self):
        super(Spindown, self).validate()
        # Check for required params
        for p in ("F0",):
            if getattr(self, p).value is None:
                raise MissingParameter("Spindown", p)
        # Check continuity
        sort_F_terms = sorted(self.F_terms)
        F_in_order = list(range(1, max(self.F_terms) + 1))
        if not sort_F_terms == F_in_order:
            diff = list(set(F_in_order) - set(sort_F_terms))
            raise MissingParameter("Spindown", "F%d" % diff[0])
        # If F1 is set, we need PEPOCH
        if self.F1.value != 0.0:
            if self.PEPOCH.value is None:
                raise MissingParameter(
                    "Spindown", "PEPOCH", "PEPOCH is required if F1 or higher are set"
                )
github nanograv / PINT / pint / models / spindown.py View on Github external
def setup(self):
        super(Spindown, self).setup()
        # Check for required params
        for p in ("F0",):
            if getattr(self, p).value is None:
                raise MissingParameter("Spindown", p)
        # If F1 is set, we need PEPOCH
        if self.F1.value != 0.0:
            if self.PEPOCH.value is None:
                raise MissingParameter("Spindown", "PEPOCH",
                        "PEPOCH is required if F1 is set")
github nanograv / PINT / pint / models / spindown.py View on Github external
def setup(self):
        super(Spindown, self).setup()
        # Check for required params
        for p in ("F0",):
            if getattr(self, p).value is None:
                raise MissingParameter("Spindown", p)

        # Check continuity
        F_terms = list(self.get_prefix_mapping_component('F').keys())
        F_terms.sort()
        F_in_order = list(range(1, max(F_terms)+1))
        if not F_terms == F_in_order:
            diff = list(set(F_in_order) - set(F_terms))
            raise MissingParameter("Spindown", "F%d"%diff[0])

        # If F1 is set, we need PEPOCH
        if self.F1.value != 0.0:
            if self.PEPOCH.value is None:
                raise MissingParameter("Spindown", "PEPOCH",
                        "PEPOCH is required if F1 or higher are set")
        self.num_spin_terms = len(F_terms) + 1
        # Add derivative functions
        for fp in list(self.get_prefix_mapping_component('F').values()) + ['F0',]:
            self.register_deriv_funcs(self.d_phase_d_F, fp)
github nanograv / PINT / pint / models / astrometry.py View on Github external
def setup(self):
        super(Astrometry, self).setup()
        # RA/DEC are required
        for p in ("RAJ", "DECJ"):
            if getattr(self, p).value is None:
                raise MissingParameter("Astrometry", p)
        # If PM is included, check for POSEPOCH
        if self.PMRA.value != 0.0 or self.PMDEC.value != 0.0:
            if self.POSEPOCH.value is None:
                if self.PEPOCH.value is None:
                    raise MissingParameter("Astrometry", "POSEPOCH",
                            "POSEPOCH or PEPOCH are required if PM is set.")
                else:
                    self.POSEPOCH.value = self.PEPOCH.value
github nanograv / PINT / pint / models / spindown.py View on Github external
def setup(self):
        super(Spindown, self).setup()
        # Check for required params
        for p in ("F0",):
            if getattr(self, p).value is None:
                raise MissingParameter("Spindown", p)

        # Check continuity
        F_terms = list(self.get_prefix_mapping_component('F').keys())
        F_terms.sort()
        F_in_order = list(range(1, max(F_terms)+1))
        if not F_terms == F_in_order:
            diff = list(set(F_in_order) - set(F_terms))
            raise MissingParameter("Spindown", "F%d"%diff[0])

        # If F1 is set, we need PEPOCH
        if self.F1.value != 0.0:
            if self.PEPOCH.value is None:
                raise MissingParameter("Spindown", "PEPOCH",
                        "PEPOCH is required if F1 or higher are set")
        self.num_spin_terms = len(F_terms) + 1
        # Add derivative functions
github nanograv / PINT / src / pint / models / wave.py View on Github external
def validate(self):
        super(Wave, self).validate()
        self.setup()
        if self.WAVEEPOCH.quantity is None:
            if self.PEPOCH.quantity is None:
                raise MissingParameter(
                    "Wave",
                    "WAVEEPOCH",
                    "WAVEEPOCH or PEPOCH are required if " "WAVE_OM is set.",
                )
            else:
                self.WAVEEPOCH = self.PEPOCH

        if (not hasattr(self, "F0")) or (self.F0.quantity is None):
            raise MissingParameter(
                "Wave", "F0", "F0 is required if WAVE entries are present."
            )
        self.wave_terms.sort()
        wave_in_order = list(range(1, max(self.wave_terms) + 1))
        if not self.wave_terms == wave_in_order:
            diff = list(set(wave_in_order) - set(self.wave_terms))
            raise MissingParameter("Wave", "WAVE%d" % diff[0])
github nanograv / PINT / src / pint / models / binary_ell1.py View on Github external
super(BinaryELL1Base, self).setup()
        for p in ["EPS1", "EPS2"]:
            if getattr(self, p).value is None:
                raise MissingParameter("ELL1", p, p + " is required for ELL1 model.")
        # Check TASC
        if self.TASC.value is None:
            if self.ECC.value == 0.0:
                warn("Since ECC is 0.0, using T0 as TASC.")
                if self.T0.value is not None:
                    self.TASC.value = self.T0.value
                else:
                    raise MissingParameter(
                        "ELL1", "T0", "T0 or TASC is required for ELL1 model."
                    )
            else:
                raise MissingParameter(
                    "ELL1", "TASC", "TASC is required for ELL1 model."
                )