-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef9f18e
commit 88a3d8c
Showing
6 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
""" | ||
Module to group images based on the target coordinates into planned stack groups | ||
""" | ||
|
||
from astropy import coordinates as coords | ||
from astropy import units as u | ||
from astropy.coordinates import Angle | ||
|
||
from mirar.data import ImageBatch | ||
from mirar.paths import OBSCLASS_KEY | ||
from mirar.processors.utils.image_selector import split_images_into_batches | ||
|
||
MAX_RADIUS_DEG = 0.2 | ||
|
||
|
||
def label_stack_id(batch: ImageBatch) -> ImageBatch: | ||
""" | ||
Label the stack id of the images in the batch | ||
:param batch: Original batch of images | ||
:return: Labeled batch of images | ||
""" | ||
|
||
ras = [] | ||
decs = [] | ||
|
||
for image in batch: | ||
|
||
if image[OBSCLASS_KEY] != "science": | ||
image["targnum"] = -1 | ||
continue | ||
|
||
target_ra = Angle(image["RA"], unit="hourangle").degree | ||
target_dec = Angle(image["DEC"], unit="degree").degree | ||
|
||
position = coords.SkyCoord(target_ra, target_dec, unit="deg") | ||
|
||
match = None | ||
|
||
if len(ras) > 0: | ||
idx, d2d, _ = position.match_to_catalog_sky( | ||
coords.SkyCoord(ra=ras, dec=decs, unit="deg") | ||
) | ||
|
||
mask = d2d < MAX_RADIUS_DEG * u.deg | ||
if mask: | ||
match = idx | ||
|
||
if match is None: | ||
ras.append(target_ra) | ||
decs.append(target_dec) | ||
image["targnum"] = int(len(ras) - 1) | ||
else: | ||
image["targnum"] = int(match) | ||
|
||
new_batches = split_images_into_batches( | ||
batch, ["targnum", "filter", "telfocus", "exptime"] | ||
) | ||
|
||
combined_batch = ImageBatch() | ||
|
||
for i, split_batch in enumerate(new_batches): | ||
label = f"stack{i}" | ||
for image in split_batch: | ||
image["stackid"] = label | ||
combined_batch.append(image) | ||
|
||
return combined_batch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters