diff --git a/CHANGELOG.md b/CHANGELOG.md index a7f1c2c7c..0cd5b6baa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project, at least loosely, adheres to [Semantic Versioning](https://sem - BIPM correction for simulated TOAs - Added try/except to `test_pldmnoise.py`/`test_PLRedNoise_recovery` to avoid exceptions during CI - Import for `longdouble2str` in `get_tempo_result` +- Plotting orbital phase in `pintk` when FB0 is used instead of PB ### Removed ## [0.9.3] 2022-12-16 diff --git a/src/pint/models/timing_model.py b/src/pint/models/timing_model.py index 55d0d2473..d371c5aa1 100644 --- a/src/pint/models/timing_model.py +++ b/src/pint/models/timing_model.py @@ -752,7 +752,15 @@ def funct(t): scs = [] for bt in bts: # Make 11 times over one orbit after bt - ts = np.linspace(bt, bt + self.PB.value, 11) + if self.PB.value is not None: + pb = self.PB.value + elif self.FB0.quantity is not None: + pb = (1 / self.FB0.quantity).to("day").value + else: + raise AttributeError( + "Neither PB nor FB0 is present in the timing model." + ) + ts = np.linspace(bt, bt + pb, 11) # Compute the true anomalies and omegas for those times nus = self.orbital_phase(ts, anom="true") omegas = bbi.omega() @@ -763,10 +771,7 @@ def funct(t): break # Now use scipy to find the root scs.append(brentq(funct, ts[lb], ts[lb + 1])) - if len(scs) == 1: - return scs[0] # Return a float - else: - return np.asarray(scs) # otherwise return an array + return scs[0] if len(scs) == 1 else np.asarray(scs) @property_exists def dm_funcs(self): diff --git a/src/pint/pintk/plk.py b/src/pint/pintk/plk.py index 63564dddf..044bf87e4 100644 --- a/src/pint/pintk/plk.py +++ b/src/pint/pintk/plk.py @@ -392,10 +392,7 @@ def __init__(self, master): self.fitterSelect.bind("<>", self.changeFitter) def updateFitterChoices(self, wideband): - if wideband: - self.fitterSelect["values"] = wb_fitters - else: - self.fitterSelect["values"] = nb_fitters + self.fitterSelect["values"] = wb_fitters if wideband else nb_fitters def changeFitter(self, event): self.fitter = self.fitterSelect.get() # get current value @@ -438,7 +435,7 @@ def addColorModeCheckbox(self, colorModes): model = self.master.psr.postfit_model else: model = self.master.psr.prefit_model - if not "PhaseJump" in model.components: + if "PhaseJump" not in model.components: self.checkboxes[index].configure(state="disabled") self.updateLayout() @@ -670,7 +667,7 @@ class PlkWidget(tk.Frame): def __init__(self, master=None, **kwargs): tk.Frame.__init__(self, master) self.configure(bg=background) - self.init_loglevel = kwargs["loglevel"] if "loglevel" in kwargs else None + self.init_loglevel = kwargs.get("loglevel") self.initPlk() self.initPlkLayout() self.current_state = State() @@ -1098,7 +1095,15 @@ def plotResiduals(self, keepAxes=False): # Get the time of conjunction after T0 or TASC tt = m.T0.value if hasattr(m, "T0") else m.TASC.value mjd = m.conjunction(tt) - phs = (mjd - tt) * u.day / m.PB + if m.PB.value is not None: + pb = m.PB.value + elif m.FB0.quantity is not None: + pb = (1 / m.FB0.quantity).to("day").value + else: + raise AttributeError( + "Neither PB nor FB0 is present in the timing model." + ) + phs = (mjd - tt) / pb self.plkAxes.plot([phs, phs], [ymin, ymax], "k-") else: self.plkAxes.set_ylabel(plotlabels[self.yid])