piXedfit_images

piXedfit.piXedfit_images.EBV_foreground_dust(ra, dec)

Function for estimating E(B-V) associated with the foreground Galactic dust attenuation.

Parameters
  • ra – Right ascension in degree.

  • dec – Declination in degree.

Returns ebv

E(B-V) associated with the foreground Galactic dust.

piXedfit.piXedfit_images.crop_stars_galregion_fits(input_fits, x_cent=[], y_cent=[], radius=[], name_out_fits=None)

A function for cropping foreground stars within a galaxy’s region of interst. The input is a FITS file of reduced multiband fluxes maps output of flux_map() function

Parameters
  • input_fits – The input FITS file.

  • and y_cent (x_cent) – Arrays containing cenral coordinates of the stars.

  • radius – Arrays containing the estimated radii of the stars.

  • name_out_fits – Desired name for the output FITS file. If None, a generic name will be used.

class piXedfit.piXedfit_images.images_processing(filters=[], sci_img={}, var_img={}, gal_ra=None, gal_dec=None, img_unit={}, img_scale={}, flag_psfmatch=0, flag_reproject=0, flag_crop=0, img_pixsizes={}, kernels={}, gal_z=None, stamp_size=[101, 101], remove_files=True)

A Python class for processing of multiband imaging data. The processing basically includes PSF-matching to homogenize the spatial (angular) resolution of the multiband imaging data and spatial-resampling and reprojection to homogenize the pixel size and spatil reprojection of the mulltiband imaging data. A list of imaging data sets that can be handle using this class in the current version of piXedfit can be seen at List of imaging data.

Parameters
  • filters – List of photometric filters names in string format. The accepted naming for the filters can be seen using list_filters() function in the utils.filtering module. It is not mandatory to give the filters names in the wavelength order (from shortest to longest).

  • sci_img – Dictionary containing names of the science images.

  • var_img – Dictionary containing names of the variance images.

  • gal_ra – Coordinate Right Ascension (RA) of the target galaxy.

  • gal_dec – Coordinate Declination (DEC) of the target galaxy.

  • img_unit – (optional) Unit of pixel value in the multiband images. The input format is python dictionary. This input will only be considered (and required) if the input images are not among the default list of recognized imaging data in piXedfit (i.e. GALEX, SDSS, 2MASS, WISE, Spitzer, and Herschel). The allowed units are: (1)”erg/s/cm2/A”, (2) “Jy”, and (3) “MJy/sr”.

  • img_scale – (optional) Scale of the pixel value with respect to the unit in img_unit. For instance, if image is in unit of MJy, the img_unit can be set to be “Jy” and img_scale is set to be 1e+6. This input is only relevant if the input images are not among the default list of recognized images in piXedfit. The format of this input should be in python dictionary.

  • flag_psfmatch – Flag stating whether the multiband imaging data have been PSF-matched or not. The options are: (1) 0 means hasn’t been PSF-matched, and (2)1 means has been PSF-matched.

  • flag_reproject – Flag stating whether the multiband imaging data have been spatially-resampled and matched in the projection. The options are: (1)0 means not yet, and (2)1 means has been carried out.

  • flag_crop – Flag stating whether the multiband imaging data have been cropped around the target galaxy. The options are: (1)0 means not yet, and (2)1 means has been cropped. If flag_crop=0, cropping will be done according to the input stamp_size. If flag_crop=1, cropping will not be done.

  • img_pixsizes – (optional) Pixel sizes (in arcsecond) of the input imaging data. This input should be in dictionary format. If not provided, pixel size will be calculated based on the WCS information in the header of the FITS file.

  • kernels – (optional) Dictionary containing names of FITS files for the kernels to be used for the PSF matching process. If None, internal convolution kernels in piXedfit will be used, given that the imaging data is recognized by piXedfit. Otherwise, input kernels should be supplied. If external kerenels avaiable, the input should be in dictionary format like the input sci_img, but the number of element should be Nb-1, where Nb is the number of photometric bands.

  • gal_z – Galaxy’s redshift. This is not used in any calculation during the image processing and calculating fluxes maps But only intended to be saved in the heder of the produced FITS file.

  • stamp_size – (default: [101,101]) Desired size for the reduced maps of multiband fluxes. This is a list data type with 2 elements. Accepted struture is: [dim_y,dim_x]. Only relevant if flag_crop=0.

  • remove_files – (default: True) If True, the unnecessary image files produced during the image processing will be removed. This can save disk space. If False, those files will not be removed.

flux_map(output_stamps, gal_region, Gal_EBV=None, scale_unit=1e-17, mag_zp_2mass=[], unit_spire='Jy_per_beam', name_out_fits=None)

Function for calculating maps of multiband fluxes

