Package: hostphot
Global and local photometry of galaxies hosting supernovae or other transientsRead the full documentation athostphot.readthedocs.io. It is recommended to read theFurther Informationsection to understand how HostPhot works.Conda environmentIt is recommended to create an environment before installing HostPhot:conda create -n hostphot pip
conda activate hostphot
pip install hostphotRequirementsHostPhot has the following requirements:numpy
pandas
matplotlib
python-dotenv
astropy
reproject
photutils
astroquery
extinction
sfdmap
pyvo
sep
ipywidgets (optional: for interactive aperture)
ipympl (optional: for interactive aperture)
ipython (optional: for interactive aperture)
pytest (optional: for testing the code)TestsTo run the tests, go to the parent directory and run the following command:pytest -vModulesCutoutsThis module allows you to download image cutouts from different surveys (e.g.PS1):fromhostphot.cutoutsimportdownload_imagesname='SN2004eo'host_ra,host_dec=308.2092,9.92755# coords of host galaxy of SN2004eosurvey='PS1'download_images(name,host_ra,host_dec,survey=survey)Image Pre-processingCoadds can be created and stars can be masked out of the images:fromhostphot.coaddimportcoadd_imagescoadd_filters='riz'coadd_images(name,filters=coadd_filters,survey=survey)# creates a new fits filefromhostphot.image_maskingimportcreate_mask# one can extract the mask parameters from the coadd# this also creates new fits filescoadd_mask_params=create_mask(name,host_ra,host_dec,filt=coadd_filters,survey=survey,extract_params=True)forfiltin'grizy':create_mask(name,host_ra,host_dec,filt,survey=survey,common_params=coadd_mask_params)If the user is not happy with the result of the masking, there are a few parameters that can be adjusted. For instance,thresholdsets the threshold used bysepfor detecting objects. Lowering it will allow the detection of fainter objects.sigmais the width of the gaussian used for convolving the image and masking the detected objects. Ifcrossmatchis set toTrue, the detected objects are cross-matched with the Gaia catalog and only those in common are kept. This is useful for very nearby host galaxies (e.g. that of SN 2011fe) so the structures of the galaxy are not maked out, artificially lowering its flux.Local PhotometryLocal photometry can be obtained for multiple circular apertures:importhostphot.local_photometryaslpap_radii=[3,4]# aperture radii in units of kpcra,dec=308.22579,9.92853# coords of SN2004eoz=0.0157# redshiftresults=lp.multi_band_phot(name,ra,dec,z,survey=survey,ap_radii=ap_radii,use_mask=True,correct_extinction=True,save_plots=True)If the results returnNaNvalues, this means that the flux is below the detection limit for the given survey.Global PhotometryGlobal photometry can be obtained in a similar way to local photometry, using common aperture:importhostphot.global_photometryasgpresults=gp.multi_band_phot(name,host_ra,host_dec,survey=survey,ra=ra,dec=dec,use_mask=True,correct_extinction=True,common_aperture=True,coadd_filters='riz',save_plots=True)By default, HostPhot corrects for Milky Way extinction using the recalibrated dust maps
by Schlafly & Finkbeiner (2011) and the extinction law from Fitzpatrick (1999).Surveys ListThis is the list of surveys in HostPhot:DESPS1SDSSGALEX2MASSWISEunWISELegacy SurveySpitzer (SEIP)VISTA (VHS, VIDEO, VIKING)HST (WFC3 only)SkyMapper (not well calibrated for extended sources)SPLUSUKIDSSContributingTo contribute, either open an issue or send a pull request (prefered option). You can also contact me directly (check my profile:https://github.com/temuller).Adding other surveysIf you wish a survey to be added to HostPhot, there are a couple of ways of doing it. 1) You can do a pull request, following the same structure as used for the surveys that are already implemented, or 2) open an issue asking for a survey to be added. Either way, there are a fews things needed to add a survey: where to download the images from (e.g., usingastroquery), zero-points to convert the images's flux/counts values into magnitudes, the magnitude system (e.g. AB, Vega), the pixel scaling of the images (in units of arcsec/pixel), the filters transmission functions and any other piece of information necessary to properly estimate magnitudes, errors, etc. If you open an issue asking for a survey to be added, please include all this information. For more information, please check theAdding New Surveyssection of the documentation.Citing HostPhotIf you make use of HostPhot, please cite the followingpaper:@article{Müller-Bravo2022, 
  author = {Tomás E. Müller-Bravo and Lluís Galbany},
  title = {HostPhot: global and local photometry of galaxies hosting supernovae or other transients},
  doi = {10.21105/joss.04508}, 
  url = {https://doi.org/10.21105/joss.04508}, 
  year = {2022}, 
  publisher = {The Open Journal}, 
  volume = {7}, 
  number = {76}, 
  pages = {4508},  
  journal = {Journal of Open Source Software} 
}What's new!v2.9.0Fixing issue when applying/propagating common-mask parameters (e.g. from a coadd) to other imagesUpdated error propagation for Legacy Survey with inverse-variance maps (using it as a weight mask now)Bumping up the DR version of VIKING and VIDEO for VISTAv2.8.0Fix SED plotting with negative or too large values/errors, and improve plotting aestheticsFix problem downloading some 2MASS images giving internal server error (no image overlap)Adding UKIDSS, SPLUS and SkyMapper surveys. WARNINGS: SkyMapper photometry (DR2) is not very accurate with extended sources!The marker showing the galaxy position on images has changed colour for better visualizationAdding functions to easily load previously saved parameteres from pickle filesAdding missing extinction correction for flux (not magnitudes)Including exposure time into flux for PS1, VISTA and UKIDSS surveysAdding SDSS ZP offsets into fluxOutput zeropoint together with the photometryUpdating LegacySurvey errors, taken from inverse-variance maps and ZP uncertaintyAdding missing offsets to unWISE W1 and W2 bands into fluxesKron radius is no longer "optimized", just the scale, which doesn't have any effect in practice for the userv2.7.1Adding SED plottingFixed plotting angle of masked objectv2.7.0MAJOR BUG: Convertion factor between different pixel scales fixed (it was previously inverted). This affects the common aperture photometry between different surveys!Moving font family to_constant.pyfilev2.6.2Prettier plots (now usingaplpy), but also more informative!Scale of the apertures for the masks is now a parameter (r)Raise exception is nowTrueby default when calculating photometryv2.6.12MASS cutouts improved (picking largest image)v2.6.0:HST (WFC3 only - pseudo-trial) included2MASS cutouts fixed (it now downloads the image closest to the given coordinates)v2.5.1:Using sfdmap2 instead of sfdmap to avoid issues with numpy version (requires Python>=3.9)v2.5.0:Systematic error floor added to PS1 photometryAdded missing uncertainties in the error budget of DES (~5 mmag)Flux/counts have been added to output photometryGALEX now downloads images with largest exposure time by defaultFixed image realignment/orientation between different surveys when using common apertures (for masking and global photometry)Added option to output mask parameters, and also aperture parameters for global photometryOption added to set a distant threshold to identify the host galaxy in the image (by default use the nearest object)Slight change in the column names of the local photometry output fileOffsets in SDSS zeropoints to place it in the AB systemoverwrite set to True by default when downloading image cutoutsOther minor bugs fixedv2.4.0:Fixed and improved GALEX cutoutsBetter galaxy identificationBetter output plots for masked imagesOption to return NaN or raise an exception when getting photometryv2.3.2:Improved download of GALEX images (download even if they seem to be just background noise)AcknowledgementsI thank Yuchen LIU for helping me adding Spitzer as part of AstroHackWeek 2022.