mirar.references.wfcam package
Subpackages
Submodules
mirar.references.wfcam.utils module
Utility functions for WFCAM
- mirar.references.wfcam.utils.combine_headers(primary_header: Header, header_to_append: Header)[source]
Function to append a header to another Args:
- param primary_header:
- param header_to_append:
- Returns:
- return:
combined header
- mirar.references.wfcam.utils.find_wfcam_surveys(ra: float, dec: float, band: str, telescope: str) list[MOCSurvey][source]
Find which UKIRT survey does the given RA/Dec belong to Args:
- param ra:
RA in degrees
- param dec:
Dec in degrees
- param band:
band name
- param telescope:
telescope name UKIRT or VISTA
- Returns:
- return:
list of surveys
- mirar.references.wfcam.utils.get_query_coordinates_from_header(header: Header, numpoints: int = 1)[source]
Function to get break an image into numpoints sections and get the relevant coordinates Args:
- param header:
header of the image
- param numpoints:
number of points to break the image into
- Returns:
- return:
list of RA and Dec coordinates
- mirar.references.wfcam.utils.get_wfcam_basename(multiframeid: int, extension_id: int) str[source]
Get the WFCAM basename
- Parameters:
multiframeid – Multiframeid of the UKIRT image
extension_id – Extension id of the UKIRT image
- Returns:
Compressed file name
- mirar.references.wfcam.utils.get_wfcam_file_identifiers_from_url(url: str) list[source]
Function to get the UKIRT file identifiers from the URL Args:
- param url:
URL of the UKIRT image
- Returns:
- return:
list of identifiers
- mirar.references.wfcam.utils.make_wfcam_image_from_hdulist(ukirt_hdulist: [<class 'astropy.io.fits.hdu.image.PrimaryHDU'>, <class 'astropy.io.fits.hdu.image.ImageHDU'>], multiframeid: int, extension_id: int, ukirt_filename: str) Image[source]
Function to convert a ukirt image with two headers to a single header image Args:
- param ukirt_hdulist:
HDUList with two headers
- param multiframeid:
multiframeid of UKIRT image
- param extension_id:
extension id of UKIRT image
- param ukirt_filename:
filename of UKIRT image
- Returns:
- return:
Image object
mirar.references.wfcam.wfcam_query module
Module to query for WFCAM images. You can either query the online WFAU archive, or query a local database to get component images.
- class mirar.references.wfcam.wfcam_query.BaseWFCAMQuery(filter_name: str, num_query_points: int = 4, query_coords_function: ~typing.Callable[[~astropy.io.fits.header.Header, int], tuple[list[float], list[float]]] = <function get_query_coordinates_from_header>, component_image_subdir: str | ~pathlib.Path = None)[source]
Bases:
objectBase class for querying WFCAM images
- run_query(image: Image) ImageBatch[source]
Run the query for the given image :param image: Image to query for :return: ImageBatch containing the queried images
- exception mirar.references.wfcam.wfcam_query.NotinWFCAMError[source]
Bases:
ProcessorErrorError when the coordinates are not in WFAU footprint
- class mirar.references.wfcam.wfcam_query.WFAUQuery(filter_name: str, num_query_points: int = 4, query_coords_function: ~typing.Callable[[~astropy.io.fits.header.Header, int], tuple[list[float], list[float]]] = <function get_query_coordinates_from_header>, component_image_subdir: str = 'wfau_components', use_db_for_component_queries: bool = False, components_db_table: ~typing.Type[~mirar.database.base_model.BaseDB] | None = None, query_db_table: ~typing.Type[~mirar.database.base_model.BaseDB] | None = None, skip_online_query: bool = False, include_vista: bool = False)[source]
Bases:
BaseWFCAMQueryClass to handle queries to the online WFAU archive. To reduce the number of queries to the server, the user can optionally choose to set up databases. If this is chosen, this script currently assumes the following database structure -> 1. Two tables : query_db_table and components_db_table a. query_db_table : This table stores the details of the queries. The following columns are required - query_ra, query_dec, query_filt, compid (primary key of the table entry of the image downloaded). b. components_db_table : This table stores the details of the individual downloaded images. The following columns are required - compid (primary_key), savepath (saved path) , mfid (multiframeid), xtnsnid (extension_id), (paramters used to uniquely identify a WFCAM image). It is recommended to use the database model files from mirar/pipelines/winter/models/ref_queries.py and mirar/pipelines/winter/models/ref_components.py to set up the tables in your database.
1. The user specifies an image and the filter to query and optionally the database details. 2. The image is broken down into user-specified number of coordinates to get overlapping images from the archive. 3. If the user has specified database details, each coordinate is checked against the query database to see if it has been queried before. If so, the corresponding component images from the comoponent_db_table are used. 4. If not, the query is made to the WFAU server to get the URLs of the images. The details of each image are extracted from the URL. 5. If the user has specified database details, the image details are xmatched to the database to see if the image has been downloaded before. If so, the corresponding image is used. 6. If not, the image is downloaded and saved to the user-specified path. 7. If the user has specified database details, the details of the downloaded image and the query are ingested into the respective tables.
- get_query_class() BaseWFAUClass[source]
Get the class that will be used to query the WFAU database, e.g. VSAClass or UKIDSSClass :return: Class that will be used to query the WFAU database
- get_query_crds(header: Header, num_query_points: int) tuple[list[float], list[float]][source]
Get the query coordinates from the header. :param header: Header of the image. :param num_query_points: Number of points to use to define the query region. The image is divided into np.sqrt(num_query_points) x np.sqrt(num_query_points) regions. :return: Tuple of lists of RA and Dec coordinates.
- get_surveys_query_class(ra: float, dec: float) -> (list[astrosurveyutils.surveys.MOCSurvey], <class 'astroquery.wfau.core.BaseWFAUClass'>)[source]
Get the surveys that are available at the given coordinates :param ra: RA of the coordinates :param dec: Dec of the coordinates :return: List of surveys that are available at the given coordinates :return: Class that will be used to query the WFAU database
- run_query(image: Image) ImageBatch[source]
Run the query on the UKIRT server. :param image: Image object with the coordinates of the image. :return: ImageBatch object with the downloaded images.
- run_wfau_query(image: Image) ImageBatch[source]
Run the query to the WFAU database. :param image: Image to query around. :return: ImageBatch with the results of the query.
- exception mirar.references.wfcam.wfcam_query.WFAUQueryDBError[source]
Bases:
ProcessorErrorError related to the databases while querying
- exception mirar.references.wfcam.wfcam_query.WFAURefError[source]
Bases:
ProcessorErrorBase UKIRTRef error
- exception mirar.references.wfcam.wfcam_query.WFCAMRefNotFoundError[source]
Bases:
ProcessorErrorError when WFCAM ref is not found for some reason
- mirar.references.wfcam.wfcam_query.check_multiframe_exists_locally(db_table: Type[BaseDB], multiframe_id: int, extension_id: int) list[Path][source]
Function to query database to check if a multiframe exists locally Args:
- param db_table:
table with multiframe details
- param multiframe_id:
multiframe id
- param extension_id:
extension id
- Returns:
- return:
list of savepaths
- mirar.references.wfcam.wfcam_query.check_query_exists_locally(query_ra: float, query_dec: float, query_filt: str, query_table: Type[BaseDB], components_table: Type[BaseDB]) list[Path][source]
Function to check if component images exist locally based on the query_ra and query_dec Args:
- param query_ra:
ra that was queried
- param query_dec:
dec that was queried
- param query_filt:
filter that was queried
- param query_table:
table with query details
- param components_table:
table with component image details
- Returns:
- return:
list of savepaths
- mirar.references.wfcam.wfcam_query.download_wfcam_archive_images(crd: ~astropy.coordinates.sky_coordinate.SkyCoord, wfau_query: ~astroquery.wfau.core.BaseWFAUClass, survey_name: str, waveband: str, save_dir_path: ~pathlib.Path, image_width: ~astropy.units.quantity.Quantity = <Quantity 90. arcmin>, image_height: ~astropy.units.quantity.Quantity = <Quantity 90. arcmin>, use_local_database: bool = False, components_table: ~typing.Type[~mirar.database.base_model.BaseDB] = None, duplicate_protocol: str = 'ignore', undeprecated_compids_file: ~pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/mirar/checkouts/latest/mirar/references/wfcam/files/wfcam_undeprecated_compids.csv')) list[Path][source]
Download the image from UKIRT server. Optionally, check if the image exists locally and ingest it into a database. :param crd: SkyCoord object with the coordinates of the image. :param wfau_query: WFAU query object. :param survey_name: Name of the survey to query. :param waveband: Waveband of the image. :param save_dir_path: Path to the directory where the image will be saved. :param image_width: Width of the image to download. :param image_height: Height of the image to download. :param use_local_database: If True, check if the image exists locally and ingest it into a database. :param components_table: Table to use for the components database. :param duplicate_protocol: Protocol to follow if the image already exists locally. :param undeprecated_compids_file: Path to the file with the list of undeprecated component ids. :return imagepaths: List of paths to the downloaded images.
- mirar.references.wfcam.wfcam_query.get_locally_existing_overlap_images(query_ra: float, query_dec: float, query_filt: str, components_table: Type[BaseDB]) list[Path][source]
Function to get the locally existing images that overlap with the given coordinates Args:
- param query_ra:
ra that was queried
- param query_dec:
dec that was queried
- param query_filt:
filter that was queried
- param components_table:
table with component image details
- Returns:
- return:
list of savepaths
mirar.references.wfcam.wfcam_stack module
Module for creating stacked reference images from WFCAM (UKIRT/VISTA) surveys. This module can be used to query THe WFAU service to download NIR images. Only single extension images overlapping with the specified coordinates are downloaded. These images are then stacked together.
This module works in the following way - 1. Images are queried using the type of query specified by the user. Query needs to be inherited from BaseWFCAMQuery. 2. The queried images are filtered to remove images with wildly different zeropoints and poor seeings. The remaining images are stacked together using SWarp. The median zeropoint is assigned to the stacked image. 3. The stacked image is optionally saved to the user-specified path and inserted into a user-specified stack-table in the database by the parent class.
- class mirar.references.wfcam.wfcam_stack.WFCAMStackedRef(filter_name: str, image_resampler_generator: ~collections.abc.Callable[[...], ~mirar.processors.astromatic.swarp.swarp.Swarp], wfcam_query: ~mirar.references.wfcam.wfcam_query.BaseWFCAMQuery, write_stacked_image: bool = True, write_stack_sub_dir: str = 'references/ref_stacks', write_stack_to_db: bool = False, stacks_db_table: ~typing.Type[~mirar.database.base_model.BaseDB] = None, component_image_sub_dir: str = None, references_base_subdir_name: str = 'references', stack_image_annotator: ~collections.abc.Callable[[~mirar.data.image_data.Image], ~mirar.data.image_data.Image] = None, photcal_stack: bool = False, sextractor_generator: ~collections.abc.Callable[[...], ~mirar.processors.astromatic.sextractor.sextractor.Sextractor] = None, phot_calibrator_generator: ~collections.abc.Callable[[...], ~mirar.processors.photcal.photcalibrator.PhotCalibrator] = None, filter_images: ~collections.abc.Callable[[~mirar.data.image_data.ImageBatch], ~mirar.data.image_data.ImageBatch] = <function default_filter_wfau_images>)[source]
Bases:
BaseStackReferenceGenerator,ImageHandlerClass to query UKIRT images from the WFAU archive and stack them together
- abbreviation = 'wfcam_stack_online_ref'
- get_component_images(image: Image) ImageBatch[source]
Function to get the component images for a given image Args:
- param image:
Image for which the component images are to be found
- return:
ImageBatch of component images
- mirar.references.wfcam.wfcam_stack.default_filter_wfau_images(image_batch: ImageBatch) ImageBatch[source]
Function to filter WFAU images based on zeropoints and seeing. The images are filtered to remove images with wildly different zeropoints (more than 0.4 mag from the median zeropoint) and seeing <= 0 or > 3.5 arcsec. Args:
- param image_batch:
ImageBatch
- Returns:
- return:
Filtered image batch