Helper class to Distortion
, FiberModel
, and PsfModel
. This class locates the fibers and the arc lamp line images on a flat field and an arc lamp frame. Trace the fibers, measure the arc lines, and provide and fit fitting functions to the fiber profiles and the shapes of the arc lamp images.
typedef gauss1D_H<float> Measure::FiberProfile |
Measure::Measure | ( | FiberModel & | F, | |
float | min_slope = 0.02 , |
|||
float | peak_offset = 8. , |
|||
float | select_chi = 100. , |
|||
float | fit_radius = 4. , |
|||
int | iter = 50 , |
|||
float | accuracy = 1.e-4 , |
|||
int | verbose = 1 , |
|||
float | peak_cutoff = 0.1 , |
|||
int | fid = FIDUCIAL_FIBER | |||
) |
References accuracy_, F_, fiducial_fib_, fit_radius_, fix_h2_, fix_h3_, iter_, min_slope_, peak_cutoff_, peak_offset_, select_chi_, and verbose_.
MArray< float, 1 > Measure::search | ( | int | search_x, | |
const MArray< float, 2 > & | Data, | |||
const MArray< float, 2 > & | Data_error | |||
) |
Look for peaks in a given Data array with peak_offset_ and a slope of at least min_slope_ returns counter number of Peaks
Look for peaks in a given Data array with peak_offset_ and a slope of at least min_slope_ returns counter number of Peaks
search_x | int column to use to search the peaks | |
Data | ltl::MArray() array in which the peaks are searched | |
Data_error | ltl::MArray() error array |
and work your way down.
References index_of_max(), min_slope_, peak_cutoff_, peak_offset_, SEARCHBORDER, and verbose_.
Referenced by fit_initial_dist(), main(), VirusHealth::validate_min_flux(), and VirusHealth::validate_n_fibers().
MArray< DistDataTuple, 2 > Measure::trace | ( | const MArray< float, 2 > & | Data, | |
const MArray< float, 2 > & | Data_error, | |||
int | x, | |||
int | start, | |||
int | stop, | |||
const MArray< float, 1 > & | peakpos | |||
) |
Trace peaks from start to stop going from x to start and x to stop using guess_y as start y position return peaks in TracePeaks
References trace_outwards().
Referenced by fit_initial_dist(), and main().
MArray< DistDataTuple, 2 > Measure::correlate | ( | const MArray< float, 2 > & | Data, | |
const MArray< float, 2 > & | Data_error, | |||
const MArray< DistDataTuple, 2 > & | Peaks, | |||
const MArray< float, 1 > & | fvalue, | |||
ArcLineList | arcLineList, | |||
ltl::FVector< double, 7 > | startpar | |||
) |
Correlate position of (trace) Peaks with lines given in configuration file to find arc peak positions in Data file at that position.
References fit_gauss2D(), fit_radius_, ArcLineList::getActivePXpos(), ArcLineList::getActiveWL(), and ArcLineList::getNumActiveLines().
Referenced by fit_initial_dist(), and main().
MArray< float, 2 > Measure::remove_spectra_ind | ( | const MArray< float, 2 > & | A, | |
const Distortion & | D | |||
) |
Prepare a data frame for processing by measure_fiberpars()
. The spectra in the frame are normalized to the interpolated data at the center of each fiber (eliminating any spectral features in the data).
References Distortion::get_reference_f(), interpolate_at_xy(), Distortion::map_wf_x(), Distortion::map_xf_y(), Distortion::map_xy_fibernum(), Distortion::map_xy_wavelength(), maxx(), maxy(), minx(), and miny().
MArray< float, 2 > Measure::remove_spectra | ( | const MArray< float, 2 > & | A, | |
const Distortion & | D | |||
) |
Prepare a data frame for processing by measure_fiberpars()
. The spectra in the frame are normalized to the interpolated data at the center of the fiducial fiber (eliminating any spectral features in the data).
References fiducial_fib_, Distortion::get_reference_f(), integrate_fiber_profile(), Distortion::map_wf_x(), Distortion::map_wf_y(), and Distortion::map_xy_wavelength().
Referenced by fit_initial_dist(), main(), plot_fibermodel_data(), and refit_models().
MArray< float, 2 > Measure::remove_spectra | ( | const MArray< float, 2 > & | A, | |
const Distortion & | D, | |||
const FiberModel & | F | |||
) |
Prepare a data frame for processing by measure_fiberpars()
. The spectra in the frame are normalized to the center each fiber using the fiber model (eliminating any spectral features in the data), then normalized to the amplitudes of the FiberModel object.
References Distortion::get_reference_f(), FiberModel::get_xy_amplitude(), integrate_fiber_profile(), Distortion::map_xf_y(), and Distortion::map_xy_fibernum().
MArray< FiberDataTuple, 2 > Measure::measure_fiberpars | ( | const MArray< float, 2 > | Data, | |
const Distortion & | D, | |||
const bool | rect_to_wf, | |||
const MArray< float, 2 > & | sigma_guess, | |||
int | start, | |||
int | end, | |||
int | step, | |||
int | length, | |||
bool | fix_h2 = false , |
|||
bool | fix_h3 = false | |||
) |
Measure the fiber profile parameters (using the FiberModel in this class) by fitting it to every fiber and from x-position start to end with step-size step on Data file. The data are assumed to be resampled into x-f space.
References UnsortFiberData::Amplitude, c, clamp_window(), UnsortFiberData::Error, fit_peaks3H_final(), fit_peaks3H_initial(), fix_h2_, fix_h3_, Distortion::get_numfibers(), Distortion::get_reference_f(), UnsortFiberData::H2, UnsortFiberData::H3, Distortion::map_wf_x(), Distortion::map_wf_y(), Distortion::map_xf_y(), Distortion::map_xy_wavelength(), rectify_to_wf(), rectify_to_xf(), UnsortFiberData::Sigma, and UnsortFiberData::Yposition.
Referenced by fit_initial_dist(), main(), plot_fibermodel_data(), and refit_models().
MArray< float, 1 > Measure::measure_at_ref_w | ( | const MArray< float, 2 > & | Data, | |
const Distortion & | D, | |||
const bool | rect_to_wf, | |||
const MArray< float, 2 > & | sigma_guess, | |||
const int | length, | |||
bool | fix_h2 = false , |
|||
bool | fix_h3 = false | |||
) |
Measure the fiber profile parameters (using the FiberModel in this class) by fitting it to every fiber at the reference wavelength only. The data are assumed to be resampled into x-f space.
References c, clamp_window(), fit_peaks3H_final(), fit_peaks3H_initial(), fix_h2_, fix_h3_, Distortion::get_numfibers(), Distortion::get_reference_f(), Distortion::get_reference_wavelength(), Distortion::map_wf_x(), Distortion::map_wf_y(), rectify_to_wf(), and rectify_to_xf().
Referenced by main(), and refit_models().
std::vector< Measure::FiberThroughputPars > Measure::fit_fiberthroughput | ( | MArray< FiberDataTuple, 2 > & | FiberPars, | |
const Distortion & | D | |||
) |
References _scalw_, a, FIDUCIAL_FIBER, UnivariateLinearLsqFit< T, Function >::fit(), and Distortion::get_numfibers().
Referenced by fit_initial_dist(), main(), and refit_models().
std::vector< Measure::FiberThroughputPars > Measure::scale_fiberthroughput | ( | MArray< FiberDataTuple, 2 > & | FiberPars, | |
const MArray< float, 1 > & | flx5577, | |||
const FiberModel & | Fold, | |||
const Distortion & | D, | |||
const bool | use_5577 | |||
) |
References _scalw_, a, FIDUCIAL_FIBER, UnivariateLinearLsqFit< T, Function >::fit(), Distortion::get_numfibers(), and FiberModel::get_wf_amplitude().
Referenced by main(), and refit_models().
MArray< float, 2 > Measure::rectify_to_xf | ( | const MArray< float, 2 > & | A, | |
const Distortion & | D | |||
) | const |
References Resampler< Interpolator, Transform >::resample_xy_xf().
Referenced by measure_at_ref_w(), and measure_fiberpars().
MArray< float, 2 > Measure::rectify_to_wf | ( | const MArray< float, 2 > & | A, | |
const Distortion & | D, | |||
float & | minw, | |||
float & | maxw | |||
) | const |
References Distortion::map_xy_wavelength(), and Resampler< Interpolator, Transform >::resample_wf().
Referenced by measure_at_ref_w(), and measure_fiberpars().
list< PsfDataTuple > Measure::fit_psf1D | ( | const MArray< float, 2 > & | I, | |
const MArray< float, 2 > & | I_e, | |||
const MArray< DistDataTuple, 2 > & | ArcPeaks, | |||
const Distortion & | D, | |||
const FiberModel & | F, | |||
const float | kappa | |||
) |
Fit gaussians to arc peaks and return a list of the best-fitting parameters. In this version of fit_psf the PSFs are fitted only in spectral direction. The cross dispersion parameters are taken from the fiber model.
References filter_peaks(), gauss1Dfit(), FiberModel::get_xy_h2(), FiberModel::get_xy_h3(), FiberModel::get_xy_sigma(), interpolate_at_xy(), Distortion::map_wf_x(), Distortion::map_wf_y(), Distortion::map_xf_y(), Distortion::map_xy_fiber(), and Distortion::map_xy_wavelength().
Referenced by fit_initial_dist(), main(), and plot_data().
list< PsfDataTuple > Measure::fit_psf2D | ( | const MArray< float, 2 > & | I, | |
const MArray< float, 2 > & | I_e, | |||
const MArray< DistDataTuple, 2 > & | ArcPeaks, | |||
const Distortion & | D, | |||
const float | kappa | |||
) |
Fit gaussians to arc peaks and return a list of the best-fitting parameters. In this version of fit_psf actual bivariate Gaussians are fitted to the PSFs. The Gauss-Hermite moments in PsfDataTuple are zero.
Fit gaussians to arc peaks and return a list of the best-fitting parameters. In this version of fit_psf actual bivariate Gaussians are fitted to the PSFs. The Gauss-Hermite Moments in PsfDataTuple are zero.
References filter_peaks(), fit_gauss2D(), fit_radius_, Distortion::get_position_angle(), Distortion::map_xy_fiber(), and Distortion::map_xy_wavelength().
void Measure::trace_outwards | ( | const MArray< float, 2 > & | Data, | |
const MArray< float, 2 > & | Data_error, | |||
int | start, | |||
int | stop, | |||
const MArray< float, 1 > & | peakpos, | |||
MArray< DistDataTuple, 2 > & | Peaks | |||
) | [protected] |
Trace peaks outwards from start to stop return peaks in TracePeaks
References UnsortFiberData::Error, fit_peaks3H(), and UnsortFiberData::Yposition.
Referenced by trace().
float Measure::interpolate_at_xy | ( | const MArray< float, 2 > & | I, | |
const float | x, | |||
const float | y | |||
) | const [protected] |
interpolate an image at fractional coordinates x
,y
References BiCubicInterpolator::interpolate().
Referenced by fit_psf1D(), integrate_fiber_profile(), and remove_spectra_ind().
UnsortFiberData Measure::fit_peaks3H_initial | ( | const MArray< float, 1 > & | Fguess, | |
const MArray< float, 1 > & | x, | |||
const MArray< float, 1 > & | Data, | |||
const MArray< float, 1 > & | sigma_guess, | |||
const Distortion & | D, | |||
const float | minw, | |||
const float | dw, | |||
const bool | wf | |||
) | [protected] |
Measure initial fiberparameters on a rectified image slice to be used as initial values for final fit.
References accuracy_, F_, fit_fiber(), fix_h2_, fix_h3_, gauss1D_2H_fit(), gauss1D_3H_fit(), get_fittype(), FiberModel::get_xy_h2(), FiberModel::get_xy_h3(), FiberModel::get_xy_sigma(), iter_, Distortion::map_wf_x(), Distortion::map_wf_y(), Distortion::map_xf_y(), peak_offset_, and verbose_.
Referenced by measure_at_ref_w(), and measure_fiberpars().
UnsortFiberData Measure::fit_peaks3H_final | ( | const UnsortFiberData & | initial_fiberdata, | |
const MArray< float, 1 > & | Fguess, | |||
const MArray< float, 1 > & | x, | |||
const MArray< float, 1 > & | Data, | |||
const MArray< float, 1 > & | sigma_guess, | |||
const Distortion & | D, | |||
const float | minw, | |||
const float | dw, | |||
const bool | wf | |||
) | [protected] |
References accuracy_, UnsortFiberData::Amplitude, UnsortFiberData::Error, fit_fiber(), fix_h2_, fix_h3_, gauss1D_H_fit(), get_fittype(), UnsortFiberData::H2, UnsortFiberData::H3, iter_, UnsortFiberData::Sigma, sum2gaussH(), verbose_, and UnsortFiberData::Yposition.
Referenced by measure_at_ref_w(), and measure_fiberpars().
UnsortFiberData Measure::fit_peaks3H | ( | const MArray< float, 1 > & | Fguess, | |
const float | x, | |||
const MArray< float, 1 > & | Data, | |||
const MArray< float, 1 > & | Data_err | |||
) | [protected] |
Fit fiber peaks with gaussians, using blocks of 3 fibers and a sum of 3 gaussians. Inputs are the initial guesses for the Y centroids of the fibers and a column of a trace flat image.
Note that the y values of the fibers are ordered opposite to the data, since we count fiber 1 at the top of the chip and FITS coordinates start at the bottom.
Returns a number-of-fibers x 4 array containing amplitude, centroid, width, goodness flag for each fiber.
References fit_fiber(), gauss1D_2H_fit(), gauss1D_3H_fit(), get_fittype(), and peak_offset_.
Referenced by trace_outwards().
float Measure::sum2gaussH | ( | float | x, | |
const ltl::FVector< float, 10 > & | C | |||
) | [protected] |
Referenced by fit_peaks3H_final().
void Measure::fit_gauss2D | ( | const MArray< float, 2 > & | Data, | |
const MArray< float, 2 > & | Data_error, | |||
ltl::FVector< double, 7 > & | parameter, | |||
ltl::FVector< double, 7 > & | errors, | |||
double & | chi2, | |||
const bool | norm = false | |||
) | [protected] |
References fit_radius_, gauss2Dfit(), and index_of_max().
Referenced by correlate(), and fit_psf2D().
int Measure::get_fittype | ( | const MArray< float, 1 > & | Fguess, | |
int | i | |||
) | [protected] |
References peak_offset_.
Referenced by fit_peaks3H(), fit_peaks3H_final(), and fit_peaks3H_initial().
void Measure::fit_fiber | ( | ltl::FVector< TPar, N > & | P, | |
ltl::FVector< TPar, N > & | dP, | |||
TPar & | chi2, | |||
const MArray< TPar, 1 > | X, | |||
float | x, | |||
float | y, | |||
const MArray< TPar, 1 > & | A, | |||
const MArray< TPar, 1 > & | dA, | |||
ltl::FVector< bool, N > & | ignore, | |||
int | iter, | |||
double | tol, | |||
int | yidx, | |||
double | ytol, | |||
Fct | F | |||
) | [inline, protected] |
Referenced by fit_peaks3H(), fit_peaks3H_final(), and fit_peaks3H_initial().
float Measure::integrate_fiber_profile | ( | const MArray< float, 2 > & | I, | |
float | x, | |||
float | y, | |||
float | aperture, | |||
int | nf | |||
) | [protected] |
References interpolate_at_xy().
Referenced by remove_spectra().
void Measure::filter_peaks | ( | list< PsfDataTuple > & | l, | |
const Distortion & | D, | |||
const float | kappa | |||
) | [protected] |
Filter arc peaks: remove peaks with large errors
Referenced by fit_psf1D(), and fit_psf2D().
string Measure::version = "$Id: measure.cpp 1032 2015-07-10 18:35:34Z drory $" [static] |
FiberModel Measure::F_ [protected] |
Referenced by fit_peaks3H_initial(), and Measure().
int Measure::fiducial_fib_ [protected] |
Referenced by Measure(), and remove_spectra().
float Measure::min_slope_ [protected] |
float Measure::peak_offset_ [protected] |
Referenced by fit_peaks3H(), fit_peaks3H_initial(), get_fittype(), Measure(), and search().
float Measure::select_chi_ [protected] |
Referenced by Measure().
float Measure::fit_radius_ [protected] |
Referenced by correlate(), fit_gauss2D(), fit_psf2D(), and Measure().
int Measure::iter_ [protected] |
Referenced by fit_peaks3H_final(), fit_peaks3H_initial(), and Measure().
float Measure::accuracy_ [protected] |
Referenced by fit_peaks3H_final(), fit_peaks3H_initial(), and Measure().
bool Measure::fix_h2_ [protected] |
Referenced by fit_peaks3H_final(), fit_peaks3H_initial(), Measure(), measure_at_ref_w(), and measure_fiberpars().
bool Measure::fix_h3_ [protected] |
Referenced by fit_peaks3H_final(), fit_peaks3H_initial(), Measure(), measure_at_ref_w(), and measure_fiberpars().
int Measure::verbose_ [protected] |
Referenced by fit_fiber(), fit_peaks3H_final(), fit_peaks3H_initial(), Measure(), and search().
float Measure::peak_cutoff_ [protected] |