FITS Images
azcam.fits
azcam.fits contains FITS image support functions for azcam.
add(filename1, filename2, filename3, datatype='uint16')
Add two images.
filename3 = filename1 + filename2
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename1 |
str
|
image filename. |
required |
filename2 |
str
|
may be an image filename or a constant. |
required |
filename3 |
str
|
optional, must be an image filename. If not specified, result to filename1. |
required |
datatype |
str
|
valid datatype string for resultant data type. |
'uint16'
|
add_history(filename, history_string, extension=0)
Adds a HISTORY line containing 'history_string' to the image. Used to record actions performed on an image. A 20 character time stamp is added as a prefix, and the result is split across up to three cards if it is too long to fit in one. Any extra text is truncated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
required |
history_string |
str
|
string to add as a HISTORY keyword. |
required |
extension |
int
|
image extension number. |
0
|
arith(filename1, operator, filename2, filename3='', datatype='uint16')
Simple image arithmetic of FITS files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename1 |
str
|
image filename. |
required |
operator |
str
|
'+','-','/', or '*'. |
required |
filename2 |
str
|
may be an image filename or a constant. |
required |
filename3 |
str
|
optional, must be an image filename. If not specified, result to filename1. |
''
|
datatype |
str
|
valid datatype string for resultant data type. |
'uint16'
|
colbias(filename='test', fit_order=3, margin_cols=0)
Remove column bias from a FITS file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
'test'
|
fit_order |
int
|
polynomial fit order, use 0 to remove median not fitted value. |
3
|
margin_cols |
int
|
number of overscan columns to skip before correction. |
0
|
combine(file_list=[], out_filename='combined.fits', combination_type='median', overscan_correct=1, fit_order=3, datatype='float32')
Make a combination iamge from a list of FITS filenames.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_list |
list
|
list of filenames to combine. |
[]
|
out_filename |
str
|
output filename. |
'combined.fits'
|
combination_type |
str
|
combination type, "median", "sum", or "mean". |
'median'
|
overscan_correct |
int
|
line fit order if >0 for overscan correction before combination. |
1
|
div(filename1, filename2, filename3, datatype='uint16')
Divide two images.
filename3 = filename1 / filename2
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename1 |
str
|
image filename. |
required |
filename2 |
str
|
may be an image filename or a constant. |
required |
filename3 |
str
|
optional, must be an image filename. If not specified, result to filename1. |
required |
datatype |
str
|
valid datatype string for resultant data type. |
'uint16'
|
edit_keyword(filename, keyword, value, extension=0)
Edits a header keyword value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
required |
keyword |
str
|
keyword name. |
required |
value |
Any
|
new value of keyword. |
required |
extension |
int
|
image extension number. |
0
|
file_exists(filename)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
filename to check if exists. |
required |
Returns: True if the file exists.
get_data(filename='test', roi=[])
Return data (pixel values) from an ROI in an image for every extension. NOT FINISHED!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
'test'
|
roi |
str
|
Region-Of-Interest. |
[]
|
Returns: list of pixel values.
get_extensions(filename)
Returns the number of image extensions and their indices. The number of extensions is 0 for a standard FITS file and >0 for MEF. The first data extension for an MEF file is 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
required |
Returns:
the list [number_exts, first_ext, last_ext]
containing the number of extensions and the
indices for the python range
function to iterate over them.
get_header(filename, extension=0)
Return an image header.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
required |
extension |
int
|
image extension number. |
0
|
Returns: the image header as a pyfits header object.
get_history(filename, extension=0)
Returns the HISTOR header lines.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
required |
extension |
int
|
image extension number. |
0
|
Returns: string containing all HISTORY lines.
get_keyword(filename, keyword, extension=0)
Return a header keyword value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
required |
keyword |
str
|
keyword name. |
required |
extension |
int
|
image extension number. |
0
|
Returns: the specified keyword value.
get_section(filename, section, extension=0)
Returns image section pixel numbers from a FITS keyword.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
required |
section |
str
|
section name (like "CCDSEC"). |
required |
extension |
int
|
image extension number where keyword is located. |
0
|
Returns:
list of zero-based pixel numbers defining the
section as [first_col,last_col,first_row,last_row]
.
maximum(filename='test', roi=[])
Compute maximum of an image ROI for every extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
'test'
|
roi |
str
|
Region-Of-Interest. |
[]
|
Returns: list of the maxima of each image extension or ROI in each extension.
mean(filename='test', roi=[])
Compute mean of an image ROI in every extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
'test'
|
roi |
list
|
Region-Of-Interest. |
[]
|
Returns: list of the means of each image extension or ROI in each extension.
minimum(filename='test', roi=[])
Compute minimum of an image ROI for every extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
'test'
|
roi |
str
|
Region-Of-Interest. |
[]
|
Returns: list of the minima of each image extension or ROI in each extension.
mult(filename1, filename2, filename3, datatype='uint16')
Multiple two images.
filename3 = filename1 * filename2
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename1 |
str
|
image filename. |
required |
filename2 |
str
|
may be an image filename or a constant. |
required |
filename3 |
str
|
optional, must be an image filename. If not specified, result to filename1. |
required |
datatype |
str
|
valid datatype string for resultant data type. |
'uint16'
|
resample(filename, resample=2)
Resample an image by combining adjacent pixels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
required |
resample |
int
|
number of pixels to combine in each dimension. |
2
|
sdev(filename='test', roi=[])
Compute standard deviation of an image ROI in every extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
'test'
|
roi |
list
|
Region-Of-Interest. |
[]
|
Returns: list of the standard deviations of each image extension or ROI in each extension.
stat(filename='test', roi=[])
Compute mean and sdev image statistics of ROI in every extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
image filename. |
'test'
|
roi |
list
|
Region-Of-Interest. |
[]
|
Returns:
list of [[means], [sdevs], ROI]
for each image extension or ROI in each extension.
sub(filename1, filename2, filename3, datatype='uint16')
Subtract two images.
filename3 = filename1 - filename2
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename1 |
str
|
image filename. |
required |
filename2 |
str
|
may be an image filename or a constant. |
required |
filename3 |
str
|
optional, must be an image filename. If not specified, result to filename1. |
required |
datatype |
str
|
valid datatype string for resultant data type. |
'uint16'
|