Parameters
  • output_stamps – Dictionary containing reduced multiband images produced by the reduced_stamps() function.

  • gal_region – 2D array containing the galaxy’s region of interest. The vlues should be 0 for masked region and 1 for the galaxy’s region of interest. It can be taken from the output of the galaxy_region() function. But, user can also defined its own.

  • Gal_EBV – (float, optional, default:None) The E(B-V) dust attenuation due to the foreground Galactic dust. This is optional parameter.

  • scale_unit – (float, optional, defult: 1.0e-17) Normalized unit for the fluxes in the output fits file. The unit is flux density in erg/s/cm^2/Ang.

  • mag_zp_2mass – (float array_like, optional, default: []) Magnitude zero-points of 2MASS images. Sshoud be in 1D array with three elements: [magzp-j,magzp-h,magzp-k]. This is optional parameter. If not given (i.e. [] or empty), the values will be taken from the FITS header information.

  • unit_spire – (string, optional, default: ‘Jy_per_beam’) Unit of SPIRE images, in case Herschel/SPIRE image is included in the analysis. Options are: [‘Jy_per_beam’, ‘MJy_per_sr’, ‘Jy_per_pixel’]

  • name_out_fits – (string, optional, default: None) Desired name for the output FITS file. If None, a generic name will be used.

galaxy_region(segm_maps=[], use_ellipse=False, x_cent=None, y_cent=None, ell=0, pa=45.0, radius_sma=30.0)

Define galaxy’s region of interest for further analysis.

Parameters
  • segm_maps – (list of string, optional, default: []) Input segmentation maps in a list format. If the galaxy’s region is to be defined based on segmentation maps obtained with SEP, this input argument is required.

  • use_ellipse – (boolean, optional, default: False) Alternative of defining galaxy’s region using elliptical aperture centered at the target galaxy. Set use_ellipse=True if you want to use this option.

  • x_cent – (float, optional, default: None) x coordinate of the ellipse center. If x_cent=None, the ellipse center is assumed to be the same as the image center.

  • y_cent – (float, optional, default: None) y coordinate of the ellipse center. If y_cent=None, the ellipse center is assumed to be the same as the image center.

  • ell – (float, optional, default: 0.0) Ellipticity of the elliptical aperture.

  • pa – (float, optional, default: 45.0) Position angle of the elliptical aperture.

  • radius_sma – (float, optional, default: 30.0) Radal distance along the semi-major axis of the elliptical aperture. This radius is in pixel unit.

Returns gal_region

(2D array) Output galaxy’s region of interest.

reduced_stamps()

Function within the Class that runs the image processing that includes PSF matching, spatial resampling and reprojection, and cropping around the target galaxy.

Returns output_stamps

Dictionary containing name of postage stamps of reduced multiband images.

segmentation_sep(output_stamps, thresh=1.5, minarea=30, deblend_nthresh=32, deblend_cont=0.005)

Get segmentation maps of a galaxy in multiple bands using the SEP (a Python version of the SExtractor).

Parameters
  • output_stamps – output_stamps output from the reduced_stamps() method.

  • thresh – (float, optional, default: 1.5) Detection threshold for the sources detection. If variance image is supplied, the threshold value for a given pixel is interpreted as a multiplicative factor of the uncertainty (i.e. square root of the variance) on that pixel. If var=None, the threshold is taken to be 2.5 percentile of the pixel values in the image.

  • minarea – (float, optional, default: 5) Minimum number of pixels (above threshold) required for a detected object.

  • deblend_nthresh – (optional, default: 32) The same as deblend_nthresh parameter in the SEP.

  • deblend_cont – (float, optional, default: 0.005) The same as deblend_cont parameter in the SEP.

Returns segm_maps

Output segmentation maps.

piXedfit.piXedfit_images.kpc_per_pixel(z=0.01, arcsec_per_pix=1.5, cosmo='flat_LCDM', H0=70.0, Om0=0.3)

Function for calculating a physical scale (in kpc) corresponding to a pixel size of an imaging data.

Parameters
  • z – (default: 0.01) Redshift of the galaxy.

  • arsec_per_pix – (default: 1.5) Pixel size in arcsecond.

  • cosmo – (default: ‘flat_LCDM’) Choices for the cosmology. The options are: (1)’flat_LCDM’ or 0, (2)’WMAP5’ or 1, (3)’WMAP7’ or 2, (4)’WMAP9’ or 3, (5)’Planck13’ or 4, (6)’Planck15’ or 5, (7)’Planck18’ or 6. These are similar to the choices available in the Astropy Cosmology package.

  • H0 – (default: 70.0) The Hubble constant at z=0. Only relevant when cosmo=’flat_LCDM’ is chosen.

  • Om0 – (default: 0.3) The Omega matter at z=0.0. Only relevant when cosmo=’flat_LCDM’ is chosen.

Returns kpc_per_pix

corresponding physical scale in kpc unit of the given pixel size.

piXedfit.piXedfit_images.subtract_background(fits_image, hdu_idx=0, sigma=3.0, box_size=None, mask_region=[], mask_sources=True, var=None, thresh=1.5, minarea=5, deblend_nthresh=32, deblend_cont=0.005)

Function for estimating 2D background and subtracting it from the input image. This function also produce RMS image. This function adopts the Background2D function from the photutils package. To estimate 2D background, the input image is gridded and sigma clipping is done to each bin/grid. Then 2D interpolation is performed to construct 2D background image. A calculation in this function is based on the Background2D of the photutils.

