Skip to content

Commit

Permalink
short cercuit
Browse files Browse the repository at this point in the history
  • Loading branch information
abhisrkckl committed Nov 19, 2024
1 parent b288fd7 commit b21fd69
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/pint/models/solar_wind_dispersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,21 +415,26 @@ def solar_wind_dm(self, toas):
"""
ne_sw_terms = self.get_NE_SW_terms()

if any(t.value != 0 for t in ne_sw_terms[1:]):
SWEPOCH = self.SWEPOCH.value
if SWEPOCH is None:
# Should be ruled out by validate()
raise ValueError(
f"SWEPOCH not set but some NE_SW derivatives are not zero: {ne_sw_terms}"
)
else:
dt = (toas["tdbld"] - SWEPOCH) * u.day
dt_value = dt.to_value(u.yr)
if len(ne_sw_terms) == 1:
ne_sw = self.NE_SW.quantity * np.ones(len(toas))
else:
dt_value = np.zeros(len(toas), dtype=np.longdouble)
if any(t.value != 0 for t in ne_sw_terms[1:]):
SWEPOCH = self.SWEPOCH.value
if SWEPOCH is None:
# Should be ruled out by validate()
raise ValueError(
f"SWEPOCH not set but some NE_SW derivatives are not zero: {ne_sw_terms}"
)
else:
dt = (toas["tdbld"] - SWEPOCH) * u.day
dt_value = dt.to_value(u.yr)
else:
dt_value = np.zeros(len(toas), dtype=np.longdouble)

ne_sw_terms_value = [d.value for d in ne_sw_terms]
ne_sw = pint.utils.taylor_horner(dt_value, ne_sw_terms_value) * self.NE_SW.units
ne_sw_terms_value = [d.value for d in ne_sw_terms]
ne_sw = (
pint.utils.taylor_horner(dt_value, ne_sw_terms_value) * self.NE_SW.units
)

if np.all(ne_sw.value == 0):
return np.zeros(len(toas)) * u.pc / u.cm**3
Expand Down

0 comments on commit b21fd69

Please sign in to comment.