Skip to content

Commit

Permalink
Merge pull request #49 from mwcraig/Make-add_in_quadrature-public
Browse files Browse the repository at this point in the history
A couple of quick fixes
  • Loading branch information
mwcraig authored Nov 3, 2021
2 parents 4ad9854 + 5d72626 commit 0b69a84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
5 changes: 3 additions & 2 deletions stellarphot/differential_photometry/aij_rel_fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from astropy.coordinates import SkyCoord
import astropy.units as u

__all__ = ['add_in_quadrature', 'calc_aij_relative_flux']

def _add_in_quadrature(array):
def add_in_quadrature(array):
"""
Add an array of numbers in quadrature.
"""
Expand Down Expand Up @@ -77,7 +78,7 @@ def calc_aij_relative_flux(star_data, comp_stars,
comp_fluxes = comp_fluxes.group_by('date-obs')
comp_totals = comp_fluxes.groups.aggregate(np.sum)[flux_column_name]
comp_num_stars = comp_fluxes.groups.aggregate(np.count_nonzero)[flux_column_name]
comp_errors = comp_fluxes.groups.aggregate(_add_in_quadrature)[error_column_name]
comp_errors = comp_fluxes.groups.aggregate(add_in_quadrature)[error_column_name]

comp_total_vector = np.ones_like(star_data[flux_column_name])
comp_error_vector = np.ones_like(star_data[flux_column_name])
Expand Down
25 changes: 15 additions & 10 deletions stellarphot/source_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,27 @@ def compute_fwhm(ccd, sources, fwhm_estimate=5,
except AttributeError:
pass

cutout = Cutout2D(ccd, (x, y), 5 * fwhm_estimate)
cutout = Cutout2D(ccd.data, (x, y), 5 * fwhm_estimate)
if fit:
fit = _fit_2dgaussian(cutout.data)
fwhm_x.append(gaussian_sigma_to_fwhm * fit.x_stddev_1)
fwhm_y.append(gaussian_sigma_to_fwhm * fit.y_stddev_1)
print('Still fitting!!')
else:
dat = np.where(cutout.data - sky > 0, cutout.data - sky, 0)
mom1 = _moments(dat, order=1)
xc = mom1[0, 1] / mom1[0, 0]
yc = mom1[1, 0] / mom1[0, 0]
moments = _moments_central(dat,
center=(xc, yc), order=2)
mom_scale = (moments / mom1[0, 0])
fwhm_xm = 2 * np.sqrt(np.log(2) * mom_scale[0, 2])
fwhm_ym = 2 * np.sqrt(np.log(2) * mom_scale[2, 0])
sc = data_properties(cutout.data - sky)

# dat = np.where(cutout.data - sky > 0, cutout.data - sky, 0)
# mom1 = _moments(dat, order=1)
# xc = mom1[0, 1] / mom1[0, 0]
# yc = mom1[1, 0] / mom1[0, 0]
# moments = _moments_central(dat,
# center=(xc, yc), order=2)
# mom_scale = (moments / mom1[0, 0])
# fwhm_xm = 2 * np.sqrt(np.log(2) * mom_scale[0, 2])
# fwhm_ym = 2 * np.sqrt(np.log(2) * mom_scale[2, 0])

fwhm_xm = sc.fwhm.value
fwhm_ym = fwhm_xm
fwhm_x.append(fwhm_xm)
fwhm_y.append(fwhm_ym)

Expand Down

0 comments on commit 0b69a84

Please sign in to comment.