ecpi.common.io.fits_tools module
Section author: ECLAIRs GP team
Generic functions to manipulate fits file
Summary
Functions:
add to the fits header the common keywords used in all the pipeline products |
|
add to fits header the keywords related to energy |
|
Return list of .fits files whose CCNM0001 is equal to name. |
|
Return list of .fits files whose CARD is equal to card_name. |
|
get name file FITS for a product |
|
add to the fits header the specific keywords for a group HDU |
|
plot/show/save the image of the array |
|
Remove '.', ':', '-' from isot string |
|
add to fits header the keywords related to pointing of ECLAIRs |
|
Read an array from a fits file |
|
read a fits file |
|
read a fits file (using read_fits) |
|
Save an array into a fits file |
Reference
- common_keyword(fits_header, tstart, tstop, creator='ECLAIRs_pipeline', version='0.1', proc_id='01')[source]
add to the fits header the common keywords used in all the pipeline products
See also
doc : ECL-GP-FITS-KEYWORDS.pdf ECLAIRs GP fits keywords https://forge.in2p3.fr/dmsf/files/6731/view
- Parameters
fits_header (astropy.io.fits.*HDU) – header data unit to add the keyword (ex: fits.PrimaryHDU)
creator (string (default='ECLAIRs_pipeline')) – name of the program that has created the fits file
version (string (default='0.1')) – fits file format version
proc_id (string (default="01")) – id of the pipeline process
tstart (string) – start time of the observation in s from MJDREF
tstop (string) – end time of the observation in s from MJDREF
- energy_keywords(fits_header, chanmin, chanmax, e_min, e_max)[source]
add to fits header the keywords related to energy
- Parameters
fits_header (astropy.io.fits.*HDU) – header data unit to add the keyword (ex: fits.PrimaryHDU)
chanmin (float) – lowest channel of the energy range
chanmax (float) – highest channel of the energy range
e_min (float) – lower energy limit in keV
e_max (float) – upper energy limit in keV
- get_caldb_files_with_name(name, workdir)[source]
Return list of .fits files whose CCNM0001 is equal to name.
- Parameters
name (string) – name of the CCNM0001 keyword to be searched for
workdir (string) – directory containing .fits files
- Returns
list of files in workdir which have their CCNM0001 equal to
card_name :rtype: list
- get_fits_files_with_extname(card_name, workdir)[source]
Return list of .fits files whose CARD is equal to card_name.
- Parameters
card_name (string) – name of the CARD keyword to be searched for
workdir (string) – directory containing .fits files
- Returns
list of files in workdir which has their CARD equal to
card_name :rtype: list
- get_name_fits(prod, t_start, obs_id='0', vers=None)[source]
get name file FITS for a product
template : prod_{obs_id_}t_start_at_t_create.fits
- Parameters
prod (string) – ECLAIRs product like ECL-SKY-IMA
t_start (string, isot format) – time start of event file associated to image
obs_id (string) – observation identificator
- grouphdu_keyword(fits_header, grp_table_name, attitude)[source]
add to the fits header the specific keywords for a group HDU
- Parameters
fits_header (astropy.io.fits.*HDU) – header data unit to add the keyword (ex: fits.PrimaryHDU)
grp_table_name (string) – grouping table name
- image_plot(image, save=None, show=False, title=None, clim=None, scale_legend=None, **kwargs)[source]
plot/show/save the image of the array
the function uses imshow
- Parameters
image (float array) – data array to plot
save (string (default=None)) – PATH/name of the file to save the fig. If None, no saving.
show (bool (default=False)) – show the plot
title (string (default=None)) – title of the plot
clim ((float, float) (default=None)) – color limit
scale_legend (string (default=None)) – legend for the color scale
**kwargs –
other arguments directly passed to plt.imshow
Warning
clim has not been tested.
- isot_whitout_sign(isot)[source]
Remove ‘.’, ‘:’, ‘-‘ from isot string
- Parameters
isot (str) – time in isot format
- pointing_keywords(fits_header, attitude, obs_time)[source]
add to fits header the keywords related to pointing of ECLAIRs
- Parameters
fits_header (astropy.io.fits.*HDU) – header data unit to add the keyword (ex: fits.PrimaryHDU)
attitude ([float, float, float]) – [ra, dec, ori] in degrees
- read_fits(name, ugts_standard=False)[source]
Read an array from a fits file
Warning
The structure of the fits file must be simple: data into hdu[0].data
- Parameters
name (string) – PATH/name of the fits file
ugts_standard (bool) – flag to read from ugts Idet,Jdet orientation and make the transformation to Yecl,Zecl
- Returns
the data from the fits file
- Return type
array
- set_array_and_header_from_file(filename, ugts_standard=False)[source]
read a fits file
- Parameters
filename (string) – PATH/filename of the fits file
ugts_standard (bool) – flag to read from ugts Idet,Jdet orientation and make the transformation to Yecl,Zecl
- Returns
array of the data, len of the first dim (=size of the square array), header object
- Return type
array, int, HDUList
- set_array_from_file(filename, ugts_standard=False)[source]
read a fits file (using read_fits)
- Parameters
filename (string) – PATH/filename of the fits file
ugts_standard (bool) – flag to read from ugts Idet,Jdet orientation and make the transformation to Yecl,Zecl
- Returns
array of the data, len of the first dim (=size of the square array)
- Return type
array, int