Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

extract/incl/extract.h File Reference

extract specific function prototyping and define More...

Go to the source code of this file.

Defines

#define FMP_XC   1027.
#define FMP_YC   1770.
 Center of distortion.

#define FMP_LENSSNORM   1.e2
#define FMP_ANGLENORM   6.e-2
#define FMP_POSITNORM   1.e3
#define FMP_ALPHANORM   1.e-8
 Normalization factors.

#define FMP_IPSFNORM   1.e2
#define FMP_XPSFNORM   0.5
 Normalization factors.

#define FMP_IPUPNORM   60.
#define FMP_XPUPNORM   0.3
#define FMP_SPUPNORM   0.1
 Normalization factors.

#define FMX_TOOFAR   2.
 Limit factor (in interpsec unit) for neighbourhood criterion.

#define FMX_SIGMA_CLIP   5.
 Sigma-clipping factor for the threshold computation.


Functions

void nllsqfit_noderiv ()
 Allow nllsqfit_bnd to be used without derivatives.

int get_lenses_col (E3D_file *frame, char *lab_col, void *zlens, int *il)
 Get spaxel-related quantities from table.

double RD_frame_interp (IMAGE2D *frame, double x, double y)
 Interpolated RD_frame.

void spatial_filter (int nrow, float X[], float Y[], float Z[], float rad, char method, int minNnb, int Nnb[])
 Spatial filtering (median or average) of arrays.

void frame_stats (const IMAGE2D *frame, double *mean, double *sigma, double *median, double *sigmed)
 Statistic elements of a frame.

SPECTRUM * array_histo (const double *array, int npts, double min, double max, int nbin)
 Histogram of a (double) vector.

SPECTRUM * subframe_histo (const IMAGE2D *frame, int imin, int imax, int jmin, int jmax, double min, double max, int nbin)
 Histogram of a subframe.

SPECTRUM * frame_histo (const IMAGE2D *frame, double min, double max, int nbin)
 Histogram of a frame.

double histo_threshold (const SPECTRUM *histospec, float frac)
 Invert an histogram.

float median_f (const float x[], int n)
 Float wrapper to statistic (double) function "median".

double mean_sig_f (const float x[], int n, double *mean, double *sigma)
 Statistics (mean+sigma) on float array.

void minmax (const double x[], int n, double *min, double *max, int *imin, int *imax)
 Find the min and max (and associated index) in a double array.

void minmax_f (const float x[], int n, float *min, float *max, int *imin, int *imax)
 Find the min and max (and associated index) in a float array.

int locate_sorted (const double x[], int n, double x0)
 Locate a value in a sorted array.

void invert_indexx (const int idx[], int n)
 Compute the rank, i.e. invert the sorting index.

int Fit_polynom2 (float *x, float *y, int npts, int input_degree, int *output_degree, float *coef, float *dy, float *chi2)
 Conversion to double of Fit_polynom.

int dump_spec_mem (SPECTRUM *spectrum, char *name, char *ident, char *unit, int fclass)
void put_tiger_arrays (TIGERfile *frame, int no_lens, void *signal, void *noise, int data_type, int npix, double start)
 Store arrays as cube spectra in signal and/or noise channels.

int dump_2Darray (void **array, int data_type, int npix[], char *name)
 Dump a 2D-array in an image (starts={0,0}, steps={1,1}).

long nllsqfit_lorentz (long *mode, long *npts, long *npar, long *ldfj, double par[], double f[], double fjac[], long *nstate, long *iuser, double x_n_sig[])
long nllsqfit_gaussian (long *mode, long *npts, long *npar, long *ldfj, double par[], double f[], double fjac[], long *nstate, long *iuser, double x_n_sig[])
long nllsqfit_NNgaussian (long *mode, long *npts, long *npar, long *ldfj, double par[], double f[], double fjac[], long *nstate, long *iuser, double x_n_sig[])
long nllsqfit_quad (long *mode, long *npts, long *npar, long *ldfj, double par[], double f[], double fjac[], long *nstate, long *iuser, double x_n_sig[])
int discard_null_mpups (int npup, int **ilist, int **jlist, float **value, int ppup[])
 Remove empty classes from mpup list.

int detect_mpups (IMAGE2D mpup, double threshold, int *ppup[], double *fpup[], float *xpup[], float *ypup[])
 Detect mpups in input frame and compute associated quantities.

int study_triangulation (IMAGE2D mpup, float xpup[], float ypup[], int npup, int iadj[], int iend[], double xtri[], double ytri[], double stri[], double ltri[], double atri[])
 Study of the (raw) mpup triangulation.

void mpup_orders (double fpup[], int opup[], int npup, double f[3], double df[3])
 Classify mpups according to their orders and compute mean fluxes.

void rotate_coord (float x[], float y[], int n, float x0, float y0, float angle, float xr[], float yr[])
 Rotate coordinates.

int select_mpup_dist (float x0, float y0, float maxdist, int npup, float xpup[], float ypup[], int opup[], int icen[])
 Select mpups according to distance criterion.

int select_mpup_sharpest_smooth (float maxdist, int npup, float xpup[], float ypup[], int opup[], float spup[], int icen[])
 Select mpups closest to the (median-smoothed) sharpest one.

double gaussian_mpup (double arr[], int n, double x, double step, double par[], double dpar[], double fit[])
 Fit a pure gaussian profile (nllsqfit_gaussian) to the mpup.

long nllsqfit_distMLA (long *mode, long *npts, long *npar, long *ldfj, double *par, double f[], double fjac[], long *nstate, long *iuser, double user[])
void model_distMLA (int npup, double dpar[], int npar, float xd[], float yd[], float rd[])
double set_geoPSF (float scale)
double geoPSF (double x)
 Geometric PSF profile, according to global parameters.

long nllsqfit_globalPSF (long *mode, long *npts, long *npar, long *ldfj, double *par, double fvec[], double fjac[], long *nstate, long *iuser, double x_n_sig[])
double globalPSF (double x, double psfpar[])
 Global PSF profile, according to parameters psfpar.

double deconv_globalPSF (int ngpsf, double psfpar[], double decfac)
 Partial deconvolution of the global PSF.

double set_corePSF (double psfpar[])
long nllsqfit_localPSFn (long *mode, long *npts, long *npar, long *ldfj, double *par, double fvec[], double fjac[], long *nstate, long *iuser, double x_n_sig[])
double final_mpup (double xarr[], int npts, double start, double step, double xloc[], double dxloc[], double xfit[])
 Final fit (nllsqfit_localPSFn) of the mpup profile.

int search_extrema (double line[], int npts, int imin[], double fmin[], int imax[], double fmax[], int *nlmin)
 Look for extrema (one minimum + one maximum) in current line.

int search_pack (double line[], int *curpeak, int imax[], int nmax, double threshold, int *packpb, int *packpe)
 Look for next pack of peak in current line.

int locate_peak (max_lines line, double x)
 Locate a peak in a sorted max line from its position.

int find_nearest_peak (Maxima_Set *maxset, int iline, float x)
 Find nearest peak in a given line of a maxima set.

int find_nearest_max (Maxima_Set *maxset, float x, float y, int *iline, int *ipeak)
 Find nearest line and peak in the maxima set.

int open_max (char *maxname, Maxima_Set *maxset)
 Open a max file.

int pup_get_maxdata (Maxima_Set *maxset, float xpup, float ypup, float lbdapup, SnifsOptics *optics, float pixsize, double lstep, double *lbda[], double *dx[], double *sigma[])
 Associate lens number and max data.

long nllsqfit_maxpack (long *mode, long *npts, long *npar, long *ldfj, double par[], double fvec[], double fjac[], long *nstate, long *iuser, double x_n_sig[])
double Fit_pack (double xarr[], int npts, int npeak, double packpar[], double dpackpar[], double xfit[])
 Simultaneous fit of a pack of peaks.

int read_PSFgeo_param (void *anyfile, double *geo_param[])
int read_PSFglobal_param (void *anyfile, double *psf_param[])
int read_PSFlocal_ng (void *anyfile)
float read_lbdaref (void *anyfile)
 Read reference wavelength in descriptor MPUP_LBDAPUP.

Channel read_channel (void *anyfile)
 Read channel in descriptor CHANNEL.

int read_focus (void *anyfile)
 Read camera/collimator position.

int read_default_snifs_config (const Channel channel, SnifsConfig *config)
 Read default SNIFS configuration.

void optics2dval (const SnifsOptics *Optics, double *dval)
 SnifsOptics structure to double array convertor

void dval2optics (const double *dval, SnifsOptics *Optics)
int write_snifs_config_to_mask (TABLE *mask, SnifsConfig *config)
 Write configuration structures to mask.

int read_snifs_config_from_mask (TABLE *mask, SnifsConfig *config)
 Set configuration structure from mask.

void print_snifs_optics (const SnifsOptics *Optics)
 Print out a Tiger_optics structure elements.

void print_snifs_telescope (const Telescope *UHT)
 Print out a Telescope structure elements.

void print_snifs_detector (const SnifsDetector *CCD)
 Print out a Detector structure elements.

void print_snifs_config (const SnifsConfig *config)
 Print out the full SNIFS config.

double blaze_function (const Grism *grism, int order, double lambda)
 Return the blaze function of the grism.

double lateral_color_ampl (const CameraCollimator *element, double lambda)
 Compute lateral color for camera or collimator.

double collimator_forward (const CameraCollimator *collimator, double gamma, double lambda, double r)
 Light propagation through the collimator, forward.

double camera_forward (const CameraCollimator *camera, double lambda, double tantheta)
 Light propagation through the camera, forward.

double invert_camcoll (double y, double e, double b)
 Inversion of $y=x(ex^2+b)$.

void rotation_2D (double *x, double *y, double theta)
 2D-rotation

void refraction (double *x, double *y, double *z, double n1, double n2)
 Refraction law from 1 to 2.

void grating_forward (double *x, double *y, double *z, double lambda, double n, double g_per_mm, int order)
 Light propagation through a grating, forward.

void grating_backward (double *x, double *y, double *z, double lambda, double n, double g_per_mm, int order)
 Light propagation through a grating, backward.

double sellmeier_index (double lambda, const double sellcoeffs[])
 Compute refractive index from Sellmeier coefficients.

void grism_forward (const Grism *grism, double lambda, double *x, double *y, double *z, int order)
 Light propagation through a grism, forward.

void grism_backward (const Grism *grism, double lambda, double *x, double *y, double *z, int order)
 Light propagation through a grism, backward.

void snifs_optics_forward (const SnifsOptics *optics, double xmla, double ymla, double *xccd, double *yccd, double lambda, int order)
 Light propagation through the Snifs instrument, forward.

void snifs_optics_backward (const SnifsOptics *optics, double xccd, double yccd, double *xmla, double *ymla, double lambda, int order)
 Light propagation through the Snifs instrument, backward.

void snifs_optics_test_forward (const SnifsOptics *optics, double xmla, double ymla, double *xccd, double *yccd, double lambda, int order)
 Testing version of snifs_optics_forward.

void snifs_optics_CCD2MLA (const SnifsOptics *optics, double xccd, double yccd, double *xmla, double *ymla, double pixsize, double lbdaref)
 Wrapper to snifs_optics_backward, [CCD/px] to [MLA/mm].

void snifs_optics_MLA2CCD (const SnifsOptics *optics, double xmla, double ymla, double *xccd, double *yccd, double pixsize, double lbda, int order)
 Wrapper to snifs_optics_forward, [MLA/mm] to [CCD/px].

void plot_set_limits (const float x[], const float y[], int n, PlotLimits *limits)
 Set limits of the plot.

void plot_increase_limits (PlotLimits *limits)
 Increase plot limits by 10% (or to valid range if min=max).

int inside_plot_limits (float x, float y, PlotLimits limits)
 Test if point is inside plot limits.

