Skip to content

Commit

Permalink
Merge pull request #707 from iancrossfield/patch-2
Browse files Browse the repository at this point in the history
Update source_pos.py
  • Loading branch information
taylorbell57 authored Oct 30, 2024
2 parents f09c39a + 876d36e commit 10d1a4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,7 @@ ecfs_*/
ecfs/

# Ignore version.py to allow automated version numbering
version.py
version.py

# GitHub Codespaces
*build-commands.txt
18 changes: 12 additions & 6 deletions src/eureka/S3_data_reduction/source_pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,13 @@ def source_pos_FWM(flux, meta, m, n=0, plot=True):

pos_max = source_pos_median(flux, meta, m, n=n, plot=False)

y_pixels = np.arange(0, x_dim)[pos_max-meta.spec_hw:pos_max+meta.spec_hw]
ymin = pos_max-meta.spec_hw
if ymin < 0:
ymin = None
ymax = min(flux.shape[0], pos_max+meta.spec_hw)
y_pixels = np.arange(0, x_dim)[ymin:ymax]

sum_row = np.ma.sum(flux, axis=1)[pos_max-meta.spec_hw:
pos_max+meta.spec_hw]
sum_row = np.ma.sum(flux, axis=1)[ymin:ymax]
sum_row -= (sum_row[0]+sum_row[-1])/2

y_pos = np.ma.sum(sum_row*y_pixels)/np.ma.sum(sum_row)
Expand Down Expand Up @@ -399,9 +402,12 @@ def source_pos_gauss(flux, meta, m, n=0, plot=True):

# Data cutout around the maximum row
pos_max = source_pos_median(flux, meta, m, n=n, plot=False)
y_pixels = np.arange(0, x_dim)[pos_max-meta.spec_hw:pos_max+meta.spec_hw]
med_row = np.ma.median(flux, axis=1)[pos_max-meta.spec_hw:
pos_max+meta.spec_hw]
ymin = pos_max-meta.spec_hw
if ymin < 0:
ymin = None
ymax = min(flux.shape[0], pos_max+meta.spec_hw)
y_pixels = np.arange(0, x_dim)[ymin:ymax]
med_row = np.ma.median(flux, axis=1)[ymin:ymax]

# Initial Guesses
sigma0 = np.ma.sqrt(np.ma.sum(med_row*(y_pixels-pos_max)**2) /
Expand Down

0 comments on commit 10d1a4d

Please sign in to comment.