From c75dfe76a3ed46cbe077872e705ddf621463e601 Mon Sep 17 00:00:00 2001 From: Erik Jensen Date: Thu, 19 Sep 2024 18:14:33 +0200 Subject: [PATCH] pytest: all tests now pass --- flows/photometry.py | 9 ++++++--- flows/visibility.py | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/flows/photometry.py b/flows/photometry.py index 8247241..81e0f2b 100644 --- a/flows/photometry.py +++ b/flows/photometry.py @@ -119,12 +119,15 @@ def make_epsf(self, stars): logger.info("Building ePSF...") # from photutils docs: recentering_boxsize must have odd values and be greater than or equal to 3 - discrete_width = int(np.round(2 * self.fwhm)) - rcb = discrete_width if discrete_width % 2 else discrete_width + 1 + rcb = int(np.round(2 * self.fwhm)) + rcb = rcb if rcb % 2 else rcb + 1 + # from photutils docs: fit_boxsize must have odd values + fb = int(np.round(1.5 * self.fwhm)) + fb = fb if fb % 2 else fb + 1 builder = self.epsf_builder( oversampling=1, shape=1 * self.star_size, - fitter=EPSFFitter(fit_boxsize=max(int(np.round(1.5 * self.fwhm)), 5)), + fitter=EPSFFitter(fit_boxsize=max(fb, 5)), recentering_boxsize=max(rcb, 5), norm_radius=max(self.fwhm, 5), maxiters=100, progress_bar=multiprocessing.parent_process() is None and logger.getEffectiveLevel() <= 20 diff --git a/flows/visibility.py b/flows/visibility.py index 5c99faf..d8b8087 100644 --- a/flows/visibility.py +++ b/flows/visibility.py @@ -16,9 +16,10 @@ import astropy.units as u import matplotlib.pyplot as plt import numpy as np -from astropy.coordinates import AltAz, SkyCoord, get_moon, get_sun +from astropy.coordinates import AltAz, SkyCoord, get_body, get_sun from astropy.time import Time from astropy.visualization import quantity_support +from matplotlib import pyplot from matplotlib.dates import DateFormatter from tendrils import api @@ -95,7 +96,7 @@ def visibility(target: Target, siteid: Optional[int] = None, date=None, output=N # The Sun and Moon: altaz_sun = get_sun(times).transform_to(AltAzFrame) - altaz_moon = get_moon(times).transform_to(AltAzFrame) + altaz_moon = get_body("moon", times).transform_to(AltAzFrame) sundown_astro = (altaz_sun.alt < -6 * u.deg) if np.any(sundown_astro): @@ -110,7 +111,7 @@ def visibility(target: Target, siteid: Optional[int] = None, date=None, output=N plt.grid(ls=':', lw=0.5) ax.plot(times.datetime, altaz_sun.alt, color='y', label='Sun') ax.plot(times.datetime, altaz_moon.alt, color=[0.75] * 3, ls='--', label='Moon') - objsc = ax.scatter(times.datetime, altaz_obj.alt, c=altaz_obj.az, label=target.name, lw=0, s=8, + objsc = ax.scatter(times.datetime, altaz_obj.alt.deg, c=altaz_obj.az.deg, label=target.name, lw=0, s=8, cmap='twilight') ax.fill_between(times.datetime, 0 * u.deg, 90 * u.deg, altaz_sun.alt < -0 * u.deg, color='0.5', zorder=0) # , label='Night' @@ -139,5 +140,6 @@ def visibility(target: Target, siteid: Optional[int] = None, date=None, output=N if output: return plotpaths - plt.show() + if pyplot.isinteractive(): + plt.show() return ax