astrophot package#
Subpackages#
- astrophot.errors package
- astrophot.fit package
- Subpackages
- Submodules
- astrophot.fit.base module
- astrophot.fit.gradient module
- astrophot.fit.hmc module
- astrophot.fit.iterative module
- astrophot.fit.lm module
- astrophot.fit.mala module
- astrophot.fit.mhmcmc module
- astrophot.fit.scipy_fit module
- Module contents
- astrophot.image package
- Subpackages
- Submodules
- astrophot.image.cmos_image module
- astrophot.image.image_object module
ImageImage.base_scaleImage.blank_copy()Image.centerImage.coordinate_center_meshgrid()Image.coordinate_corner_meshgrid()Image.coordinate_quad_meshgrid()Image.coordinate_simpsons_meshgrid()Image.copy()Image.copy_kwargs()Image.corners()Image.crop()Image.crpixImage.dataImage.expect_ctypeImage.fits_images()Image.fits_info()Image.flatten()Image.flip_ra_axisImage.get_astropywcs()Image.get_indices()Image.get_other_indices()Image.get_window()Image.identityImage.load()Image.pixel_areaImage.pixel_center_meshgrid()Image.pixel_collecting_area()Image.pixel_corner_meshgrid()Image.pixel_quad_meshgrid()Image.pixel_simpsons_meshgrid()Image.pixel_to_plane()Image.pixel_to_world()Image.pixelscaleImage.plane_to_pixel()Image.plane_to_world()Image.reduce()Image.save()Image.to()Image.windowImage.world_to_pixel()Image.world_to_plane()Image.zeropoint
ImageList
- astrophot.image.jacobian_image module
- astrophot.image.model_image module
- astrophot.image.psf_image module
PSFImagePSFImage.base_scalePSFImage.coordinate_center_meshgrid()PSFImage.coordinate_corner_meshgrid()PSFImage.coordinate_quad_meshgrid()PSFImage.coordinate_simpsons_meshgrid()PSFImage.copy()PSFImage.copy_kwargs()PSFImage.crpixPSFImage.dataPSFImage.fits_info()PSFImage.flatten()PSFImage.flip_ra_axisPSFImage.get_indices()PSFImage.get_window()PSFImage.identityPSFImage.jacobian_image()PSFImage.model_image()PSFImage.mypixel_to_targpixel()PSFImage.normalize()PSFImage.padPSFImage.pixel_areaPSFImage.pixel_center_meshgrid()PSFImage.pixel_collecting_area()PSFImage.pixel_corner_meshgrid()PSFImage.pixel_quad_meshgrid()PSFImage.pixel_simpsons_meshgrid()PSFImage.pixelscalePSFImage.reduce()PSFImage.targpixel_to_mypixel()PSFImage.upsamplePSFImage.windowPSFImage.zeropoint
- astrophot.image.sip_image module
- astrophot.image.target_image module
- astrophot.image.window module
- Module contents
CMOSModelImageCMOSTargetImageImageImage.base_scaleImage.blank_copy()Image.centerImage.coordinate_center_meshgrid()Image.coordinate_corner_meshgrid()Image.coordinate_quad_meshgrid()Image.coordinate_simpsons_meshgrid()Image.copy()Image.copy_kwargs()Image.corners()Image.crop()Image.crpixImage.dataImage.expect_ctypeImage.fits_images()Image.fits_info()Image.flatten()Image.flip_ra_axisImage.get_astropywcs()Image.get_indices()Image.get_other_indices()Image.get_window()Image.identityImage.load()Image.pixel_areaImage.pixel_center_meshgrid()Image.pixel_collecting_area()Image.pixel_corner_meshgrid()Image.pixel_quad_meshgrid()Image.pixel_simpsons_meshgrid()Image.pixel_to_plane()Image.pixel_to_world()Image.pixelscaleImage.plane_to_pixel()Image.plane_to_world()Image.reduce()Image.save()Image.to()Image.windowImage.world_to_pixel()Image.world_to_plane()Image.zeropoint
ImageBatchMixinImageListJacobianImageJacobianImageBatchJacobianImageListModelImageModelImageBatchModelImageListPSFImagePSFImage.base_scalePSFImage.coordinate_center_meshgrid()PSFImage.coordinate_corner_meshgrid()PSFImage.coordinate_quad_meshgrid()PSFImage.coordinate_simpsons_meshgrid()PSFImage.copy()PSFImage.copy_kwargs()PSFImage.crpixPSFImage.dataPSFImage.fits_info()PSFImage.flatten()PSFImage.flip_ra_axisPSFImage.get_indices()PSFImage.get_window()PSFImage.identityPSFImage.jacobian_image()PSFImage.model_image()PSFImage.mypixel_to_targpixel()PSFImage.normalize()PSFImage.padPSFImage.pixel_areaPSFImage.pixel_center_meshgrid()PSFImage.pixel_collecting_area()PSFImage.pixel_corner_meshgrid()PSFImage.pixel_quad_meshgrid()PSFImage.pixel_simpsons_meshgrid()PSFImage.pixelscalePSFImage.reduce()PSFImage.targpixel_to_mypixel()PSFImage.upsamplePSFImage.windowPSFImage.zeropoint
SIPModelImageSIPTargetImageTargetImageTargetImageBatchTargetImageListWindowWindowBatchWindowList
- astrophot.models package
- Subpackages
- astrophot.models.func package
- Submodules
- astrophot.models.func.base module
- astrophot.models.func.convolution module
- astrophot.models.func.exponential module
- astrophot.models.func.ferrer module
- astrophot.models.func.gaussian module
- astrophot.models.func.gaussian_ellipsoid module
- astrophot.models.func.integration module
- astrophot.models.func.king module
- astrophot.models.func.moffat module
- astrophot.models.func.nuker module
- astrophot.models.func.sersic module
- astrophot.models.func.spline module
- astrophot.models.func.transform module
- astrophot.models.func.zernike module
- Module contents
- astrophot.models.mixins package
- Submodules
- astrophot.models.mixins.brightness module
- astrophot.models.mixins.exponential module
- astrophot.models.mixins.ferrer module
- astrophot.models.mixins.gaussian module
- astrophot.models.mixins.king module
- astrophot.models.mixins.moffat module
- astrophot.models.mixins.nuker module
- astrophot.models.mixins.sample module
- astrophot.models.mixins.sersic module
- astrophot.models.mixins.spline module
- astrophot.models.mixins.transform module
- Module contents
- astrophot.models.func package
- Submodules
- astrophot.models.airy module
- astrophot.models.base module
ModelModel.List_Models()Model.angular_metric()Model.build_parameter_specs()Model.gaussian_log_likelihood()Model.hessian()Model.model_typeModel.optionsModel.parameter_specsModel.poisson_log_likelihood()Model.radius_metric()Model.softeningModel.to()Model.total_flux()Model.total_flux_uncertainty()Model.total_magnitude()Model.total_magnitude_uncertainty()Model.usableModel.window
- astrophot.models.basis module
- astrophot.models.basis_psf module
- astrophot.models.batch_model_object module
- astrophot.models.bilinear_sky module
- astrophot.models.edgeon module
- astrophot.models.flatsky module
- astrophot.models.galaxy_model_object module
- astrophot.models.gaussian_ellipsoid module
- astrophot.models.group_model_object module
- astrophot.models.group_psf_model module
- astrophot.models.model_object module
- astrophot.models.multi_gaussian_expansion module
- astrophot.models.pixelated_model module
- astrophot.models.pixelated_psf module
- astrophot.models.planesky module
- astrophot.models.point_source module
- astrophot.models.psf_model_object module
- astrophot.models.radial module
ExponentialFourierEllipseExponentialGalaxyExponentialRayExponentialSuperEllipseExponentialWarpExponentialWedgeFerrerFourierEllipseFerrerGalaxyFerrerRayFerrerSuperEllipseFerrerWarpFerrerWedgeGaussianFourierEllipseGaussianGalaxyGaussianRayGaussianSuperEllipseGaussianWarpGaussianWedgeKingFourierEllipseKingGalaxyKingRayKingSuperEllipseKingWarpKingWedgeMoffatFourierEllipseMoffatGalaxyMoffatRayMoffatSuperEllipseMoffatWarpMoffatWedgeNukerFourierEllipseNukerGalaxyNukerRayNukerSuperEllipseNukerWarpNukerWedgeSersicFourierEllipseSersicGalaxySersicRaySersicSuperEllipseSersicWarpSersicWedgeSplineFourierEllipseSplineGalaxySplineRaySplineSuperEllipseSplineWarpSplineWedgeTExponentialFourierEllipseTExponentialGalaxyTExponentialSuperEllipseTExponentialWarpTFerrerFourierEllipseTFerrerGalaxyTFerrerSuperEllipseTFerrerWarpTGaussianFourierEllipseTGaussianGalaxyTGaussianSuperEllipseTGaussianWarpTKingFourierEllipseTKingGalaxyTKingSuperEllipseTKingWarpTMoffatFourierEllipseTMoffatGalaxyTMoffatSuperEllipseTMoffatWarpTNukerFourierEllipseTNukerGalaxyTNukerSuperEllipseTNukerWarpTSersicFourierEllipseTSersicGalaxyTSersicSuperEllipseTSersicWarpTSplineFourierEllipseTSplineGalaxyTSplineSuperEllipseTSplineWarp
- astrophot.models.radial_psf module
ExponentialPSFExponentialPSFEllipseExponentialPSFFourierEllipseExponentialPSFSuperEllipseExponentialPSFWarpFerrerPSFFerrerPSFEllipseFerrerPSFFourierEllipseFerrerPSFSuperEllipseFerrerPSFWarpGaussianPSFGaussianPSFEllipseGaussianPSFFourierEllipseGaussianPSFSuperEllipseGaussianPSFWarpKingPSFKingPSFEllipseKingPSFFourierEllipseKingPSFSuperEllipseKingPSFWarpMoffatPSFMoffatPSFEllipseMoffatPSFFourierEllipseMoffatPSFSuperEllipseMoffatPSFWarpNukerPSFNukerPSFEllipseNukerPSFFourierEllipseNukerPSFSuperEllipseNukerPSFWarpSersicPSFSersicPSFEllipseSersicPSFFourierEllipseSersicPSFSuperEllipseSersicPSFWarpSplinePSFSplinePSFEllipseSplinePSFFourierEllipseSplinePSFSuperEllipseSplinePSFWarp
- astrophot.models.sky_model_object module
- Module contents
AiryPSFBasisModelBatchModelBilinearSkyComponentModelEdgeonIsothermalEdgeonModelEdgeonSechExponentialFourierEllipseExponentialGalaxyExponentialMixinExponentialPSFExponentialPSFEllipseExponentialPSFFourierEllipseExponentialPSFSuperEllipseExponentialPSFWarpExponentialRayExponentialSuperEllipseExponentialWarpExponentialWedgeFerrerFourierEllipseFerrerGalaxyFerrerMixinFerrerPSFFerrerPSFEllipseFerrerPSFFourierEllipseFerrerPSFSuperEllipseFerrerPSFWarpFerrerRayFerrerSuperEllipseFerrerWarpFerrerWedgeFlatSkyFourierEllipseMixinGalaxyModelGaussianEllipsoidGaussianFourierEllipseGaussianGalaxyGaussianMixinGaussianPSFGaussianPSFEllipseGaussianPSFFourierEllipseGaussianPSFSuperEllipseGaussianPSFWarpGaussianRayGaussianSuperEllipseGaussianWarpGaussianWedgeGroupModelInclinedMixinKingFourierEllipseKingGalaxyKingMixinKingPSFKingPSFEllipseKingPSFFourierEllipseKingPSFSuperEllipseKingPSFWarpKingRayKingSuperEllipseKingWarpKingWedgeModelModel.List_Models()Model.angular_metric()Model.build_parameter_specs()Model.gaussian_log_likelihood()Model.hessian()Model.model_typeModel.optionsModel.parameter_specsModel.poisson_log_likelihood()Model.radius_metric()Model.softeningModel.to()Model.total_flux()Model.total_flux_uncertainty()Model.total_magnitude()Model.total_magnitude_uncertainty()Model.usableModel.window
MoffatFourierEllipseMoffatGalaxyMoffatMixinMoffatPSFMoffatPSFEllipseMoffatPSFFourierEllipseMoffatPSFSuperEllipseMoffatPSFWarpMoffatRayMoffatSuperEllipseMoffatWarpMoffatWedgeMultiGaussianExpansionNukerFourierEllipseNukerGalaxyNukerMixinNukerPSFNukerPSFEllipseNukerPSFFourierEllipseNukerPSFSuperEllipseNukerPSFWarpNukerRayNukerSuperEllipseNukerWarpNukerWedgePSFGroupModelPSFModelPixelBasisPSFPixelatedPixelatedPSFPlaneSkyPointSourceRadialMixinRayMixinSampleMixinSersicFourierEllipseSersicGalaxySersicMixinSersicPSFSersicPSFEllipseSersicPSFFourierEllipseSersicPSFSuperEllipseSersicPSFWarpSersicRaySersicSuperEllipseSersicWarpSersicWedgeSkyModelSplineFourierEllipseSplineGalaxySplineMixinSplinePSFSplinePSFEllipseSplinePSFFourierEllipseSplinePSFSuperEllipseSplinePSFWarpSplineRaySplineSuperEllipseSplineWarpSplineWedgeSuperEllipseMixinTruncationMixinWarpMixinWedgeMixiniExponentialMixiniFerrerMixiniGaussianMixiniKingMixiniMoffatMixiniNukerMixiniSersicMixiniSplineMixin
- Subpackages
- astrophot.param package
- astrophot.plots package
- astrophot.utils package
Submodules#
astrophot.backend_obj module#
astrophot.config module#
- astrophot.config.set_logging_output(stdout=True, filename=None, **kwargs)[source]#
Change the logging system for AstroPhot. Here you can set whether output prints to screen or to a logging file. This function will remove all handlers from the current logger in logger, then add new handlers based on the input to the function.
- Parameters:
stdout (bool): If True, log messages will be printed to the console (standard output). Default is True. filename (str): If given as a string, this will be the name of the file that log messages are written to.
If None, no logging file will be used. Default is None.
- stdout_level (logging.INFO): The logging level of messages written to stdout, this can be different from the file level.
Default is logging.INFO.
stdout_formatter (logging.Formatter): A logging.Formatter object which determines what information to include with the logging message only when printing to stdout. Default is logging.Formatter(‘%(message)s’). filename_level (int): The logging level of messages written to the log file, this can be different from the stdout level. Default is logging.INFO. filename_formatter (logging.Formatter): A logging.Formatter object which determines what information to include with the logging message only when printing to the log file. Default is logging.Formatter(‘%(asctime)s:%(levelname)s: %(message)s’).
Module contents#
- class astrophot.CMOSModelImage(*args, subpixel_loc: Tuple[float, float] = (0, 0), subpixel_scale: float = 1.0, filename: str | None = None, **kwargs)[source]#
Bases:
CMOSMixin,ModelImageA ModelImage with CMOS-specific functionality.
CMOSMixin
A mixin class for CMOS image processing. This class can be used to add CMOS-specific functionality to image processing classes.
ModelImage
Image object which represents the sampling of a model at the given coordinates of the image. Extra arithmetic operations are available which can update model values in the image. The whole model can be shifted by less than a pixel to account for sub-pixel accuracy.
Image
Core class to represent images with pixel values, pixel scale, and a window defining the spatial coordinates on the sky. It supports arithmetic operations with other image objects while preserving logical image boundaries. It also provides methods for determining the coordinate locations of pixels
- Parameters:
crval – The reference coordinate of the image in degrees [RA, DEC]. [model param]
crtan – The tangent plane coordinate of the image in arcseconds [x, y]. [model param]
CD – The coordinate transformation matrix in arcseconds/pixel. [model param]
crpix – The reference pixel coordinates in the image, which is used to convert from pixel coordinates to tangent plane coordinates. This is not a model param and is fixed for a given image.
data – The image data as a Array of pixel values. If not provided, a Array of zeros will be created.
zeropoint – The zeropoint of the image, which is used to convert from pixel flux to magnitude.
pixelscale – The side length of a pixel, used to create a simple diagonal CD matrix.
wcs – An optional Astropy WCS object to initialize the image.
filename – The filename to load the image from. If provided, the image will be loaded from the file.
hduext – The HDU extension to load from the FITS file specified in filename.
identity – An optional identity string for the image (mostly used internally).
- class astrophot.CMOSTargetImage(*args, subpixel_loc: Tuple[float, float] = (0, 0), subpixel_scale: float = 1.0, filename: str | None = None, **kwargs)[source]#
Bases:
CMOSMixin,TargetImageA TargetImage with CMOS-specific functionality. This class is used to represent a target image with CMOS-specific features. It inherits from TargetImage and CMOSMixin.
CMOSMixin
A mixin class for CMOS image processing. This class can be used to add CMOS-specific functionality to image processing classes.
TargetImage
Image object which represents the data to be fit by a model. It can include a variance image, mask, and PSF as anciliary data which describes the target image.
Target images are a basic unit of data in AstroPhot, they store the information collected from telescopes for which models are to be fit. There is minimal functionality in the Target_Image object itself, it is mostly defined in terms of how other objects interact with it.
Basic usage:
Some important information to keep in mind. First, providing an astropy WCS object is the best way to keep track of coordinates and pixel scale properties, especially when dealing with multi-band data. If images have relative positioning, rotation, pixel sizes, field of view this will all be handled automatically by taking advantage of WCS objects. Second, Providing accurate variance (or weight) maps is critical to getting a good fit to the data. This is a very common source of issues so it is worthwhile to review literature on how best to construct such a map. A good starting place is the FAQ for GALFIT: https://users.obs.carnegiescience.edu/peng/work/galfit/CHI2.html which is an excellent resource for all things image modeling. Just note that AstroPhot uses variance or weight maps, not sigma images. AstroPhot will not crete a variance map for the user, by default it will just assume uniform variance which is rarely accurate. Third, The PSF pixelscale must be a multiple of the image pixelscale. So if the image has a pixelscale of 1 then the PSF must have a pixelscale of 1, 1/2, 1/3, etc for anything to work out. Note that if the PSF pixelscale is finer than the image, then all modelling will be done at the higher resolution. This is recommended for accuracy though it can mean higher memory consumption.
DataMixin
Mixin for data handling in image objects.
This mixin provides functionality for handling variance and mask, as well as other ancillary data.
Image
Core class to represent images with pixel values, pixel scale, and a window defining the spatial coordinates on the sky. It supports arithmetic operations with other image objects while preserving logical image boundaries. It also provides methods for determining the coordinate locations of pixels
- Parameters:
crval – The reference coordinate of the image in degrees [RA, DEC]. [model param]
crtan – The tangent plane coordinate of the image in arcseconds [x, y]. [model param]
CD – The coordinate transformation matrix in arcseconds/pixel. [model param]
crpix – The reference pixel coordinates in the image, which is used to convert from pixel coordinates to tangent plane coordinates. This is not a model param and is fixed for a given image.
data – The image data as a Array of pixel values. If not provided, a Array of zeros will be created.
zeropoint – The zeropoint of the image, which is used to convert from pixel flux to magnitude.
pixelscale – The side length of a pixel, used to create a simple diagonal CD matrix.
wcs – An optional Astropy WCS object to initialize the image.
filename – The filename to load the image from. If provided, the image will be loaded from the file.
hduext – The HDU extension to load from the FITS file specified in filename.
identity – An optional identity string for the image (mostly used internally).
mask – A boolean mask indicating which pixels to ignore.
std – Standard deviation of the image pixels.
variance – Variance of the image pixels.
weight – Weights for the image pixels.
Note that only one of std, variance, or weight should be provided at a time. If multiple are provided, an error will be raised.
- model_image(window: Window, **kwargs) CMOSModelImage[source]#
Model the image with CMOS-specific features.
- class astrophot.Image(*, data: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, CD: float | Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, zeropoint: float | Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, crpix: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | tuple = (0.0, 0.0), crtan: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | tuple = (0.0, 0.0), crval: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | tuple = (0.0, 0.0), pixelscale: float | Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = 1.0, wcs: WCS | None = None, filename: str | None = None, hduext: int = 0, identity: str = None, name: str | None = None, _data: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None)[source]#
Bases:
ModuleCore class to represent images with pixel values, pixel scale, and a window defining the spatial coordinates on the sky. It supports arithmetic operations with other image objects while preserving logical image boundaries. It also provides methods for determining the coordinate locations of pixels
- Parameters:
crval – The reference coordinate of the image in degrees [RA, DEC]. [model param]
crtan – The tangent plane coordinate of the image in arcseconds [x, y]. [model param]
CD – The coordinate transformation matrix in arcseconds/pixel. [model param]
crpix – The reference pixel coordinates in the image, which is used to convert from pixel coordinates to tangent plane coordinates. This is not a model param and is fixed for a given image.
data – The image data as a Array of pixel values. If not provided, a Array of zeros will be created.
zeropoint – The zeropoint of the image, which is used to convert from pixel flux to magnitude.
pixelscale – The side length of a pixel, used to create a simple diagonal CD matrix.
wcs – An optional Astropy WCS object to initialize the image.
filename – The filename to load the image from. If provided, the image will be loaded from the file.
hduext – The HDU extension to load from the FITS file specified in filename.
identity – An optional identity string for the image (mostly used internally).
- base_scale = 1.0#
- blank_copy(**kwargs)[source]#
Produces a blank copy of the image which has the same properties except that its data is now filled with zeros.
- property center#
- coordinate_center_meshgrid() Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of coordinate locations in the image, centered on the pixel grid.
- coordinate_corner_meshgrid() Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of coordinate locations in the image, with corners at the pixel grid.
- coordinate_quad_meshgrid(order=3) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of coordinate locations in the image, with quadrature sampling.
- coordinate_simpsons_meshgrid() Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of coordinate locations in the image, with Simpson’s rule sampling.
- copy(**kwargs)[source]#
Produce a copy of this image with all of the same properties. This can be used when one wishes to make temporary modifications to an image and then will want the original again.
- corners() Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
- crop(pixels: int | Tuple[int, int] | Tuple[int, int, int, int], **kwargs)[source]#
Crop the image by the number of pixels given. This will crop the image in all four directions by the number of pixels given.
given data shape (N, M) the new shape will be:
crop - int: crop the same number of pixels on all sides. new shape (N - 2*crop, M - 2*crop) crop - (int, int): crop each dimension by the number of pixels given. new shape (N - 2*crop[1], M - 2*crop[0]) crop - (int, int, int, int): crop each side by the number of pixels given assuming (x low, x high, y low, y high). new shape (N - crop[2] - crop[3], M - crop[0] - crop[1])
- property crpix: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']#
The reference pixel coordinates in the image, which is used to convert from pixel coordinates to tangent plane coordinates.
- property data#
The image data, which is a Array of pixel values.
- expect_ctype = (('RA---TAN',), ('DEC--TAN',))#
- flatten(attribute: str = 'data') Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
- property flip_ra_axis#
- get_window(other: Window | Image, indices=None, **kwargs)[source]#
Get a new image object which is a window of this image corresponding to the other image’s window. This will return a new image object with the same properties as this one, but with the data cropped to the other image’s window.
- property identity#
- load(filename: str | HDUList, hduext: int = 0)[source]#
Load an image from a FITS file. This will load the primary HDU and set the data, CD, crpix, crval, and crtan attributes accordingly. If the WCS is not tangent plane, it will warn the user.
- property pixel_area#
The area inside a pixel in arcsec^2
- pixel_center_meshgrid(window=None, pad=0, upsample=1) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of pixel coordinates in the image, centered on the pixel grid.
- pixel_collecting_area(I_, J_, upsample, CD)[source]#
The area of the sky that each pixel collects light from, in arcsec^2. This is just the pixel area, but can be overridden for certain types of images (e.g. SIP images) where the pixel collecting area is not the same as the pixel area.
- pixel_corner_meshgrid(window=None, pad=0, upsample=1) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of pixel coordinates in the image, with corners at the pixel grid.
- pixel_quad_meshgrid(window=None, pad=0, upsample=1, order=3) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of pixel coordinates in the image, with quadrature sampling.
- pixel_simpsons_meshgrid(window=None, pad=0, upsample=1) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of pixel coordinates in the image, with Simpson’s rule sampling.
- pixel_to_plane(i: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], j: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], crtan: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], CD: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], _crpix: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
- pixel_to_world(i: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], j: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
A wrapper which applies
pixel_to_plane()thenplane_to_world(), see those methods for further information.
- property pixelscale#
The approximate side length of a pixel, which is just sqrt(pixel_area). For square pixels this is the actual pixel length, for rectangular pixels it is a kind of average.
The pixelscale is not used for exact calculations and instead sets a size scale within an image.
- plane_to_pixel(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], crtan: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], CD: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], _crpix: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
- plane_to_world(x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], crval: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
- reduce(scale: int, **kwargs)[source]#
This operation will downsample an image by the factor given. If scale = 2 then 2x2 blocks of pixels will be summed together to form individual larger pixels. A new image object will be returned with the appropriate pixelscale and data Array. Note that the window does not change in this operation since the pixels are condensed, but the pixel size is increased correspondingly.
- Parameters:
scale (int) – The scale factor by which to reduce the image.
- to(dtype=None, device=None)[source]#
Moves and/or casts the values of the
Nodeto a particular device and/or dtype.Parameters#
- device: (Optional[torch.device], optional)
The device to move the values to. Defaults to None.
- dtype: (Optional[torch.dtype], optional)
The desired data type. Defaults to None.
- world_to_pixel(ra: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], dec: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
A wrapper which applies
world_to_plane()thenplane_to_pixel(), see those methods for further information.
- world_to_plane(ra: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], dec: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], crval: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) Tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
- property zeropoint: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']#
The zeropoint of the image, which is used to convert from pixel flux to magnitude.
- class astrophot.ImageBatchMixin(*args, **kwargs)[source]#
Bases:
objectSpecialized ImageList type where the images are all the same size.
An ImageBatch has restrictions on the shape of the images it can hold, but in exchange it allows vectorized operations over a batch of images.
Some notes to keep in mind: - All the images must be the regular image type (i.e. not SIP or CMOS images yet). - All the images must have the same shape, otherwise the batch operations will not work. - The ImageBatch does not itself accelerate any operations, it facilitates the BatchSceneModel. - Otherwise the ImageBatch behaves like a regular ImageList.
- property CD#
- property crpix#
- property crtan#
- property crval#
- property data#
- property window#
- class astrophot.ImageList(images: list[Image], **kwargs)[source]#
Bases:
ModuleA class to represent a list of images.
This is useful for operations that involve multiple images, mostly for joint modelling. The ImageList class provides methods for matching images based on their identity, and for applying operations to all images in the list while preserving their individual properties. For certain applications (the
flattenmethod) you can use ImageList and Image objects interchangably/agnostically.- property data#
- flatten(attribute: str = 'data') Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
- match_indices(other: ImageList)[source]#
Match the indices of the images in this list with those in another ImageList.
- to(dtype=None, device=None)[source]#
Moves and/or casts the values of the
Nodeto a particular device and/or dtype.Parameters#
- device: (Optional[torch.device], optional)
The device to move the values to. Defaults to None.
- dtype: (Optional[torch.dtype], optional)
The desired data type. Defaults to None.
- property window#
- class astrophot.JacobianImage(parameters: List[str], **kwargs)[source]#
Bases:
ImageJacobian of a model evaluated in an image.
Image object which represents the evaluation of a jacobian on an image. It takes the form of a 3D (Image x Nparameters) Array. This object can be added other other Jacobian images to build up a full jacobian for a complex model.
Image
Core class to represent images with pixel values, pixel scale, and a window defining the spatial coordinates on the sky. It supports arithmetic operations with other image objects while preserving logical image boundaries. It also provides methods for determining the coordinate locations of pixels
- Parameters:
crval – The reference coordinate of the image in degrees [RA, DEC]. [model param]
crtan – The tangent plane coordinate of the image in arcseconds [x, y]. [model param]
CD – The coordinate transformation matrix in arcseconds/pixel. [model param]
crpix – The reference pixel coordinates in the image, which is used to convert from pixel coordinates to tangent plane coordinates. This is not a model param and is fixed for a given image.
data – The image data as a Array of pixel values. If not provided, a Array of zeros will be created.
zeropoint – The zeropoint of the image, which is used to convert from pixel flux to magnitude.
pixelscale – The side length of a pixel, used to create a simple diagonal CD matrix.
wcs – An optional Astropy WCS object to initialize the image.
filename – The filename to load the image from. If provided, the image will be loaded from the file.
hduext – The HDU extension to load from the FITS file specified in filename.
identity – An optional identity string for the image (mostly used internally).
- copy(**kwargs)[source]#
Produce a copy of this image with all of the same properties. This can be used when one wishes to make temporary modifications to an image and then will want the original again.
- match_parameters(other: JacobianImage | JacobianImageList | List)[source]#
- class astrophot.JacobianImageBatch(*args, **kwargs)[source]#
Bases:
ImageBatchMixin,JacobianImageList
- class astrophot.JacobianImageList(*args, **kwargs)[source]#
Bases:
ImageListFor joint modelling, represents Jacobians evaluated on a list of images.
Stores jacobians evaluated on a number of image objects. Since jacobian images are aware of the target images they were evaluated on, it is possible to combine this object with other Jacobian_Image_List objects or even Jacobian_Image objects and everything will be sorted into the proper locations of the list, and image.
- match_parameters(other: JacobianImage | JacobianImageList | List[str])[source]#
- property parameters: List[str]#
List of parameters for the jacobian images in this list.
- class astrophot.Model(*, filename=None, model_type=None, **kwargs)[source]#
Bases:
ModuleBase class for all AstroPhot models.
- gaussian_log_likelihood() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
Compute the negative log likelihood of the model wrt the target image in the appropriate window.
- model_type = 'model'#
- options = {'softening'}#
- parameter_specs = {}#
- poisson_log_likelihood() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
Compute the negative log likelihood of the model wrt the target image in the appropriate window.
- softening = 0.001#
- to(dtype=None, device=None)[source]#
Moves and/or casts the values of the
Nodeto a particular device and/or dtype.Parameters#
- device: (Optional[torch.device], optional)
The device to move the values to. Defaults to None.
- dtype: (Optional[torch.dtype], optional)
The desired data type. Defaults to None.
- total_flux() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
- total_flux_uncertainty() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
- total_magnitude() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
Compute the total magnitude of the model in the given window.
- total_magnitude_uncertainty() Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
Compute the uncertainty in the total magnitude of the model in the given window.
- usable = False#
- property window: Window | None#
The window defines a region on the sky in which this model will be optimized and typically evaluated. Two models with non-overlapping windows are in effect independent of each other. If there is another model with a window that spans both of them, then they are tenuously connected.
If not provided, the model will assume a window equal to the target it is fitting. Note that in this case the window is not explicitly set to the target window, so if the model is moved to another target then the fitting window will also change.
- class astrophot.ModelImage(*, data: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, CD: float | Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, zeropoint: float | Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, crpix: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | tuple = (0.0, 0.0), crtan: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | tuple = (0.0, 0.0), crval: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | tuple = (0.0, 0.0), pixelscale: float | Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = 1.0, wcs: WCS | None = None, filename: str | None = None, hduext: int = 0, identity: str = None, name: str | None = None, _data: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None)[source]#
Bases:
ImageImage object which represents the sampling of a model at the given coordinates of the image. Extra arithmetic operations are available which can update model values in the image. The whole model can be shifted by less than a pixel to account for sub-pixel accuracy.
Image
Core class to represent images with pixel values, pixel scale, and a window defining the spatial coordinates on the sky. It supports arithmetic operations with other image objects while preserving logical image boundaries. It also provides methods for determining the coordinate locations of pixels
- Parameters:
crval – The reference coordinate of the image in degrees [RA, DEC]. [model param]
crtan – The tangent plane coordinate of the image in arcseconds [x, y]. [model param]
CD – The coordinate transformation matrix in arcseconds/pixel. [model param]
crpix – The reference pixel coordinates in the image, which is used to convert from pixel coordinates to tangent plane coordinates. This is not a model param and is fixed for a given image.
data – The image data as a Array of pixel values. If not provided, a Array of zeros will be created.
zeropoint – The zeropoint of the image, which is used to convert from pixel flux to magnitude.
pixelscale – The side length of a pixel, used to create a simple diagonal CD matrix.
wcs – An optional Astropy WCS object to initialize the image.
filename – The filename to load the image from. If provided, the image will be loaded from the file.
hduext – The HDU extension to load from the FITS file specified in filename.
identity – An optional identity string for the image (mostly used internally).
- class astrophot.ModelImageBatch(*args, **kwargs)[source]#
Bases:
ImageBatchMixin,ModelImageListImageBatchMixin
Specialized ImageList type where the images are all the same size.
An ImageBatch has restrictions on the shape of the images it can hold, but in exchange it allows vectorized operations over a batch of images.
Some notes to keep in mind: - All the images must be the regular image type (i.e. not SIP or CMOS images yet). - All the images must have the same shape, otherwise the batch operations will not work. - The ImageBatch does not itself accelerate any operations, it facilitates the BatchSceneModel. - Otherwise the ImageBatch behaves like a regular ImageList.
ModelImageList
A list of ModelImage objects.
ImageList
A class to represent a list of images.
This is useful for operations that involve multiple images, mostly for joint modelling. The ImageList class provides methods for matching images based on their identity, and for applying operations to all images in the list while preserving their individual properties. For certain applications (the
flattenmethod) you can use ImageList and Image objects interchangably/agnostically.
- class astrophot.ModelImageList(*args, **kwargs)[source]#
Bases:
ImageListA list of ModelImage objects.
ImageList
A class to represent a list of images.
This is useful for operations that involve multiple images, mostly for joint modelling. The ImageList class provides methods for matching images based on their identity, and for applying operations to all images in the list while preserving their individual properties. For certain applications (the
flattenmethod) you can use ImageList and Image objects interchangably/agnostically.
- class astrophot.PSFImage(*, data: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, upsample: int = 1, crpix: tuple[int, int] | None = None, filename: str | None = None, hduext: int = 0, identity: str = None, _data: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, **kwargs)[source]#
Bases:
DataMixinImage object which represents a model of PSF (Point Spread Function).
PSFImage inherits from the base Image class and represents the model of a point spread function. The point spread function characterizes the response of an imaging system to a point source or point object.
The shape of the PSF data should be odd (for your sanity) but this is not enforced.
DataMixin
Mixin for data handling in image objects.
This mixin provides functionality for handling variance and mask, as well as other ancillary data.
- Parameters:
mask – A boolean mask indicating which pixels to ignore.
std – Standard deviation of the image pixels.
variance – Variance of the image pixels.
weight – Weights for the image pixels.
Note that only one of std, variance, or weight should be provided at a time. If multiple are provided, an error will be raised.
- base_scale = 1.0#
- coordinate_center_meshgrid() tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
- coordinate_corner_meshgrid() tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
- coordinate_quad_meshgrid(order=3) tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
- coordinate_simpsons_meshgrid() tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
- copy(**kwargs)[source]#
Produce a copy of this image with all of the same properties. This can be used when one wishes to make temporary modifications to an image and then will want the original again.
- copy_kwargs(**kwargs) dict[source]#
Produce a copy of this image with all of the same properties. This can be used when one wishes to make temporary modifications to an image and then will want the original again.
- property crpix#
- property data#
The image data, which is a Array of pixel values.
- flatten(attribute: str = 'data') Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#
- property flip_ra_axis#
- get_window(other: Window | Image, indices=None, **kwargs)[source]#
Get a new image object which is a window of this image corresponding to the other image’s window. This will return a new image object with the same properties as this one, but with the data cropped to the other image’s window.
- property identity#
- jacobian_image(parameters: List[str] | None = None, data: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, **kwargs) JacobianImage[source]#
Construct a blank JacobianImage object formatted like this current PSFImage object. Mostly used internally.
- model_image(window=None, **kwargs) PSFImage[source]#
Construct a blank ModelImage object formatted like this current TargetImage object. Mostly used internally.
- mypixel_to_targpixel(i, j)[source]#
Convert between coordinate spaces. “targpixel” refers to the pixel coordinates of the target of this PSF, which have the origin at the center of the PSF and a step of 1 corresponds to one target pixel length. “mypixel” refers to the pixel coordinates of this PSF image, which have an origin at the center of the [0,0] pixel and a step of 1 corresponds to one PSF pixel length (which is 1/upsample of a target pixel length).
- property pad: int#
- property pixel_area#
- pixel_center_meshgrid(window=None, pad=0, upsample=1) tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of pixel coordinates in the image, centered on the pixel grid.
- pixel_corner_meshgrid(window=None, pad=0, upsample=1) tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of pixel coordinates in the image, with corners at the pixel grid.
- pixel_quad_meshgrid(window=None, pad=0, upsample=1, order=3) tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of pixel coordinates in the image, with quadrature sampling.
- pixel_simpsons_meshgrid(window=None, pad=0, upsample=1) tuple[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']][source]#
Get a meshgrid of pixel coordinates in the image, with Simpson’s rule sampling.
- property pixelscale#
- reduce(scale: int)[source]#
Returns a new TargetImage object with a reduced resolution compared to the current image. scale should be an integer indicating how much to reduce the resolution. If the TargetImage was originally (48,48) pixels across with a pixelscale of 1 and reduce(2) is called then the image will be (24,24) pixels and the pixelscale will be 2. If reduce(3) is called then the returned image will be (16,16) pixels across and the pixelscale will be 3.
- targpixel_to_mypixel(I_, J_)[source]#
Convert between coordinate spaces. “targpixel” refers to the pixel coordinates of the target of this PSF, which have the origin at the center of the PSF and a step of 1 corresponds to one target pixel length. “mypixel” refers to the pixel coordinates of this PSF image, which have an origin at the center of the [0,0] pixel and a step of 1 corresponds to one PSF pixel length (which is 1/upsample of a target pixel length).
- property upsample: int#
- property zeropoint#
- class astrophot.Param(*args, uncertainty=None, prof=None, **kwargs)[source]#
Bases:
ParamA class that extends the Caskade Param class to include additional functionality. This class is used to define parameters for models in the AstroPhot package.
- property full_shape#
- property initialized#
Check if the parameter is initialized.
- property name_array#
- property prof#
- property uncertainty#
- class astrophot.SIPModelImage(*args, sipA: dict[Tuple[int, int], float] = {}, sipB: dict[Tuple[int, int], float] = {}, sipAP: dict[Tuple[int, int], float] = {}, sipBP: dict[Tuple[int, int], float] = {}, pixel_area_map: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, distortion_ij: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, distortion_IJ: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, filename: str | None = None, **kwargs)[source]#
Bases:
SIPMixin,ModelImageA ModelImage with SIP distortion coefficients.
SIPMixin
A mixin class for SIP (Simple Image Polynomial) distortion model.
ModelImage
Image object which represents the sampling of a model at the given coordinates of the image. Extra arithmetic operations are available which can update model values in the image. The whole model can be shifted by less than a pixel to account for sub-pixel accuracy.
Image
Core class to represent images with pixel values, pixel scale, and a window defining the spatial coordinates on the sky. It supports arithmetic operations with other image objects while preserving logical image boundaries. It also provides methods for determining the coordinate locations of pixels
- Parameters:
crval – The reference coordinate of the image in degrees [RA, DEC]. [model param]
crtan – The tangent plane coordinate of the image in arcseconds [x, y]. [model param]
CD – The coordinate transformation matrix in arcseconds/pixel. [model param]
crpix – The reference pixel coordinates in the image, which is used to convert from pixel coordinates to tangent plane coordinates. This is not a model param and is fixed for a given image.
data – The image data as a Array of pixel values. If not provided, a Array of zeros will be created.
zeropoint – The zeropoint of the image, which is used to convert from pixel flux to magnitude.
pixelscale – The side length of a pixel, used to create a simple diagonal CD matrix.
wcs – An optional Astropy WCS object to initialize the image.
filename – The filename to load the image from. If provided, the image will be loaded from the file.
hduext – The HDU extension to load from the FITS file specified in filename.
identity – An optional identity string for the image (mostly used internally).
- crop(pixels: int | Tuple[int, int] | Tuple[int, int, int, int], **kwargs)[source]#
Crop the image by the number of pixels given. This will crop the image in all four directions by the number of pixels given.
- reduce(scale: int, **kwargs)[source]#
This operation will downsample an image by the factor given. If scale = 2 then 2x2 blocks of pixels will be summed together to form individual larger pixels. A new image object will be returned with the appropriate pixelscale and data Array. Note that the window does not change in this operation since the pixels are condensed, but the pixel size is increased correspondingly.
- Parameters:
scale – factor by which to condense the image pixels. Each scale X scale region will be summed [int]
- class astrophot.SIPTargetImage(*args, sipA: dict[Tuple[int, int], float] = {}, sipB: dict[Tuple[int, int], float] = {}, sipAP: dict[Tuple[int, int], float] = {}, sipBP: dict[Tuple[int, int], float] = {}, pixel_area_map: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, distortion_ij: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, distortion_IJ: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, filename: str | None = None, **kwargs)[source]#
Bases:
SIPMixin,TargetImageA TargetImage with SIP distortion coefficients. This class is used to represent a target image with SIP distortion coefficients. It inherits from TargetImage and SIPMixin.
SIPMixin
A mixin class for SIP (Simple Image Polynomial) distortion model.
TargetImage
Image object which represents the data to be fit by a model. It can include a variance image, mask, and PSF as anciliary data which describes the target image.
Target images are a basic unit of data in AstroPhot, they store the information collected from telescopes for which models are to be fit. There is minimal functionality in the Target_Image object itself, it is mostly defined in terms of how other objects interact with it.
Basic usage:
Some important information to keep in mind. First, providing an astropy WCS object is the best way to keep track of coordinates and pixel scale properties, especially when dealing with multi-band data. If images have relative positioning, rotation, pixel sizes, field of view this will all be handled automatically by taking advantage of WCS objects. Second, Providing accurate variance (or weight) maps is critical to getting a good fit to the data. This is a very common source of issues so it is worthwhile to review literature on how best to construct such a map. A good starting place is the FAQ for GALFIT: https://users.obs.carnegiescience.edu/peng/work/galfit/CHI2.html which is an excellent resource for all things image modeling. Just note that AstroPhot uses variance or weight maps, not sigma images. AstroPhot will not crete a variance map for the user, by default it will just assume uniform variance which is rarely accurate. Third, The PSF pixelscale must be a multiple of the image pixelscale. So if the image has a pixelscale of 1 then the PSF must have a pixelscale of 1, 1/2, 1/3, etc for anything to work out. Note that if the PSF pixelscale is finer than the image, then all modelling will be done at the higher resolution. This is recommended for accuracy though it can mean higher memory consumption.
DataMixin
Mixin for data handling in image objects.
This mixin provides functionality for handling variance and mask, as well as other ancillary data.
Image
Core class to represent images with pixel values, pixel scale, and a window defining the spatial coordinates on the sky. It supports arithmetic operations with other image objects while preserving logical image boundaries. It also provides methods for determining the coordinate locations of pixels
- Parameters:
crval – The reference coordinate of the image in degrees [RA, DEC]. [model param]
crtan – The tangent plane coordinate of the image in arcseconds [x, y]. [model param]
CD – The coordinate transformation matrix in arcseconds/pixel. [model param]
crpix – The reference pixel coordinates in the image, which is used to convert from pixel coordinates to tangent plane coordinates. This is not a model param and is fixed for a given image.
data – The image data as a Array of pixel values. If not provided, a Array of zeros will be created.
zeropoint – The zeropoint of the image, which is used to convert from pixel flux to magnitude.
pixelscale – The side length of a pixel, used to create a simple diagonal CD matrix.
wcs – An optional Astropy WCS object to initialize the image.
filename – The filename to load the image from. If provided, the image will be loaded from the file.
hduext – The HDU extension to load from the FITS file specified in filename.
identity – An optional identity string for the image (mostly used internally).
mask – A boolean mask indicating which pixels to ignore.
std – Standard deviation of the image pixels.
variance – Variance of the image pixels.
weight – Weights for the image pixels.
Note that only one of std, variance, or weight should be provided at a time. If multiple are provided, an error will be raised.
- model_image(upsample: int = 1, pad: int = 0, **kwargs) SIPModelImage[source]#
Construct a blank ModelImage object formatted like this current TargetImage object. Mostly used internally.
- class astrophot.TargetImage(*args, psf=None, **kwargs)[source]#
-
Image object which represents the data to be fit by a model. It can include a variance image, mask, and PSF as anciliary data which describes the target image.
Target images are a basic unit of data in AstroPhot, they store the information collected from telescopes for which models are to be fit. There is minimal functionality in the Target_Image object itself, it is mostly defined in terms of how other objects interact with it.
Basic usage:
Some important information to keep in mind. First, providing an astropy WCS object is the best way to keep track of coordinates and pixel scale properties, especially when dealing with multi-band data. If images have relative positioning, rotation, pixel sizes, field of view this will all be handled automatically by taking advantage of WCS objects. Second, Providing accurate variance (or weight) maps is critical to getting a good fit to the data. This is a very common source of issues so it is worthwhile to review literature on how best to construct such a map. A good starting place is the FAQ for GALFIT: https://users.obs.carnegiescience.edu/peng/work/galfit/CHI2.html which is an excellent resource for all things image modeling. Just note that AstroPhot uses variance or weight maps, not sigma images. AstroPhot will not crete a variance map for the user, by default it will just assume uniform variance which is rarely accurate. Third, The PSF pixelscale must be a multiple of the image pixelscale. So if the image has a pixelscale of 1 then the PSF must have a pixelscale of 1, 1/2, 1/3, etc for anything to work out. Note that if the PSF pixelscale is finer than the image, then all modelling will be done at the higher resolution. This is recommended for accuracy though it can mean higher memory consumption.
DataMixin
Mixin for data handling in image objects.
This mixin provides functionality for handling variance and mask, as well as other ancillary data.
Image
Core class to represent images with pixel values, pixel scale, and a window defining the spatial coordinates on the sky. It supports arithmetic operations with other image objects while preserving logical image boundaries. It also provides methods for determining the coordinate locations of pixels
- Parameters:
crval – The reference coordinate of the image in degrees [RA, DEC]. [model param]
crtan – The tangent plane coordinate of the image in arcseconds [x, y]. [model param]
CD – The coordinate transformation matrix in arcseconds/pixel. [model param]
crpix – The reference pixel coordinates in the image, which is used to convert from pixel coordinates to tangent plane coordinates. This is not a model param and is fixed for a given image.
data – The image data as a Array of pixel values. If not provided, a Array of zeros will be created.
zeropoint – The zeropoint of the image, which is used to convert from pixel flux to magnitude.
pixelscale – The side length of a pixel, used to create a simple diagonal CD matrix.
wcs – An optional Astropy WCS object to initialize the image.
filename – The filename to load the image from. If provided, the image will be loaded from the file.
hduext – The HDU extension to load from the FITS file specified in filename.
identity – An optional identity string for the image (mostly used internally).
mask – A boolean mask indicating which pixels to ignore.
std – Standard deviation of the image pixels.
variance – Variance of the image pixels.
weight – Weights for the image pixels.
Note that only one of std, variance, or weight should be provided at a time. If multiple are provided, an error will be raised.
- copy_kwargs(**kwargs)[source]#
Produce a copy of this image with all of the same properties. This can be used when one wishes to make temporary modifications to an image and then will want the original again.
- property has_psf: bool#
Returns True when the target image object has a PSF model.
- jacobian_image(parameters: List[str], data: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'] | None = None, **kwargs) JacobianImage[source]#
Construct a blank JacobianImage object formatted like this current TargetImage object. Mostly used internally.
- load(filename: str, hduext: int = 0)[source]#
Load the image from a FITS file. This will load the data, WCS, and any ancillary data such as variance, mask, and PSF.
- model_image(window: Window = None, **kwargs) ModelImage[source]#
Construct a blank ModelImage object formatted like this current TargetImage object. Mostly used internally.
- property psf#
- psf_image(data: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], upsample: int = 1, **kwargs) PSFImage[source]#
- reduce(scale: int, **kwargs) TargetImage[source]#
Returns a new TargetImage object with a reduced resolution compared to the current image. scale should be an integer indicating how much to reduce the resolution. If the TargetImage was originally (48,48) pixels across with a pixelscale of 1 and reduce(2) is called then the image will be (24,24) pixels and the pixelscale will be 2. If reduce(3) is called then the returned image will be (16,16) pixels across and the pixelscale will be 3.
- class astrophot.TargetImageBatch(*args, **kwargs)[source]#
Bases:
ImageBatchMixin,TargetImageList- jacobian_image(parameters: List[str], data: List[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']] | None = None) JacobianImageBatch[source]#
- property mask#
- model_image(window=None) ModelImageBatch[source]#
- property psf_stack#
- property variance#
- property weight#
- class astrophot.TargetImageList(*args, **kwargs)[source]#
Bases:
ImageListImageList
A class to represent a list of images.
This is useful for operations that involve multiple images, mostly for joint modelling. The ImageList class provides methods for matching images based on their identity, and for applying operations to all images in the list while preserving their individual properties. For certain applications (the
flattenmethod) you can use ImageList and Image objects interchangably/agnostically.- property has_psf: bool#
- jacobian_image(parameters: List[str], data: List[Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']] | None = None) JacobianImageList[source]#
- property mask#
- model_image(window=None) ModelImageList[source]#
- property psf#
- property variance#
- property weight#
- class astrophot.Window(window: Tuple[int, int, int, int] | Tuple[Tuple[int, int], Tuple[int, int]], image: Image)[source]#
Bases:
object- property crpix#
- property extent#
- property identity#
- property shape#
- class astrophot.WindowBatch(windows: list[Window])[source]#
Bases:
WindowList
- astrophot.forward(method)[source]#
Decorator to define a forward method for a module.
Parameters#
- method: (Callable)
The forward method to be decorated.
Examples#
Standard usage of the forward decorator:
class ExampleSim(Module): def __init__(self, a, b, c): super().__init__("example_sim") self.a = a self.b = Param("b", b) self.c = Param("c", c) @forward def example_func(self, x, b=None): return x + self.a + b E = ExampleSim(a=1, b=None, c=3) print(E.example_func(4, params=[5])) # Output: 10
Returns#
- Callable
The decorated forward method.