Skip to content

Commit

Permalink
remove mentions of coadd
Browse files Browse the repository at this point in the history
  • Loading branch information
ismael-mendoza committed Nov 12, 2021
1 parent 882952a commit da6dc62
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 60 deletions.
22 changes: 12 additions & 10 deletions btk/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def basic_measure(
):
"""Return centers detected with skimage.feature.peak_local_max.
For each potentially multi-band image, an average over the bands is taken before measurement.
NOTE: If this function is used with the multiresolution feature,
measurements will be carried on the first survey.
Expand All @@ -114,17 +115,17 @@ def basic_measure(
if surveys is None:
raise ValueError("surveys are required in order to use the MR feature.")
survey_name = surveys[0].name
coadd = np.mean(batch["blend_images"][survey_name][idx], axis=channel_indx)
avg_image = np.mean(batch["blend_images"][survey_name][idx], axis=channel_indx)
wcs = batch["wcs"][survey_name]

# single-survey
else:
coadd = np.mean(batch["blend_images"][idx], axis=channel_indx)
avg_image = np.mean(batch["blend_images"][idx], axis=channel_indx)
wcs = batch["wcs"]

# set detection threshold to 5 times std of image
threshold = 5 * np.std(coadd)
coordinates = peak_local_max(coadd, min_distance=2, threshold_abs=threshold)
threshold = 5 * np.std(avg_image)
coordinates = peak_local_max(avg_image, min_distance=2, threshold_abs=threshold)

# construct catalog from measurement.
catalog = astropy.table.Table()
Expand All @@ -145,6 +146,7 @@ def sep_measure(
):
"""Return detection, segmentation and deblending information with SEP.
For each potentially multi-band image, an average over the bands is taken before measurement.
NOTE: If this function is used with the multiresolution feature,
measurements will be carried on the first survey, and deblended images
or segmentations will not be returned.
Expand All @@ -166,19 +168,19 @@ def sep_measure(
raise ValueError("surveys are required in order to use the MR feature.")
survey_name = surveys[0].name
image = batch["blend_images"][survey_name][idx]
coadd = np.mean(image, axis=channel_indx)
avg_image = np.mean(image, axis=channel_indx)
wcs = batch["wcs"][survey_name]

# single-survey
else:
image = batch["blend_images"][idx]
coadd = np.mean(image, axis=channel_indx)
avg_image = np.mean(image, axis=channel_indx)
wcs = batch["wcs"]

stamp_size = coadd.shape[0]
bkg = sep.Background(coadd)
stamp_size = avg_image.shape[0]
bkg = sep.Background(avg_image)
catalog, segmentation = sep.extract(
coadd, sigma_noise, err=bkg.globalrms, segmentation_map=True
avg_image, sigma_noise, err=bkg.globalrms, segmentation_map=True
)

n_objects = len(catalog)
Expand Down Expand Up @@ -230,7 +232,7 @@ def __init__(
isolated images, blend catalog, wcs info, and psf.
cpus: The number of parallel processes to run [Default: 1].
verbose (bool): Whether to print information about measurement.
measure_kwargs (list): list of dictionaries containing keyword arguments
measure_kwargs (list): List of dictionaries containing keyword arguments
to be passed in to each of the `measure_functions`. Each dictionnary is
passed one time to each function, meaning that each function which be
ran as many times as there are different dictionnaries.
Expand Down
2 changes: 1 addition & 1 deletion btk/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def plot_blends(blend_images, blend_list, detected_centers=None, limits=None, ba
ax[0].set_title("gri bands")
ax[0].axis("off")
ax[1].imshow(np.sum(blend_images[i, :, :, :], axis=0))
ax[1].set_title("Coadd")
ax[1].set_title("Sum over bands")
if limits:
ax[1].set_xlim(limits)
ax[1].set_ylim(limits)
Expand Down
11 changes: 6 additions & 5 deletions docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ You can use BTK to directly carry out the measurements on the generated data. To
def sep_measure(batch, idx, channels_last=False, surveys=None, sigma_noise=1.5, **kwargs):
"""Return detection, segmentation and deblending information with SEP.
For each potentially multi-band image, an average over the bands is taken before measurement.
NOTE: If this function is used with the multiresolution feature,
measurements will be carried on the first survey, and deblended images
or segmentations will not be returned.
Expand All @@ -357,19 +358,19 @@ You can use BTK to directly carry out the measurements on the generated data. To
raise ValueError("surveys are required in order to use the MR feature.")
survey_name = surveys[0].name
image = batch["blend_images"][survey_name][idx]
coadd = np.mean(image, axis=channel_indx)
avg_image = np.mean(image, axis=channel_indx)
wcs = batch["wcs"][survey_name]

# single-survey
else:
image = batch["blend_images"][idx]
coadd = np.mean(image, axis=channel_indx)
avg_image = np.mean(image, axis=channel_indx)
wcs = batch["wcs"]

stamp_size = coadd.shape[0]
bkg = sep.Background(coadd)
stamp_size = avg_image.shape[0]
bkg = sep.Background(avg_image)
catalog, segmentation = sep.extract(
coadd, sigma_noise, err=bkg.globalrms, segmentation_map=True
avg_image, sigma_noise, err=bkg.globalrms, segmentation_map=True
)

n_objects = len(catalog)
Expand Down
32 changes: 16 additions & 16 deletions notebooks/00-intro.ipynb

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions notebooks/01b-scarlet-measure.ipynb

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions notebooks/02b-custom-tutorial.ipynb

Large diffs are not rendered by default.

0 comments on commit da6dc62

Please sign in to comment.