Functions¶
-
refstis.functions.
RemoveIfThere
(item)[source]¶ Remove a file only if it already exists
Parameters: item (str) – file to be removed Examples
>>> RemoveIfThere('/path/to/file.txt')
-
refstis.functions.
apply_dark_correction
(filename, expstart)[source]¶ Perform temperature scaling to input dark file
All science extensions in the input filename will be scaled to the reference temperatue of 18.0 c.
Parameters: - filename (str) – full path to input FITS file
- expstart (str) – start time in MJD of the dataset
-
refstis.functions.
bd_calstis
(joinedfile, thebiasfile=None)[source]¶ Run CalSTIS on the joined file
Header keywords will be set for ocrreject to work correctly and not flag regions outside the original aperture: APERTURE –> 50CCD APER_FOV –> ‘50x50’ DARKCORR –> ‘OMIT’ FLATCORR –> ‘OMIT’
Parameters: - joinedfile (str) – join of multiple input darks
- thebiasfile (str, bool) – the biasfile to be subtracted by basic2d
-
refstis.functions.
bd_crreject
(joinedfile)[source]¶ Check if cosmic-ray rejection has been performed on input file
if cosmic-ray rejection has already been done on the input bias image, skip all calstis-related calibration steps
-
refstis.functions.
bias_subtract_data
(filename, biasfile)[source]¶ Perform bias subtraction on input dataset
basic2d from calstis will be run on the input dataset with the steps DQICORR, BLEVCORR, and BIASCORR set to perform.
Parameters: - filename (str) – full path to input FITS file
- biasfile (str) – full path to the bias FITS file to be subtracted
Returns: filename – full_path to the bias subtracted file
Return type: str
-
refstis.functions.
count_imsets
(file_list)[source]¶ Count the total number of imsets in a file list.
The total number of imsets is counted by dividing the total number of extensions (NEXTEND) by 3 (SCI, ERR, DQ).
Parameters: file_list (list) – list of all files to be counted Returns: total – number of imsets Return type: ine
-
refstis.functions.
divide_anneal_month
(data_begin, data_end, database_path, N_period)[source]¶ This function divides an anneal month into anneal weeks and returns tuples of the start and end dates of the anneal weeks
-
refstis.functions.
figure_days_in_period
(N_periods, N_days, add_remainder=False)[source]¶ Spreads out the extra days among the periods.
Notes
Extra days will be added to the periods beginning with the first, until there are no more, so the lengths may not be perfectly even but will not differ by more than a day.
Parameters: - N_periods (int) – total number of periods to be split into
- N_days (float, int) – total number of days to be divided
Returns: periods – list of days/period: e.g. [8,8,8,7]
Return type: list
Examples
>>> figure_days_in_period(4, 28) [7, 7, 7, 7]
>>> figure_days_in_period(4, 29) [8, 7, 7, 7]
>>> figure_days_in_period(3, 21) [7, 7, 7]
-
refstis.functions.
figure_number_of_periods
(number_of_days, mode)[source]¶ Determines the number of periods (‘weeks’) that the anneal ‘month’ should be split into.
Takes the number of days in the period and the mode (‘WK’ or ‘BIWK’) and returns the total number of periods.
Parameters: - number_of_days (int) – total number of days in the ‘month’
- mode (str) – wk or biwk
Returns: number_of_periods – the total number of periods to split the month into
Return type: int
-
refstis.functions.
get_anneal_month_dates
(data_begin, data_end, database_path)[source]¶ This function uses the anneal database to get the dates of the anneal
This is written under the assumption that data_begin and data_end fall in the same anneal period
data_begin and data_end are the start and end dates of the data and should be in mjd
-
refstis.functions.
get_keyword
(file_list, keyword, ext=0)[source]¶ return the value from a header keyword over a list of files
if the value is not consistent accross the input files, an assertion error will be raised
-
refstis.functions.
make_path_safe
(filename)[source]¶ Make a full path to file safe for use in FITS headers.
For full paths that are less than 67 characters, the filename is simply returned. When the full path is equal to or greater than 67, then the path is inserted into the environment as ‘refdir’ and the filename is returned as ‘refdir$filename’. This will prevent the filename from being split accross multiple FITS keywords, and is a convention understood by many tasks/pipelines.
Parameters: filename (str) – Full path + name to the file. Returns: filename – Safe filename that can fit in a single FITS keyword. Return type: str Examples
>>> make_path_safe('/short/path/reference_file.fits') /short/path/reference_file.fits
>>> make_path_safe('/really/really/really/really/really/really/really/really/reference_file.fits') refdir$reference_file.fits
-
refstis.functions.
make_residual
(mean_bias, kern=(3, 15))[source]¶ Create residual image
Median filter the median with a 15 x 3 box and subtract from the mean to produce the residual image.
-
refstis.functions.
msjoin
(imset_list, out_name='joined_out.fits')[source]¶ Replicate msjoin functionality in pure python
-
refstis.functions.
normalize_crj
(filename)[source]¶ Normalize the input filename by exptim/gain and flush hdu
-
refstis.functions.
refaver
(reffiles, combined_name)[source]¶ Average two reference files together using msarith.
Warning
This task requires IRAF/PyRAF to be installed.
Parameters: - reffiles (list) – List of reference files to be averaged together
- combined_name (str) – Output name of the combined file