Skip to content

Commit

Permalink
Merge pull request #16 from lsst/tickets/DM-22137
Browse files Browse the repository at this point in the history
tickets/DM-22137
  • Loading branch information
fred3m committed Jan 17, 2020
2 parents 62b7f63 + 8ad4279 commit 74da54f
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 367 deletions.
3 changes: 2 additions & 1 deletion python/lsst/meas/extensions/scarlet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
from .observation import *
from .source import *
from .blend import *
from .deblend import *
from . import deblend
from .version import *
36 changes: 12 additions & 24 deletions python/lsst/meas/extensions/scarlet/blend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import numpy as np

from scarlet.blend import Blend

__all__ = ["LsstBlend"]
__all__ = ["LsstBlend", "checkBlendConvergence"]


def checkBlendConvergence(blend, f_rel):
"""Check whether or not a blend has converged
"""
deltaLoss = np.abs(blend.loss[-2] - blend.loss[-1])
convergence = f_rel * np.abs(blend.loss[-1])
return deltaLoss < convergence


class LsstBlend(Blend):
Expand All @@ -32,26 +42,4 @@ class LsstBlend(Blend):
for multiresolution blends. So this class exists for any
LSST specific changes.
"""
def get_model(self, seds=None, morphs=None, observation=None):
model = super().get_model(seds, morphs)
if observation is not None:
model = observation.render(model)
return model

def display_model(self, observation=None, ax=None, filters=None, Q=10, stretch=1, show=True):
import matplotlib.pyplot as plt
from astropy.visualization import make_lupton_rgb

model = self.get_model(observation=observation)
if ax is None:
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(1, 1, 1)
if filters is None:
filters = [2, 1, 0]
imgRgb = make_lupton_rgb(image_r=model[filters[0]], # numpy array for the r channel
image_g=model[filters[1]], # numpy array for the g channel
image_b=model[filters[2]], # numpy array for the b channel
stretch=stretch, Q=Q) # parameters used to stretch and scale the values
ax.imshow(imgRgb, interpolation='nearest')
if show:
plt.show()
pass

0 comments on commit 74da54f

Please sign in to comment.