def create_combined_fits_file(cls, name: str, data: ndarray, file_type_code: int, image_type_string: str, exposure: float, temperature: float, filter_name: str, binning: int, comment: str): """Write a new FITS file with the given data and name. Create a FITS header in the file by copying the header from a given existing file and adding a given comment""" # Create header header = fits.Header() header["FILTER"] = filter_name header["COMMENT"] = comment header["EXPTIME"] = exposure header["CCD-TEMP"] = temperature header["SET-TEMP"] = temperature header["XBINNING"] = binning header["YBINNING"] = binning header["PICTTYPE"] = file_type_code header["IMAGETYP"] = image_type_string # Create primary HDU data_16_bit = data.round().astype("i2") primary_hdu = fits.PrimaryHDU(data_16_bit, header=header) # Create HDUL hdul = fits.HDUList([primary_hdu]) # Write to file hdul.writeto(name, output_verify="fix", overwrite=True, checksum=True)
def create_combined_fits_file(cls, name: str, data: ndarray, file_type_code: int, image_type_string: str, exposure: float, temperature: float, filter_name: str, binning: int, comment: str): """ Write a new FITS file with the given data and name. Create a FITS header in the file by copying the header from a given existing file and adding a given comment :param name: File name :param data: 2-dimensional array of pixel values, the file contents :param file_type_code: What kind of FITS image file is this (dark, bias, flat, etc.)? :param image_type_string: String for FITS filel "IMGTYP" parameter :param exposure: Exposure time in seconds :param temperature: Temperature in degrees if known, else 0 :param filter_name: Name of filter if known :param binning: Binning value of this frame (1, 2, 3, or 4) :param comment: General comment describing this file """ # Create header header = fits.Header() header["FILTER"] = filter_name header["COMMENT"] = comment header["EXPTIME"] = exposure header["CCD-TEMP"] = temperature header["SET-TEMP"] = temperature header["XBINNING"] = binning header["YBINNING"] = binning header["PICTTYPE"] = file_type_code header["IMAGETYP"] = image_type_string # Create primary HDU data_16_bit = data.round().astype("i2") primary_hdu = fits.PrimaryHDU(data_16_bit, header=header) # Create HDUL hdul = fits.HDUList([primary_hdu]) # Write to file hdul.writeto(name, output_verify="fix", overwrite=True, checksum=True)