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
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
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
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)