padre_craft.io.fits_tools#

Provides utilities to read and write fits files

Functions

add_process_info_to_header(header[, n])

Add processing info metadata to a fits header.

get_bunit(data_level, data_type)

Get the bunit and comment for a given data level and data type.

get_comment(keyword)

Given a keyword, return the standard comment for a header card.

get_obs_header(data_level, data_type)

Create a standard FITS header for the observation.

get_prhsh([n, a])

Get the processing hash and standard comment for FITS header.

get_primary_header(file_path, data_level, ...)

Create a standard FITS primary header following SOLARNET conventions.

get_prlib([n, a])

Get the processing library description and standard comment for FITS header.

get_prproc([n])

Get the processing procedure description and standard comment for FITS header.

get_prpver([n])

Get the processing version and standard comment for FITS header.

get_prstep([n])

Get the processing step description and standard comment for FITS header.

get_prver([n, a])

Get the processing version and standard comment for FITS header.

padre_craft.io.fits_tools.add_process_info_to_header(header: Header, n: int = 1) Header[source]#

Add processing info metadata to a fits header.

It adds the following SOLARNET compatible FITS cards; PRSTEPn, PRPROCn, PRPVERn, PRLIBnA, PRVERnA, PRLIBnA, PRHSHnA, PRVERnB

Parameters:
  • header (fits.Header) – The fits header to add the new cards to

  • n (int, default 1) – The processing step number. Must be >= 1 and <= 9.

Returns:

header (fits.Header)

padre_craft.io.fits_tools.get_bunit(data_level: str, data_type: str) Tuple[str, str][source]#

Get the bunit and comment for a given data level and data type.

Parameters:
  • data_level (str) – Data Processing step (e.g., ‘L0’, ‘L1’)

  • data_type (str) – Type of data being processed

Returns:

tuple – A tuple of (bunit, comment)

padre_craft.io.fits_tools.get_comment(keyword: str) str[source]#

Given a keyword, return the standard comment for a header card.

padre_craft.io.fits_tools.get_obs_header(data_level: str, data_type: str)[source]#

Create a standard FITS header for the observation.

This function creates a new FITS header with standard metadata including the current date, default PADRE attributes, processing information, data level, data type, original APID, and original filename.

Parameters:
  • data_level (str) – Data Processing step (e.g., ‘L0’, ‘L1’)

  • data_type (str) – Type of data being processed

Returns:

fits.Header – A FITS header populated with standard metadata

padre_craft.io.fits_tools.get_prhsh(n: int = 1, a: str = 'A') Tuple[str, str][source]#

Get the processing hash and standard comment for FITS header. This function returns a tuple containing the processing hash and the corresponding standard comment based on the Processing step.

Parameters:
  • n (int, optional) – Processing step number, default is 1.

  • a (str, optional) – Library version, default is A.

Returns:

tuple – A tuple of (processing_hash, standard_comment)

padre_craft.io.fits_tools.get_primary_header(file_path: Path, data_level: str, data_type: str, procesing_step: int = 1) Header[source]#

Create a standard FITS primary header following SOLARNET conventions.

This function creates a new FITS header with standard metadata including the current date, default PADRE attributes, processing information, data level, data type, original APID, and original filename.

Parameters:
  • file_path (Path) – Path to the original file, used to extract the filename

  • data_level (str) – Data Processing step (e.g., ‘L0’, ‘L1’)

  • data_type (str) – Type of data being processed

  • procesing_step (int, default 1) – Processing step number to be added to header metadata

Returns:

fits.Header – A FITS header populated with standard metadata

padre_craft.io.fits_tools.get_prlib(n: int = 1, a: str = 'A') Tuple[str, str][source]#

Get the processing library description and standard comment for FITS header. This function returns a tuple containing the processing library description and the corresponding standard comment based on the Processing step.

Parameters:
  • n (int, optional) – Processing step number, default is 1.

  • a (str, optional) – Library version, default is A.

Returns:

tuple – A tuple of (processing_library_description, standard_comment)

padre_craft.io.fits_tools.get_prproc(n: int = 1) Tuple[str, str][source]#

Get the processing procedure description and standard comment for FITS header. This function returns a tuple containing the processing procedure description and the corresponding standard comment based on the Processing step.

Parameters:

n (int, optional) – Processing step number, default is 1.

Returns:

tuple – A tuple of (processing_procedure_description, standard_comment)

padre_craft.io.fits_tools.get_prpver(n: int = 1) Tuple[str, str][source]#

Get the processing version and standard comment for FITS header. This function returns a tuple containing the processing version and the corresponding standard comment based on the Processing step.

Parameters:

n (int, optional) – Processing step number, default is 1.

Returns:

tuple – A tuple of (processing_version, standard_comment)

padre_craft.io.fits_tools.get_prstep(n: int = 1) Tuple[str, str][source]#

Get the processing step description and standard comment for FITS header. This function returns a tuple containing the processing step description and the corresponding standard comment based on the Processing step.

Parameters:

n (int, optional) – Processing step number, default is 1. 1: Raw to L1 2: L1 to L2 3: L2 to L3 4: L3 to L4

Returns:

tuple – A tuple of (processing_step_description, standard_comment)

Raises:

ValueError – If the Processing step number is not in the range 1-4.

padre_craft.io.fits_tools.get_prver(n: int = 1, a: str = 'A') Tuple[str, str][source]#

Get the processing version and standard comment for FITS header. This function returns a tuple containing the processing version and the corresponding standard comment based on the Processing step.

Parameters:
  • n (int, optional) – Processing step number, default is 1.

  • a (str, optional) – Library version, default is A.

Returns:

tuple – A tuple of (processing_version, standard_comment)