int plot_compticks (int nticks, float min, float max, float *first, float *step)
void plot_start (Plot *plot, float scale)
 Initialize and set various default quantities for a DISLIN 2D-plot.

void plot_axes (const Plot *plot, char *xlabel, char *ylabel)
 Plot the axes in a DISLIN 2D-plot.

void plot_title (char *title)
 Plot the title strings.

void plot_set_bkgnd (IMAGE2D *bkgndima, Plot *plot, float mincut, float maxcut, int *nx, int *ny, float ***zmat)
 Set a background plot.

void plot_max (const Maxima_Set *maxset, const Plot *plot, const double shift[])
 Plot max data.

void plot_lens (const SnifsOptics *optics, int nopup, float xppup, float yppup, int nlbda, const float lbda[], int order, const Plot *plot, float lbdaref, float pixsize, int dxnc, double *dxcoeff, const double shift[], double *xmla, double *ymla)
 Plot a lens spectrum onto the CCD.

void plot_lens_tab (const SnifsOptics *optics, float xppup, float yppup, int nlbda, const float lbda[], int order, TABLE *table, const int colid[], int row, float lbdaref, float pixsize, int dxnc, double *dxcoeff, const double shift[], double *xmla, double *ymla)
 Plot a lens spectrum onto the CCD (table storage).

void plot_array_err (const PlotSymbol *symbol, float x[], float y[], int n, float dx[], float dy[])
 DISLIN curve with errors.

void plot_initialize (Plot *plot, int GRAPH, const char *devname, const PlotLimits *limits, const PlotSymbol *symbol, float mincut, float maxcut)
 Initialize a Plot structure.

void norm_mask_param (Channel channel, double par[16])
 Mask parameters normalization.

void unnorm_mask_param (Channel channel, double par[16])
 Mask parameters unnormalization.

void set_mask_param_limits (double par[16], double parlb[16], double parub[16])
 Set limits to mask parameters.

void optics2mask_param (SnifsOptics *optics, double par[16])
 Copy mask parameters from SnifsOptics.

void mask_param2optics (double par[16], SnifsOptics *optics)
 Copy mask parameters to SnifsOptics.

void print_mask_param (double par[16])
 Print-out (non-normalized) mask parameters.

void print_mask_param_in (double par[16], double parlb[16], double parub[16])
 Print-out (non-norm.) mask parameters (including fit boundaries).

void print_mask_param_out (double par[16], double epar[16])
 Print-out (non-norm.) mask parameters (including fit errors).

int open_mask (char *maskname, TABLE *mask, char *mode)
 Open a mask table.

int read_local_model (TABLE *mask, int flag, double ***coeff)
 Read local coeffs from mask (position adjusment or sigma).

int open_image (IMAGE2D *frame, char *name, char *mode, int class, char *type)
 Open a frame and check FCLASS.

int open_image_ext (IMAGE2D *signal, IMAGE2D *variance, char *name, char *mode, int class, char *type)
float read_mean_RoN (void *anyfile, Channel channel)
 Compute mean RoN from RDNOISE descriptors.

float read_airmass (void *anyfile)
 Read AIRMASS descriptor (defaulted to 1) from open file.

float read_juliandate (void *anyfile)
 Read MJDATE descriptor (defaulted to 0) from open file.

float check_airmass (char *arcname, float cal_airmass, char *objname, float obj_airmass)
 Check airmass consistency between two exposures.

float check_jdate (char *arcname, float cal_jdate, char *objname, float obj_jdate)
 Check julian date consistency between two exposures.

int extract_arc (const IMAGE2D *frame, int npix, double **tab)
 Extract central part of arc exposure.

void negate_2D (double **I, int nx, int ny)
 Negate a nx*ny 2D array.

void complex_product_2D (double **AR, double **AI, double **BR, double **BI, int nx, int ny, double **CR, double **CI)
 Compute the complex product C = A * B for nx*ny 2D arrays.

int FFT2D_real (double **in, int nx, int ny, double **outR, double **outI)
 FFT of a nx*ny 2D real dataset.

int iFFT2D_real (double **inR, double **inI, int nx, int ny, double **outR)
 Inverse FFT (real part) of a nx*ny 2D dataset.

int correlation2D (double **A, double **B, int nx, int ny, double **X)
 Compute correlation of nx*ny 2D arrays A and B.

long nllsqfit_2Dgauss (long *mode, long *npts, long *npar, long *ldfj, double *par, double *f, double *fjac, long *nstate, long *iuser, double *user)
int Fit_Xpeak (double **ref_tab, double **cur_tab, int nx, int ny, int winx, int winy, double par[6], double epar[6])
double Mpup_PSF (int no, float x)
 Integral over the pixel of the X-disp. model profile.

int good_neighbor (float *ylo, float *yup, int *neighbors, float y)
 Find the good neightbor among 2 candidates.

void comp_mean_disp (double parpeak[6], double eparpeak[6], double *msig, double *emsig)
 Convert correlation-peak quantities to intrinsic quantities.

void print_parpeak (double parpeak[6], double eparpeak[6], double msig, double emsig)
 Print-out correlation-peak quantities.

int comp_calibration_offsets (char *refname, float *ref_airmass, char *arcname, float *cal_airmass, float *cal_jdate, char *arc2name, float *cal2_airmass, float *cal2_jdate, double shift[2])
 Compute the offset between reference and calibration frames.


Detailed Description

extract specific function prototyping and define

Copyright:
(c) 2002 IPNL
Date:
Date
2004/11/12 16:24:39
Author:
Yannick Copin <y.copin@ipnl.in2p3.fr>

Author
ycopin
Version:
Revision
1.31
Id
extract.h,v 1.31 2004/11/12 16:24:39 ycopin Exp

Note:
Can somebody explain me the use of const and extern declarations?

Definition in file extract.h.


Define Documentation

#define FMP_XC   1027.
 

Definition at line 27 of file extract.h.

Referenced by main().

#define FMP_YC   1770.
 

Center of distortion.

Definition at line 28 of file extract.h.

Referenced by main().

#define FMP_LENSSNORM   1.e2
 

Definition at line 29 of file extract.h.

Referenced by main(), and nllsqfit_distMLA().

#define FMP_ANGLENORM   6.e-2
 

Definition at line 30 of file extract.h.

Referenced by main(), and nllsqfit_distMLA().

#define FMP_POSITNORM   1.e3
 

Definition at line 31 of file extract.h.

Referenced by main(), and nllsqfit_distMLA().

#define FMP_ALPHANORM   1.e-8
 

Normalization factors.

Definition at line 32 of file extract.h.

Referenced by main(), and nllsqfit_distMLA().

#define FMP_IPSFNORM   1.e2
 

Definition at line 36 of file extract.h.

Referenced by main(), and nllsqfit_globalPSF().

#define FMP_XPSFNORM   0.5
 

Normalization factors.

Definition at line 37 of file extract.h.

Referenced by main(), and nllsqfit_globalPSF().

#define FMP_IPUPNORM   60.
 

Definition at line 41 of file extract.h.

Referenced by final_mpup(), nllsqfit_localPSF(), and nllsqfit_localPSFn().

#define FMP_XPUPNORM   0.3
 

Definition at line 42 of file extract.h.

Referenced by final_mpup(), nllsqfit_localPSF(), and nllsqfit_localPSFn().

#define FMP_SPUPNORM   0.1
 

Normalization factors.

Definition at line 43 of file extract.h.

Referenced by final_mpup(), nllsqfit_localPSF(), and nllsqfit_localPSFn().

#define FMX_TOOFAR   2.
 

Limit factor (in interpsec unit) for neighbourhood criterion.

Definition at line 48 of file extract.h.

Referenced by main(), and search_pack().

#define FMX_SIGMA_CLIP   5.
 

Sigma-clipping factor for the threshold computation.

Definition at line 54 of file extract.h.

Referenced by main().


Function Documentation

void nllsqfit_noderiv  ) 
 

Allow nllsqfit_bnd to be used without derivatives.

Definition at line 25 of file least_sq.c.

Referenced by main().

int get_lenses_col E3D_file *  frame,
char *  lab_col,
void *  zlens,
int *  il
 

Get spaxel-related quantities from table.

Parameters:
frame E3D file structure
lab_col Column label
zlens List of quantities
il List of table rows
Returns:
Status
Note:
Based on get_lenses_coord

Todo:
In the E3D case, one has to specify the science table extension name in which to look to for the specified column. For the moment, look in the table associated to the cube (the data table?)

Definition at line 41 of file io.c.

References InputIO.

Referenced by main().

double RD_frame_interp IMAGE2D *  frame,
double  x,
double  y
 

Interpolated RD_frame.

Read a frame at a given world-coordinate (x,y). E.g. if

\[ (x,y) = (startx + i\times stepx, starty + j\times stepy) \]

then returns RD_frame(frame,i,j).

Parameters:
frame Input frame
x 
y Input world coordinates
Returns:
Interpolated value (or MAXDOUBLE if outside frame)

Definition at line 121 of file io.c.

Referenced by nllsqfit_mask().

void spatial_filter int  nrow,
float  X[],
float  Y[],
float  Z[],
float  rad,
char  method,
int  minNnb,
int  Nnb[]
 

Spatial filtering (median or average) of arrays.

Parameters:
nrow Nb of input coordinates
X 
Y Input coordinates
Z Input values/Filtered values
rad Radius of filtering [coord]
method Filtering method
  • 'A': average,
  • 'M': median,
minNnb Minimal nb of neighbors. If <0, exclude central point.
Nnb Ouput nb of neighbors (or NULL)

Definition at line 36 of file filter.c.

Referenced by select_mpup_sharpest_smooth().

void frame_stats const IMAGE2D *  frame,
double *  mean,
double *  sigma,
double *  median,
double *  sigmed
 

Statistic elements of a frame.

Compute statistic elements (mean,dispersion and median, median dispersion if required) of frame. Median and median dispersion are computed if both pointers are non-NULL

Parameters:
frame Input frame
mean Arithmetic mean $\mu$
sigma Arithmetic dispersion $\sigma$: $\sigma^2 = \frac{n\sum p_{ij}^2 - (\sum p_{ij})^2}{n(n-1)}$
median Median $m$ (or NULL if not needed)
sigmed Median dispersion (i.e. median of $|p_{ij}-m|$) (or NULL if not needed)

Definition at line 38 of file stats.c.

Referenced by main().

SPECTRUM* array_histo const double *  array,
int  npts,
double  min,
double  max,
int  nbin
 

Histogram of a (double) vector.

Compute the histogram -- with ~nbin bins between min and max -- of a vector, and return it as a memory spectrum. If nbin>0, there is indeed nbin bins. If nbin<0, there are two extra outer bins for the values outside the range [min,max].

Parameters:
array input (double) vector
npts of size npts
min 
max min and max of the histogram range
nbin number of bins (can be negative, see description)
Returns:
pointer to the histogram memory spectrum

Definition at line 97 of file stats.c.

Referenced by main(), and subframe_histo().

SPECTRUM* subframe_histo const IMAGE2D *  frame,
int  imin,
int  imax,
int  jmin,
int  jmax,
double  min,
double  max,
int  nbin
 

Histogram of a subframe.

Compute the histogram -- with ~nbin bins between min and max -- of subframe [imin,jmin:imax,jmax], and return it as a memory spectrum (see array_histo).

Parameters:
frame input frame
imin 
imax 
jmin 
jmax subframe definition [px]
min 
max min and max of the histogram range
nbin number of bins (can be negative)
Returns:
pointer to the histogram memory spectrum
Warning:
There's no checking for validity of subframe.

Definition at line 166 of file stats.c.

References array_histo().

Referenced by frame_histo(), and plot_set_bkgnd().

SPECTRUM* frame_histo const IMAGE2D *  frame,
double  min,
double  max,
int  nbin
 

