Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_units(self):
with self.assertRaises(u.UnitConversionError):
t = TOA(self.MJD * u.m)
with self.assertRaises(u.UnitConversionError):
t = TOA((self.MJD * u.m, 0))
t = TOA((self.MJD * u.day).to(u.s))
with self.assertRaises(u.UnitConversionError):
t = TOA((self.MJD * u.day, 0))
t = TOA((self.MJD * u.day, 0 * u.day))
with self.assertRaises(u.UnitConversionError):
t = TOA(self.MJD, error=1 * u.m)
t = TOA(self.MJD, freq=100 * u.kHz)
with self.assertRaises(u.UnitConversionError):
t = TOA(self.MJD, freq=100 * u.s)
fermiobs = get_observatory("Fermi")
except KeyError:
log.error(
"Fermi observatory not defined. Make sure you have specified an FT2 file!"
)
raise
try:
if weightcolumn is None:
toalist = [
toa.TOA(m, obs="Fermi", scale="tt", energy=e, error=1.0 * u.us)
for m, e in zip(mjds, energies)
]
else:
toalist = [
toa.TOA(
m,
obs="Fermi",
scale="tt",
energy=e,
weight=w,
error=1.0 * u.us,
)
for m, e, w in zip(mjds, energies, weights)
]
except KeyError:
log.error(
"Error processing Fermi TOAs. You may have forgotten to specify an FT2 file with --ft2"
)
raise
else:
log.info("Building geocentered TOAs")
mjds[0], mjds[-1]
)
)
assert timesys == "TT"
try:
fermiobs = get_observatory("Fermi")
except KeyError:
log.error(
"Fermi observatory not defined. Make sure you have specified an FT2 file!"
)
raise
try:
if weightcolumn is None:
toalist = [
toa.TOA(m, obs="Fermi", scale="tt", energy=e, error=1.0 * u.us)
for m, e in zip(mjds, energies)
]
else:
toalist = [
toa.TOA(
m,
obs="Fermi",
scale="tt",
energy=e,
weight=w,
error=1.0 * u.us,
)
for m, e, w in zip(mjds, energies, weights)
]
except KeyError:
log.error(
new_kwargs = _get_columns_from_fits(hdulist[1],
mission_config[mission]["fits_columns"])
hdulist.close()
if weights is not None:
new_kwargs["weights"] = weights
toalist = [None] * len(mjds)
kw = {}
for i in range(len(mjds)):
# Create TOA list
for key in new_kwargs.keys():
kw[key] = new_kwargs[key][i]
toalist[i] = toa.TOA(mjds[i], obs=obs, scale=scale, **kw)
return toalist
new_kwargs = _get_columns_from_fits(
hdulist[1], mission_config[mission]["fits_columns"]
)
hdulist.close()
if weights is not None:
new_kwargs["weights"] = weights
toalist = [None] * len(mjds)
kw = {}
for i in range(len(mjds)):
# Create TOA list
for key in new_kwargs.keys():
kw[key] = new_kwargs[key][i]
toalist[i] = toa.TOA(mjds[i], obs=obs, scale=scale, **kw)
return toalist