Exemplo n.º 1
0
# Load in the region
region_path = fs.join(input_path, arguments.region)
region = Region.from_file(region_path, only=arguments.shapes, color=arguments.color, ignore_color=arguments.ignore_color)

# Inform the user
log.info("Creating a mask from the region ...")

# Create a mask from the region
mask = region.to_mask(frame.xsize, frame.ysize)

# Inform the user
log.info("Interpolating the frame within the masked pixels ...")

# Create a mask of the pixels that are NaNs
nans = Mask.is_nan(frame)

# Set the NaN pixels to zero in the frame
frame[nans] = 0.0

# Interpolate the frame in the masked pixels
if arguments.method == "biharmonic": data = interpolation.inpaint_biharmonic(frame, mask)
elif arguments.method == "local_mean": data = interpolation.in_paint(frame, mask, method="localmean")
else: raise ValueError("Invalid interpolation method (should be 'biharmonic' or 'local_mean')")
new_frame = Frame(data)

# Set the original NaN pixels back to NaN
new_frame[nans] = float("nan")

# Inform the user
log.info("Saving the result ...")
Exemplo n.º 2
0
region = Region.from_file(region_path,
                          only=arguments.shapes,
                          color=arguments.color,
                          ignore_color=arguments.ignore_color)

# Inform the user
log.info("Creating a mask from the region ...")

# Create a mask from the region
mask = region.to_mask(frame.xsize, frame.ysize)

# Inform the user
log.info("Interpolating the frame within the masked pixels ...")

# Create a mask of the pixels that are NaNs
nans = Mask.is_nan(frame)

# Set the NaN pixels to zero in the frame
frame[nans] = 0.0

# Interpolate the frame in the masked pixels
if arguments.method == "biharmonic":
    data = interpolation.inpaint_biharmonic(frame, mask)
elif arguments.method == "local_mean":
    data = interpolation.in_paint(frame, mask, method="localmean")
else:
    raise ValueError(
        "Invalid interpolation method (should be 'biharmonic' or 'local_mean')"
    )
new_frame = Frame(data)
Exemplo n.º 3
0
                    help="invert the mask so that mask covers outside regions")

# Parse the command line arguments
arguments = parser.parse_args()

# -----------------------------------------------------------------

# Load the image
frame = Frame.from_file(arguments.image)

# Load the region
region_name = os.path.splitext(os.path.basename(arguments.region))[0]
region = Region.from_file(arguments.region)

# Create the mask
mask = Mask(region.get_mask(shape=frame.shape))

# Calculate the inverse, if requested
if arguments.invert: mask = mask.inverse()

# -----------------------------------------------------------------

if arguments.data:

    new_frame = frame
    frame[mask] = arguments.value

# Create a frame for the total mask
else:
    new_frame = Frame(mask.astype(int))
Exemplo n.º 4
0
# Determine the full path to the image
image_path = os.path.abspath(arguments.image)

# Determine the full path to the bad region file
bad_region_path = os.path.join(
    arguments.input_path, arguments.bad) if arguments.bad is not None else None

# Import the image
importer = ImageImporter()
importer.run(image_path, bad_region_path=bad_region_path)

# Determine the full path to the mask
mask_path = os.path.abspath(arguments.mask)

# Open the mask frame
mask = Mask.from_file(mask_path)

# -----------------------------------------------------------------

# Determine the full path to the galaxy region file and the saturation region file
galaxy_region_path = os.path.join(arguments.input_path, arguments.galaxies)
saturation_region_path = os.path.join(
    arguments.input_path,
    arguments.saturation) if arguments.saturation is not None else None

# Create a SkySubtractor instance and configure it according to the command-line arguments
subtractor = SkySubtractor.from_arguments(arguments)

# Run the subtractor
subtractor.run(importer.image.frames.primary,
               mask,
Exemplo n.º 5
0
parser.add_argument('--invert', action="store_true", help="invert the mask so that mask covers outside regions")

# Parse the command line arguments
arguments = parser.parse_args()

# -----------------------------------------------------------------

# Load the image
frame = Frame.from_file(arguments.image)

# Load the region
region_name = os.path.splitext(os.path.basename(arguments.region))[0]
region = Region.from_file(arguments.region)

# Create the mask
mask = Mask(region.get_mask(shape=frame.shape))

# Calculate the inverse, if requested
if arguments.invert: mask = mask.inverse()

# -----------------------------------------------------------------

if arguments.data:
    
    new_frame = frame
    frame[mask] = arguments.value
    
# Create a frame for the total mask
else: new_frame = Frame(mask.astype(int))

# Write out the new frame