Histogram of a frame.

Compute the histogram -- with ~nbin bins between min and max -- of a frame, and return it as a memory spectrum (see array_histo).

Parameters:
frame input frame
min 
max min and max of the histogram range
nbin number of bins (can be negative)
Returns:
pointer to the histogram memory spectrum

Definition at line 205 of file stats.c.

References subframe_histo().

Referenced by main().

double histo_threshold const SPECTRUM *  histospec,
float  frac
 

Invert an histogram.

According to the histogram stored in the input spectrum, computes the threshold so that a given fraction of the population is below.

Parameters:
histospec input histogram spectrum, as computed from frame_histo
frac fraction of the population that should be below
Returns:
threshold

Definition at line 227 of file stats.c.

Referenced by main(), and plot_set_bkgnd().

float median_f const float  x[],
int  n
 

Float wrapper to statistic (double) function "median".

Parameters:
x float array
n nb of points
Returns:
(float)median

Definition at line 260 of file stats.c.

Referenced by main().

double mean_sig_f const float  x[],
int  n,
double *  mean,
double *  sigma
 

Statistics (mean+sigma) on float array.

Parameters:
x float array
n nb of points
mean arithmetic mean
sigma arithmetic dispersion (n-1)
Returns:
mean
Note:
Similar to gsl_stats_mean and gsl_stats_sd_m

Definition at line 291 of file stats.c.

Referenced by main().

void minmax const double  x[],
int  n,
double *  min,
double *  max,
int *  imin,
int *  imax
 

Find the min and max (and associated index) in a double array.

Parameters:
x input array
n size of input array
min minimum value of the input array
max maximum value of the input array
imin index of the minimum value
imax index of the maximum value
Note:
Similar to gsl_stats_minmax_index

Definition at line 322 of file stats.c.

Referenced by main().

void minmax_f const float  x[],
int  n,
float *  min,
float *  max,
int *  imin,
int *  imax
 

Find the min and max (and associated index) in a float array.

Parameters:
x input array
n size of input array
min minimum value of the input array
max maximum value of the input array
imin index of the minimum value
imax index of the maximum value
Note:
Similar to gsl_stats_minmax_index

Definition at line 348 of file stats.c.

Referenced by main(), and select_mpup_sharpest_smooth().

int locate_sorted const double  x[],
int  n,
double  x0
 

Locate a value in a sorted array.

Parameters:
x input array (monotonely sorted)
n input array length
x0 target value
Returns:
Index i (in -1,n-1) such that x[i] <= x0 < x[i+1]
Note:
Log_2(n) algorithm adapted from locate of NRC.

Definition at line 372 of file stats.c.

void invert_indexx int  idx[],
int  n
 

Compute the rank, i.e. invert the sorting index.

At input, idx has been computed (by e.g. indexx) according to an external array such as array[idx[i]] is in increasing order. At output, idx contains the rank of array[i], i.e. idx_new[idx_old[i]] = i.

Parameters:
idx Sorting/ranking index
n Size of the array

Definition at line 404 of file stats.c.

Referenced by main().

int Fit_polynom2 float *  x,
float *  y,
int  npts,
int  input_deg,
int *  output_deg,
float *  coef,
float *  dy,
float *  chi2
 

Conversion to double of Fit_polynom.

Routine Fit_polynom in IFU_C_mathlibs-6.1/C_libs/math/least_sq/misc_routines.c makes its internal computations in float, which is unsifficient.

Definition at line 449 of file stats.c.

Referenced by main().

int dump_spec_mem SPECTRUM *  spectrum,
char *  name,
char *  ident,
char *  unit,
int  fclass
 

Dump a memory spectrum (as created with create_spec_mem) to disk

Parameters:
spectrum spectrum structure to be dumped
name spectrum filename
ident identifier
unit units
fclass file class
Returns:
status 0 if OK

Definition at line 32 of file dump.c.

Referenced by main().

void put_tiger_arrays TIGERfile *  frame,
int  no_lens,
void *  signal,
void *  noise,
int  data_type,
int  npix,
double  start
 

Store arrays as cube spectra in signal and/or noise channels.

Parameters:
frame destination cube
no_lens destination lens
signal array to be stored in signal, of type data_type (NULL if none)
noise array to be stored in noise, of type data_type (NULL if none)
data_type arrays data-type (INT, FLOAT, etc., not necessarily the same as frame)
npix number of points in signal and noise arrays
start start coord. of signal and noise arrays
Warning:
According to the I/O library (at least in the TIGER format), if a datacube spaxel has both signal and noise spectra, all the spaxels of this datacube should have both.

Definition at line 77 of file dump.c.

Referenced by main().

int dump_2Darray void **  array,
int  data_type,
int  npix[],
char *  name
 

Dump a 2D-array in an image (starts={0,0}, steps={1,1}).

Parameters:
array Input 2D-array
data_type Array data_type
npix Array size (npix[0] x npix[1])
name Name of the output image
Returns:
Creation status
Note:
There's a fundamental incompatibility between the image and 2D-array data ordering: images have i index running faster, while 2D-arrays have j index running faster. Hence, e.g., two very similar routines, nllsqfit_2Dgauss and nllsqfit_2DgaussB.

Definition at line 142 of file dump.c.

Referenced by extract_arc(), and Fit_Xpeak().

long nllsqfit_lorentz long *  mode,
long *  npts,
long *  npar,
long *  ldfj,
double  par[],
double  f[],
double  fjac[],
long *  nstate,
long *  iuser,
double  x_n_sig[]
 

Normalized Lorentz fit w/ nllsqfit_bnd proc. The array x_n_sig[0..2*npts-1] is filled prior to call with

  • x_n_sig[0..npts-1]: x
  • x_n_sig[npts..2*npts-1]: y-sigma Fit function:

    \[ f_{I,\mu,\sigma}(x) = \frac{I}{\sigma\pi} \frac{1}{1+\left(\frac{x-\mu}{\sigma}\right)^2} \]

    with $I,\mu,\sigma$ in par[0,1,2]

Definition at line 35 of file nllsqfit_fn.c.

long nllsqfit_gaussian long *  mode,
long *  npts,
long *  npar,
long *  ldfj,
double  par[],
double  f[],
double  fjac[],
long *  nstate,
long *  iuser,
double  x_n_sig[]
 

Normalized Gaussian fit w/ nllsqfit_bnd proc. The array x_n_sig[0..2*npts-1] is filled prior to call with

  • x_n_sig[0..npts-1]: x
  • x_n_sig[npts..2*npts-1]: y-sigma Fit function:

    \[ f_{I,\mu,\sigma}(x) = \frac{I}{\sigma\sqrt{2*\pi}} \exp{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2} \]

    with $I,\mu,\sigma$ in par[0,1,2]

Definition at line 84 of file nllsqfit_fn.c.

Referenced by gaussian_mpup().

long nllsqfit_NNgaussian long *  mode,
long *  npts,
long *  npar,
long *  ldfj,
double  par[],
double  f[],
double  fjac[],
long *  nstate,
long *  iuser,
double  x_n_sig[]
 

Non-normalized Gaussian fit w/ nllsqfit_bnd proc. The array x_n_sig[0..2*npts-1] is filled prior to call with

  • x_n_sig[0..npts-1]: x
  • x_n_sig[npts..2*npts-1]: y-sigma Fit function:

    \[ f_{I,\mu,\sigma}(x) = I\exp{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2} \]

    with $I,\mu,\sigma$ in par[0,1,2]

Definition at line 132 of file nllsqfit_fn.c.

long nllsqfit_quad long *  mode,
long *  npts,
long *  npar,
long *  ldfj,
double  par[],
double  f[],
double  fjac[],
long *  nstate,
long *  iuser,
double  x_n_sig[]
 

Quadratic fit w/ nllsqfit_bnd proc. The array x_n_sig[0..2*npts-1] is filled prior to call with

  • x_n_sig[0..npts-1]: x
  • x_n_sig[npts..2*npts-1]: y-sigma Fit function:

    \[ f_{a,b,c}(x) = a*(x-b)^2 + c \]

    with $a,b,c$ in par[0,1,2]

Definition at line 179 of file nllsqfit_fn.c.

Referenced by main().

int discard_null_mpups int  npup,
int **  ilist,
int **  jlist,
float **  value,
int  ppup[]
 

Remove empty classes from mpup list.

Parameters:
npup Nb of classes (input)
ilist i-index of pixels in mpups (2D-array)
jlist j-index of pixels in mpups (2D-array)
value flux of pixels in mpups (2D-array)
ppup nb of pixels in mpups
Returns:
Nb of non-null mpups

Definition at line 47 of file proc_mpup.c.

Referenced by detect_mpups().

int detect_mpups IMAGE2D  mpup,
double  threshold,
int *  ppup[],
double *  fpup[],
float *  xpup[],
float *  ypup[]
 

Detect mpups in input frame and compute associated quantities.

Parameters:
mpup input frame
threshold detection limit for the mpups
ppup nb of pixels in mpups (dynamically allocated)
fpup total flux in mpups (dynamically allocated)
xpup centroid (x) of mpups (dynamically allocated)
ypup centroid (y) of mpups (dynamically allocated)
Returns:
total number of mpups

Definition at line 84 of file proc_mpup.c.

References discard_null_mpups(), MEDSIG2GAUSSIG, MERGENEIGHBOR, SNIFS_LENS_NX, SNIFS_LENS_NY, and SNIFS_LENS_PX.

Referenced by main().

int study_triangulation IMAGE2D  mpup,
float  xpup[],
float  ypup[],
int  npup,
int  iadj[],
int  iend[],
double  xtri[],
double  ytri[],
double  stri[],
double  ltri[],
double  atri[]
 

Study of the (raw) mpup triangulation.

Will clean up the raw mpup triangulation to keep only unique good-shape (half-square) triangles, and compute triangle quantities (center, surface, shortest lengthes, orientation). The xtri,...,atri double arrays should be allocated prior to call with size npup*6 (except ltri, of size npup*12).

Parameters:
mpup mpup frame
xpup 
ypup mpup positions
npup nb of mpups
iadj 
iend triangulation vectors, as issued from TRMESH
xtri 
ytri triangle barycenter (length: ntri)
stri triangle surface (length: ntri)
ltri shortest sides length (length: 2*ntri)
atri triangle orientation (length: ntri)
Returns:
final number of triangles (ntri)
Note:
If compilation variable HAVE_LIBDISLIN is defined, a graphical output of the triangulation can be stored in dislin_triangulation.eps using the graphical library DISLIN (in debug-mode).

Bug:
In previous versions of find_mpup, npts is initialized to iend[0]-1 instead of iend[0].

Definition at line 279 of file proc_mpup.c.

References DISLIN, Plot::Limits, plot_axes(), plot_increase_limits(), plot_initialize(), plot_set_limits(), plot_start(), plot_title(), SNIFS_LENS_PX, and Plot::Symbol.

Referenced by main().

void mpup_orders double  fpup[],
int  opup[],
int  npup,
double  f[3],
double  df[3]
 

Classify mpups according to their orders and compute mean fluxes.

Parameters:
fpup mpup flux
opup mpup order
npup nb of mpups
f mean flux for each mpup class
df flux dispersion for each mpup class

Definition at line 443 of file proc_mpup.c.

Referenced by main().

void rotate_coord float  x[],
float  y[],
int  n,
float  x0,
float  y0,
float  angle,
float  xr[],
float  yr[]
 

Rotate coordinates.

Parameters:
x 
y input coord.
n 
x0 
y0 center of rotation
angle angle of rotation (trigonometric radians)
xr 
yr rotated coord.

Definition at line 484 of file proc_mpup.c.

Referenced by main().

int select_mpup_dist float  x0,
float  y0,
float  maxdist,
int  npup,
float  xpup[],
float  ypup[],
int  opup[],
int  icen[]
 

