-
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
d0d57da
commit 1212490
Showing
9 changed files
with
166 additions
and
16 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
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,65 @@ | ||
""" | ||
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 = 9.0 / 60.0 # WASP is 18 arc minutes each side | ||
|
||
|
||
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["CRVAL1"], unit="hourangle").degree | ||
target_dec = Angle(image["CRVAL2"], 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", "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Module to annotate target coordinates on images. | ||
""" | ||
|
||
from mirar.data import ImageBatch | ||
from mirar.paths import TARGET_KEY, TIME_KEY | ||
|
||
|
||
def annotate_target_coordinates(image_batch: ImageBatch) -> ImageBatch: | ||
""" | ||
Function to annotate target coordinates on images. | ||
For WASP, this should be the value of RA/DEC in the header of the first image. | ||
:param image_batch: ImageBatch object | ||
:return: ImageBatch object | ||
""" | ||
|
||
times = [image[TIME_KEY] for image in image_batch] | ||
min_time = min(times) | ||
first_image = image_batch[times.index(min_time)] | ||
|
||
# In case one of the dithers is mis-named, we'll use the most common name | ||
names = [x[TARGET_KEY] for x in image_batch] | ||
most_common_name = max(set(names), key=names.count) | ||
|
||
for image in image_batch: | ||
image["OBJRA"] = first_image["OBJRA"] | ||
image["OBJDEC"] = first_image["OBJDEC"] | ||
image[TARGET_KEY] = most_common_name | ||
|
||
return image_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
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