Parameters
  • fits_image – Input image.

  • hdu_idx – (int, optional, default: 0) The FITS file extension where the image is stored. Default is 0 (HDU0).

  • sigma – (float, optional, default: 3.0) Sigma clipping threshold value.

  • box_size – (int or array_like, optional, default: None) The box size along each axis in the image gridding. The format is: [ny, nx]. If None, both axes will be divided into 10 grids.

  • mask_region – (array_like, optional, default: []) Region within the image that are going to be excluded. mask_region should be 2D array with the same size as the input image.

  • mask_sources – (array_like, default: True) If True, source detection and segmentation will be performed with SEP (Pyhton version of SExtractor) and the regions associated with the detected sources will be excluded. This help reducing contamination by astronomical sources.

  • var – (optional, optional, default: None) Variance image (in FITS file format) to be used in the sources detection process. This input argument is only relevant if mask_sources=True.

  • thresh – (float, optional, default: 1.5) Detection threshold for the sources detection. If variance image is supplied, the threshold value for a given pixel is interpreted as a multiplicative factor of the uncertainty (i.e. square root of the variance) on that pixel. If var=None, the threshold is taken to be 2.5 percentile of the pixel values in the image.

  • minarea – (int, optional, default: 5) Minimum number of pixels above threshold triggering detection.

  • deblend_nthresh – (float, optional, default: 32) The same as deblend_nthresh parameter in the SEP.

  • deblend_cont – (float, optional, default: 0.005) The same as deblend_cont parameter in the SEP.

piXedfit.piXedfit_images.var_img_2MASS(sci_img, skyrms_img=[], skyrms_img_data=[], skyrms_value=None, name_out_fits=None)

Function for deriving a variance image from a 2MASS image. The estimation of uncertainty is based on information from the 2MASS website.

Parameters
  • sci_img – Input science image (i.e., background subtracted).

  • skyrms_img – FITS file of the RMS background image. If skyrms_img_data==[] or skyrms_value==None, this parameter should be provided. The background subtraction and calculation of RMS image can be done using the subtract_background() function.

  • skyrms_img_data – 2D array of the RMS background image.

  • skyrms_value – Scalar value of median or mean of the RMS background image. If the 2D data of RMS is not provided, this value will be used.

  • name_out_fits – (optional, default: None) Desired name for the output FITS file.

piXedfit.piXedfit_images.var_img_GALEX(sci_img, skybg_img, filter_name, name_out_fits=None)

Function for calculating variance image from an input GALEX image

Parameters
  • sci_img – Input GALEX science image (i.e., background subtracted). This type of image is provided in the GALEX website as indicated with “-intbgsub” (i.e., background subtracted intensity map).

  • skybg_img – Input sky background image .

  • filter_name – A string of filter name. Options are: ‘galex_fuv’ and ‘galex_nuv’.

  • name_out_fits – (optional, default: None) Desired name for the output variance image. If None, a generic name will be used.

piXedfit.piXedfit_images.var_img_WISE(sci_img, unc_img, filter_name, skyrms_img, name_out_fits=None)

Function for constructing variance image from an input WISE image. The uncertainty estimation is based on information from the WISE website

Parameters
  • sci_img – Input science image (i.e., background subtracted).

  • unc_img – Input uncertainty image. This type of image is provided in the IRSA website and indicated with ‘-unc-‘ keyword.

  • filter_name – A string of filter name. Options are: ‘wise_w1’, ‘wise_w2’, ‘wise_w3’, and ‘wise_w4’

  • skyrms_img – Input RMS background image. This image is produced in the background subtraction with the subtract_background() function.

  • name_out_fits – (optional, default: None) Desired name for the output FITS file. If None, a generic name will be made.

piXedfit.piXedfit_images.var_img_from_unc_img(unc_image, name_out_fits=None)

Function for constructing a variance image from an input of uncertainty image. This function simply takes square of the uncertainty image and store it into a FITS file while retaining the header information.

Parameters
  • unc_img – Input uncertainty image.

  • name_out_fits – (optional, default: None) Name of output FITS file. If None, a generic name will be generated.

piXedfit.piXedfit_images.var_img_from_weight_img(wht_image, name_out_fits=None)

Function for constructing a variance image from an input weight (i.e., inverse variance) image. This funciton will simply take inverse of the weight image and store it into a new FITS file while retaining the header information.

Parameters

wht_image – Input of weight image (i.e., inverse variance).

Returns name_out_fits

(optional, default: None) Name of output FITS file. If None, a generic name will be used.

piXedfit.piXedfit_images.var_img_sdss(fits_image, filter_name, name_out_fits=None)

A function for constructing a variance image of SDSS image

Parameters
  • fits_image – Input SDSS image (corrected frame type).

  • filter_name – A string of filter name. Options are: ‘sdss_u’, ‘sdss_g’, ‘sdss_r’, ‘sdss_i’, and ‘sdss_z’.

Returns name_out_fits

(optional, default: None) Name of output FITS file. If None, a generic name will be used.