Select mpups according to distance criterion.

Parameters:
x0 
y0 Center of reference
maxdist Maximal distance (minimal if <0)
npup 
xpup 
ypup 
opup Mpups number, position and order
icen Selected indices
Returns:
Nb of selected mpups

Definition at line 518 of file proc_mpup.c.

Referenced by select_mpup_sharpest_smooth().

int select_mpup_sharpest_smooth float  maxdist,
int  npup,
float  xpup[],
float  ypup[],
int  opup[],
float  spup[],
int  icen[]
 

Select mpups closest to the (median-smoothed) sharpest one.

Parameters:
maxdist Smoothing distance/Maximal distance
npup 
xpup 
ypup 
opup 
spup Mpups number, position, order and dispersion
icen Selected indices
Returns:
Nb of selected mpups

Definition at line 555 of file proc_mpup.c.

References minmax_f(), select_mpup_dist(), and spatial_filter().

Referenced by main().

double gaussian_mpup double  arr[],
int  npts,
double  start,
double  step,
double  par[],
double  dpar[],
double  fit[]
 

Fit a pure gaussian profile (nllsqfit_gaussian) to the mpup.

Parameters:
arr profile array to be adjusted
npts nb of points in profile
start starting coordinate of the profile
step step of the profile
par parameters of the fit
dpar error on the parameters
fit adjusted profile (zero-ed if error)
Returns:
RMS if OK, -status otherwise (as returned by nllsqfit_bnd)

Definition at line 66 of file fit_mpup.c.

References nllsqfit_gaussian().

Referenced by main().

long nllsqfit_distMLA long *  mode,
long *  npup,
long *  npar,
long *  ldfj,
double *  par,
double  f[],
double  fjac[],
long *  nstate,
long *  iuser,
double  user[]
 

Fitting procedure for the MLA distortion. Distortion law: $ 1 + \alpha*r^2$. Parameters to be adjusted: lenssize, angle, (xc,yc), alpha.

To be used with nllsqfit_bnd. Derivatives have been checked.

Note:
Make use of global variables

If compilation variable USE_R4_DIST is defined, an extra term is added to the distortion law: $ 1 + \alpha*r^2 + \beta*r^4$

Definition at line 113 of file fit_mpup.c.

References FMP_ALPHANORM, FMP_ANGLENORM, FMP_LENSSNORM, FMP_POSITNORM, glmlaml, glmlanl, glmlaxlc, glmlaxpup, glmlaylc, and glmlaypup.

Referenced by main().

void model_distMLA int  npup,
double  dpar[],
int  npar,
float  xd[],
float  yd[],
float  rd[]
 

Reconstruct the mpup positions according to the dist. parameters computed from nllsqfit_distMLA.

Note:
Make use of global variables

Definition at line 220 of file fit_mpup.c.

References DISLIN, glmlaml, glmlanl, glmlaxlc, glmlaxpup, glmlaylc, glmlaypup, Plot::Limits, plot_axes(), plot_increase_limits(), plot_initialize(), plot_set_limits(), plot_start(), plot_title(), and Plot::Symbol.

Referenced by main().

double set_geoPSF float  scale  ) 
 

Set the geometric PSF (described by the global (allocated) arrays glIgeo, glXgeo and glSgeo) as a glnggeo -component model from an external ad-hoc analysis (see fit_mpupgeo), for a given spatial scale.

Parameters:
scale spatial scale on CCD (in px)
Returns:
norm of the geometric PSF

Definition at line 354 of file fit_mpup.c.

References GEOPUP3G_I0, GEOPUP3G_I1, GEOPUP3G_S0, GEOPUP3G_S1, GEOPUP3G_X1, GEOPUP5G_I0, GEOPUP5G_I1, GEOPUP5G_I2, GEOPUP5G_S0, GEOPUP5G_S1, GEOPUP5G_S2, GEOPUP5G_X1, GEOPUP5G_X2, GEOPUP7G_I0, GEOPUP7G_I1, GEOPUP7G_I2, GEOPUP7G_I3, GEOPUP7G_S0, GEOPUP7G_S1, GEOPUP7G_S2, GEOPUP7G_S3, GEOPUP7G_X1, GEOPUP7G_X2, GEOPUP7G_X3, glIgeo, glnggeo, glSgeo, and glXgeo.

Referenced by main().

double geoPSF double  x  ) 
 

Geometric PSF profile, according to global parameters.

Definition at line 427 of file fit_mpup.c.

References glIgeo, glnggeo, glSgeo, and glXgeo.

Referenced by main().

long nllsqfit_globalPSF long *  mode,
long *  npts,
long *  npar,
long *  ldfj,
double *  par,
double  fvec[],
double  fjac[],
long *  nstate,
long *  iuser,
double  x_n_sig[]
 

Fitting procedure for the global PSF parameters: glnggeo(>0)-gaussian profile (x) glngpsf(>0)-gaussian global PSF simultaneously adjusted on npup mpups.

To be used with nllsqfit_bnd. Derivatives have been checked.

Note:
Make use of global variables

Bug:
In n_gauss_pup (in SAURON/find_mpup), Is and Ss are ngauss*ngauss (here npsf*npsf) instead of NGGEOPUP*ngauss (here ngeo*npsf)

Definition at line 454 of file fit_mpup.c.

References FMP_IPSFNORM, FMP_XPSFNORM, glIgeo, glnggeo, glngpsf, glpcen, glSgeo, and glXgeo.

Referenced by main().

double globalPSF double  x,
double  psfpar[]
 

Global PSF profile, according to parameters psfpar.

Definition at line 555 of file fit_mpup.c.

References glngpsf.

Referenced by main().

double deconv_globalPSF int  ngpsf,
double  psfpar[],
double  decfac
 

Partial deconvolution of the global PSF.

Parameters:
ngpsf number of gaussian components in global PSF
psfpar description of the global PSF
decfac deconvolution factor (Sdec = Smin*sqrt(decfac))
Returns:
norm of the partially deconvolved global PSF

Definition at line 577 of file fit_mpup.c.

Referenced by main().

double set_corePSF double  psfpar[]  ) 
 

Set the core PSF (described by the global (allocated) arrays glIpsf and glSpsf) as the convolution of the geom. PSF (glnggeo>0 components) and the global PSF (glngpsf>=0 components).

Parameters:
psfpar description of the global PSF (if glngpsf>0)
Returns:
norm of the core PSF

Definition at line 627 of file fit_mpup.c.

References glIgeo, glIpsf, glnggeo, glngpsf, glSgeo, and glSpsf.

Referenced by main().

long nllsqfit_localPSFn long *  mode,
long *  npts,
long *  npar,
long *  ldfj,
double *  par,
double  fvec[],
double  fjac[],
long *  nstate,
long *  iuser,
double  x_n_sig[]
 

Fitting procedure for the local PSF parameters: fixed glnggeo(>0)-gaussian profile (x) fixed glngpsf(>=0)-gaussian global PSF (x) glngloc-gaussian local PSF adjusted on a single mpup.

To be used with nllsqfit_bnd. Derivatives have been checked.

Note:
Make use of global variables

Definition at line 668 of file fit_mpup.c.

References FMP_IPUPNORM, FMP_SPUPNORM, FMP_XPUPNORM, glIpsf, glnggeo, glngloc, glngpsf, glSpsf, and glXgeo.

Referenced by final_mpup().

double final_mpup double  xarr[],
int  npts,
double  start,
double  step,
double  xloc[],
double  dxloc[],
double  xfit[]
 

Final fit (nllsqfit_localPSFn) of the mpup profile.

Parameters:
xarr profile array to be adjusted
npts nb of points in profile
start starting coordinate of the profile
step step of the profile
xloc parameters of the fit (initialized to initial guess)
dxloc error on the parameters
xfit adjusted profile (zero-ed if error)
Returns:
RMS if OK, -status otherwise (as returned by nllsqfit_bnd)
Note:
Make use of global variables

Definition at line 776 of file fit_mpup.c.

References FMP_IPUPNORM, FMP_SPUPNORM, FMP_XPUPNORM, glngloc, and nllsqfit_localPSFn().

Referenced by main().

int search_extrema double  line[],
int  npts,
int  imin[],
double  fmin[],
int  imax[],
double  fmax[],
int *  nlmin
 

Look for extrema (one minimum + one maximum) in current line.

Parameters:
line Current line
npts Nb of points in current line
imin Minima indices
fmin Minima fluxes
imax Maxima indices
fmax Maxima fluxes
nlmin Nb of minima found
Returns:
Nb of maxima found
Warning:
imin and imax contain the extrema indices, not the coord.

Definition at line 38 of file proc_max.c.

Referenced by main().

int search_pack double  line[],
int *  curpeak,
int  imax[],
int  nmax,
double  threshold,
int *  packpb,
int *  packpe
 

Look for next pack of peak in current line.

Parameters:
line Current line
curpeak Current peak (will be updated)
imax Maxima indices
nmax Nb of maxima in current line
threshold 
packpb Index of 1st peak in pack
packpe Index of last peak in pack
Returns:
nb of peaks in current pack (0 if no more pack)

Definition at line 85 of file proc_max.c.

References FMX_TOOFAR, and SNIFS_INTERSP.

Referenced by main().

int locate_peak max_lines  line,
double  x
 

Locate a peak in a sorted max line from its position.

Parameters:
line Input max line (monotingly sorted, assumed non-empty)
x Target value
Returns:
Index i (in -1,nb_max-1) such that line.maxima[i].xcoord <= x < ...[i+1]
Note:
Log_2(n) algorithm adapted from locate_sorted
Warning:
In some case, the xcoord of the max line are not strictly increasing!

Definition at line 125 of file proc_max.c.

Referenced by find_nearest_peak().

int find_nearest_peak Maxima_Set *  maxset,
int  iline,
float  x
 

Find nearest peak in a given line of a maxima set.

Parameters:
maxset Input maxima set
iline Input line
x Input coordinate
Returns:
Peak index (in 0..n-1)
Note:
Input line is supposed to have a peak, i.e. maxset->line[iline].nb_max > 0

Definition at line 159 of file proc_max.c.

References locate_peak().

Referenced by find_nearest_max().

int find_nearest_max Maxima_Set *  maxset,
float  x,
float  y,
int *  iline,
int *  ipeak
 

Find nearest line and peak in the maxima set.

Parameters:
maxset Input maxima set
x 
y Input coordinates
iline 
ipeak Nearest max. point is maxset->line[iline].maxima[ipeak]
Returns:
Status OK || UNKNOWN

Definition at line 191 of file proc_max.c.

References find_nearest_peak().

Referenced by nllsqfit_mask(), and pup_get_maxdata().

int open_max char *  maxname,
Maxima_Set *  maxset
 

Open a max file.

Parameters:
maxname Name of the max file
maxset Max structure
Returns:
Error status

Definition at line 222 of file proc_max.c.

Referenced by main().

int pup_get_maxdata Maxima_Set *  maxset,
float  xpup,
float  ypup,
float  lbdapup,
SnifsOptics optics,
float  pixsize,
double  lstep,
double *  lbda[],
double *  dx[],
double *  sigma[]
 

Associate lens number and max data.

Parameters:
maxset Input maxima set
xpup 
ypup Mpup coordinates [px]
lbdapup Mpup ref. wavelength [AA]
optics Snifs optics
pixsize Pixel size [mm]
lstep Lambda step (from optics->filter.inf_util to optics->filter.sup_util)
lbda Lambda where max positions have been found (array to be freed)
dx Corresponding offset (max - computed position) (array to be freed)
sigma Corresponding max local PSF sigma (array to be freed)
Returns:
Number of max points associated to that lens
Warning:
This is a tricky task to make the association between the lenses and the max quantities... Some ad-hoc criteria on maximal distance to max position and/or X-disp. sigma are applied (see e.g. MAX_XDISPSIG_B).

