Skip to content

Commit

Permalink
Merge pull request #55 from pysersic/bd-decomp
Browse files Browse the repository at this point in the history
Add sersic_exp rendering method, and add a doc on how to use it (or doublesersic)
  • Loading branch information
prappleizer committed Apr 29, 2024
2 parents 783e310 + 95d92a5 commit 6ffd2dd
Show file tree
Hide file tree
Showing 4 changed files with 657 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The empirically derived Sérsic profile is the most common parametric form for t
multi-source-fitting
manual-priors
multiband-example
bulge-disk-decomposition

.. toctree::
:maxdepth: 1
Expand Down
601 changes: 601 additions & 0 deletions examples/bulge-disk-decomposition.ipynb

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions pysersic/priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def render_tilted_plane_sky(X, Y, back, x_sl, y_sl):
base_profile_types = [
"sersic",
"doublesersic",
"sersic_exp",
"sersic_pointsource",
"pointsource",
"exp",
Expand All @@ -63,6 +64,18 @@ def render_tilted_plane_sky(X, Y, back, x_sl, y_sl):
"ellip_2",
"theta",
],
[
"xc",
"yc",
"flux",
"f_1",
"r_eff_1",
"n",
"ellip_1",
"r_eff_2",
"ellip_2",
"theta",
],
["xc", "yc", "flux", "f_ps", "r_eff", "n", "ellip", "theta"],
["xc", "yc", "flux"],
["xc", "yc", "flux", "r_eff", "ellip", "theta"],
Expand Down Expand Up @@ -981,7 +994,7 @@ def generate_prior(
if profile_type == "sersic_pointsource":
prior.set_uniform_prior("f_ps", 0.0, 1.0)

elif profile_type == "doublesersic":
elif profile_type in ["doublesersic", "sersic_exp"]:
prior.set_uniform_prior("f_1", 0.0, 1.0)

# prior.set_custom_prior('theta',
Expand All @@ -1003,9 +1016,11 @@ def generate_prior(

prior.set_uniform_prior("ellip_1", 0, 0.9)
prior.set_uniform_prior("ellip_2", 0, 0.9)

prior.set_truncated_gaussian_prior("n_1", 4, 1, low=0.65, high=8)
prior.set_truncated_gaussian_prior("n_2", 1, 1, low=0.65, high=8)
if profile_type == "doublesersic":
prior.set_truncated_gaussian_prior("n_1", 4, 1, low=0.65, high=8)
prior.set_truncated_gaussian_prior("n_2", 1, 1, low=0.65, high=8)
else:
prior.set_truncated_gaussian_prior("n", 4, 1, low=0.65, high=8)

return prior

Expand Down
36 changes: 36 additions & 0 deletions pysersic/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
base_profile_types = [
"sersic",
"doublesersic",
"sersic_exp",
"sersic_pointsource",
"pointsource",
"exp",
Expand All @@ -37,6 +38,18 @@
"ellip_2",
"theta",
],
[
"xc",
"yc",
"flux",
"f_1",
"r_eff_1",
"ellip_1",
"r_eff_2",
"n",
"ellip_2",
"theta",
],
["xc", "yc", "flux", "f_ps", "r_eff", "n", "ellip", "theta"],
["xc", "yc", "flux"],
["xc", "yc", "flux", "r_eff", "ellip", "theta"],
Expand Down Expand Up @@ -168,6 +181,29 @@ def render_doublesersic(self, params: dict):

return F1 + F2, im_int_1 + im_int_2, im_obs_1 + im_obs_2

def render_sersic_exp(self, params: dict):
dict_1 = {
"xc": params["xc"],
"yc": params["yc"],
"flux": params["flux"] * params["f_1"],
"n": params["n"],
"ellip": params["ellip_1"],
"theta": params["theta"],
"r_eff": params["r_eff_1"],
}
dict_2 = {
"xc": params["xc"],
"yc": params["yc"],
"flux": params["flux"] * (1.0 - params["f_1"]),
"ellip": params["ellip_2"],
"theta": params["theta"],
"r_eff": params["r_eff_2"],
}
F1, im_int_1, im_obs_1 = self.render_sersic(dict_1)
F2, im_int_2, im_obs_2 = self.render_exp(dict_2)

return F1 + F2, im_int_1 + im_int_2, im_obs_1 + im_obs_2

def render_sersic_pointsource(self, params: dict):
pointsource_dict = {}
sersic_dict = params.copy()
Expand Down

0 comments on commit 6ffd2dd

Please sign in to comment.