Skip to content

Commit

Permalink
Merge pull request #158 from robelgeda/depreciate_3
Browse files Browse the repository at this point in the history
change `bkg_sub` -> `bg_sub`
  • Loading branch information
robelgeda authored Aug 6, 2023
2 parents 69ea30f + 029ca24 commit 1b69c59
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
" # Options \n",
" error=rms, # Error image (optional)\n",
" cutout_size=max(r_list)*2, # Cutout out size, set to double the max radius \n",
" bkg_sub=True, # Subtract background \n",
" bg_sub=True, # Subtract background \n",
" sigma=3, sigma_type='clip', # Fit a 2D plane to pixels within 3 sigma of the mean\n",
" plot=True, vmax=vmax, vmin=vmin, # Show plot with max and min defined above\n",
")\n",
Expand Down Expand Up @@ -1072,7 +1072,7 @@
" \n",
" # Options \n",
" cutout_size=max(r_list)*2, # Cutout out size, set to double the max radius \n",
" bkg_sub=True, # Subtract background \n",
" bg_sub=True, # Subtract background \n",
" sigma=3, sigma_type='clip', # Fit a 2D plane to pixels within 3 sigma of the mean\n",
" plot=True, vmax=vmax, vmin=vmin, # Show plot with max and min defined above\n",
")\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/multi_object.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"\n",
" # Options \n",
" cutout_size=max(r_list)*2, # Cutout out size, set to double the max radius \n",
" bkg_sub=True, # Subtract background \n",
" bg_sub=True, # Subtract background \n",
" sigma=3, sigma_type='clip', # Fit a 2D plane to pixels within 3 sigma of the mean\n",
" plot=False, vmax=vmax, vmin=vmin, # Show plot with max and min defined above\n",
" )\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/photometry_and_petrosian.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,12 @@
"- Once the `cutout_size` is determined, cutouts of the error map (if provided) and image are produced. Before the raw image is cutout, sources that are not the source of interest are masked using the segmentation map. The `mask_background` option gives us the ability to also mask pixels that are considered to be background pixels because they do not belong to any source’s segmentation map. All masked pixels are replaced by `np.nan` and are not counted in the returned area array. \n",
"\n",
"\n",
"- If `bkg_sub` is set to true, a 2D plane is used to fit pixels that are below a specified sigma from the mean using the `petrofit.fitting.fit_plane` function. The sigma `sigma` value is used to determine noise pixels. Once the pixels above this value are masked, a 2D plane is fit to determine the background. The 2D plane model is then converted into an image and subtracted from the cutout of the target source. `sigma_type` is used to set how this `sigma` value will be used. The `sigma_type` options are `'clip'` and `'bound'`:\n",
"- If `bg_sub` is set to true, a 2D plane is used to fit pixels that are below a specified sigma from the mean using the `petrofit.fitting.fit_plane` function. The sigma `sigma` value is used to determine noise pixels. Once the pixels above this value are masked, a 2D plane is fit to determine the background. The 2D plane model is then converted into an image and subtracted from the cutout of the target source. `sigma_type` is used to set how this `sigma` value will be used. The `sigma_type` options are `'clip'` and `'bound'`:\n",
" - ``'clip'`` (default): Uses `astropy.stats.sigma_clipping.sigma_clip` to clip at the provided `sigma` std value. Note that `sigma` in this case is the number of stds above the mean.\n",
" - ``'bound'`` : After computing the mean of the image, clip at `mean - sigma` and `mean + sigma`. Note that `sigma` in this case is a value and not the number of stds above the mean.\n",
"\n",
"\n",
"- The resulting image (after being noise subtracted if `bkg_sub` is set to true) is passed to the `petrofit.photometry.photometry_step` which constructs the apertures and performs photometry. \n",
"- The resulting image (after being noise subtracted if `bg_sub` is set to true) is passed to the `petrofit.photometry.photometry_step` which constructs the apertures and performs photometry. \n",
"\n",
"After calculating the photometry at each radius, three arrays are returned:\n",
"\n",
Expand Down Expand Up @@ -472,7 +472,7 @@
" \n",
" # Options \n",
" cutout_size=max(r_list)*2, # Cutout out size, set to double the max radius \n",
" bkg_sub=True, # Subtract background \n",
" bg_sub=True, # Subtract background \n",
" sigma=3, sigma_type='clip', # Fit a 2D plane to pixels within 3 sigma of the mean\n",
" plot=True, vmax=vmax, vmin=vmin, # Show plot with max and min defined above\n",
")\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/quick_start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@
"\n",
" # Options\n",
" cutout_size=max(r_list)*2, # Cutout out size, set to double the max radius\n",
" bkg_sub=True, # Subtract background\n",
" bg_sub=True, # Subtract background\n",
" sigma=3, sigma_type='clip', # Fit a 2D plane to pixels within 3 sigma of the mean\n",
" plot=True, vmax=vmax, vmin=vmin, # Show plot with max and min defined above\n",
")\n",
Expand Down
8 changes: 4 additions & 4 deletions petrofit/photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def photometry_step(position, r_list, image, error=None, mask=None, elong=1., th


def source_photometry(source, image, segm_deblend, r_list, error=None, cutout_size=None,
bkg_sub=False, sigma=3.0, sigma_type='clip', method='exact', mask_background=False,
bg_sub=False, sigma=3.0, sigma_type='clip', method='exact', mask_background=False,
plot=False, vmin=0, vmax=None, ):
"""
Aperture photometry on a PhotUtils `SourceProperties`.
Expand All @@ -313,7 +313,7 @@ def source_photometry(source, image, segm_deblend, r_list, error=None, cutout_si
cutout_size : int
Size of cutout.
bkg_sub : bool
bg_sub : bool
If the code should subtract the background using the `sigma` provided.
sigma : float
Expand Down Expand Up @@ -419,7 +419,7 @@ def source_photometry(source, image, segm_deblend, r_list, error=None, cutout_si

# Subtract Mean Plane
# -------------------
if bkg_sub:
if bg_sub:
if len(np.where(~np.isnan(masked_stats_image))[0]) > 10:
with warnings.catch_warnings():

Expand All @@ -445,7 +445,7 @@ def source_photometry(source, image, segm_deblend, r_list, error=None, cutout_si
masked_image = np.clip(masked_image, - sigma, np.inf)

elif plot:
print("bkg_sub: Not enough datapoints, did not subtract.")
print("bg_sub: Not enough datapoints, did not subtract.")

# Make mask
# ---------
Expand Down
2 changes: 1 addition & 1 deletion petrofit/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def sersic_petrosian(sersic_2d_image, segm_and_cat):

# Options
cutout_size=max(r_list) * 2, # Cutout out size, set to double the max radius
bkg_sub=False, # Subtract background
bg_sub=False, # Subtract background
sigma=1, sigma_type='clip', # Fit a 2D plane to pixels within 1 sigma of the mean
plot=False, vmax=0, vmin=1, # Show plot with max and min defined above
)
Expand Down
3 changes: 1 addition & 2 deletions petrofit/tests/test_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ def test_source_photometry(sersic_2d_image, segm_and_cat):

# Options
cutout_size=max(r_list)*2, # Cutout out size, set to double the max radius
bkg_sub=True, # Subtract background
bg_sub=True, # Subtract background
sigma=1, sigma_type='clip', # Fit a 2D plane to pixels within 1 sigma of the mean
plot=True, vmax=0, vmin=1, # Show plot with max and min defined above
)



def test_order_cat(segm_and_cat):
"""Test if ordering is correct"""
cat, segm, segm_deblend = segm_and_cat
Expand Down

0 comments on commit 1b69c59

Please sign in to comment.