Source code for ecpi.common.instru.ref_geom

'''
Created on 14 juin 2018

functions to write/save geometric parameters of ECLAIRs in the file of the mask

@author: Colley Jean-Marc, APC/IN2P3/CNRS
'''

from astropy.io import fits


[docs]def add_kw_geom_eclairs_to_mask(f_in, f_out): """add mask keywords to the mask fits file :param f_in: input file :param f_out: output file :type f_in: string (PATH/name) :type f_out: string (PATH/name) """ hdul = fits.open(f_in) mask = hdul[0].data eg = ECLAIRsGeom() # change attribut if necessary # eg.vers_geo = "myvers" # eg.vers_mas = "myvers" eg.save_with_kw_geom_eclairs(mask, f_out, "IJDET") hdul.close()
[docs]class ECLAIRsGeom(object): def __init__(self): """ All distance are in cm :param mask: mask data array :param filename: PATH/name of the file to save in :param detpix: number of detector pixels in a row :param detpsize: size of a detector pixel :param pixpitch: pitch between detector pixels :param distdetmask: distance detector to mask planes :param maspix: number of mask pixels in a row :param maspsize: size of a mask pixel :param massize: size of the mask in :param masnerv: thickness of the mask cross in :param detmas: distance between mask and detector :param alpha: average open fraction of the mask :param version: version of the mask :type mask: float array (46x46) :type filename: string :type detpix: int (default=80) :type detpsize: float (default=0.4) :type pixpitch: float (default=0.45) :type distdetmask: float (default=27) :type maspix: int (default=46) :type maspsize: float (default=1.1393617) :type massize: float (default=54) :type masnerv: float (default=1.5893617) :type detmas: float (default=45.77) :type alpha: float (default=0.4) :type version: string (default="none") """ self.detpix = 80 self.detpsize = 0.4 self.pixpitch = 0.45 self.distdetmask = 27 self.maspix = 46 self.maspsize = 1.1393617 self.massize = 54 self.masnerv = 1.5893617 self.detmas = 45.77 self.alpha = 0.4 self.vers_mas = "COMPETITOR_6_V3" self.vers_geo = "17-12-2018"
[docs] def save_with_kw_geom_eclairs(self, mask, filename, convention=None): """save mask in a fits file with good keywords """ hdu = fits.PrimaryHDU(mask) hdu.header['comment'] = "ECLAIRs instrument's dimension" hdu.header['DETPIX'] = (self.detpix , 'number of detector pixels in a row') hdu.header['DETPSIZE'] = (self.detpsize, 'size of a detector pixel in cm') hdu.header['PIXPITCH'] = (self.pixpitch, 'pitch between detector pixels in cm') hdu.header['MASPIX'] = (self.maspix, 'number of mask pixels in a row') hdu.header['MASPSIZE'] = (self.maspsize, 'size of a mask pixel in cm') hdu.header['MASSIZE'] = (self.massize, 'size of the mask in cm') hdu.header['MASNERV'] = (self.masnerv, 'thickness of the mask cross in cm') hdu.header['DETMAS'] = (self.detmas, 'distance between mask and detector in cm') hdu.header['ALPHA'] = (self.alpha, 'average open fraction of the mask') hdu.header['VERS_MAS'] = (self.vers_mas, 'name version mask') hdu.header['VERS_GEO'] = (self.vers_geo, 'name version instru geometry') if convention: hdu.header['IM_FORMT'] = (convention, 'image format IJDET (UGTS), EGP, DS9') hdu.writeto(filename, overwrite=True)