punchbowl.data.punch_io#
Attributes#
Classes#
A formatter that doesn't fail if a keyword is missing. Used for quicklook. |
Functions#
|
Create a SHA-256 hash for a file. |
|
Determine the base file name without file type extension. |
|
Convert image header metadata into an XML Tree that can be inserted into a JPEG2000 file header. |
|
Generate the JPEG2000 XML box to be inserted into the JPEG2000 file. |
|
Write an NDCube to a Quicklook format as a jpeg. |
|
Write a list of input quicklook jpeg2000 files to an output mp4 animation. |
|
Write an NDCube as a FITS file. |
|
Compress the uncertainty for writing to file. |
|
Uncompress the uncertainty when reading from a file. |
|
Update image statistics in metadata before writing to file. |
|
Load an NDCube from a FITS file. |
Module Contents#
- punchbowl.data.punch_io._ROOT = b'.'#
- punchbowl.data.punch_io.CALIBRATION_ANNOTATION = '{OBSRVTRY} - {TYPECODE}{OBSCODE} - {DATE-OBS} - exptime: {EXPTIME} s - polarizer: {POLAR} deg'#
- punchbowl.data.punch_io.write_file_hash(path: str) None#
Create a SHA-256 hash for a file.
- punchbowl.data.punch_io.get_base_file_name(cube: ndcube.NDCube) str#
Determine the base file name without file type extension.
- class punchbowl.data.punch_io.DefaultFormatter#
Bases:
string.FormatterA formatter that doesn’t fail if a keyword is missing. Used for quicklook.
- get_field(field_name: str, args: Any, kwargs: Any) str#
Provide a special getter that returns the name if it fails.
- punchbowl.data.punch_io._header_to_xml(header: astropy.io.fits.Header) lxml.etree.Element#
Convert image header metadata into an XML Tree that can be inserted into a JPEG2000 file header.
(Helper function adapted from SunPy)
- punchbowl.data.punch_io._generate_jp2_xmlbox(header: astropy.io.fits.Header) glymur.jp2box.XMLBox#
Generate the JPEG2000 XML box to be inserted into the JPEG2000 file.
(Helper function adapted from SunPy)
- punchbowl.data.punch_io.write_ndcube_to_quicklook(cube: ndcube.NDCube, filename: str, layer: int | None = None, vmin: float = 1e-15, vmax: float = 8e-12, include_meta: bool = True, annotation: str | None = None, color: bool = False) None#
Write an NDCube to a Quicklook format as a jpeg.
- Parameters:
cube (NDCube) – data cube to visualize
filename (str) – path to save output, must end in .jp2, .j2k, .jpeg, .jpg
layer (int | None) – if the cube is 3D, then selects cube.data[layer] for visualization
vmin (float) – the lower limit value to visualize
vmax (float) – the upper limit value to visualize
include_meta (bool) – whether to include metadata in the JPEG2000 file
annotation (str | None) – a formatted string to add to the bottom of the image as a label can access metadata by key, e.g. “typecode={TYPECODE}” would write the data’s typecode into the image
color (bool) – flag to generate RGB quicklook files, grayscale by default
- Return type:
None
- punchbowl.data.punch_io.write_quicklook_to_mp4(files: list[str], filename: str, framerate: int = 5, resolution: int = 1024, codec: str = 'libx264', ffmpeg_cmd: str = 'ffmpeg') None#
Write a list of input quicklook jpeg2000 files to an output mp4 animation.
- Parameters:
files (list[str]) – List of input files to animate
filename (str) – Output filename
framerate (int, optional) – Frame rate (default 5)
resolution (int, optional) – Output resolution (default 1024)
codec (str, optional) – Codec to use for encoding. For GPU acceleration. “h264_videotoolbox” can be used on ARM Macs, “h264_nvenc” can be used on Intel machines.
ffmpeg_cmd (str) – path to the ffmpeg executable
- punchbowl.data.punch_io.write_ndcube_to_fits(cube: ndcube.NDCube, filename: str, overwrite: bool = False, write_hash: bool = True, skip_stats: bool = False, uncertainty_quantize_level: float = 16) None#
Write an NDCube as a FITS file.
- punchbowl.data.punch_io._pack_uncertainty(cube: ndcube.NDCube) numpy.ndarray#
Compress the uncertainty for writing to file.
- punchbowl.data.punch_io._unpack_uncertainty(uncertainty_array: numpy.ndarray, data_array: numpy.ndarray) numpy.ndarray#
Uncompress the uncertainty when reading from a file.
- punchbowl.data.punch_io._update_statistics(cube: ndcube.NDCube) None#
Update image statistics in metadata before writing to file.
- punchbowl.data.punch_io.load_ndcube_from_fits(path: str | pathlib.Path, key: str = ' ', include_provenance: bool = True, include_uncertainty: bool = True) ndcube.NDCube#
Load an NDCube from a FITS file.