galaxy.grabber
Script to fetch cutouts from the legacy survey
Classes
Class for fetching image cutouts from the legacy survey. |
Functions
|
Downloads a file from a given URL with retries in case of errors. |
Module Contents
- galaxy.grabber.download_url(url: str, outfile: str, max_attempts: int = 100) bool
Downloads a file from a given URL with retries in case of errors.
- Args:
url (str): URL of the file to download. outfile (str): Output file path. max_attempts (int, optional): Maximum number of download attempts. Defaults to 100.
- Returns:
bool: True if the download was successful, False otherwise.
- class galaxy.grabber.Grabber(survey_layer: str | None = None, bands: str | None = None, imgsize_arcmin: float = 1.5, imgsize_pix: int = 224, extra_processing: Callable | None = None, extra_processing_kwargs: Dict[Any, Any] = dict())
Class for fetching image cutouts from the legacy survey.
- survey_layer
- bands
- imgsize_arcmin = 1.5
- imgsize_pix = 224
- extra_processing = None
- extra_processing_kwargs
- make_url(ra: float, dec: float, s_arcmin: float = 3.0, s_px: int = 512, format: str = 'fits') str
Creates a URL for fetching an image cutout from the legacy survey.
- Args:
ra (float): Right ascension in degrees. dec (float): Declination in degrees. s_arcmin (float, optional): Size of the image in arcminutes. Defaults to 3.0. s_px (int, optional): Size of the image in pixels. Defaults to 512. format (str, optional): Format of the output file. ‘fits’ or ‘jpeg’. Defaults to “fits”.
- Returns:
str: URL for the cutout.
- separate_band(path_to_file: str)
Fetches bands that were passed into grab_cutout function from the collected fits file and replaces the file with fits containing only required bands.
Args:
- grab_cutout(ra: float, dec: float, output_path: pathlib.Path, file_format: str = 'fits') None
Fetches a single image cutout.
- Args:
ra (float): Right ascension in degrees. dec (float): Declination in degrees. output_path (Path): Output file path. file_format (str): File format (‘fits’ or ‘jpeg’).
- grab_cutouts(targets: pandas.DataFrame, name_col: str = 'name', ra_col: str = 'ra_deg', dec_col: str = 'dec_deg', output_dir: str = '', suffix: str = '', file_format: str = 'fits') None
Function to download image cutouts from any survey.
- Arguments:
- target_file {str, pd.DataFrame} – Input file or DataFrame containing the list of target
coordinates and names.
-
- Keyword Arguments:
- name_col {str} – The column name in target_file that contains the desired file name
(default: {“Component_name”})
ra_col {str} – RA column name (default: {“RA”}) dec_col {str} – Dec column name (default: {“DEC”}) survey {str} – Survey name to pass to the legacy server (default: {“vlass1.2”}) output_dir {str} – Output path for the image cutouts (default: {“”}) prefix {str} – Prefix for the output filename (default {“”}) suffix {str} – Suffix for the output filename (default {survey}) imgsize_arcmin {float} – Image angular size in arcminutes (default: {3.0}) imgsize_pix {int} – Image size in pixels (default: {500})