Defines | |
| #define | SEGNO(a, b) ((b) >= 0.0 ? fabs(a) : -fabs(a)) |
| #define | READY 1 |
| Montecarlo simulation to evaluate error on polynomial fit. | |
Functions | |
| static void | mos_seed (void) |
| static double | mos_randg (int seme) |
| static cpl_image * | mos_image_vertical_median_filter (cpl_image *ima_in, int filtsizey, int refrow, int above, int below, int step) |
| static int | peakPosition (float *data, int size, float *position, int minPoints) |
| static double | values_to_dx (double v1, double v2, double v3) |
| static float * | min_filter (float *buffer, int length, int size) |
| static float * | max_filter (float *buffer, int length, int size) |
| static float * | smo_filter (float *buffer, int length, int size) |
| static cpl_polynomial * | read_global_distortion (cpl_table *global, int row) |
| static cpl_table * | write_global_distortion (cpl_table *global, int row, cpl_polynomial *poly) |
| static int | robustLinearFit (cpl_bivector *list, double *a, double *b, double *abdev) |
| cpl_table * | mos_hough_table (cpl_table *table, const char *x, const char *y) |
| static void | mos_extraction (cpl_image *sciwin, cpl_image *skywin, cpl_image *extracted, cpl_image *sky, cpl_image *error, int nobjects, int extraction, double ron, double conad, int ncomb) |
| cpl_table * | mos_global_distortion (cpl_table *slits, cpl_table *maskslits, cpl_table *ids, cpl_table *crv, double reference) |
| Determine all global distortions models. | |
| cpl_table * | mos_build_slit_location (cpl_table *global, cpl_table *maskslits, int ysize) |
| Build the slit location table from a global distortions table. | |
| cpl_table * | mos_build_curv_coeff (cpl_table *global, cpl_table *maskslits, cpl_table *slits) |
| Build the curvature coefficients table from a global distortions table. | |
| cpl_table * | mos_build_disp_coeff (cpl_table *global, cpl_table *slits) |
| Build the IDS coefficients table from a global distortions table. | |
| cpl_image * | mos_subtract_sky (cpl_image *science, cpl_table *slits, cpl_table *polytraces, double reference, double blue, double red, double dispersion) |
| Subtract the sky from the scientific CCD exposure. | |
| cpl_image * | mos_normalise_flat (cpl_image *flat, cpl_image *spatial, cpl_table *slits, cpl_table *polytraces, double reference, double blue, double red, double dispersion, int sradius, int polyorder) |
| Normalise a flat field exposure. | |
| cpl_image * | mos_normalise_longflat (cpl_image *flat, int sradius, int dradius, int polyorder) |
| Normalise a long slit flat field exposure. | |
| cpl_error_code | mos_interpolate_wavecalib (cpl_table *idscoeff, cpl_image *wavemap, int mode) |
| Interpolate LSS wavelength calibration. | |
| cpl_image * | mos_remove_bias (cpl_image *image, cpl_image *bias, cpl_table *overscans) |
| Subtract the bias from a CCD exposure. | |
| cpl_error_code | mos_arc_background_1D (float *spectrum, float *back, int length, int msize, int fsize) |
| Background determination on 1D emission line spectrum (arc). | |
| cpl_image * | mos_arc_background (cpl_image *image, int msize, int fsize) |
| Background determination on emission line spectrum (arc). | |
| int | mos_lines_width (float *spectrum, int length) |
| Estimate lines widths (in pixel) in arc lamp spectrum. | |
| cpl_vector * | mos_peak_candidates (float *spectrum, int length, float level, float exp_width) |
| Find positions of peaks candidates. | |
| cpl_vector * | mos_refine_peaks (float *spectrum, int length, cpl_vector *peaks, int sradius) |
| Improve (when possible) accuracy of peaks candidates positions. | |
| cpl_bivector * | mos_identify_peaks (cpl_vector *peaks, cpl_vector *lines, double min_disp, double max_disp, double tolerance) |
| Identify peak candidates. | |
| double | mos_eval_dds (cpl_polynomial *ids, double blue, double red, double refwave, double pixel) |
| Evaluate the wavelength of a pixel position. | |
| cpl_polynomial * | mos_poly_wav2pix (cpl_bivector *pixwav, int order, double reject, int minlines, int *nlines, double *err) |
| Fit polynomial relation from wavelengths to pixels. | |
| cpl_polynomial * | mos_poly_pix2wav (cpl_bivector *pixwav, int order, double reject, int minlines, int *nlines, double *err) |
| Fit polynomial relation from pixels to wavelengths. | |
| cpl_bivector * | mos_find_peaks (float *spectrum, int length, cpl_vector *lines, cpl_polynomial *ids, double refwave, int sradius) |
| Find the reference lines peaks using a polynomial first-guess. | |
| cpl_image * | mos_wavelength_calibration_raw (cpl_image *image, cpl_vector *lines, double dispersion, float level, int sradius, int order, double reject, double refwave, double *wavestart, double *waveend, int *nlines, double *error, cpl_table *idscoeff, cpl_image *calibration, cpl_image *residuals, cpl_table *restable, cpl_mask *refmask) |
| Derive wavelength calibration from a raw arc lamp or sky exposure. | |
| cpl_table * | mos_locate_spectra (cpl_mask *mask) |
| Find the location of detected spectra on the CCD Find the location of detected spectra on the CCD. | |
| cpl_error_code | mos_validate_slits (cpl_table *slits) |
| Check validity of a slit location table. | |
| cpl_error_code | mos_rotate_slits (cpl_table *slits, int rotation, int nx, int ny) |
| Rotate a slit location table. | |
| cpl_table * | mos_identify_slits (cpl_table *slits, cpl_table *maskslits, cpl_table *global) |
| Identify slits listed in a slit location table. | |
| cpl_table * | mos_trace_flat (cpl_image *flat, cpl_table *slits, double reference, double blue, double red, double dispersion) |
| Trace flat field spectra. | |
| cpl_table * | mos_poly_trace (cpl_table *slits, cpl_table *traces, int order) |
| Fit spectral traces. | |
| cpl_error_code | mos_global_trace (cpl_table *slits, cpl_table *polytraces, int mode) |
| Recompute tracing coefficients globally. | |
| cpl_image * | mos_spatial_calibration (cpl_image *spectra, cpl_table *slits, cpl_table *polytraces, double reference, double blue, double red, double dispersion, int flux, cpl_image *calibration) |
| Spatial remapping of CCD spectra eliminating the spectral curvature. | |
| cpl_image * | mos_wavelength_calibration_final (cpl_image *image, cpl_table *slits, cpl_vector *lines, double dispersion, float level, int sradius, int order, double reject, double refwave, double *wavestart, double *waveend, int *nlines, double *error, cpl_table *idscoeff, cpl_image *calibration, cpl_image *residuals, cpl_table *restable) |
| Derive wavelength calibration from a rectified arc lamp or sky exposure. | |
| cpl_image * | mos_wavelength_calibration (cpl_image *image, double refwave, double firstLambda, double lastLambda, double dispersion, cpl_table *idscoeff, int flux) |
| Remap at constant wavelength step an image of rectified scientific spectra. | |
| cpl_table * | mos_wavelength_align (cpl_image *image, cpl_table *slits, double refwave, double firstLambda, double lastLambda, cpl_table *idscoeff, cpl_vector *skylines, int highres, int order, cpl_image *calibration, int sradius) |
| Modify the input wavelength solution to match reference sky lines. | |
| cpl_table * | mos_wavelength_align_lss (cpl_image *image, double refwave, double firstLambda, double lastLambda, cpl_table *idscoeff, cpl_vector *skylines, int highres, int order, cpl_image *calibration, int sradius) |
| Modify the input wavelength solution to match reference sky lines (LSS). | |
| double | mos_distortions_rms (cpl_image *rectified, cpl_vector *lines, double wavestart, double dispersion, int radius, int highres) |
| Estimate the spectral distortion modeling goodness. | |
| cpl_image * | mos_map_pixel (cpl_table *idscoeff, double reference, double blue, double red, double dispersion, int trend) |
| Create a pixel map from an IDS coefficients table. | |
| cpl_image * | mos_map_idscoeff (cpl_table *idscoeff, int xsize, double reference, double blue, double red) |
| Create a wavelengths map from an IDS coefficients table. | |
| cpl_image * | mos_map_wavelengths (cpl_image *spatial, cpl_image *calibration, cpl_table *slits, cpl_table *polytraces, double reference, double blue, double red, double dispersion) |
| Remapping of spatially rectified wavelengths to original CCD pixels. | |
| cpl_image * | mos_map_spectrum (cpl_image *spectra, cpl_image *wavecalib, cpl_image *spatial, cpl_table *slits, cpl_table *polytraces, double reference, double blue, double red, double dispersion, int flux) |
| Remapping of slit spectra into a grid of lambda-space coordinates. | |
| cpl_table * | mos_sky_map_super (cpl_image *spectra, cpl_image *wavemap, double dispersion, double factor, int minpoints, cpl_image *skymap) |
| Create a CCD median sky map. | |
| cpl_table * | mos_sky_map (cpl_image *spectra, cpl_image *wavemap, double dispersion, cpl_image *skymap) |
| Create a CCD median sky map. | |
| cpl_image * | mos_sky_local_old (cpl_image *spectra, cpl_table *slits) |
| Local determination of sky. | |
| cpl_image * | mos_sky_local (cpl_image *spectra, cpl_table *slits, int order) |
| Local determination of sky. | |
| cpl_error_code | mos_clean_cosmics (cpl_image *image, float gain, float threshold, float ratio) |
| Remove cosmic rays from sky-subtracted CCD spectral exposure. | |
| cpl_error_code | mos_clean_bad_pixels (cpl_image *image, cpl_table *table, int spectral) |
| cpl_image * | mos_spatial_map (cpl_image *spectra, cpl_table *slits, cpl_table *polytraces, double reference, double blue, double red, double dispersion) |
| Create coordinate map from spectral curvature table. | |
| cpl_image * | mos_detect_objects (cpl_image *image, cpl_table *slits, int margin, int maxradius, int conradius) |
| Detect objects in rectified scientific frame. | |
| cpl_image ** | mos_extract_objects (cpl_image *science, cpl_image *sky, cpl_table *objects, int extraction, double ron, double gain, int ncombined) |
| Extract detected objects from rectified scientific frame. | |
| int | mos_spectral_resolution (cpl_image *image, double lambda, double startwave, double dispersion, int saturation, double *mfwhm, double *rmsfwhm, double *resolution, double *rmsres, int *nlines) |
| Compute mean spectral resolution at a given arc lamp line. | |
| cpl_table * | mos_resolution_table (cpl_image *image, double startwave, double dispersion, int saturation, cpl_vector *lines) |
| Compute mean spectral resolution at a given arc lamp line. | |
| double | mos_integrate_signal (cpl_image *image, cpl_image *wavemap, int ystart, int yend, double wstart, double wend) |
| Integrate signal from wavelength and spatial interval. | |
| cpl_table * | mos_load_slits_fors_mxu (cpl_propertylist *header) |
| Create slit location table from FITS header of FORS2-MXU data. | |
| cpl_table * | mos_load_slits_fors_mos (cpl_propertylist *header) |
| Create slit location table from FITS header of FORS1/2 MOS data. | |
| cpl_table * | mos_load_slits_fors_lss (cpl_propertylist *header) |
| Create slit location table from FITS header of FORS1/2 LSS data. | |
| double | mos_get_gain_vimos (cpl_propertylist *header) |
| Return gain factor for a VIMOS exposure. | |
| cpl_table * | mos_load_slits_vimos (cpl_propertylist *header) |
| Create slit location table from FITS header of VIMOS data. | |
| cpl_table * | mos_load_overscans_vimos (cpl_propertylist *header, int check_consistency) |
| Get the overscan positions from FITS header of VIMOS data. | |
| cpl_polynomial * | mos_montecarlo_polyfit (cpl_table *points, cpl_table *evaluate, int samples, int order) |
|
|
Montecarlo simulation to evaluate error on polynomial fit.
y = p(x) + y_err * mos_randg(1) where p(x) is the fit on the original points, and x are taken from the points table together with the corresponding y_err. The evaluate table should contain a column labeled x, and is returned with a new column labeled sigma, listing the sigma of the model variation at each of the indicated x coordinates. |
|
||||||||||||||||||||||||
|
Determine all global distortions models.
The crv table lists the values of the curvature polynomial for each end of the detected slits. Such values are associated to the mask coordinates listed in the maskslits table having the same "slit_id". Each coefficient can then be modeled as a function of the mask coordinates by fitting a second order bivariate polynomial. All the coefficients of the obtained bivariate polynomial are written to the newly created global distortions table. Conventionally this table consists of 6 columns and 10 rows. Each row corresponds to the modeling of one coefficient of the original polynomial coefficients belonging to the local solutions. The first 6 table rows are a description of the IDS coefficients, up to the fifth polynomial degree; these rows are followed by a row where just the first element is assigned the value of the reference wavelength for the given IDS model. The remaining 3 rows are a description of the spectral curvature, up to the second polynomial degree. At least 12 valid slits must be listed in the slits tables. |
|
||||||||||||||||
|
Build the slit location table from a global distortions table.
mos_identify_slits(), i.e. the "position" and "length" columns are still missing (such columns would be added by the mos_spatial_calibration() function). The column "slit_id" is obtained from the "slit_id" column of the input maskslits table, while the "xtop", "ytop", "xbottom", "ybottom" columns are obtained as xtop = poly0(mxtop, mytop)
xbottom = poly0(mxbottom, mybottom)
ytop = poly7(mxtop, mytop)
+ poly8(mxtop, mytop) * xtop;
+ poly9(mxtop, mytop) * xtop^2
ybottom = poly7(mxbottom, mybottom)
+ poly8(mxbottom, mybottom) * xbottom;
+ poly9(mxbottom, mybottom) * xbottom^2
Definition at line 1534 of file moses.c. References read_global_distortion(). |
|
||||||||||||||||
|
Build the curvature coefficients table from a global distortions table.
mos_poly_trace(). The column "slit_id" is obtained from the "slit_id" column of the input maskslits table. The coefficients columns are obtained as c0 = poly7(mx, my)
c1 = poly8(mx, my)
c2 = poly9(mx, my)
Definition at line 1680 of file moses.c. References read_global_distortion(). |
|
||||||||||||
|
Build the IDS coefficients table from a global distortions table.
mos_spatial_calibration(), i.e., it should already have the columns "position" and "length". The output IDS coefficients table will have the same structure of the one created by mos_wavelength_calibration_final(), but without the "error" and "nlines" columns. This output table will have as many rows as the sum of the "length" values in the input slits table, corresponding to the number of spatial pseudo-pixels of a corresponding rectified data image. If a given slit extends between CCD coordinates ytop and ybottom (as listed in the input slits table), the corresponding number of spatial pseudo-pixels is conventionally set to length = ceil(ytop-ybottom)+1 (corresponding to the content of the "length" column, as computed by the mos_spatial_calibration() function). The spatial pseudo-pixels p are counted from top to bottom, starting from 0, and their corresponding y coordinate on the CCD is therefore given by y = ytop - p*(ytop-ybottom)/length . The corresponding x coordinate is computed in the same way, as x = xtop - p*(xtop-xbottom)/length . The coefficients columns are obtained as c0 = poly0(xmask, ymask)
c1 = poly1(x, y)
c2 = poly2(x, y)
c3 = poly3(x, y)
c4 = poly4(x, y)
c5 = poly5(x, y)
Definition at line 1835 of file moses.c. References read_global_distortion(). |
|
||||||||||||||||||||||||||||||||
|
Subtract the sky from the scientific CCD exposure.
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Normalise a flat field exposure.
Definition at line 2279 of file moses.c. References mos_spatial_calibration(). |
|
||||||||||||||||||||
|
Normalise a long slit flat field exposure.
|
|
||||||||||||||||
|
Interpolate LSS wavelength calibration.
mos_wavelength_calibration_raw() also in those image rows where the calibration failed. The input idscoeff table and wavemap image are reprocessed and modified in-place according to what indicated by the mode argument. The idscoeff table coefficients and the wavelengths in wavemap are modeled by low degree polynomials: if mode is 1, the model values are used to fill the gaps in the input solutions, otherwise all the inputs are replaced with the fitted model values. If the wavemap is not given, just the idscoeff table will be interpolated: the corresponding wavelength map could still be calculated using the function mos_map_idscoeff().
|
|
||||||||||||||||
|
Subtract the bias from a CCD exposure.
|
|
||||||||||||||||||||||||
|
Background determination on 1D emission line spectrum (arc).
This function fills the array back with the estimated values of the background along the input spectrum. The algorithm is based on the assumption that there is at least one background value at any position of the min-filter box running along the spectrum. A min-filter is passed on the spectrum, and the result is smoothed by averaging on a running box of size fsize. The min-filter is run between the positions msize / 2 and length - msize / 2, and the min value found at such positions is then repeated up to the spectrum ends. Similarly, the running average is limited to the interval from fsize / 2 and length - fsize / 2, leaving the most external values untouched. After this, a max filter and a smoothing using boxes with double the specified sizes are run, as a way to eliminate the contamination from occasional cold pixels. Finally, the min filter and the smoothing are applied again to obviate the slight background over-estimation introduced by the max filter.
It is required that the back array is at least long as the array spectrum. Moreover msize must be greater than 1, and fsize greater than, or equal to, msize. Likewise, length must be greater than twice fsize. If such conditions are not met, or if the input arrays are Definition at line 3400 of file moses.c. References max_filter(), min_filter(), and smo_filter(). Referenced by mos_arc_background(). |
|
||||||||||||||||
|
Background determination on emission line spectrum (arc).
The input image is assumed to be of type
It is required that msize is greater than 1, and fsize greater than, or equal to, msize. Likewise, the image size along the X direction must be greater than fsize / 2. If such conditions are not met, or if the input image is a Definition at line 3502 of file moses.c. References mos_arc_background_1D(). |
|
||||||||||||
|
Estimate lines widths (in pixel) in arc lamp spectrum.
Definition at line 3578 of file moses.c. Referenced by mos_spectral_resolution(). |
|
||||||||||||||||||||
|
Find positions of peaks candidates.
NULL pointer is returned in case no peak candidate is found. No error code is set in this case.If very very broad and flat-topped peaks are expected, i.e., if the expected lines FWHM is more than 5 pixels, the spectrum is slightly smoothed before peaks are searched. If the expected lines FWHM is more than 20 pixels, the spectrum is preliminary sampled at a step of half exp_width. These operations are applied to ensure that the top of an emission line profile is never flat. |
|
||||||||||||||||||||
|
Improve (when possible) accuracy of peaks candidates positions.
mos_peak_candidates() ) is made more accurate, whenever possible, by applying a line baricenter determination method. In case the baricentric method fails, the corresponding peak position is not rejected, but just kept unchanged. The final peaks candidates list is finally cleaned from peak positions that are closer than 0.5 pixel (to avoid duplications). The input vector is destroyed, and a newly allocated vector is returned.
Definition at line 3783 of file moses.c. References peakPosition(). |
|
||||||||||||||||||||||||
|
Identify peak candidates.
mos_peak_candidates(), and possibly mos_refine_peaks() ) is compared with a list of expected emission lines wavelengths. The algorithm is based on pattern recognition, where the pattern is contained in the vector lines, and is searched in the list peak.In order to work, this method just requires a rough expectation value of the spectral dispersion (in Angstrom/pixel), and a line catalog. The line catalog lines should just include lines that are expected somewhere in the CCD exposure of the calibration lamp (note, however, that a catalog including extra lines at its blue and/or red ends is still allowed). Typically, the arc lamp lines candidates peak will include light contaminations, hot pixels, and other unwanted signal, but only in extreme cases this prevents the pattern-recognition algorithm from identifying all the spectral lines. The pattern is detected even in the case peak contained more arc lamp lines than actually listed in the input line catalog. This method is based on the assumption that the relation between wavelengths and CCD positions is with good approximation locally linear (this is always true, for any existing spectrograph). The ratio between consecutive intervals pairs in wavelength and in pixel is invariant to linear transformations, and therefore this quantity can be used in the recognition of local portions of the searched pattern. All the examined sub-patterns will overlap, leading to the final identification of the whole pattern, notwithstanding the overall non-linearity of the relation between pixels and wavelengths. Ambiguous cases, caused by exceptional regularities in the pattern, or by a number of undetected (but expected) peaks that disrupt the pattern on the data, are solved by linear interpolation and extrapolation of the safe identifications. More details about the applied algorithm can be found in the comments to the function code. |
|
||||||||||||||||||||||||
|
Evaluate the wavelength of a pixel position.
|
|
||||||||||||||||||||||||||||
|
Fit polynomial relation from wavelengths to pixels.
mos_identify_peaks() or the function mos_find_peaks() ) must contain at least minlines entries. A fit is tried, and all the peaks farther than the reject threshold from the model are rejected. This process is iterated until either the number of surviving lines is less than minlines or there are no more outliers (whichever comes first). Only in the latter case a fit is returned. If the reject threshold is negative, no outliers rejection is applied, and the first fit is accepted. In case of error, a NULL pointer is returned, and nlines and err are set to zero.
Definition at line 4586 of file moses.c. Referenced by mos_poly_pix2wav(). |
|
||||||||||||||||||||||||||||
|
Fit polynomial relation from pixels to wavelengths.
mos_identify_peaks() ) must contain at least minlines entries. A fit is tried, and all the peaks farther than the reject threshold from the model are rejected. This process is iterated until either the number of surviving lines is less than minlines or there are no more outliers (whichever comes first). Only in the latter case a fit is returned. If the reject threshold is negative, no outliers rejection is applied, and the first fit is accepted. In case of error, a NULL pointer is returned, and nlines and err are set to zero.
Definition at line 4746 of file moses.c. References mos_poly_wav2pix(). |
|
||||||||||||||||||||||||||||
|
Find the reference lines peaks using a polynomial first-guess.
NULL pointer is returned.
Definition at line 4798 of file moses.c. References peakPosition(). |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Derive wavelength calibration from a raw arc lamp or sky exposure.
The rows of the input image are independently calibrated one by one. First, the function
Optionally, in case sradius is positive, the obtained polynomial solution is passed to the function An array nlines, containing the number of lines used for each fit, and an array error, containing the mean error of the polynomial models (in pixels), are returned. A fit failure is indicated with the corresponding element of nlines set to zero. The mean error of the polynomial model is evaluated by dividing the RMS of the fit residuals by the square root of the number of fitted points divided the degrees of freedom of the model: mean error = RMS / sqrt(N / (order + 1))
The arrays nlines and error must be pre-allocated, and should all have as many elements as the number of rows in the input image. If
As a by-product of the wavelength calibration, the input image is resampled at a constant wavelength step, dispersion, and is returned by this function. In case of error a
Optionally, an image of the wavelength calibrated input exposure, calibration, an image of the fit residuals, residuals, and a monochromatic mask image, refmask, that is obtained at a given wavelength refwave, can be returned. These images must be pre-allocated, and should all have the same size of the input image. If |
|
|
Find the location of detected spectra on the CCD Find the location of detected spectra on the CCD.
mos_wavelength_calibration_raw(). The output table contains the start and end image coordinates of the slit on the input mask at reference wavelength. The slits are ordered from top to bottom of the image starting from the first table row.
Note that possible gaps within the images of the slits will result in splitting the same slit into two or more sub-slits. This kind of problem is solved within the slit identification task, performed by the function |
|
|
Check validity of a slit location table.
mos_locate_spectra() and mos_rotate_slits. This table is expected to contain double precision columns labeled xtop, ytop, xbottom, and ybottom, and this is the check that is performed here.
Definition at line 5721 of file moses.c. Referenced by mos_identify_slits(), and mos_rotate_slits(). |
|
||||||||||||||||||||
|
Rotate a slit location table.
mos_locate_spectra(), or by this self. This table is expected to contain double precision columns labeled xtop, ytop, xbottom, and ybottom, containing the start and end image coordinates of the slits on the mask obtained at reference wavelength. The transformation will affect these columns, other columns are ignored. The reference wavelength image was expected to be oriented with horizontal dispersion direction and red wavelengths on the right side, but the slits columns are not renamed after a rotation to reflect the change of convention. If the sizes of the reference mask, nx and ny, are greater than 0, the new coordinates will be related to the image rotated in the same way, otherwise a simple geometrical rotation is applied. The sizes nx and ny must refer to the reference image after it is rotated in the same way.
Definition at line 5785 of file moses.c. References mos_validate_slits(). |
|
||||||||||||||||
|
Identify slits listed in a slit location table.
mos_locate_spectra(), with no rotation applied. This table is expected to contain the double precision columns labeled xtop, ytop, xbottom, and ybottom, containing the start and end image coordinates of the slits on the CCD obtained at reference wavelength. The table maskslits is expected to contain the same columns, but with the start and end coordinates of the slits on the telescope focal plane. The coordinate system should have approximately the same orientation of the input slits table, i.e., with horizontal dispersion direction and red wavelengths dispersed toward the right side. In addition to the standard columns listed above, the input maskslits table should also have a slit identifying integer column, labeled "slit_id", containing the unique slit identifiers that will be assigned to the identified slits in the input slits table. The construction of this table is instrument dependent, and should be provided at instrument recipe level.The output slit location table will contain the same columns as the input tables, with the CCD positions of all the slits listed in the maskslits table: such positions are not necessarily all contained in the CCD. The new positions are obtained by mean of a low degree bivariate polynomial model converting from mask positions to CCD positions. This model is derived from a subset of safely identified slits positions. The preliminary identification is performed by matching similar triangles constructed both on the mask and on the CCD of the slits taken three-by-three. Recomputing all positions will remove false detections, join slits containing gaps, and separate slits that were accidentally joined together. The slit identification may fail in case of masks containing a regular spacing of slits: such masks would invariably lead to ambiguous pattern matching, that would not be processed. This would not prevent that data reduction in itself: simply, the reduced spectra would miss their identification. Note that this is not a real problem, since ambiguous masks are typically masks used for calibration, and not for scientific observations. In case a global distortion table is specified in input, the coefficients of the bivariate polynomials describing the relation between mask and CCD coordinates (at reference wavelength) are written to rows 0 and 7. Definition at line 5899 of file moses.c. References mos_validate_slits(). |
|
||||||||||||||||||||||||||||
|
Trace flat field spectra.
CPL_TYPE_FLOAT. The slits table should be the output of either the function mos_identify_slits() (if available) or the function mos_locate_spectra().The flat image is shifted one pixel down and is subtracted from the original image. The result is a vertical gradient map. Next, the negative values are forced positive, to obtain an absolute gradient map. The map is passed with a horizontal median filter, and after that the gradient peaks are traced starting from the slits positions listed in the input slits table. The number of pixels to the left and to the right of the reference pixel is trivially derived from the specified spectral range blue to red and dispersion. The output table contains the traced spectral edges positions in CCD (Y) coordinates for each spectrum. The columns are named after the "slit_id" listed in the input slits table, and are preceded by a "t" for upper edges, and by a "b" for bottom edges: for instance, the trace corresponding to the upper edge of a spectrum with id = 123 will be found in a column named "t123". If the "slit_id" column is missing in the input table, one will be created with conventional (unique) numbers. One more column will be created, named "x", listing the corresponding CCD (X) coordinates of the trace. |
|
||||||||||||||||
|
Fit spectral traces.
mos_trace_flat(), and the slits table should be the same used and processed there. The order of the fitting polynomial should not be greater than 5. If the fit of a trace is successful, a column containing the residuals of the fit is added to the traces table. If the fitted data are contained in a column named "xyz" (in the convention used by the function mos_trace_flat()), the column containing the residuals will be named "xyz_res".
|
|
||||||||||||||||
|
Recompute tracing coefficients globally.
mos_trace_flat(), and the slits table should be the same used and processed there. The trend of the tracing coefficients as a function of the first (offset) coefficient c0 is modelled by a linear fit. If mode is 2, all the coefficients are recomputed according to this model. If mode is 1, just missing solutions are found by interpolation. If some tracings are missing from the polytraces table, the value of the coefficient c0 is drawn from the y coordinate of the corresponding slit edge in the slits table, and the rest of the coefficients are derived from it.
|
|
||||||||||||||||||||||||||||||||||||||||
|
Spatial remapping of CCD spectra eliminating the spectral curvature.
CPL_TYPE_FLOAT. The slits table should be the output of either the function mos_identify_slits() (if available) or the function mos_locate_spectra(). The polytraces table is the output of the function mos_poly_trace().The spectra are spatially remapped (with a slight oversampling) starting from the pixel containing the reference wavelength (as reported for each entry of the slits table). The number of pixels to the left and to the right of the reference pixel is trivially derived from the specified spectral range blue to red and dispersion. At each x pixel position the interval between the top and the bottom edges of each spectrum is linearly remapped into N = ceil(t-b)+1 spatial pseudo-pixels, where t and b are its edges positions at the CCD reference pixel (i.e., if the slit spectrum is widening or narrowing along the wavelength range, it is mapped always to the same number of pseudo-pixels). The returned image will have the same x size of the input spectra image, and a y size equal to the sum of the N spatial sizes of the resampled spectra.
Optionally, an image of the spatially calibrated input exposure, calibration, can be returned. This image must be pre-allocated, and should have the same size of the input spectra image. If a In case flux is set to a value different from zero, the remapping is performed applying a correction for flux conservation. Here is how the spatial resampling is applied: the value of a spatial pseudo-pixel p (counted from 0, corresponding to the top spectral trace at a given x position on the CCD of a given spectrum), is computed by linear interpolation between the two values of the consecutive CCD pixels closest to the position y = t - p*(t-b)/N, with the same meaning for N, b, and t, described above, and with 0 <= p <= N. On the calibration image the original y pixel positions (at a given x) are assigned the value of their distance from the top spectral trace, computed as p = N*(t-y)/(t-b), where p is now a float, and y an integer varying from ceil(t) to floor(b). The input slits table is added two new columns, labeled "position" and "length", reporting the number of the first (bottom) row belonging to the corresponding slit spectrum, and its extension in pseudo-pixels on the returned spatially rectified image. Definition at line 7482 of file moses.c. Referenced by mos_normalise_flat(). |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Derive wavelength calibration from a rectified arc lamp or sky exposure.
mos_wavelength_calibration_raw(). The fundamental difference is that the algorithm is here applied to an image containing just spectra where the spectral curvature was eliminated, as produced by the function mos_spatial_calibration(). The input slits table should be the same used and processed by the function mos_spatial_calibration(), containing a column named "position" listing the position of the individual spectra in the rectified image.
The rows of the input image are independently calibrated one by one. The spectral continuum is assumed to have been already removed (and it should be so, if the function
Optionally, in case sradius is positive, the polynomial solutions obtained for all rows of each individual slit are averaged into a single solution, that is used as a first-guess that is passed to the function An array nlines, containing the number of lines used for each fit, and an array error, containing the mean error of the polynomial models (in pixels), are returned. A fit failure is indicated with the corresponding element of nlines set to zero. The mean error of the polynomial model is evaluated by dividing the RMS of the fit residuals by the square root of the number of fitted points divided the degrees of freedom of the model: mean error = RMS / sqrt(N / (order + 1))
The arrays nlines and error must be pre-allocated, and should all have as many elements as the number of rows in the input image. If In the table idscoeff will be written the polynomial fits coefficients obtained for each input image row: this table must therefore be preallocated, before calling this function, with the same number of rows as the input image. No columns should be defined in this table: they will be created automatically by this function, and will be labeled c0, c1, c2, ... up to the specified order of the fitting polynomial.
As a by-product of the wavelength calibration, the input image is resampled at a constant wavelength step, dispersion, and is returned by this function. In case of error a
Optionally, an image of the wavelength calibrated input exposure, calibration, might be filled with the value of the wavelength for each pixel. This image may be significantly more accurate than the calibration image obtained with the preliminary wavelength calibration, returned by the function |
|
||||||||||||||||||||||||||||||||
|
Remap at constant wavelength step an image of rectified scientific spectra.
mos_spatial_calibration(). The table idscoeff contains the polynomial fits coefficients obtained for each input image row, as produced by the function mos_wavelength_calibration_final(), and possibly modified by the function mos_wavelength_align(), used to align the wavelength solution to available sky lines. The input image is resampled at a constant wavelength step, dispersion, and is returned by this function. In case of error a NULL pointer is returned.
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Modify the input wavelength solution to match reference sky lines.
mos_spatial_calibration(). The input slits table should be the same used and processed by the same function, containing a column named "position" listing the position of the individual spectra in the rectified image. The table idscoeff contains the polynomial fits coefficients obtained for each input image row, as produced by the function mos_wavelength_calibration_final(). The vector skylines should list a number of reference sky-lines wavelengths. The calibrating polynomials will be used to get the expected positions of the reference skylines for each slit, for measuring their offset from this position as a function of wavelength. If the skylines vector is not provided, an internal list of sky lines is used instead. Only in this case the argument highres is checked in order to select a sky lines list for high or low resolution data (by high resolution data we mean here R > 700). In all cases, only the sky lines within the specified range firstLambda lastLambda will be used. If the rectified wavelengths calibration image produced by the function mos_wavelength_calibration_final() is provided, the mapped wavelengths will be upgraded to reflect the alignment of the old solution to the position of the detected sky lines. Subsequently, such map may be transferred to the CCD image using the function mos_map_wavelengths().More in detail: for each slit, a "sky" spectrum is derived by computing the median slit spectrum, reducing in this way possible contamination by bright scientific object(s) contained in the slit. All the IDS polynomials modelling the slit are used to determine the sky lines offsets: with N slit rows, N independent offsets for each reference sky line are found; a new table is created, with columns containing the median offsets obtained for each reference sky line and for each slit. The columns are named after the "slit_id" listed in the input slits table, preceded by "offset". For instance, the median offsets for all sky lines observed on a slit with id = 123 will be written to a column named "offset123". A column "wave" listing the reference wavelengths used will be also included to the table. For each slit, the median offsets are fitted by a polynomial relation that is then summed to all the IDS polynomials pertaining to that slit, modifying in this way the input idscoeff table. It is of course advisable not to go beyond a fitting polynomial of 0th or 1st order, unless many and well distributed reference sky lines are available within the specified range. Note that this way of proceeding is applied to avoid destroying the information about irregularities in the slit ("slit geometry"). |
|
||||||||||||||||||||||||||||||||||||||||||||
|
Modify the input wavelength solution to match reference sky lines (LSS).
mos_spatial_calibration(). The table idscoeff contains the polynomial fits coefficients obtained for each input image row, as produced by the function mos_wavelength_calibration_final(). The vector skylines should list a number of reference sky-lines wavelengths. The calibrating polynomials will be used to get the expected positions of the reference skylines for each slit, for measuring their offset from this position as a function of wavelength. If the skylines vector is not provided, an internal list of sky lines is used instead. Only in this case the argument highres is checked in order to select a sky lines list for high or low resolution data (by high resolution data we mean here R > 700). In all cases, only the sky lines within the specified range firstLambda lastLambda will be used. If the rectified wavelengths calibration image produced by the function mos_wavelength_calibration_final() is provided, the mapped wavelengths will be upgraded to reflect the alignment of the old solution to the position of the detected sky lines. Subsequently, such map may be transferred to the CCD image using the function mos_map_wavelengths().More in detail: a "sky" spectrum is derived by computing the median spectrum, reducing in this way possible contamination by bright scientific object(s) contained in the image. All the IDS polynomials modelling the image are used to determine the sky lines offsets: with N image rows, N independent offsets for each reference sky line are found; a new table is created, with a column containing the median offsets obtained for each reference sky line and for each image row. This column is named "offset". A column "wave" listing the reference wavelengths used will be also included to the table. For each image row, the measured offsets are fitted by a polynomial relation of given order. The coefficients of all the obtained polynomial relations are then modeled as a function of the image row, and their modeled values are then summed to all the IDS polynomials modifying in this way the input idscoeff table. It is of course advisable not to go beyond a fitting polynomial of 0th or 1st order, unless many and well distributed reference sky lines are available within the specified range. Note that this way of proceeding is applied to avoid destroying the information about irregularities in the slit ("slit geometry"). |
|
||||||||||||||||||||||||||||
|
Estimate the spectral distortion modeling goodness.
mos_wavelength_calibration_raw() and mos_wavelength_calibration_final() The RMS of the residuals between the expected positions of the arc lamp lines and the actual position of a detected peak is computed. The peak is searched within the search radius specified by the last argument, which typically would depend on the expected lines FWHM. This function prints also the computed RMS for each wavelength listed in the line catalog to screen. If the lines vector is not provided, an internal list of sky lines wavelengths is used instead. Only in this case the argument highres is checked in order to select a sky lines list for high or low resolution data (by high resolution data we mean here R > 700).
|
|
||||||||||||||||||||||||||||
|
Create a pixel map from an IDS coefficients table.
|
|
||||||||||||||||||||||||
|
Create a wavelengths map from an IDS coefficients table.
|
|
||||||||||||||||||||||||||||||||||||
|
Remapping of spatially rectified wavelengths to original CCD pixels.
mos_spatial_calibration() (argument: calibration). It is expected to be oriented with horizontal dispersion direction and red wavelengths on the right side, and it should have the same x-length of the input calibration image. The calibration image is the one produced by the function mos_wavelength_calibration_final() (argument: calibration). The slits table should be the same processed by the function mos_spatial_calibration(). The polytraces table is the output of the function mos_poly_trace(). The other arguments should be in principle the same specified for the function mos_spatial_calibration().For each slit, each (x,y) coordinate on the spatial image is characterised by a spatial coordinate p. The wavelength at that spatial coordinate is derived by linear interpolation of the two wavelengths with the same coordinate x that are closer to p on the calibration image. |
|
||||||||||||||||||||||||||||||||||||||||||||
|
Remapping of slit spectra into a grid of lambda-space coordinates.
The input wavecalib image is the one returned by the function
The target grid in lambda and pseudo spatial coordinates is defined on the basis of the indicated spectral range and dispersion, while the number of spatial pixels assigned to each slits are compatible with the positions listed in the slits table (column "position") following the convention used in the rest of the spectral reduction, in particular the functions mos_spatial_calibration() and Indicating with (x,y) a pixel position on the CCD, and with (L,S) a pixel position on one extracted slit, the mapping from (x,y) to (L,S) is done in the following way (for each slit): for each (x,y) read the corresponding value of lambda and space from the input images wavecalib and spatial; find the pixel (L,S) on the output (remapped) slit that has the highest lambda and space that are less than the lambda and space obtained above; read the values of the following CCD pixels from the input spectrum: (x,y), (x-1,y), (x+N,y+1), (x+N-1,y+1), where N is an offset pointing to the pixel on the row y+1 having the closest wavelength to the wavelength of pixel (x,y). This is a way to avoid possible discontinuities in the wavelength calibration along the cross-dispersion direction (due to slit irregularities, also commonly indicated with the expression "slit geometry"). Typically, it will always be N = 0. The pixel value to assign to the pixel (L,S) is computed by linear interpolation to its corresponding (x',y') position of the 4 pixel values (horizontal interpolation followed by vertical interpolation of the interpolated values). The corresponding flux-conservation factor, if requested, is computed as (dL/dx)*(dS/dy). The interpolated value is multiplied by this factor before being written to the pixel (L,S). DO NOT USE THIS FUNCTION, IT GIVES BAD RESULTS (and it should be eventually removed). |
|
||||||||||||||||||||||||||||
|
Create a CCD median sky map.
mos_wavelength_calibration_final(), possibly modified by the function mos_wavelength_align() used to align the wavelength solution to available sky lines. The sky spectrum is computed as the median level of all the pixel values of all the CCD spectra in the wavelength interval corresponding to that bin, on bins containing at least minpoints; otherwise it is computed by linear interpolation from the nearest valid bins. To each bin is assigned in the first case the median of the contributing wavelengths, and in the second case its central wavelength. The skymap image should be preallocated: each one of its pixels, corresponding to a wavelength read from wavemap, will be assigned a value obtained by linear interpolation of the two pixels of the supersampled spectrum that are closest to its wavelength.
|
|
||||||||||||||||||||
|
Create a CCD median sky map.
mos_wavelength_calibration_final(), possibly modified by the function mos_wavelength_align() used to align the wavelength solution to available sky lines. The computed sky spectrum will consist of pixels of size dispersion: typically the passed dispersion should be slightly smaller than the dispersion of the original spectra. How much smaller will affect the level of supersampling of the computed sky spectrum: a too small value will increase the noise of the output sky spectrum, leading to no advantage in the determination of the sky map to be subtracted from the scientific data. Each pixel of the resulting sky spectrum is computed as the median of all the pixel values of all the CCD spectra in the wavelength interval corresponding to that pixel. The skymap image should be preallocated: each one of its pixels, corresponding to a wavelength read from wavemap, will be assigned a value obtained by linear interpolation of the two pixels of the supersampled spectrum that are closest to its wavelength.
|
|
||||||||||||
|
Local determination of sky.
|
|
||||||||||||||||
|
Local determination of sky.
|
|
||||||||||||||||||||
|
Remove cosmic rays from sky-subtracted CCD spectral exposure.
|
|
||||||||||||||||||||||||||||||||
|
Create coordinate map from spectral curvature table.
CPL_TYPE_FLOAT. The slits table should be the output of either the function mos_identify_slits() (if available) or the function mos_locate_spectra(). The polytraces table is the output of the function mos_poly_trace().The returned image image has the same size of the input spectra image, and it will consist of pixels having the value of their spatial coordinate along the slit they belong to, or the value zero if the pixels do not belong to any spectrum. The original y pixel positions (at a given x) are assigned the value of their distance from the top spectral trace measured in CCD pixels. |
|
||||||||||||||||||||||||
|
Detect objects in rectified scientific frame.
The algorithm applied is based on the relative peak intensity of each detected object. First of all, a peak is identified by a positive value that is preceded and followed by two lower positive values that decrease with distance. Also the first and the last (valid) spatial pixel of a slit is considered a peak, if followed or preceded by decreasing pixels, to keep it into account in the computation of the contaminations, but it is never extracted in the end. Each peak is compared with all the other peaks to determine if this peak is contaminated by any of the others. Indicating with L_o the peak value of the examined peak and with L the peak value of another peak, the quantity S = C * (L / L_o) B_i = (P_i * L_j + P_j * L_i) / (L_i + L_j) |
|
||||||||||||||||||||||||||||||||
|
Extract detected objects from rectified scientific frame.
mos_detect_objects(). The arguments ron, gain, and ncombined are used only in case the extraction mode is set to 1 (optimal extraction). The optimal extraction is based on Horne, K., (1986), PASP, 98, 609. If the science and science_sky frames are the result of the combination of different frames, the value of ron will be divided by the square root of ncombined.
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Compute mean spectral resolution at a given arc lamp line.
Definition at line 13176 of file moses.c. References mos_lines_width(). Referenced by mos_resolution_table(). |
|
||||||||||||||||||||||||
|
Compute mean spectral resolution at a given arc lamp line.
mos_spectral_resolution() for each line of the input line catalog, and creates a spectral resolution table. This table has a column "wavelength" listing the line catalog wavelengths, a column "resolution" containing the corresponding mean spectral resolutions, a column "rms" with the population standard deviation of the measured resolutions, and a column "nlines" reporting the number of measurement for each wavelength.
Definition at line 13372 of file moses.c. References mos_spectral_resolution(). |
|
||||||||||||||||||||||||||||
|
Integrate signal from wavelength and spatial interval.
|
|
|
Create slit location table from FITS header of FORS2-MXU data.
Definition at line 13532 of file moses.c. References instrume. |
|
|
Create slit location table from FITS header of FORS1/2 MOS data.
Definition at line 13771 of file moses.c. References instrume. |
|
|
Create slit location table from FITS header of FORS1/2 LSS data.
Definition at line 13970 of file moses.c. References instrume. |
|
|
Return gain factor for a VIMOS exposure.
|
|
|
Create slit location table from FITS header of VIMOS data.
|
|
||||||||||||
|
Get the overscan positions from FITS header of VIMOS data.
mos_remove_bias(). In the specific case of VIMOS the keywords used are NAXIS1, NAXIS2, ESO DET OUT1 PRSCX, ESO DET OUT1 OVSCX, ESO DET OUT1 PRSCY, and ESO DET OUT1 OVSCY. The input header should come from a raw, unprocessed image (typically the image from which a master bias was not yet subtracted).
Definition at line 14286 of file moses.c. Referenced by fors_image_load(). |
1.4.6