Ejemplo n.º 1
0
    def create_wcs(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Creating the WCS ...")

        min_pixelscale = None

        # Determine the path to the headers directory
        headers_path = fs.join(m81_data_path, "headers")

        # Loop over the header files
        for path, name in fs.files_in_path(headers_path, extension="txt", returns=["path", "name"]):

            # Get the filter
            fltr = parse_filter(name)
            filter_name = str(fltr)

            # Set the path of the file for the filter name
            self.wcs_paths[filter_name] = path

            # Get WCS
            wcs = CoordinateSystem.from_header_file(path)

            # Adjust the pixelscale
            if min_pixelscale is None:
                min_pixelscale = wcs.pixelscale
                self.wcs = wcs
            elif min_pixelscale > wcs.pixelscale:
                min_pixelscale = wcs.pixelscale
                self.wcs = wcs
Ejemplo n.º 2
0
Archivo: test.py Proyecto: rag9704/PTS
    def create_coordinate_systems(self):
        """
        This function ...
        :return: 
        """

        # Inform the user
        log.info("Creating the coordinate systems ...")

        # Loop over the number of frames
        for index in range(self.config.nframes):

            # Get the next filter
            fltr = parse_filter(filter_names[index])

            # Set properties
            size = Extent(self.config.npixels, self.config.npixels)
            center_pixel = size * 0.5
            pixelscale = Pixelscale(1.0, unit="arcsec")

            # Create the coordinate system
            wcs = CoordinateSystem.from_properties(size, center_pixel,
                                                   self.center, pixelscale)

            # Add the wcs
            self.coordinate_systems.append(wcs, fltr)
Ejemplo n.º 3
0
Archivo: test.py Proyecto: SKIRT/PTS
    def create_coordinate_systems(self):

        """
        This function ...
        :return: 
        """

        # Inform the user
        log.info("Creating the coordinate systems ...")

        # Loop over the number of frames
        for index in range(self.config.nframes):

            # Get the next filter
            fltr = parse_filter(filter_names[index])

            # Set properties
            size = Extent(self.config.npixels, self.config.npixels)
            center_pixel = size * 0.5
            pixelscale = Pixelscale(1.0, unit="arcsec")

            # Create the coordinate system
            wcs = CoordinateSystem.from_properties(size, center_pixel, self.center, pixelscale)

            # Add the wcs
            self.coordinate_systems.append(wcs, fltr)
Ejemplo n.º 4
0
Archivo: test.py Proyecto: SKIRT/PTS
    def create_wcs(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Creating the WCS ...")

        min_pixelscale = None

        # Determine the path to the headers directory
        headers_path = fs.join(m81_data_path, "headers")

        # Loop over the header files
        for path, name in fs.files_in_path(headers_path, extension="txt", returns=["path", "name"]):

            # Get the filter
            fltr = parse_filter(name)
            filter_name = str(fltr)

            # Set the path of the file for the filter name
            self.wcs_paths[filter_name] = path

            # Get WCS
            wcs = CoordinateSystem.from_header_file(path)

            # Adjust the pixelscale
            if min_pixelscale is None:
                min_pixelscale = wcs.pixelscale
                self.wcs = wcs
            elif min_pixelscale > wcs.pixelscale:
                min_pixelscale = wcs.pixelscale
                self.wcs = wcs
Ejemplo n.º 5
0
    def wcs(self):
        """
        Thisfunction ...
        :return:
        """

        return CoordinateSystem(header=self.header)
Ejemplo n.º 6
0
Archivo: test.py Proyecto: SKIRT/PTS
def get_coordinate_system(fltr):

    """
    This function ...
    :param fltr: 
    :return: 
    """

    for path, name in fs.files_in_path(headers_path, extension="txt", returns=["path", "name"]):
        header_fltr = parse_filter(name)
        if header_fltr == fltr: return CoordinateSystem.from_header_file(path)
    return None
Ejemplo n.º 7
0
Archivo: test.py Proyecto: SKIRT/PTS
    def create_wcs_not_working(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Creating the WCS ...")

        # Determine the path to the headers directory
        headers_path = fs.join(m81_data_path, "headers")

        # Loop over the files in the directory
        ra_range = None
        dec_range = None
        min_pixelscale = None
        for path, name in fs.files_in_path(headers_path, extension="txt", returns=["path", "name"]):

            # Get the filter
            fltr = parse_filter(name)

            # Get WCS
            wcs = CoordinateSystem.from_header_file(path)

            # Adjust RA range
            if ra_range is None: ra_range = wcs.ra_range
            else: ra_range.adjust(wcs.ra_range)

            # Adjust DEC range
            if dec_range is None: dec_range = wcs.dec_range
            else: dec_range.adjust(wcs.dec_range)

            # Adjust the pixelscale
            if min_pixelscale is None: min_pixelscale = wcs.pixelscale
            elif min_pixelscale > wcs.pixelscale: min_pixelscale = wcs.pixelscale

        # Create coordinate system
        # size, center_pixel, center_sky, pixelscale
        self.wcs = CoordinateSystem.from_ranges(ra_range, dec_range, min_pixelscale)
Ejemplo n.º 8
0
    def create_wcs_not_working(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Creating the WCS ...")

        # Determine the path to the headers directory
        headers_path = fs.join(m81_data_path, "headers")

        # Loop over the files in the directory
        ra_range = None
        dec_range = None
        min_pixelscale = None
        for path, name in fs.files_in_path(headers_path, extension="txt", returns=["path", "name"]):

            # Get the filter
            fltr = parse_filter(name)

            # Get WCS
            wcs = CoordinateSystem.from_header_file(path)

            # Adjust RA range
            if ra_range is None: ra_range = wcs.ra_range
            else: ra_range.adjust(wcs.ra_range)

            # Adjust DEC range
            if dec_range is None: dec_range = wcs.dec_range
            else: dec_range.adjust(wcs.dec_range)

            # Adjust the pixelscale
            if min_pixelscale is None: min_pixelscale = wcs.pixelscale
            elif min_pixelscale > wcs.pixelscale: min_pixelscale = wcs.pixelscale

        # Create coordinate system
        # size, center_pixel, center_sky, pixelscale
        self.wcs = CoordinateSystem.from_ranges(ra_range, dec_range, min_pixelscale)
Ejemplo n.º 9
0
Archivo: test.py Proyecto: rag9704/PTS
def get_coordinate_system(fltr):
    """
    This function ...
    :param fltr: 
    :return: 
    """

    for path, name in fs.files_in_path(headers_path,
                                       extension="txt",
                                       returns=["path", "name"]):
        header_fltr = parse_filter(name)
        if header_fltr == fltr: return CoordinateSystem.from_header_file(path)
    return None
Ejemplo n.º 10
0
Archivo: test.py Proyecto: rag9704/PTS
    def load_coordinate_systems(self):
        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Loading the coordinate systems ...")

        nfilters_stars = 0
        nfilters_extra = 0

        # Loop over the header files
        for path, name in fs.files_in_path(headers_path,
                                           extension="txt",
                                           returns=["path", "name"]):

            # Get the filter and wavelength
            fltr = parse_filter(name)
            wavelength = fltr.effective if fltr.effective is not None else fltr.center

            # SKip Planck
            if fltr.observatory == "Planck": continue

            # Wavelength greater than 25 micron
            if wavelength > wavelengths.ranges.ir.mir.max:

                if nfilters_extra == self.config.nfilters_extra: continue
                else: nfilters_extra += 1

            # Wavelength smaller than 25 micron
            else:

                if nfilters_stars == self.config.nfilters_stars: continue
                else: nfilters_stars += 1

            # Debugging
            log.debug("Loading the coordinate system for the '" + str(fltr) +
                      "' filter ...")

            # Get WCS
            wcs = CoordinateSystem.from_header_file(path)

            # Add the coordinate system
            self.coordinate_systems.append(wcs, fltr=fltr)

            # Break the loop if we have enough
            if nfilters_stars == self.config.nfilters_stars and nfilters_extra == self.config.nfilters_extra:
                break
Ejemplo n.º 11
0
    def create_wcs(self):
        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Creating WCS ...")

        # Create WCS
        size = PixelStretch(1000, 1000)
        center_pixel = PixelCoordinate(500, 500)
        center_sky = self.properties.center
        pixelscale = Pixelscale(parse_quantity("2 arcsec"))
        self.wcs = CoordinateSystem.from_properties(size, center_pixel,
                                                    center_sky, pixelscale)
Ejemplo n.º 12
0
Archivo: test.py Proyecto: SKIRT/PTS
    def load_coordinate_systems(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Loading the coordinate systems ...")

        nfilters_stars = 0
        nfilters_extra = 0

        # Loop over the header files
        for path, name in fs.files_in_path(headers_path, extension="txt", returns=["path", "name"]):

            # Get the filter and wavelength
            fltr = parse_filter(name)
            wavelength = fltr.effective if fltr.effective is not None else fltr.center

            # SKip Planck
            if fltr.observatory == "Planck": continue

            # Wavelength greater than 25 micron
            if wavelength > wavelengths.ranges.ir.mir.max:

                if nfilters_extra == self.config.nfilters_extra: continue
                else: nfilters_extra += 1

            # Wavelength smaller than 25 micron
            else:

                if nfilters_stars == self.config.nfilters_stars: continue
                else: nfilters_stars += 1

            # Debugging
            log.debug("Loading the coordinate system for the '" + str(fltr) + "' filter ...")

            # Get WCS
            wcs = CoordinateSystem.from_header_file(path)

            # Add the coordinate system
            self.coordinate_systems.append(wcs, fltr=fltr)

            # Break the loop if we have enough
            if nfilters_stars == self.config.nfilters_stars and nfilters_extra == self.config.nfilters_extra: break
Ejemplo n.º 13
0
# **       © Astronomical Observatory, Ghent University          **
# *****************************************************************

## \package pts.do.magic.sky_to_pix Convert a sky coordinate to a pixel coordinate for a specific WCS.

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

# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.magic.basics.coordinatesystem import CoordinateSystem

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

definition = ConfigurationDefinition()

definition.add_required("coordinate", "skycoordinate", "the sky coordinate")
definition.add_required("wcs_path", "file_path", "the path to the file holding the WCS info")

# Get the configuration
config = parse_arguments("pix_to_sky", definition)

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

# Print the pixel coordinate
print(config.coordinate.to_pixel(CoordinateSystem.from_file(config.wcs_path)))

# -----------------------------------------------------------------
Ejemplo n.º 14
0
## \package pts.do.magic.pix_to_sky Convert a pixel coordinate to a sky coordinate for a specific WCS.

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

# Ensure Python 3 compatibility
from __future__ import absolute_import, division, print_function

# Import the relevant PTS classes and modules
from pts.core.basics.configuration import ConfigurationDefinition, parse_arguments
from pts.magic.basics.coordinatesystem import CoordinateSystem

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

definition = ConfigurationDefinition()

definition.add_required("coordinate", "pixelcoordinate",
                        "the pixel coordinate")
definition.add_required("wcs_path", "file_path",
                        "the path to the file holding the WCS info")

# Get the configuration
config = parse_arguments("pix_to_sky", definition)

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

# Print the sky coordinate
print(config.coordinate.to_sky(CoordinateSystem.from_file(config.wcs_path)))

# -----------------------------------------------------------------
Ejemplo n.º 15
0
# -----------------------------------------------------------------

# Create the configuration definition
definition = ConfigurationDefinition()
definition.add_positional_optional("galaxy_name", "string", "galaxy name")
definition.add_optional("image", "file_path", "image path")

# Get the configuration
config = parse_arguments("attenuation", definition)

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

# Create attenuation object
if config.image is not None:
    wcs = CoordinateSystem.from_file(config.image)
    attenuation = GalacticAttenuation(wcs.bounding_box.center)
    # or attenuation = GalacticAttenuation(wcs.center_sky)
else: attenuation = GalacticAttenuation(config.galaxy_name)

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

#specs = categorize_filters()
#for label in categorized_filters_sorted_labels(specs):
#    filter_names = specs[label]
#    curve = extinction.extinction_curve(filter_names)
#    plot = Plot()
#    plot.add_curve(curve, "hello")
#    plot.finish()

# -----------------------------------------------------------------
Ejemplo n.º 16
0
# -----------------------------------------------------------------

data_path = fs.join(modeling_path, "data")
prep_path = fs.join(modeling_path, "prep")

galex_images_path = fs.join(data_path, "images", "GALEX")
sdss_images_path = fs.join(data_path, "images", "SDSS")

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

# Path to the reference image
reference_path = fs.join(prep_path, "Pacs red", "initialized.fits")

# Load the reference wcs
reference_wcs = CoordinateSystem.from_file(reference_path)

# Get center coordinate
center_coordinate = reference_wcs.coordinate_range[0]

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

# Create the galactic attenuation calculator
attenuation = GalacticAttenuation(center_coordinate)

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

# The aniano kernels service
aniano = AnianoKernels()

# -----------------------------------------------------------------
Ejemplo n.º 17
0
Archivo: rebin.py Proyecto: rag9704/PTS
definition.add_flag("backup", "make backups", True)

# Parse the command line arguments
config = parse_arguments("rebin", definition)

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

# Load frame list
frames = NamedFrameList.from_directory(config.path, contains=config.contains)

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

# Rebin
if config.name is not None: frames.rebin_to_name(config.name)
elif config.wcs is not None:
    wcs = CoordinateSystem.from_file(config.wcs)
    frames.rebin_to_wcs(wcs)
else:
    frames.rebin_to_highest_pixelscale()

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

# Backup original files
if config.backup:
    fs.backup_files_in_directory(config.path,
                                 extension="fits",
                                 contains=config.contains)

# Save new frames
frames.write_to_directory(config.path, replace=True)
Ejemplo n.º 18
0
modeling_path = verify_modeling_cwd()

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

data_images_path = get_data_images_path(modeling_path)

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

pixelscales = dict()

# Loop over the images
for image_path, image_name in fs.files_in_path(data_images_path, extension="fits", not_contains="poisson", returns=["path", "name"], recursive=True, recursion_level=1):

    # Load the images
    wcs = CoordinateSystem.from_file(image_path)

    # Get pixelscale
    pixelscale = wcs.average_pixelscale

    # Get filter name
    header = get_header(image_path)
    fltr = headers.get_filter(image_name, header)
    filter_name = str(fltr)

    # Set pixelscale
    pixelscales[filter_name] = pixelscale

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

# Sort on pixelscale