Definition at line 262 of file proc_max.c.

References BLUE_CHANNEL, SnifsOptics::channel, SnifsOptics::filter, find_nearest_max(), MAX_XDISPSIG_B, MAX_XDISPSIG_R, MIN_XDISPSIG_B, MIN_XDISPSIG_R, SNIFS_INTERSP, snifs_optics_CCD2MLA(), and snifs_optics_MLA2CCD().

Referenced by main().

long nllsqfit_maxpack long *  mode,
long *  npts,
long *  npar,
long *  ldfj,
double  par[],
double  fvec[],
double  fjac[],
long *  nstate,
long *  iuser,
double  x_n_sig[]
 

Fitting procedure for the pack cross-dispersion profile: fixed glnggeo(>0)-gaussian profile (x) fixed glngpsf(>=0)-gaussian global PSF (x) 1-gaussian local PSF simultaneously adjusted.

To be used with nllsqfit_bnd. Derivatives have been checked.

Note:
Make use of global variables

Previous version known as n_3gausspup

See nllsqfit_globalPSFn for further development tips (including multi-gaussian local PSF)

Definition at line 61 of file fit_max.c.

References FMX_IPEAKNORM, FMX_SPEAKNORM, FMX_XPEAKNORM, glIpsf, glnggeo, glngpsf, glSpsf, and glXgeo.

Referenced by Fit_pack().

double Fit_pack double  xarr[],
int  npts,
int  npeak,
double  packpar[],
double  dpackpar[],
double  xfit[]
 

Simultaneous fit of a pack of peaks.

Parameters:
xarr multi-peak profile to be adjsuted
npts nb of pixels in profile
npeak nb of peaks in profile
packpar parameters of the fit (initial guess/fit result)
dpackpar error on the parameters
xfit adjusted multi-peak profile
Returns:
RMS if OK, -status otherwise (as returned by nllsqfit_bnd)

Definition at line 176 of file fit_max.c.

References FMX_IPEAKNORM, FMX_SPEAKNORM, FMX_XPEAKNORM, FMX_XPEAKOFFS, glipeaknorm, glngloc, glxpeakoffs, nllsqfit_maxpack(), and SNIFS_INTERSP.

Referenced by main().

int read_PSFgeo_param void *  anyfile,
double *  geo_param[]
 

Read the geometric PSF model from descriptors MPUP_NGGEO and MPUP_GEOPAR

Parameters:
anyfile Input file
geo_param Output parameter array (3*nggeo)
Returns:
Number of gaussian components in PSF model (nggeo>0 or -1)
geo_param
Add a description.

Definition at line 36 of file proc_config.c.

References MPUP_GEOPAR, and MPUP_NGGEO.

Referenced by main().

int read_PSFglobal_param void *  anyfile,
double *  psf_param[]
 

Read the global PSF model from descriptors MPUP_NGPSF and MPUP_PSFPAR

Parameters:
anyfile Input file
psf_param Output parameter array (1+2*ngpsf)
Returns:
Number of gaussian components in PSF model (ngpsf>0 or -1)
psf_param
psf_param[0] = geometric pupil scale

Definition at line 70 of file proc_config.c.

References MPUP_NGPSF, and MPUP_PSFPAR.

Referenced by main().

int read_PSFlocal_ng void *  anyfile  ) 
 

Read the number of component in local PSF model from descriptor MPUP_NGLOC

Parameters:
anyfile Input file
Returns:
Number of gaussian components in PSF model (ngloc or MAXINT)

Definition at line 102 of file proc_config.c.

References MPUP_NGLOC.

Referenced by main().

float read_lbdaref void *  anyfile  ) 
 

Read reference wavelength in descriptor MPUP_LBDAPUP.

Definition at line 122 of file proc_config.c.

References MPUP_LBDAPUP.

Referenced by main().

Channel read_channel void *  anyfile  ) 
 

Read channel in descriptor CHANNEL.

Definition at line 149 of file proc_config.c.

References BLUE_CHANNEL, Channel, CHANNEL, channel_names, RED_CHANNEL, and UNKNOWN_CHANNEL.

Referenced by comp_calibration_offsets(), main(), read_focus(), and read_snifs_config_from_mask().

int read_focus void *  anyfile  ) 
 

Read camera/collimator position.

If the focus position xCFOCUS (x=B or R, as read from CHANNEL descriptor) is absent, return the rank of the frame in the calling sequence

Parameters:
anyfile Input file
Returns:
Focus position

Definition at line 195 of file proc_config.c.

References Channel, channel_names, read_channel(), SPECFOC, and UNKNOWN_CHANNEL.

Referenced by main().

int read_default_snifs_config const Channel  channel,
SnifsConfig config
 

Read default SNIFS configuration.

Parameters:
channel Channel
config Configuration
Returns:
Error status
Warning:
This procedure will have to be updated according to the file specifications and headers, to include:
  • update of snifs_instrument::h, including:
    • CCD gains, RON (e.g. standard vs. quick), darks, format
    • Red MLA angle
  • update of structures in tiger_items.h (not yet):
    • Tiger_optics does not include lateral color coefficients
    • Detector does not include ReadOut Noise

Beware the definition of rotz. The dispersion orientation is "red is down, blue is up" (same as OASIS), but to keep the grism orientation rotz around 0 (and not $\pi$), we need to aff $\pi$ in optics_signature::c probably because of internal folding.

Open questions and current answers:

Bug:
In structure Tiger_optics, g_per_mm should be a DOUBLE.

Definition at line 252 of file proc_config.c.

References Grism::A, Telescope::aperture, Grism::blaze, BLUE_CHANNEL, SnifsOptics::camera, SnifsConfig::ccd, CCDB_GAIN, CCDB_NAME, CCDB_NX, CCDB_NY, CCDB_PIX, CCDB_RON, CCDR_GAIN, CCDR_NAME, CCDR_NX, CCDR_NY, CCDR_PIX, CCDR_RON, SnifsOptics::center, Telescope::central_obscuration, SnifsOptics::channel, channel_names, SnifsOptics::collimator, SnifsDetector::dark, DFLT_BLU_CFG_NAME, DFLT_RED_CFG_NAME, CameraCollimator::distor, SnifsOptics::enlarger, SnifsOptics::filter, CameraCollimator::focal, Telescope::fratio, Grism::g_per_mm, SnifsDetector::gain, Grism::grating, SnifsOptics::grism, Material::id, CameraCollimator::LateralColor, material_names, material_sellcoeffs, SnifsOptics::MLA, SnifsConfig::name, SnifsDetector::name, Material::name, SnifsDetector::nx, SnifsDetector::ny, SnifsConfig::optics, SnifsDetector::pixsize, Grism::prism, RED_CHANNEL, SnifsDetector::ron, Grism::rotz, Telescope::scale, Material::sellcoeffs, Grism::set, SNIFS_GAMMA, SNIFS_LENS_MM, SNIFSB_CAM_A1, SNIFSB_CAM_A2, SNIFSB_CAM_A3, SNIFSB_CAM_E, SNIFSB_CAM_F, SNIFSB_COLL_A1, SNIFSB_COLL_A2, SNIFSB_COLL_A3, SNIFSB_COLL_E, SNIFSB_COLL_F, SNIFSB_FILT_E, SNIFSB_FILT_H, SNIFSB_FILT_L, SNIFSB_FILT_S, SNIFSB_GRISM_ANG, SNIFSB_GRISM_BLA, SNIFSB_GRISM_D, SNIFSB_GRISM_GLA, SNIFSB_GRISM_GRA, SNIFSB_GRISM_RES, SNIFSB_LBDA_REF, SNIFSB_LENS_AN, SNIFSB_LENS_PX, SNIFSR_CAM_A1, SNIFSR_CAM_A2, SNIFSR_CAM_A3, SNIFSR_CAM_E, SNIFSR_CAM_F, SNIFSR_COLL_A1, SNIFSR_COLL_A2, SNIFSR_COLL_A3, SNIFSR_COLL_E, SNIFSR_COLL_F, SNIFSR_FILT_E, SNIFSR_FILT_H, SNIFSR_FILT_L, SNIFSR_FILT_S, SNIFSR_GRISM_ANG, SNIFSR_GRISM_BLA, SNIFSR_GRISM_D, SNIFSR_GRISM_GLA, SNIFSR_GRISM_GRA, SNIFSR_GRISM_RES, SNIFSR_LBDA_REF, SNIFSR_LENS_AN, SNIFSR_LENS_PX, SnifsConfig::telescope, Grism::tiltx, Grism::tilty, UHT_COBS, UHT_DIAM, UHT_FOCR, UHT_SCALE, and Grism::w_disp.

Referenced by main().

void optics2dval const SnifsOptics Optics,
double *  dval
 

SnifsOptics structure to double array convertor

Definition at line 433 of file proc_config.c.

References Grism::A, Grism::blaze, SnifsOptics::camera, SnifsOptics::center, SnifsOptics::collimator, CameraCollimator::distor, SnifsOptics::enlarger, SnifsOptics::filter, CameraCollimator::focal, Grism::g_per_mm, SnifsOptics::grism, CameraCollimator::LateralColor, SnifsOptics::MLA, Grism::rotz, Grism::tiltx, Grism::tilty, and Grism::w_disp.

Referenced by write_snifs_config_to_mask().

void dval2optics const double *  dval,
SnifsOptics Optics
 

int write_snifs_config_to_mask TABLE *  mask,
SnifsConfig config
 

Write configuration structures to mask.

Parameters:
mask Output mask
config Configuration
Returns:
Status

Bug:
Could there be a bug when char *confname[lg_ident+1] while RD_desc(mask,CONFIG_NAME,CHAR,lg_ident,confname)? Does RD_desc add the null character?

Definition at line 527 of file proc_config.c.

References Telescope::aperture, SnifsConfig::ccd, CCD_NAME, Telescope::central_obscuration, CHANNEL, SnifsOptics::channel, channel_names, CONFIG_NAME, SnifsDetector::dark, DFLT_BLU_CFG_NAME, DFLT_RED_CFG_NAME, Telescope::fratio, SnifsDetector::gain, Grism::grating, SnifsOptics::grism, Material::id, MSK_DCCDPAR, MSK_DOPTPAR, MSK_DTELPAR, MSK_FCCDPAR, MSK_FTELPAR, MSK_ICCDPAR, MSK_IOPTPAR, SnifsConfig::name, SnifsDetector::name, SnifsDetector::nx, SnifsDetector::ny, SnifsConfig::optics, optics2dval(), SnifsDetector::pixsize, Grism::prism, SnifsDetector::ron, Telescope::scale, Grism::set, and SnifsConfig::telescope.

Referenced by main().

int read_snifs_config_from_mask TABLE *  mask,
SnifsConfig config
 

Set configuration structure from mask.

Parameters:
mask Mask
config Configuration
Returns:
Status

Definition at line 639 of file proc_config.c.

References Telescope::aperture, SnifsConfig::ccd, CCD_NAME, Telescope::central_obscuration, SnifsOptics::channel, CONFIG_NAME, SnifsDetector::dark, dval2optics(), Telescope::fratio, SnifsDetector::gain, Grism::grating, SnifsOptics::grism, Material::id, material_names, material_sellcoeffs, MSK_DCCDPAR, MSK_DOPTPAR, MSK_DTELPAR, MSK_FCCDPAR, MSK_FTELPAR, MSK_ICCDPAR, MSK_IOPTPAR, SnifsConfig::name, Material::name, SnifsDetector::name, SnifsDetector::nx, SnifsDetector::ny, SnifsConfig::optics, SnifsDetector::pixsize, Grism::prism, read_channel(), SnifsDetector::ron, Telescope::scale, Material::sellcoeffs, Grism::set, and SnifsConfig::telescope.

Referenced by main().

