Virus Health check routines.
VirusHealth::VirusHealth | ( | const string & | filename, | |
unsigned int | recipe, | |||
const CommonCheckOptions & | copts | |||
) |
Initialize the VirusHealth class with the opened fits image, the recipe type (one of the vh() enum), and the optional verbose flag.
fitsfile | ltl::FitsIn() of the opened fits image. | |
recipe | integer specifying the recipe. | |
verbose | boolean, if true write extened output to stdout. |
References fitsfile_, get_string_key_(), n_checks_, n_passed_, opts_, recipe_, response_, unknown, CommonCheckOptions::verbose, and verbose_.
VirusHealth::~VirusHealth | ( | ) |
References filename_, fitsfile_, opts_, and CommonCheckOptions::write_file.
void VirusHealth::write_file | ( | ) |
void VirusHealth::check_header | ( | ) |
Run the common header checks.
References CommonCheckOptions::chk_exptime, CommonCheckOptions::chk_keywords, CommonCheckOptions::chk_npixels, CommonCheckOptions::chk_overscan, CommonCheckOptions::maxdev_ovc_mean, CommonCheckOptions::maxdev_ovc_rms, opts_, CommonCheckOptions::overscan_mean, CommonCheckOptions::overscan_stddev, validate_exptime(), validate_keywords(), validate_overscan(), and validate_size().
Referenced by main().
void VirusHealth::validate_size | ( | ) |
Validate the image size. Check that the number of pixels along NAXIS1 is 1064 pixels (2064 / 2 + 32 pixels overscan) and along NAXIS2 is 1032 pixels (2064 binned 2 for 1).
References finish_check_(), fitsfile_, and log_test_().
Referenced by check_header().
void VirusHealth::validate_keywords | ( | ) |
Validate the presence of various header keywords, keywords checked are:
References finish_check_(), get_float_key_(), get_int_key_(), get_string_key_(), and log_test_().
Referenced by check_header().
void VirusHealth::validate_overscan | ( | const float | mean, | |
const float | stddev, | |||
const float | maxdev_mean, | |||
const float | maxdev_rms | |||
) |
Validate the rms of the overscan by checking that the standard deviation of the overscan region is below the given maximum. The overscan region is read from the `BIASSEC` header keyword.
mean | float expected mean. | |
stddev | float expected standard deviation. | |
maxdev_mean | float maximum allowed fractional difference of the mean. | |
maxdev_mean | float maximum allowed fractional difference of the standard deviation. |
References finish_check_(), log_test_(), and read_overscan_().
Referenced by check_header().
void VirusHealth::validate_exptime | ( | ) |
Validate the exposure time depending on the image type recipe. For bias frames, the exposure time must be zero seconds, for other images it must be not zero. For HETDEX observations the exposure time must be at least 3600 seconds.
References bias, finish_check_(), get_float_key_(), log_test_(), and recipe_.
Referenced by check_header().
void VirusHealth::validate_flatbias | ( | const float | maxdiff | ) |
Validate the overall flatness of the bias frame, by comparing the standard deviation and average of different sub images at 250:500,500:1000, 250:500,1500:2000, 750:1000,500:1000, 750:1000,1500:2000, and the overcan. If any of the differences exceeds the difference allowed by the relative difference given by maxdiff.
maxdiff | float giving the maximum difference relative to the average / rms. |
References finish_check_(), log_test_(), read_image_(), and read_overscan_().
Referenced by main().
void VirusHealth::validate_refbias | ( | const float | mean, | |
const float | stddev, | |||
const float | maxdev_mean, | |||
const float | maxdev_rms | |||
) |
Validate that the bias and the reference bias frame are not too deviant. Check that the average image flux of the bias frame and the reference bias frame or the standard deviation of bias frame and the reference bias frame do not differ more than the maximum given by maxdiff.
mean | float expected mean. | |
stddev | float expected standard deviation. | |
maxdev_mean | float maximum allowed fractional difference of the mean. | |
maxdev_mean | float maximum allowed fractional difference of the standard deviation. |
References finish_check_(), log_test_(), and read_image_().
Referenced by main().
void VirusHealth::validate_saturation | ( | const float | saturation | ) |
Validate that the image fluxes are below saturation limit.
saturation | The saturation limit of the chip. |
References finish_check_(), log_test_(), and read_image_().
Referenced by main().
void VirusHealth::validate_min_flux | ( | const float | minflux, | |
const int | nfibers, | |||
const int | maxbad | |||
) |
Validate the flux in all fibers is above the required minimum flux.
minflux | The expected minimum flux |
References finish_check_(), log_test_(), read_image_(), read_overscan_(), and Measure::search().
Referenced by main().
void VirusHealth::validate_n_fibers | ( | const int | nfibers, | |
const int | maxbad | |||
) |
Validate that all expected fibers are lit.
nfibers | Expected number of active fibers. | |
maxbad | Maximum number of fibers allowed to go dark with only a warning raised. If more fibers fail an error is logged. |
References finish_check_(), log_test_(), read_image_(), read_overscan_(), and Measure::search().
Referenced by main().
void VirusHealth::validate_throughput | ( | ) |
Validate the throughput.
Not yet implemented, the check always succeeds.
References finish_check_(), and log_test_().
Referenced by main().
void VirusHealth::validate_distortion | ( | const string & | distname | ) |
Validate the position of the fibers on the chip against a reference distortion.
distname | The name of the reference distortion |
Not yet implemented, the check always succeeds.
References finish_check_(), and log_test_().
Referenced by main().
void VirusHealth::validate_peaks | ( | const string & | linelist, | |
const string & | distname, | |||
int | peak_tolerance, | |||
int | max_missing | |||
) |
Validate the arc peaks are at the expected positions and actual peaks.
linelist | string The name of the arc line lists. | |
distname | string The name of the reference distortion | |
peak_tolerance | int maximum pixel offset from the expected position and half size of the patch used to perform the arc peak fit | |
max_missing | int maximum number of missing fibers before giving up |
References finish_check_(), gauss2Dfit(), Distortion::get_numfibers(), Distortion::get_reference_f(), get_string_key_(), ArcLineList::getActiveWLs(), ArcLineList::getNumActiveLines(), header_to_region_(), log_test_(), log_warning_(), Distortion::map_wf_x(), Distortion::map_wf_y(), read_image_(), read_overscan_(), and verbose_.
Referenced by main().
void VirusHealth::validate_sky | ( | float | skylevel | ) |
Validate the sky level is above the minimum sky level.
skylevel | The minimum expected sky level. |
Not yet implemented, the check always succeeds.
References finish_check_(), and log_test_().
Referenced by main().
int VirusHealth::get_n_checks | ( | ) | [inline] |
int VirusHealth::get_n_passed | ( | ) | [inline] |
string& VirusHealth::get_response | ( | ) | [inline] |
MArray<float,2> VirusHealth::read_overscan_ | ( | void | ) | [inline, private] |
References fitsfile_, get_string_key_(), header_to_region_(), and read_region_().
Referenced by validate_flatbias(), validate_min_flux(), validate_n_fibers(), validate_overscan(), and validate_peaks().
MArray<float,2> VirusHealth::read_image_ | ( | void | ) | [inline, private] |
References fitsfile_, get_string_key_(), header_to_region_(), and read_region_().
Referenced by validate_flatbias(), validate_min_flux(), validate_n_fibers(), validate_peaks(), validate_refbias(), and validate_saturation().
MArray< float, 2 > VirusHealth::read_region_ | ( | FitsIn & | in, | |
const util::Region & | reg | |||
) | [private] |
Read a region from the fits file.
in | The ltl::FitIn() object to read the region from. | |
reg | The util::Region to read. |
Referenced by read_image_(), and read_overscan_().
util::Region VirusHealth::header_to_region_ | ( | const string & | key | ) | throw (ltl::IOException) [private] |
Convert a header region to a ltl Region. Read the region string from the header, and convert it to a util::Region object.
key | The header key from which to read the region string |
ltl::IOException | Thrown if the header key cannot be found. |
Referenced by read_image_(), read_overscan_(), and validate_peaks().
float VirusHealth::get_float_key_ | ( | const string | key | ) | throw (ltl::IOException) [private] |
Get a float header keyword.
key | The keyword to read from the checked image. |
util::IOException() | Thrown if the keyword cannot be found |
Referenced by validate_exptime(), and validate_keywords().
int VirusHealth::get_int_key_ | ( | const string | key | ) | throw (ltl::IOException) [private] |
Get a integer header keyword.
key | The keyword to read from the checked image. |
util::IOException() | Thrown if the keyword cannot be found |
Referenced by validate_keywords().
string VirusHealth::get_string_key_ | ( | const string | key | ) | throw (ltl::IOException) [private] |
Get a string header keyword.
key | The keyword to read from the checked image. |
util::IOException() | Thrown if the keyword cannot be found |
Referenced by read_image_(), read_overscan_(), validate_keywords(), validate_peaks(), and VirusHealth().
bool VirusHealth::get_bool_key_ | ( | const string | key | ) | throw (ltl::IOException) [private] |
Get a boolean header keyword.
key | The keyword to read from the checked image. |
util::IOException() | Thrown if the keyword cannot be found |
void VirusHealth::set_keyword | ( | const string & | key, | |
bool | passed | |||
) | [private] |
void VirusHealth::add_error_ | ( | const string & | str | ) | [inline, private] |
Add an error message to the response string, prepending the current filename.
str | The string to add. |
References filename_, and response_.
Referenced by finish_check_().
void VirusHealth::log_test_ | ( | const string & | str | ) | [inline, private] |
References filename_, and fitsfile_.
Referenced by validate_distortion(), validate_exptime(), validate_flatbias(), validate_keywords(), validate_min_flux(), validate_n_fibers(), validate_overscan(), validate_peaks(), validate_refbias(), validate_saturation(), validate_size(), validate_sky(), and validate_throughput().
void VirusHealth::log_warning_ | ( | const string & | str | ) | [inline, private] |
References filename_.
Referenced by validate_peaks().
void VirusHealth::finish_check_ | ( | const string & | hkey, | |
const string & | error, | |||
const string & | warn = "" | |||
) | [private] |
Finish a check.
hkey | The keyword to be set in the header | |
error | The check error message. If it is "", the check is considered passed. | |
warn | Optional warning generated by the test, placed into the key comment. |
References add_error_(), fitsfile_, n_checks_, and n_passed_.
Referenced by validate_distortion(), validate_exptime(), validate_flatbias(), validate_keywords(), validate_min_flux(), validate_n_fibers(), validate_overscan(), validate_peaks(), validate_refbias(), validate_saturation(), validate_size(), validate_sky(), and validate_throughput().
FitsIn VirusHealth::fitsfile_ [private] |
Referenced by finish_check_(), log_test_(), read_image_(), read_overscan_(), validate_size(), VirusHealth(), and ~VirusHealth().
string VirusHealth::filename_ [private] |
Referenced by add_error_(), log_test_(), log_warning_(), and ~VirusHealth().
unsigned int VirusHealth::recipe_ [private] |
Referenced by validate_exptime(), and VirusHealth().
string VirusHealth::response_ [private] |
Referenced by add_error_(), get_response(), and VirusHealth().
int VirusHealth::n_checks_ [private] |
Referenced by finish_check_(), get_n_checks(), and VirusHealth().
int VirusHealth::n_passed_ [private] |
Referenced by finish_check_(), get_n_passed(), and VirusHealth().
bool VirusHealth::verbose_ [private] |
Referenced by validate_peaks(), and VirusHealth().
CommonCheckOptions VirusHealth::opts_ [private] |
Referenced by check_header(), VirusHealth(), and ~VirusHealth().