FrameData#
- class astropop.framedata.FrameData(data, unit=None, dtype=None, uncertainty=None, mask=None, flags=None, use_memmap_backend=False, cache_folder=None, cache_filename=None, origin_filename=None, **kwargs)#
Bases:
object
Data container for image frame to handle memmapping data from disk.
The main difference from Astropy’s
CCDData
is the memmapping itself. However it handles uncertainties in a totally different way. It stores only StdDev uncertainty arrays. It also stores the unit.- Parameters:
- dataarray_like or
Quantity
The main data values. If
Quantity
, unit will be set automatically. If using any quantity with masks, you must set the mask in a separate parameter.- unit
Unit
or string (optional) The data unit. Must be
Unit
compliant.- dtypestring or
dtype
(optional) Mandatory dtype of the data.
- uncertaintyarray_like or
Uncertanty
orNone
(optional) Uncertainty of the data.
- maskarray_like or
None
(optional) Frame mask. All the masked pixels will be flagged as
PixelMaskFlags.MASKED
andPixelMaskFlags.UNSPECIFIED
.- flagsarray_like or
None
(optional) Pixel flags for the frame. See
PixelMaskFlags
. for values.- wcs
dict
,Header
orWCS
(optional) World Coordinate System of the image. If meta or header keys already contain WCS informations, an error will be raised.
- meta or header: `dict` or `astropy.fits.Header` (optional)
Metadata (header) of the frame. Only one accepted. If both are passed, error will be raised.
- cache_folderstring,
Path
orNone
(optional) Place to store the cached
FrameData
- cache_filenamestring,
Path
orNone
(optional) Base file name to store the cached
FrameData
.- origin_filenamestring,
Path
orNone
(optional) Original file name of the data. If set, it will be stored in the
FrameData
metadata.- use_memmap_backend
bool
(optional) True if enable memmap in constructor.
- dataarray_like or
Notes
The physical unit is assumed to be the same for data and uncertainty. So, we droped the support for data with data with different uncertainty unit, like
CCDData
does.As this is intended to be a safe container for data, it do not handle builtin math operations. For math operations using FrameData, check
imarith
module.
Attributes Summary
Get the FrameData stored comments.
Get the main data container.
Get the dta type of the data.
Get the flags frame container.
Get the header (metadata) of the frame.
Get the FrameData stored history.
Mask all flagged pixels.
Get the metadata (header) of the frame.
Get the original filename of the data.
Get the data shape following numpy.
Get the size of the data.
Get the uncertainty frame container.
Physical unit of the data.
Get the World Coordinate System.
Methods Summary
add_flags
(flag, where)Add a given flag to the pixels in the given positions.
astype
(dtype)Return a copy of the current FrameData with new dtype in data.
copy
([dtype])Copy the current FrameData to a new instance.
Disable frame file memmapping (load to memory).
enable_memmap
([filename, cache_folder])Enable array file memmapping.
get_masked_data
([fill_value])Return a copy of the data with masked pixels as
fill_value
.get_uncertainty
([return_none])Get the uncertainty frame in a safer way.
mask_flags
(flags)Get a mask pixels with an specific flag.
mask_pixels
(pixels)Mask pixels.
max
()Compute minimum value of the data.
mean
(**kwargs)Compute and return the mean of the data.
median
(**kwargs)Compute and return the median of the data.
min
()Compute minimum value of the data.
Compute general statistics ofthe image.
std
(**kwargs)Compute and return the std dev of the data.
Convert actual FrameData to CCDData.
to_hdu
([wcs_relax, no_fits_standard_units])Generate an HDUList from this FrameData.
write
(filename[, overwrite, ...])Write frame to a fits file.
Attributes Documentation
- cache_filename = None#
- cache_folder = None#
- comment#
Get the FrameData stored comments.
- data#
Get the main data container.
- dtype#
Get the dta type of the data.
FrameData.data.dtype
.
- flags#
Get the flags frame container.
- header#
Get the header (metadata) of the frame.
- history#
Get the FrameData stored history.
- mask#
Mask all flagged pixels. True for all masked/removed pixels.
- meta#
Get the metadata (header) of the frame.
- origin_filename#
Get the original filename of the data.
- shape#
Get the data shape following numpy.
FrameData.data.shape
.
- size#
Get the size of the data.
FrameData.data.size
.
- uncertainty#
Get the uncertainty frame container.
- unit#
Physical unit of the data.
- wcs#
Get the World Coordinate System.
Methods Documentation
- add_flags(flag, where)#
Add a given flag to the pixels in the given positions.
- Parameters:
- flag
PixelMaskFlags
Flag to be added.
- where
ndarray
Positions where the flag will be added.
- flag
- astype(dtype)#
Return a copy of the current FrameData with new dtype in data.
- copy(dtype=None)#
Copy the current FrameData to a new instance.
- disable_memmap()#
Disable frame file memmapping (load to memory).
- enable_memmap(filename=None, cache_folder=None)#
Enable array file memmapping.
- Parameters:
- filenamestr, optional
Custom memmap file name.
- cache_folderstr, optional
Custom folder to cache data.
- get_masked_data(fill_value=nan)#
Return a copy of the data with masked pixels as
fill_value
.
- get_uncertainty(return_none=True)#
Get the uncertainty frame in a safer way.
In some cases, like interfacing with QFloat, the uncertainty cannot be None or an empty container. So, in cases like this, is prefered to get a whole matrix containing zeroes. This method is responsible for this special returns. For non-empty containers, a copy in
ndarray
container will be returned.- Parameters:
- - return_none: bool (optional)
If True, an empty uncertainty frame will return only None. Else, a matrix filled with zeroes will be returned. Default: True
- mask_flags(flags)#
Get a mask pixels with an specific flag.
- Parameters:
- flags: list of `PixelMaskFlags` or `PixelMaskFlags`
- Returns:
- mask:
ndarray
Masked pixels. True for masked pixels.
- mask:
- mask_pixels(pixels)#
Mask pixels.
- Parameters:
- pixels: `~numpy.ndarray` or tuple
Pixels to be masked. Can be a tuple of (y, x) positions or a boolean array where True means masked. Uses the same standard as `~numpy.ndarray`[pixels] access.
- max()#
Compute minimum value of the data.
- mean(**kwargs)#
Compute and return the mean of the data.
- median(**kwargs)#
Compute and return the median of the data.
- min()#
Compute minimum value of the data.
- statistics()#
Compute general statistics ofthe image.
- std(**kwargs)#
Compute and return the std dev of the data.
- to_ccddata()#
Convert actual FrameData to CCDData.
- Returns:
CCDData
CCDData instance with actual FrameData informations.
- to_hdu(wcs_relax=True, no_fits_standard_units=True, **kwargs)#
Generate an HDUList from this FrameData.
- Parameters:
- wcs_relax: `bool`, optional.
Allow non-standard WCS keys. Default:
True
- no_fits_standard_units: `bool`, optional
Skip FITS units standard for units. If this options is choose, the units will be printed in header as
Unit
compatible string. Default:True
- **kwargs:
- hdu_uncertainty: string, optional
Extension name to store the uncertainty in 2D image format.
- hdu_flags: string, optional
Extension name to store the pixel list flags in table format.
- unit_key: string, optional
Header key for physical unit.
- Returns:
HDUList
HDU storing all FrameData informations.
- write(filename, overwrite=False, no_fits_standard_units=True, **kwargs)#
Write frame to a fits file.
- Parameters:
- filename: str
Name of the file to write.
- overwrite: bool, optional
If True, overwrite the file if it exists.
- wcs_relax: `bool`, optional.
Allow non-standard WCS keys. Default:
True
- no_fits_standard_units: `bool`, optional
Skip FITS units standard for units. If this options is choose, the units will be printed in header as
Unit
compatible string. Default:True
- **kwargs:
- hdu_uncertainty: string, optional
Extension name to store the uncertainty in 2D image format.
- hdu_flags: string, optional
Extension name to store the pixel list flags in table format.
- unit_key: string, optional
Header key for physical unit.