void print_snifs_optics const SnifsOptics Optics  ) 
 

Print out a Tiger_optics structure elements.

Definition at line 738 of file proc_config.c.

References Grism::A, Grism::blaze, SnifsOptics::camera, SnifsOptics::channel, channel_names, SnifsOptics::collimator, CameraCollimator::distor, SnifsOptics::enlarger, SnifsOptics::filter, CameraCollimator::focal, Grism::g_per_mm, Grism::grating, SnifsOptics::grism, CameraCollimator::LateralColor, SnifsOptics::MLA, Material::name, Grism::prism, Grism::rotz, Grism::tiltx, Grism::tilty, and Grism::w_disp.

Referenced by print_snifs_config().

void print_snifs_telescope const Telescope UHT  ) 
 

Print out a Telescope structure elements.

Definition at line 791 of file proc_config.c.

References Telescope::aperture, Telescope::central_obscuration, Telescope::fratio, and Telescope::scale.

Referenced by print_snifs_config().

void print_snifs_detector const SnifsDetector CCD  ) 
 

Print out a Detector structure elements.

Definition at line 805 of file proc_config.c.

References SnifsDetector::dark, SnifsDetector::gain, SnifsDetector::name, SnifsDetector::nx, SnifsDetector::ny, SnifsDetector::pixsize, and SnifsDetector::ron.

Referenced by print_snifs_config().

void print_snifs_config const SnifsConfig config  ) 
 

Print out the full SNIFS config.

Definition at line 820 of file proc_config.c.

References SnifsConfig::ccd, SnifsConfig::name, SnifsConfig::optics, print_snifs_detector(), print_snifs_optics(), print_snifs_telescope(), and SnifsConfig::telescope.

Referenced by main().

double blaze_function const Grism grism,
int  order,
double  lambda
 

Return the blaze function of the grism.

Parameters:
grism Grism structure
order Order
lambda Wavelength [AA]
Returns:
Blaze function
In the normal configuration, the blaze function of a grism is given by

\[ B = \left(\frac{\sin^2\Theta}{\Theta}\right) \]

with

  • $\Theta = \pi\cos\gamma(n_r\sin i - \sin r) / \rho / \lambda $, $\gamma$ being the blaze angle and $\rho$ the line density of the grating
  • $i = \alpha' - \gamma$ where $\alpha' = \arcsin(n_g/n_r \sin A)$ with $n_g$ and $n_r$ the ref. index of prism glass and grating resine resp. and $A$ the grism angle
  • $r = \beta - \gamma$ where $\beta = \arcsin(n_g\sin A - m\rho\lambda)$ with $m$ the diffraction order.

Note:
See `Redefinition of the blue grating' (E.P., SNIFS/02-004) for an extensive description.

Definition at line 51 of file optics_signature.c.

References Grism::A, Grism::blaze, Grism::g_per_mm, Grism::grating, Grism::prism, Material::sellcoeffs, and sellmeier_index().

Referenced by plot_lens().

double lateral_color_ampl const CameraCollimator element,
double  lambda
 

Compute lateral color for camera or collimator.

Parameters:
element CameraCollimator structure
lambda Input wavelength [AA]
Returns:
Lateral color term

Definition at line 81 of file optics_signature.c.

References CameraCollimator::LateralColor.

Referenced by camera_forward(), and collimator_forward().

double collimator_forward const CameraCollimator collimator,
double  gamma,
double  lambda,
double  r
 

Light propagation through the collimator, forward.

Parameters:
collimator CameraCollimator structure
gamma Spectrograph magnification (fcam/fcoll)
lambda Input wavelength
r Input radius [units of fcoll]
Returns:
tan(output angle)
The collimator equation is

\[ \tan\theta = \frac{r}{f_{coll}} (1+e_{coll}\frac{r}{f_{coll}}^2+\frac{a_{coll}}{\gamma}) \]

Definition at line 111 of file optics_signature.c.

References CameraCollimator::distor, CameraCollimator::focal, and lateral_color_ampl().

Referenced by snifs_optics_forward(), and snifs_optics_test_forward().

double camera_forward const CameraCollimator camera,
double  lambda,
double  tantheta
 

Light propagation through the camera, forward.

Parameters:
camera CameraCollimator structure
lambda Input wavelength [AA]
tantheta tan(input angle)
Returns:
Output radius [units of fcam]
The camera equation is

\[ \frac{r}{f_{cam}} = \tan\theta(1+e_{cam}\tan^2\theta+a_{cam}) \]

Definition at line 139 of file optics_signature.c.

References CameraCollimator::distor, CameraCollimator::focal, and lateral_color_ampl().

Referenced by snifs_optics_forward(), and snifs_optics_test_forward().

double invert_camcoll double  y,
double  e,
double  b
 

Inversion of $y=x(ex^2+b)$.

Inversion of $y=x(ex^2+b)$ using analytical solutions from GSL

gsl_poly_solve_cubic solves $x^3 + a x^2 + b x + c = 0$. Our eq. can be written $x^3 + b/e x - y/e = 0$

Definition at line 161 of file optics_signature.c.

void rotation_2D double *  x,
double *  y,
double  theta
 

2D-rotation

Parameters:
x 
y Input/output coordinates
theta Rotation angle [rad]

Definition at line 260 of file optics_signature.c.

void refraction double *  x,
double *  y,
double *  z,
double  n1,
double  n2
 

Refraction law from 1 to 2.

Parameters:
x 
y 
z Input/output vector
n1 Indice of first material
n2 Indice of second material

Definition at line 310 of file optics_signature.c.

Referenced by grism_backward(), grism_forward(), and snifs_optics_test_forward().

void grating_forward double *  x,
double *  y,
double *  z,
double  lambda,
double  n,
double  g_per_mm,
int  order
 

Light propagation through a grating, forward.

The grooves of the (transmission) grating are aligned along x. The propagation is done from material (n) to air (1).

Parameters:
x 
y 
z Input/output vector
lambda Input wavelength [AA]
n Refractive index
g_per_mm Nb of grooves [1/mm]
order Order of dispersion (0,1,2,...)

Definition at line 334 of file optics_signature.c.

Referenced by grism_forward(), and snifs_optics_test_forward().

void grating_backward double *  x,
double *  y,
double *  z,
double  lambda,
double  n,
double  g_per_mm,
int  order
 

Light propagation through a grating, backward.

The grooves of the (transmission) grating are aligned along x. The back-propagation is done from air (1) to material (n).

Parameters:
x 
y 
z Input/output vector
lambda Input wavelength [AA]
n Refractive index
g_per_mm Nb of grooves/mm
order Order of dispersion (0,1,2,...)

Definition at line 358 of file optics_signature.c.

Referenced by grism_backward().

double sellmeier_index double  lambda,
const double  sellcoeffs[]
 

Compute refractive index from Sellmeier coefficients.

Sellmeier expansion for refractive index:

\[ n(\lambda)^2 = 1+\sum_{i=1}^3\frac{B_i\lambda^2}{\lambda^2-C_i} \]

with $\lambda$ in microns.

Parameters:
lambda Input wavelength [AA]
sellcoeffs Sellmeier coeffs (B1,B2,B3,C1,C2,C3) as defined in snifs_materials::h
Returns:
Refractive index at input wavelength

Definition at line 388 of file optics_signature.c.

Referenced by blaze_function(), grism_backward(), grism_forward(), and snifs_optics_test_forward().

void grism_forward const Grism grism,
double  lambda,
double *  x,
double *  y,
double *  z,
int  order
 

Light propagation through a grism, forward.

Parameters:
grism Grism structure
lambda Input wavelength [AA]
x 
y 
z Input/output vector
order Order of dispersion

Definition at line 413 of file optics_signature.c.

References Grism::A, Grism::g_per_mm, grating_forward(), Grism::prism, refraction(), Grism::rotz, Material::sellcoeffs, sellmeier_index(), Grism::tiltx, Grism::tilty, x_rotation, y_rotation, and z_rotation.

Referenced by snifs_optics_forward(), and snifs_optics_test_forward().

void grism_backward const Grism grism,
double  lambda,
double *  x,
double *  y,
double *  z,
int  order
 

Light propagation through a grism, backward.

Parameters:
grism Grism structure
lambda Input wavelength [AA]
x 
y 
z Input/output vector
order Order of dispersion

Definition at line 454 of file optics_signature.c.

References Grism::A, Grism::g_per_mm, grating_backward(), Grism::prism, refraction(), Grism::rotz, Material::sellcoeffs, sellmeier_index(), Grism::tiltx, Grism::tilty, x_rotation, y_rotation, and z_rotation.

Referenced by snifs_optics_backward(), and snifs_optics_test_forward().

void snifs_optics_forward const SnifsOptics optics,
double  xmla,
double  ymla,
double *  xccd,
double *  yccd,
double  lambda,
int  order
 

Light propagation through the Snifs instrument, forward.

Parameters:
optics Optical structure
xmla 
ymla MLA coordinates [mm]
xccd 
yccd Image coordinates [mm]
lambda Wavelength [AA]
order Order of dispersion
Warning:
The collimator, the grism and the camera are supposed to be perfectly aligned

Bug:
In previous optics_signature functions, the computation of the direction vector is probably wrong by the sign of the x and y components. However, since the tilts of the grism are adjusted, there should not be any incidence.

Definition at line 504 of file optics_signature.c.

References SnifsOptics::camera, camera_forward(), SnifsOptics::collimator, collimator_forward(), CameraCollimator::focal, SnifsOptics::grism, and grism_forward().

Referenced by main(), and snifs_optics_MLA2CCD().

void snifs_optics_backward const SnifsOptics optics,
double  xccd,
double  yccd,
double *  xmla,
double *  ymla,
double  lambda,
int  order
 

Light propagation through the Snifs instrument, backward.

Parameters:
optics Optical structure
xccd 
yccd Image coordinates [mm]
xmla 
ymla MLA coordinates [mm]
lambda Wavelength [AA]
order Order of dispersion
Warning:
The collimator, the grism and the camera are supposed to be perfectly aligned

I'm not sure about the (x,y,z) definition: should it be backward-ed too? Probably not, as whatever_backward just invert the whatever equation, but the light always propagate in the same direction.

Definition at line 571 of file optics_signature.c.

References SnifsOptics::camera, camera_backward, SnifsOptics::collimator, collimator_backward, CameraCollimator::focal, SnifsOptics::grism, and grism_backward().

Referenced by main(), and snifs_optics_CCD2MLA().

void snifs_optics_test_forward const SnifsOptics optics,
double  xmla,
double  ymla,
double *  xccd,
double *  yccd,
double  lambda,
int  order
 

Testing version of snifs_optics_forward.

Definition at line 623 of file optics_signature.c.

References Grism::A, SnifsOptics::camera, camera_backward, camera_forward(), SnifsOptics::collimator, collimator_backward, collimator_forward(), CameraCollimator::focal, Grism::g_per_mm, grating_forward(), SnifsOptics::grism, grism_backward(), grism_forward(), Grism::prism, refraction(), Grism::rotz, Material::sellcoeffs, sellmeier_index(), Grism::tiltx, Grism::tilty, x_rotation, y_rotation, and z_rotation.

Referenced by main().

void snifs_optics_CCD2MLA const SnifsOptics optics,
double  xccd,
double  yccd,
double *  xmla,
double *  ymla,
double  pixsize,
double  lbdaref
 

Wrapper to snifs_optics_backward, [CCD/px] to [MLA/mm].

Parameters:
optics Optical structure
xccd 
yccd Image coordinates [px]
xmla 
ymla MLA coordinates [mm]
pixsize Pixel size [mm]
lbdaref Ref. wavelength [AA]

Definition at line 771 of file optics_signature.c.

References SnifsOptics::center, and snifs_optics_backward().

Referenced by main(), nllsqfit_mask(), plot_lens(), plot_lens_tab(), and pup_get_maxdata().

void snifs_optics_MLA2CCD const SnifsOptics optics,
double  xmla,
double  ymla,
double *  xccd,
double *  yccd,
double  pixsize,
double  lbda,
int  order
 

Wrapper to snifs_optics_forward, [MLA/mm] to [CCD/px].

Parameters:
optics Optical structure
xmla 
ymla MLA coordinates [mm]
xccd 
yccd Image coordinates [px]
pixsize Pixel size [mm]
lbda Wavelength [AA]
order Order

Definition at line 800 of file optics_signature.c.

References SnifsOptics::center, and snifs_optics_forward().

Referenced by main(), nllsqfit_mask(), plot_lens(), plot_lens_tab(), and pup_get_maxdata().

void plot_set_limits const float  x[],
const float  y[],
int  n,
PlotLimits limits
 

Set limits of the plot.

If the PlotLimits structure has never been set (ie = 0,0,0,0), it is set according to the min and max of the input arrays. Otherwise, it is updated to include these min and max.

Parameters:
x 
y Input arrays
n Size of input arrays
limits PlotLimits structure.
Note:
See DISLIN routine setscl.

Definition at line 52 of file proc_plot.c.

References PlotLimits::xmax, PlotLimits::xmin, PlotLimits::ymax, and PlotLimits::ymin.

Referenced by main(), model_distMLA(), and study_triangulation().

void plot_increase_limits PlotLimits limits  ) 
 

Increase plot limits by 10% (or to valid range if min=max).

Definition at line 81 of file proc_plot.c.

References PlotLimits::xmax, PlotLimits::xmin, PlotLimits::ymax, and PlotLimits::ymin.

Referenced by main(), model_distMLA(), and study_triangulation().

int inside_plot_limits float  x,
float  y,
PlotLimits  limits
 

Test if point is inside plot limits.

Parameters:
x 
y Input coordinates
limits Plot limits
Returns:
TRUE or FALSE

Definition at line 107 of file proc_plot.c.

References PlotLimits::xmax, PlotLimits::xmin, PlotLimits::ymax, and PlotLimits::ymin.

Referenced by plot_lens(), and plot_max().

int plot_compticks int  nticks,
float  min,
float  max,
float *  first,
float *  step
 

Compute reasonable first and step values to get approx. 6 ticks over range min-max

Parameters:
nticks Requested (approximate) nb of ticks in input range
min 
max Input range
first First value
step Step value
Returns:
Actual number of ticks

Definition at line 127 of file proc_plot.c.

Referenced by main(), and plot_axes().

void plot_start Plot plot,
float  scale
 

Initialize and set various default quantities for a DISLIN 2D-plot.

Parameters:
plot Plot structure
scale Plot scaling.
  • if scale=0, default scale (2/3 of the whole window) is used
  • if scale>0, the scale is used
  • if scale<0, the scale is used such that the plot is isoscale in x and y.
Note:
This routine has to be called from DISLIN level 0 (i.e. before any call to to disini) and will set it to 1 (e.g. suitable for plot_axes).

Definition at line 165 of file proc_plot.c.

References Plot::devname, Plot::Limits, PlotLimits::xmax, PlotLimits::xmin, PlotLimits::ymax, and PlotLimits::ymin.

Referenced by main(), model_distMLA(), and study_triangulation().

void plot_axes const Plot plot,
char *  xlabel,
char *  ylabel
 

Plot the axes in a DISLIN 2D-plot.

Parameters:
plot Plot structure
xlabel X-axis label
ylabel Y-axis label
Note:
This routine has to be called from DISLIN level 1 (i.e. after a call to plot_start) and will set it to 3 (e.g. suitable for title).

Definition at line 225 of file proc_plot.c.

References Plot::Limits, Plot::maxcut, Plot::mincut, NTICKS, plot_compticks(), PlotLimits::xmax, PlotLimits::xmin, PlotLimits::ymax, and PlotLimits::ymin.

Referenced by main(), model_distMLA(), and study_triangulation().

void plot_title char *  string  ) 
 

Plot the title strings.

Parameters:
string Title string
The title string (of length 4*lg_ident+1) contains the (up to 4) title chunks separated with newlines.

Definition at line 263 of file proc_plot.c.

Referenced by main(), model_distMLA(), and study_triangulation().

void plot_set_bkgnd IMAGE2D *  bkgndima,
Plot plot,
float  mincut,
float  maxcut,
int *  nx,
int *  ny,
float ***  zmat
 

Set a background plot.

Parameters:
bkgndima Background image
plot Plot structure
mincut 
maxcut LUT cuts (in percentile of histogram)
nx 
ny 
zmat Resulting 2D array (nx$\times$ny)

Todo:
Set the limits so that the border spaxels are displayed completely.

Definition at line 298 of file proc_plot.c.

References histo_threshold(), Plot::Limits, Plot::maxcut, MAXNBIN, Plot::mincut, subframe_histo(), PlotLimits::xmax, PlotLimits::xmin, PlotLimits::ymax, and PlotLimits::ymin.

Referenced by main().

void plot_max const Maxima_Set *  maxset,
const Plot plot,
const double  shift[]
 

Plot max data.

Parameters:
maxset Max structure
plot Plot definition
shift Offset (NULL if none)

Definition at line 382 of file proc_plot.c.

References PlotSymbol::color, Plot::Graph, inside_plot_limits(), Plot::Limits, NCOORD, PlotSymbol::shape, PlotSymbol::size, and Plot::Symbol.

Referenced by main().

void plot_lens const SnifsOptics optics,
int  nopup,
float  xppup,
float  yppup,
int  nlbda,
const float  lbda[],
int  order,
const Plot plot,
float  lbdaref,
float  pixsize,
int  dxnc,
double *  dxcoeff,
const double  shift[],
double *  xmla,
double *  ymla
 

Plot a lens spectrum onto the CCD.

Parameters:
optics Optical structure
nopup Mpup number (needed just for labelling)
xppup 
yppup Mpup coordinates [px]
nlbda 
lbda Wavelength array to be plotted
order Order of dispersion
plot Plot structure
lbdaref Ref. wavelength [AA]
pixsize Pixel size [mm]
dxnc Nb of coefficients in local adjustment
dxcoeff Coefficients of the local adjustment (1st-order)
shift Offset (NULL if none)
xmla 
ymla MLA coordinates [mm] Set to MAXDOUBLE if unknown (will then be computed)

Definition at line 485 of file proc_plot.c.

References blaze_function(), PlotSymbol::color, SnifsOptics::filter, Plot::Graph, SnifsOptics::grism, inside_plot_limits(), Plot::Limits, NCOORD, PlotSymbol::shape, PlotSymbol::size, snifs_optics_CCD2MLA(), snifs_optics_MLA2CCD(), and Plot::Symbol.

Referenced by main().

void plot_lens_tab const SnifsOptics optics,
float  xppup,
float  yppup,
int  nlbda,
const float  lbda[],
int  order,
TABLE *  table,
const int  colid[],
int  row,
float  lbdaref,
float  pixsize,
int  dxnc,
double *  dxcoeff,
const double  shift[],
double *  xmla,
double *  ymla
 

Plot a lens spectrum onto the CCD (table storage).

Parameters:
optics Optical structure
xppup 
yppup Mpup coordinates [px]
nlbda 
lbda Wavelength array to be plotted
order Order of dispersion
table Output table (previously created)
colid Output column IDs (previously created) xlbda_1, ylbda_1, ... , xlbda_nlbda, ylbda_nlbda
row Row in output table
lbdaref Ref. wavelength [AA]
pixsize Pixel size [mm]
dxnc Nb of coefficients in local adjustment
dxcoeff Coefficients of the local adjustment (1st-order)
shift Offset (NULL if none)
xmla 
ymla MLA coordinates [mm] Set to MAXDOUBLE if unknown (will then be computed)

Definition at line 619 of file proc_plot.c.

References SnifsOptics::filter, snifs_optics_CCD2MLA(), and snifs_optics_MLA2CCD().

Referenced by main().

void plot_array_err const PlotSymbol symbol,
float  x[],
float  y[],
int  n,
float  dx[],
float  dy[]
 

DISLIN curve with errors.

Parameters:
symbol PlotSymbol structure
x data-x
y data-y
n data size
dx sym. error in x (or NULL if none)
dy sym. error in y (or NULL if none)

Definition at line 672 of file proc_plot.c.

References PlotSymbol::color, PlotSymbol::shape, and PlotSymbol::size.

Referenced by main().

void plot_initialize Plot plot,
int  GRAPH,
const char *  devname,
const PlotLimits limits,
const PlotSymbol symbol,
float  mincut,
float  maxcut
 

Initialize a Plot structure.

Parameters:
plot Plot structure
GRAPH Graph flag (=!ASCII)
devname Device name
limits PlotLimits structure (or NULL)
symbol PlotSymbol structure (or NULL)
mincut 
maxcut z-axis limits

Definition at line 716 of file proc_plot.c.

References PlotSymbol::color, Plot::devname, Plot::Graph, Plot::Limits, Plot::maxcut, Plot::mincut, PlotSymbol::shape, PlotSymbol::size, Plot::Symbol, PlotLimits::xmax, PlotLimits::xmin, PlotLimits::ymax, and PlotLimits::ymin.

Referenced by main(), model_distMLA(), and study_triangulation().

void norm_mask_param Channel  channel,
double  par[16]
 

Mask parameters normalization.

Definition at line 29 of file proc_mask.c.

References BLUE_CHANNEL, CCDB_NX, CCDB_NY, CCDR_NX, CCDR_NY, NB_CHANNELS, RED_CHANNEL, SNIFSB_CAM_A1, SNIFSB_CAM_A2, SNIFSB_CAM_A3, SNIFSB_CAM_E, SNIFSB_CAM_F, SNIFSB_COLL_A1, SNIFSB_COLL_A2, SNIFSB_COLL_A3, SNIFSB_COLL_E, SNIFSB_COLL_F, SNIFSB_GRISM_ANG, SNIFSR_CAM_A1, SNIFSR_CAM_A2, SNIFSR_CAM_A3, SNIFSR_CAM_E, SNIFSR_CAM_F, SNIFSR_COLL_A1, SNIFSR_COLL_A2, SNIFSR_COLL_A3, SNIFSR_COLL_E, SNIFSR_COLL_F, SNIFSR_GRISM_ANG, and UNKNOWN_CHANNEL.

Referenced by main().

void unnorm_mask_param Channel  channel,
double  par[16]
 

Mask parameters unnormalization.

Definition at line 90 of file proc_mask.c.

References BLUE_CHANNEL, CCDB_NX, CCDB_NY, CCDR_NX, CCDR_NY, NB_CHANNELS, RED_CHANNEL, SNIFSB_CAM_A1, SNIFSB_CAM_A2, SNIFSB_CAM_A3, SNIFSB_CAM_E, SNIFSB_CAM_F, SNIFSB_COLL_A1, SNIFSB_COLL_A2, SNIFSB_COLL_A3, SNIFSB_COLL_E, SNIFSB_COLL_F, SNIFSB_GRISM_ANG, SNIFSR_CAM_A1, SNIFSR_CAM_A2, SNIFSR_CAM_A3, SNIFSR_CAM_E, SNIFSR_CAM_F, SNIFSR_COLL_A1, SNIFSR_COLL_A2, SNIFSR_COLL_A3, SNIFSR_COLL_E, SNIFSR_COLL_F, SNIFSR_GRISM_ANG, and UNKNOWN_CHANNEL.

Referenced by main(), and nllsqfit_mask().

void set_mask_param_limits double  par[16],
double  parlb[16],
double  parub[16]
 

Set limits to mask parameters.

Definition at line 143 of file proc_mask.c.

References LIMITS_RANGE.

Referenced by main().

void optics2mask_param SnifsOptics optics,
double  par[16]
 

Copy mask parameters from SnifsOptics.

Definition at line 181 of file proc_mask.c.

References Grism::A, SnifsOptics::camera, SnifsOptics::center, SnifsOptics::collimator, CameraCollimator::distor, CameraCollimator::focal, SnifsOptics::grism, CameraCollimator::LateralColor, Grism::rotz, Grism::tiltx, and Grism::tilty.

Referenced by main().

void mask_param2optics double  par[16],
SnifsOptics optics
 

Copy mask parameters to SnifsOptics.

Definition at line 214 of file proc_mask.c.

References Grism::A, SnifsOptics::camera, SnifsOptics::center, SnifsOptics::collimator, CameraCollimator::distor, CameraCollimator::focal, SnifsOptics::grism, CameraCollimator::LateralColor, Grism::rotz, Grism::tiltx, and Grism::tilty.

Referenced by main(), and nllsqfit_mask().

void print_mask_param double  par[16]  ) 
 

Print-out (non-normalized) mask parameters.

Definition at line 247 of file proc_mask.c.

Referenced by nllsqfit_mask().

void print_mask_param_in double  par[16],
double  parlb[16],
double  parub[16]
 

Print-out (non-norm.) mask parameters (including fit boundaries).

Definition at line 283 of file proc_mask.c.

References pmpin_line().

Referenced by main().

void print_mask_param_out double  par[16],
double  epar[16]
 

Print-out (non-norm.) mask parameters (including fit errors).

Definition at line 331 of file proc_mask.c.

References pmpout_line().

Referenced by main().

int open_mask char *  maskname,
TABLE *  mask,
char *  mode
 

Open a mask table.

Parameters:
maskname Name of the mask
mask Mask structure
mode I/O mode (same as open_table)
Returns:
Error status

Definition at line 367 of file proc_mask.c.

Referenced by main().

int read_local_model TABLE *  mask,
int  flag,
double ***  coeff
 

Read local coeffs from mask (position adjusment or sigma).

Parameters:
mask Mask table
flag 1: dx (position adjustment), 2: sigma (X-disp.)
coeff Coefficients of the local model
Returns:
Nb of coeff. in the local model

Definition at line 401 of file proc_mask.c.

References MSK_DXNC, and MSK_SIGNC.

Referenced by main().

int open_image IMAGE2D *  frame,
char *  name,
char *  mode,
int  class,
char *  type
 

Open a frame and check FCLASS.

Parameters:
frame Frame structure
name Name of the frame
mode I/O mode (same as open_frame)
class Required FCLASS
  • >0 for a known fclass
  • 0 if unknown (no check)
  • <0 to disable check explicitely
type The msg will be ("Opening %s frame",type)
Returns:
Error status

Definition at line 37 of file proc_misc.c.

Referenced by comp_calibration_offsets(), main(), and open_image_ext().

int open_image_ext IMAGE2D *  signal,
IMAGE2D *  variance,
char *  name,
char *  mode,
int  class,
char *  type
 

Open a frame (possibly with extensions [signal] and [variance]) and check FCLASS

Parameters:
signal Frame structure with signal
variance Frame structure with variance (or NULL if not needed)
name Name of the frame
mode I/O mode (same as open_frame)
class Required FCLASS
  • >0 for a known fclass
  • 0 if unknown (no check)
  • <0 to disable check explicitely
type The msg will be ("Opening %s frame",type)
Returns:
Error status

Definition at line 89 of file proc_misc.c.

References open_image().

Referenced by main().

float read_mean_RoN void *  anyfile,
Channel  channel
 

Compute mean RoN from RDNOISE descriptors.

Definition at line 127 of file proc_misc.c.

References BLUE_CHANNEL, CCDB_RON, CCDR_RON, channel_names, and RDNOISE2.

Referenced by main().

float read_airmass void *  anyfile  ) 
 

Read AIRMASS descriptor (defaulted to 1) from open file.

Definition at line 153 of file proc_misc.c.

References AIRMASS.

Referenced by comp_calibration_offsets(), and main().

float read_juliandate void *  anyfile  ) 
 

Read MJDATE descriptor (defaulted to 0) from open file.

Definition at line 178 of file proc_misc.c.

References MJDATE.

Referenced by comp_calibration_offsets(), and main().

float check_airmass char *  arcname,
float  cal_airmass,
char *  objname,
float  obj_airmass
 

Check airmass consistency between two exposures.

Definition at line 203 of file proc_misc.c.

Referenced by main().

float check_jdate char *  arcname,
float  cal_jdate,
char *  objname,
float  obj_jdate
 

Check julian date consistency between two exposures.

Definition at line 226 of file proc_misc.c.

Referenced by main().

int extract_arc const IMAGE2D *  frame,
int  npix,
double **  tab
 

Extract central part of arc exposure.

Parameters:
frame Input arc frame
npix Size of the central part
tab Output central part (npix x npix allocated 2D-array)
Returns:
Error status

Definition at line 38 of file proc_corr.c.

References DBG_PREFIX, and dump_2Darray().

Referenced by comp_calibration_offsets(), and main().

void negate_2D double **  I,
int  nx,
int  ny
 

Negate a nx*ny 2D array.

Note:
Replace the NAG routine C06GCF

Definition at line 88 of file proc_corr.c.

Referenced by correlation2D(), and iFFT2D_real().

void complex_product_2D double **  AR,
double **  AI,
double **  BR,
double **  BI,
int  nx,
int  ny,
double **  CR,
double **  CI
 

Compute the complex product C = A * B for nx*ny 2D arrays.

Parameters:
AR Real part of A
AI Imaginary part of A
BR Real part of B
BI Imaginary part of B
nx 
ny Size of the input arrays
CR Real part of C (allocated nx*ny 2D array)
CI Imaginary part of C (allocated nx*ny 2D array)

Definition at line 112 of file proc_corr.c.

Referenced by correlation2D().

int FFT2D_real double **  in,
int  nx,
int  ny,
double **  outR,
double **  outI
 

FFT of a nx*ny 2D real dataset.

Parameters:
in Input real dataset
nx 
ny Size of the input dataset
outR Real part of FFT (allocated nx*ny 2D array)
outI Imaginary part of FFT (allocated nx*ny 2D array)
Returns:
Error status (from C06FUF)
Warning:
Uses NAG routine C06FUF.

Definition at line 141 of file proc_corr.c.

Referenced by correlation2D().

int iFFT2D_real double **  inR,
double **  inI,
int  nx,
int  ny,
double **  outR
 

Inverse FFT (real part) of a nx*ny 2D dataset.

Parameters:
inR 
inI Input complex dataset (inI is returned negated)
nx 
ny Size of the input dataset
outR Real part of iFFT (allocated nx*ny 2D array)
Returns:
Error status (from C06FUF)
Warning:
Uses NAG routine C06FUF.

Definition at line 193 of file proc_corr.c.

References negate_2D().

Referenced by correlation2D().

int correlation2D double **  A,
double **  B,
int  nx,
int  ny,
double **  X
 

Compute correlation of nx*ny 2D arrays A and B.

Parameters:
A Input array (reference)
B Input array
nx 
ny Size of the input arrays
X Correlation (allocated nx*ny 2D array)
Returns:
Error status

Definition at line 251 of file proc_corr.c.

References complex_product_2D(), FFT2D_real(), iFFT2D_real(), and negate_2D().

Referenced by Fit_Xpeak().

long nllsqfit_2Dgauss long *  mode,
long *  npts,
long *  npar,
long *  ldfj,
double *  par,
double *  f,
double *  fjac,
long *  nstate,
long *  iuser,
double *  user
 

Single 2D-gaussian fitting procedure (e.g. for the cross-correlation peak). Parameters to be adjusted: position offset (x,y), intensity, dispersion (Sx,Sy) and background level.

To be used with nllsqfit_bnd. Derivatives have been checked.

Note:
Previously known as nllsqfit_Xpeak.

This routine uses a 2D-array oriented array ordering (j is the fastes index). A very similar routine nllsqfit_2DgaussB included in center_gauss::c has an image-oriented array ordering (i is then the fastest index).

Warning:
Not very generic routine. It needs a "dirty trick" on input parameters to pass 2D-sizes to . See Fit_Xpeak for example.

Definition at line 302 of file proc_corr.c.

Referenced by Fit_Xpeak().

int Fit_Xpeak double **  ref_tab,
double **  cur_tab,
int  nx,
int  ny,
int  winx,
int  winy,
double  par[6],
double  epar[6]
 

Compute correlation between 2 arc rasters and fit a 2D-gaussian to the central peak (6 parameters: position offset (x,y), intensity, dispersion (Sx,Sy) and background level), in order to measure relative offsets or focus-quality.

Parameters:
ref_tab Reference 2D-array
cur_tab Input 2D-array (could be a copy of ref. for auto-correlation)
nx 
ny Input arrays size
winx 
winy Fitting window half-width (be sure to fit in input arrays)
par Adjusted parameters
epar Error on adjusted parameters
Returns:
Error status

Definition at line 362 of file proc_corr.c.

References correlation2D(), DBG_PREFIX, dump_2Darray(), nllsqfit_2Dgauss(), and TOO_CLOSE.

Referenced by comp_calibration_offsets(), and main().

double Mpup_PSF int  no,
float  x
 

Integral over the pixel of the X-disp. model profile.

Parameters:
no Lens number
x Position [px]
Returns:
Integral of model over pixel

Definition at line 44 of file proc_extract.c.

References glIcs, glnggeo, glngpsf, glScs, and glXgeo.

Referenced by funct1(), and main().

int good_neighbor float *  ylo,
float *  yup,
int *  neighbors,
float  y
 

Find the good neightbor among 2 candidates.

Parameters:
ylo 
yup Total spectral extensions
neighbors Candidates index array
y Current position
Returns:
Good neighbor index

Definition at line 78 of file proc_extract.c.

Referenced by main().

void comp_mean_disp double  parpeak[6],
double  eparpeak[6],
double *  msig,
double *  emsig
 

Convert correlation-peak quantities to intrinsic quantities.

Parameters:
parpeak 
eparpeak X-corr. peak fit parameters and errors (x-, y-offset, intensity, x-, y-sigma, background)
msig 
emsig Mean dispersion and error

Definition at line 35 of file proc_shift.c.

Referenced by comp_calibration_offsets(), and main().

void print_parpeak double  parpeak[6],
double  eparpeak[6],
double  msig,
double  emsig
 

Print-out correlation-peak quantities.

Definition at line 52 of file proc_shift.c.

Referenced by comp_calibration_offsets(), and main().

int comp_calibration_offsets char *  refname,
float *  ref_airmass,
char *  arcname,
float *  cal_airmass,
float *  cal_jdate,
char *  arc2name,
float *  cal2_airmass,
float *  cal2_jdate,
double  offset[2]
 

Compute the offset between reference and calibration frames.

Parameters:
refname Name of the input reference calibration frame
ref_airmass Airmass of the reference frame
arcname Name of the calibration frame
cal_airmass 
cal_jdate Airmass and julian date of the calibration frame
arc2name Name of the 2nd calibration frame (if any, or NULL)
cal2_airmass 
cal2_jdate Airmass and julian date of the 2nd calibration frame
offset Computed calibration offset
Returns:
Error status
Warning:
Logically, but conter-intuitively, it computes the offset to be subtracted to the reference frame (from which the optical model is derived) to get back to the calibration frame position (to which the optical model has to be applied)!

Definition at line 87 of file proc_shift.c.

References ARCWIDTH, Channel, channel_names, comp_mean_disp(), extract_arc(), Fit_Xpeak(), open_image(), print_parpeak(), read_airmass(), read_channel(), and read_juliandate().

Referenced by main().


Generated on Tue Nov 23 18:04:21 2004 for Snifs by doxygen 1.3.3