----- Documentation for Fit\average_parameters.pro ----- NAME: AVERAGE_PARAMETERS AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: average parameter vector estimates using weighted mean, calculate errors from direct bootstrap (if enough parameter vectors to average) CATEGORY: fitting INPUTS: need text input file (in OBS_PATH/INP/ directory) with: - number of model parameter file(s) to average - input model parameter file name(s) - observation parameter file name(s) associated REQUIREMENTS: data read in input model parameter file(s) (in OBS_PATH/ subdirectory, .out extension) must be in ASCII format and contain (in this order) : - model flag, flux flag, synthetic exitance+radiance file names, data format flag, starting parameters, free parameter flags, goodness-of-fit parameter, input parameters, inferior errors, superior errors, confidence level data read in input observation parameter file(s) (in OBS_PATH/ subdirectory, .obs extension, one row per observation) are of complex type : - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]), (START_FWHM["] , END_FWHM), (START_TAU0[s] , START_TAU0[s]), (MJD@Oh , 0) OUPUTS: data written in output file (in OBS_PATH/OUT/ directory) must be in ASCII format and contain (in this order) : - model flag, flux flag, synthetic exitance+radiance file name, data format flag, starting parameters, free parameter flags, goodness-of-fit parameter, output parameters, inferior errors, superior errors, nber of degrees of freedom LOCAL PROCEDURE CALLED: RESET_PLOT LOCAL FUNCTION USED: EXTRACT_PROHEADER GET_OUTLIER_FENCES TRI_STDEV WAVG WSTDEV WSTERR LOCAL SYSTEM VARIABLE USED: EPSILON FORMAT_OUT MAX_REL_ERR NB_BOOT_LOOPS NB_DATA_BOOT NB_MAX_PARAM NB_OB_MAX NB_TARG_MAX OBS_PATH PLOT_DEV SPIDAST_PATH REVISION HISTORY: Written by pcr 2010/10/22 last modification by pcr 2010/12/12 ----- Documentation for Fit\boot_fit.pro ----- NAME: BOOT_FIT AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: Proceed nonparametric residual bootstrap iterations (random shoot of centered residuals with replacement) of gradient-expansion fits calculate free-parameter confidence intervals. CATEGORY: fitting. CALLING SEQUENCE: DPAR = BOOT_FIT(XX,BSL,BWARR,MEAS,WGHT,PAR,PAR0,IDXF,NMODEL,VISI, TEFF,REF,CLEVEL,NBOOT,PAROUT,DCHISQR,IDXC,PAR_ARR) INPUTS: XX = Row vector of synthetic wavelengths, or structure with synthetic wavelength vector XX.WVL and relative impact parameter vect. XX.RIP BSL = Row vector of baselengths. BWARR = 2-D ARRAY WITH # OF BASELENGTHS AND # OF WAVELENGTHS FOR EACH PART (DEFINED BY P2VM SETTING). BWARR(I,0) = # OF BASELENGTHS FOR PART I BWARR(I,1) = # OF WAVELENGTHS FOR PART I MEAS = Row vector of measurements, length(MEAS)=length(XX or XX.WVL) *length(BSL). WGHT = Row vector of experimental weight, same length as MEAS. PAR = Row vector of parameter values. PAR0 = Row vector of starting parameter values. IDXF = Row vector of free parameter indexes, length lower or equal to PAR. NMODEL = Nber of model used for fit. VISI = Visibility flag ( 1:vis / 0:no vis ), for bispectrum calculation VISI=table. TEFF = Effective temperature used with MARCS flux or intensity tabulated data. REF = Row vector of reference synthetic fluxes, same length as XX, or 2-dim array of ref. synth. intensities, dim=(length(XX.WVL), length(XX.RIP)). CLEVEL = Desired confidence level. NBOOT = number of bootstrap loops. OUTPUTS: CLEVEL = Final confidence level. PAROUT = 2-dim array of final parameters, dim=(length(PAR),!NB_BOOT_LOOPS). DCHISQR = Row vector of final chi-square differences sorted by ascending order, length=!NB_BOOT_LOOPS. IDXC = Row vector of success indexes (parameters in confidence region), length lower or equal to !NB_BOOT_LOOPS. PAR_ARR = 2-dim array of confid lev/nb of chi2 val in 68.3%/95.4%/99.7%/99.99%-CI, and param(s) at lower/upper fences of each CI, dim=(length(PAR)+1,3) FUNCTION RESULT: DPAR = Row array of parameter inferior/superior error estimate(s), dim=(length(PAR),2). COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. REQUIREMENTS: The function to be fit must be defined and called in MODEL_DATA_FUNCT_PROJ. For an example see FUNCT in the PV-WAVE User's Library. Call to MODEL_DATA_FUNCT_PROJ is: MODEL_DATA_FUNCT_PROJ,XX,BSL,BWARR,PAR,IDXF,NMODEL,VISI,TEFF,REF, DEPTH_INTENS_DATA,DATA_FIT where: XX = row vector or structure of independant variables (wavelength or wavelength + relative inpact parameter), input. BSL = row vector of baselength, input. BWARR = 2-D array, input PAR = row vector of parameters, input. IDXF = row vector unforzen-parameter indexes, input. NMODEL = number of model used for calculation of function, input. VISI = visibility flag or bispectrum index table, input. TEFF = temperature, input. REF = row vector of synthetic fluxes or 2-dim array of synthetic intensities, input. DEPTH_INTENS_DATA = 2-dim complex array with optical depth and intensity or flag (=1/0) for opt. depth based models, output. DATA_FIT = row vector of projected function values at each projected frequency (or proj. wavelength if base=0), output. RESTRICTIONS: NONE. PROCEDURE: SEE CODE. LOCAL PROCEDURE CALLED: LOCA_SCALE_CHI2 LOCA_SCALE_NORM MODEL_DATA_FUNCT_PROJ LOCAL FUNCTION USED: GET_OUTLIER_FENCES LM_FIT LOCAL SYSTEM VARIABLE USED: EPSILON MAX_REL_ERR NB_BASE_STEP NB_BOOT_MIN NB_DATA_BOOT NB_DATA_MAX NB_MAX_BOOTS NB_DATA_MAX NB_RES_STEP REVISION HISTORY: Written by pcr 2007/12/17 last modification by pcr 2011/01/04 ----- Documentation for Fit\create_fitting_batch.pro ----- NAME: CREATE_FITTING_BATCH AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: create program batch for model fitting processing and make input files used by programs : - limb-darkened spectral radiance conversion - model fitting - model parameter averaging CATEGORY: fitting INPUTS: needs text input file (in OBS_PATH/INP/ directory) with : - target name - data format ('vis', 'spec', 'coh', 'bisp', 'trip' or 'clos') - model number used for fitting - starting parameters (for LM) - parameter flags (0:frozen / 1:unfrozen) - name of synthetic spectrum ('none' if not needed) - min and max wavelengths of global spectral range covered with all bandwidths in all parts [mum] (in same row) - fit format ('ob', 'part', 'dir', 'run', or 'all' for fit of model with individual OBs, with target files contained in each data part, directory (=day) or run, or with all target files) - allocation programme information file (used only if fit format = 'run') REQUIREMENTS: individual OB files and dir/run/global concatenated obs parameter files (in SCIENCE/ sub-directory) must have been previously created by concatenate_observations call(s) data read in allocation programme file (in OBS_PATH/ directory) must be in ASCII format and contain 2*nrun+1 rows with : - total number of run(s) allocated for the observing programme and obs run name(s) (same row) then for each run : - nber of allocated night(s) in run and name(s) of obs data directory(ies) (1 dir per obs night) OUTPUTS: model fitting processing batch text file (in SPIDAST_PATH/ directory) and needed text input files (in OBS_PATH/INP/ directory) LOCAL PROCEDURE CALLED: EXTRACT_PROHEADER LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: MAX_HEADER NB_BAND_MAX NB_PAIR_MAX NB_OB_MAX NB_PART_MAX NB_TARG_MAX NB_TRIPLE_MAX OBS_PATH SPEC_RES SPIDAST_PATH REVISION HISTORY: Written by pcr 2010/11/03 last modification by pcr 2011/01/11 ----- Documentation for Fit\fit_model.pro ----- NAME: FIT_MODEL AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: fit model parameter(s)on calibrated spectro-interferometric data use bootstrap loops of non-linear least squares fit (gradient-expansion algorithm) combining gradient search with analytical solution developed from linearizing fitting function. CATEGORY: fitting INPUTS: need text input file (in OBS_PATH/INP/ directory) with: - data format ('vis', 'spec', 'coh', 'bisp', 'trip' or 'clos') - number of part(s) (one file per P2VM setting) spec data : - input calibrated spec file name(s) (1 name per row) other data : - baselength file name(s) - input calibrated data file name(s) (1 name per row, same order than in baselength files : NTEL*(NTEL-1)/2 baselines per OB) then, for all data formats : - model number used for fitting - starting parameters (for LM) - parameter flags (0:frozen / 1:unfrozen) - synthetic exitance and radiance file names ('none' if not needed, in same row) - number of values per parameter, used for chi-square plots - desired confidence level (between 0 and 1) - number of bootstrap iterations (-1 for no fit) - optionaly : final spectral resolution at mean wavelength REQUIREMENTS: type of data used for fitting must be: 'vis' for visibility data 'spec' for spectrum data 'coh' for coherent spectrum data 'bisp' for bispectrum data 'trip' for triple product data 'clos' for closure phase data spec data: data read/written in input/output calibrated/fitted spec file (in subdirectory of OBS_DATA/) must be in ASCII format and contain (1 row per spectral channel): - wavelength and bandwidth [m], flux and error [W/m^2/mum] for each data file data read in input baseline file(s) (in subdirectory of OBS_PATH/) must be in ASCII format and contain (2*NBASE=NTEL*(NTEL-1) columns, one row per obs file): - (length[m] , angle[deg]) of each projected baseline at obs file start/end vis data: data read/written in input/output calibrated/fitted vis. file (in subdirectory of OBS_PATH/) must be in ASCII format and contain (1 row per spectral channel): - wavelength and bandwidth [m], visibility and error for each data file coh spec data: data read/written in input/output calibrated/fitted coh. spec. file (in subdirectory of OBS_PATH/) must be in ASCII format and contain (1 row per spectral channel): - wavelength and bandwidth [m], coherent flux and error [W/m^2/mum] for each data file bisp data: data read/written in input/output calibrated/fitted bisp. file (in subdirectory of OBS_PATH/) must be in ASCII format and contain (1 row per spectral channel): - wavelength and bandwidth [m], real part of bispectrum and error, imaginary part of bispectrum and error [(W/m^2/mum)^3] for each data file trip data: data read/written in input/output calibrated/fitted triple prod. file (in subdirectory of OBS_PATH/) must be in ASCII format and contain (1 row per spectral channel): - wavelength and bandwidth [m], real part of triple product and error, imaginary part of triple product and error for each data file clos data: data read/written in input/output calibrated/fitted clos. phase file (in subdirectory of OBS_PATH) must be in ASCII format and contain (1 row per spectral channel): - wavelength and bandwidth [m], closure phase and error [deg] for each data file flag for model are defined in model_spectrum.pro as well as order of starting parameters data read in input synthetic exitance file (of name exitance_file_stem.spec, in SYNTHE_PATH/ directory) must be in ASCII format and contain: - wavelength [AA = 10^-4 mum] and exitance [erg/cm^2/s/AA = 10*W/m^2/mum) if input synthetic radiance available (in SYNTHE_PATH/ directory) use also radiance data composed of !NB_LUMIN+1 columns with: - zero and relative impact parameters (!NB_LUMIN values between 0. and 1., in first row) - wavelength [mum] and !NB_LUMIN values of absolute radiance [W/m^2/mum/sr] (one row per spectral channel) OUTPUTS: data written in output fit file (of name input_file_stem.out, in OBS_PATH/OUT/ directory) must be in ASCII format and contain (in this order): - model flag, flux flag, synthetic exitance+radiance file names, data format flag, starting parameters, free flags, final goodness-of-fit parameter, fitted parameters, inferior errors, superior errors, number of degrees of freedom data written in covariance file (of name input_file_stem.cova, in OBS_PATH/OUT/ directory) must be in ASCII format and contain the covariance matrix (of size NB_MAX_PARAM*NB_MAX_PARAM) data written in output first parameter file (of name input_file_stem.par, in OBS_PATH/OUT/ directory) must be in ASCII format and contain (in this order) : - delta(chi-square) and free parameter vector(s) (1 row per vector) data written in output second parameter file (of name input_file_stem.param, in OBS_PATH/OUT/ directory) must be in ASCII format and contain (in this order, one row per confid level) : - confid lev/nb of chi2 val in confidence interval, and free param(s) at lower/upper fences of each CI LOCAL PROGRAM CALLED: ENGELKE GET_SYN_REF LOCA_SCALE_NORM MODEL_DATA_FUNCT MODEL_DATA_FUNCT_PROJ MODEL_SPECTRUM PLANCK PLOT_DISTRI RESET_PLOT UNIFORM_DISK LOCAL FUNCTION USED: BOOT_FIT EXTRACT_PROHEADER FUNCTPROJ GET_OUTLIER_FENCES LM_FIT MAKE_TAB3 SYM TRAP LOCAL SYSTEM VARIABLE USED: EPSILON FORMAT_OUT MAS2RADIAN MAX_LONG MAX_REL_ERR NB_BASE_STEP NB_BOOT_MIN NB_DATA_MAX NB_LAMBDA_MAX NB_MAX_FITS NB_MAX_PARAM NB_OB_MAX NB_PAIR_MAX NB_RES_STEP OBS_PATH PARAM_REL_DIST PLOT_DEV SPEC_RES SPIDAST_PATH SYNTHE_PATH REVISION HISTORY: Written by pcr 2006/09/15 last modification by pcr 2011/01/22 ----- Documentation for Fit\fit_sed.pro ----- NAME: FIT_SED AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: fit model parameter(s) on SED data use bootstrap loops of non-linear least squares method (gradient-expansion algorithm) combining gradient search with analytical solution developed from linearizing fitting function INPUTS: need text input file with : - input SED and broadband effective parameter file name ('none' if not needed, in same row) - flag for model to be used for fitting - starting parameters (for LM) - parameter flags (0:frozen / 1:unfrozen) - synthetic exitance file name - number of values per parameter, used for chi-squared plots - desired confidence level (between 0. and 1.) - number of bootstrap iterations (-1 for no fit) REQUIREMENTS: data read in SED file (in subdirectory of OBS_PATH/) must be in ASCII format and contain (in this order) : - wavelength and bandwidth [mum], measured flux and error [W/m^2/mum] data read in broadband effective parameter file (in ALL_DATA_PATH/ directory) must be in ASCII format and contain (in this order) : - effective wavelength and bandwidth [mum] in each band for the used model flag for model are defined in model_spectrum.pro as well as start-parameter order data read in input synthetic exitance file (of name exitance_file_stem.spec in SYNTHE_PATH/ directory) must be in ASCII format and contain : - wavelength [AA = 10^-4 mum] and exitance [erg/cm^2/s/AA = 10*W/m^2/mum] OUTPUTS: data written in output file (of name input_file_stem.out in OBS_PATH/OUT/ directory) must be in ASCII format and contain (in this order) : - model flag , flux flag, synthetic exitance+radiance file names, data format flag, starting parameters, free flags, final goodness-of-fit parameter, fitted parameters, inferior errors, superior errors, number of degrees of freedom data written in covariance file (of name input_file_stem.cova in OBS_PATH/OUT/ directory) must be in ASCII format and contain the covariance matrix (of size NB_MAX_PARAM*NB_MAX_PARAM) data written in first parameter file (of name input_file_stem.par in OBS_PATH/OUT/ directory) must be in ASCII format and contain (in this order) : - delta(chi2) and free parameter vector(s) (1 row per vector) data written in second parameter file (of name input_file_stem.param in OBS_PATH/OUT/ directory) must be in ASCII format and contain (in this order, one row per confid level) : - confid lev/nb of chi2 val in confidence interval, and free param(s) at lower/upper fences of each CI LOCAL PROCEDURE_CALLED: ENGELKE GET_SYN_REF LOCA_SCALE_NORM MODEL_DATA_FUNCT_PROJ MODEL_SPECTRUM PLANCK PLOT_DISTRI RESET_PLOT LOCAL FUNCTION USED: BOOT_FIT EXTRACT_PROHEADER FUNCTPROJ GET_OUTLIER_FENCES LM_FIT TRAP LOCAL SYSTEM VARIABLE USED: ALL_DATA_PATH EPSILON FORMAT_OUT MARCS_RES MAX_LONG MAX_REL_ERR NB_BOOT_MIN NB_DATA_MAX NB_MAX_FITS NB_MAX_PARAM NB_RES_STEP OBS_PATH PARAM_REL_DIST PLOT_DEV SPIDAST_PATH SYNTHE_PATH REVISION HISTORY: Written by pcr 2007/02/01 last modification by pcr 2011/01/22 ----- Documentation for Fit\ld_poly_fit.pro ----- NAME: LD_POLY_FIT PURPOSE: Non-linear least squares fit to a function of an arbitrary number of parameters. The function may be any non-linear function where the partial derivatives are known or can be approximated. CATEGORY: fitting. USAGE: yfit = LD_POLY_FIT(x, y, w, params [,sigmas]) INPUT: x - A vector of independent variables y - A vector of dependent variable, same length as x w - A vector of weights, same length as x. For no weighting set w(i) = 1., for instrumental weighting w(i) = 1./y(i), etc params - On input, a vector containing the initial estimates of the parameters. The length of params must equal the number of parameters in the function that is trying to be fit to the x,y data OUTPUT: params - A vector of the calculated parameters of the fitted function sigmas - (Optional) a vector of standard deviations of the parameters RETURNED yfit - A vector of fitted dependent variable values SIDE EFFECTS: The function to be fit must be defined and called LD_POLY_FUNCT. The call to LD_POLY_FUNCT is LD_POLY_FUNCT, x,p,f, pder where: x - Input, a vector of independent variables p - Input, a vector of function parameters f - Output, a vector of values of the function, f(i)=ld_poly_funct(x(i)) pder - Optional output, an array of size length_of_x by number_of_parameters containing the partial derivatives of funct. pder(i,j) is the derivative of the function at the ith point with respect to the jth parameter. PROCEDURE: Copied from "CURFIT", least squares fit to a non-linear function, pages 237-239, Bevington, Data Reduction and Error Analysis for the Physical Sciences. "This method is the Gradient-expansion algorithm which combines the best features of the gradient search with the method of linearizing the fitting function." Iterations are perform until the chi square changes by only 0.1% or until 20 iterations have been performed. The initial guess of the parameter values should be as close to the actual values as possible or the solution may not converge. LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: LD_POLY_FUNCT LOCAL SYSTEM VARIABLE USED: EPSILON REVISION HISTORY: Written by pcr 2008/04/23 last modification by pcr 2010/06/28 ----- Documentation for Fit\ld_poly_funct.pro ----- NAME: LD_POLY_FUNCT AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: EVALUATE THE POLYNOMIAL LIMB-DARKENED LAW DERIVED FROM MANDUCA ET AL. (1997) AND OPTIONALLY RETURN THE VALUE OF IT'S PARTIAL DERIVATIVES. NORMALLY, THIS FUNCTION IS USED BY LD_POLY_FIT TO FIT THE POLYNOMIAL LAW TO ACTUAL LIMB-DARKENED DATA. CATEGORY: FITTING. CALLING SEQUENCE: LD_POLY_FUNCT,X,A,F,PDER INPUTS: X = VALUES OF INDEPENDENT VARIABLE (= 1-MU). A = PARAMETERS OF EQUATION DESCRIBED BELOW. OUTPUTS: F = VALUE OF FUNCTION AT EACH X(I). OPTIONAL OUTPUT PARAMETERS: PDER = (N_ELEMENTS(X),NDEGREE) ARRAY CONTAINING THE PARTIAL DERIVATIVES. P(I,J) = DERIVATIVE AT ITH POINT W/RESPECT TO JTH PARAMETER. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: F = 1-A(0)*X-A(1)*X^2-A(2)*X^3-A(3)*X^4+... LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2008/04/23 last modification by pcr 2010/07/01 ----- Documentation for Fit\lm_fit.pro ----- NAME: LM_FIT PURPOSE: Non-linear least squares fit to a synthetic function of an arbitrary number of parameters. Function may be any non-linear function where the partial derivatives are known or can be approximated. CATEGORY: Fitting CALLING SEQUENCE: YFIT = LM_FIT(SX,BL,BWA,VY,WG,PA,IDX,MNB,VIS,TEMP,SRF,COVAA) INPUTS: SX = Independent variables = Row vector of synthetic wavelengths, or structure with wavelengths and impact parameters. BL = Row vector of baselengths. BWA= 2-D array with # of baselengths and # of wavelengths for each part (defined by P2VM setting). BWA(I,0) = # of baselengths for part I BWA(I,1) = # of wavelengths for part I VY = Row vector of dependent variables (can be complex). WG = Row vector of weights (can be complex), same length as VY. PA = Row vector containing the initial parameter estimates. IDX = Row vector of unfrozen-parameter indexes. MNB = Model nber. VIS = Visibility flag (if null no vis, else vis), for bispectrum calculation VIS = bispectrum index table . TEMP = Effective temperature used with MARCS flux/intensity data. SRF = Row vector (or matrix) of synthetic fluxes (or intensities). PRINT_INFO = Flag for LM-info printing ( 0: no print / 1: print ). OUTPUTS: PA = Row vector of parameters containing fit. IDX = Row vector of output unfrozen-parameter indexes. PRINT_INFO = Flag for LM-info printing ( -1: fit failed ). COVAA = Formal covariance matrix of the fit. FUNCTION RESULT: YFIT = Row vector of calculated values (same length as Y). COMMON BLOCKS: NONE. SIDE EFFECTS: The function to be fit must be defined and called in MODEL_DATA_FUNCT_PROJ. For an example see FUNCT in the PV-WAVE User's Library. Call to MODEL_DATA_FUNCT_PROJ is: MODEL_DATA_FUNCT_PROJ,XX,BASE,BWA,PA,IDX,MNB,VIS,TEMP,R0, DEPTH_INTENS_DATA,F_PROJ,PDER_PROJ where: XX = row vector or structure of independant variables (wavelength or wavelength + relative inpact parameter), input. BASE = row vector of baselength, input. BWA = 2-D array, input PA = row vector of parameters, input. IDX = row vector unfrozen-parameter indexes, input. MNB = model flag for calculation of function (and partial derivatives), input. VIS = visibility flag or bispectrum index table, input. TEMP = temperature, input. R0 = row vector of synthetic fluxes or 2-D array of synthetic intensities, input. DEPTH_INTENS_DATA = 2-dim complex array with optical depth and intensity or flag (=1/0) for opt. depth based models, output. F_PROJ = row vector of projected function values at each projected frequency (or proj. wavelength if base=0), output. PDER_PROJ = 2-dim array containing the projected partial derivatives, optional output. PDER_PROJ(I,J) = projected derivative at Ith projected frequency (or wavelength) w/respect to JTH parameter. RESTRICTIONS: NONE. PROCEDURE: Copied from "CURFIT", least squares fit to a non-linear function, pages 237-239, Bevington, Data Reduction and Error Analysis for the Physical Sciences. Modified, to output covariance matrix and make final function call, Amara Graps, August 1987 "This method is the Gradient-expansion algorithm which combines the best features of the gradient search with the method of linearizing the fitting function." Iterations are performed until the chi square changes by only TOL_CHI2 (in absolute or fractional) or until NITER iterations have been performed. The initial guess of the parameter values should be as close to the actual values as possible or the solution may not converge. LOCAL PROCEDURE CALLED: MODEL_DATA_FUNCT_PROJ LOCAL FUNCTION USED: COMPLEX2REAL LOCAL SYSTEM VARIABLE USED: EPSILON CHI2_LM_TOLE DEL_FLAMBDA_LM FLAMBDA_LM MAX_REL_ERR NB_LM_ITER REVISION HISTORY: Written by pcr 2006/10/24 last modification by pcr 2011/01/22 ----- Documentation for Fit\polybootw.pro ----- NAME: POLYBOOTW AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: Proceed nonparametric residual bootstrap iterations (ramdom shoot of residuals with replacement) of polynomial weighted fits giving estimates of upper and lower coefficient errors. CATEGORY: fitting. CALLING SEQUENCE: DCOEFF = POLYBOOTW(X,Y,WEIGHT,DEG,CLEVEL,COEFF) INPUTS: X = Row vector of independent coordinates. Y = Row vector of data, same length as X. WEIGHT = Row vector of experimental weights, same length as Y (e.g. proportional to (meas errors)^-2). DEG = Degree of polynomial to be fitted to data. CLEVEL = Desired confidence level (between 0 and 1). COEFF = Row vector of polynomial coefficients, length=DEG+1. OUTPUTS: None. FUNCTION RESULT: DCOEFF = Row array of parameter inferior/superior error estimate(s), dim=(DEG+1,2). COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: SEE CODE. LOCAL PROCEDURE CALLED: LOCA_SCALE_CHI2 LOCAL FUNCTION USED: GET_OUTLIER_FENCES LOCAL SYSTEM VARIABLE USED: NB_BOOT_LOOPS NB_DATA_BOOT NB_MAX_BOOTS REVISION HISTORY: written by pcr 2008/06/05 last modification by pcr 2010/12/12 ----- Documentation for Fit\poly_boot.pro ----- NAME: POLY_BOOT AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: Proceed nonparametric residual bootstrap iterations (ramdom shoot of residuals with replacement) of polynomial fits giving estimates of upper and lower coefficient errors. CATEGORY: fitting. CALLING SEQUENCE: DCOEFF = POLY_BOOT(X,Y,DEG,CLEVEL,COEFF) INPUTS: X = Row vector of independent coordinates. Y = Row vector of data, same length as X. DEG = Degree of polynomial to be fitted to data. CLEVEL = Desired confidence level (between 0 and 1). COEFF = Row vector of polynomial coefficients, length=DEG+1. OUTPUTS: None. FUNCTION RESULT: DCOEFF = Row array of parameter inferior/superior error estimate(s), dim=(DEG+1,2). COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: SEE CODE. LOCAL PROCEDURE CALLED: LOCA_SCALE_CHI2 LOCAL FUNCTION USED: GET_OUTLIER_FENCES LOCAL SYSTEM VARIABLE USED: NB_BOOT_LOOPS NB_DATA_BOOT NB_MAX_BOOTS REVISION HISTORY: Written by pcr 2008/06/04 last modification by pcr 2010/12/12 ----- Documentation for Fit\test_model.pro ----- NAME: TEST_MODEL AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: test model and partial derivatives vs parameters and also test Levenberg-Marquardt (LM) algorithm CATEGORY: fitting INPUTS: need text input file (in OBS_PATH/INP/ directory) with: - number of baselength file(s) (one file per P2VM setting, null if not needed, e.g. for flux or sed fit) - baselength file name(s) (if needed) - nber of wavelength bands for each baselength file: - name(s) of wavelength list(s) (1 row per spectral band) then: - data format - model number used for fitting - number of values per parameter, band number, pair number (used for derivative test) - parameter value(s) (= starting parameters used for fit) - parameter flags (0:frozen / 1:unfrozen) (used for fit) - synthetic exitance and radiance file names ('none' if not needed, in same row) - parameter relative error used for fit (null if no fit) REQUIREMENTS: data read in input baseline file(s) (in subdirectory of OBS_PATH/) must be in ASCII format and contain (2*NBASE=NTEL*(NTEL-1) columns, one row per obs file) : - (length[m] , angle[deg]) of each projected baseline at obs file start/end data read in wavelength list(s) (in subdirectory of OBS_PATH/) must be in ASCII format and contain (one row per spectral channel, decreasing order of wavelength): - wavelength and bandwith [m] data format must be: 'vis' for visibility data 'spec' for spectrum data 'coh' for coherent spectrum data 'bisp' for bispectrum data 'sed' for sed data model number is defined in model_spectrum.pro as well as order of starting parameters data read in input synthetic exitance file (.spec, 4 first characters=temperature, in SYNTHE_PATH/ directory) must be in ASCII format and contain 2 columns of data: - wavelength (in AA = 10^-4 mu) and spectral exitance (in erg.cm^-2.s^-1.AA^-1 = 10*W.m^-2.mu^-1) if input synthetic radiance available (in SYNTHE_PATH/ directory) use also radiance data composed of !NB_LUMIN+1 columns with: - zero and relative impact parameters (!NB_LUMIN values between 0. and 1., in first row) - wavelength [mum] and !NB_LUMIN values of absolute radiance [W/m^2/mum/sr] (one row per spectral channel) also use relative impact parameter list of name RIP_LIST_NAME composed of: - 1 column of NB_LUMIN values (between 0. and 1.) OUTPUTS: data written in test data file(s) (in the same subdirectory of OBS_PATH/, one file per baseline/triplet) must be in ASCII format and contain (in this order, one row per wavelength): for visibility data (.vis): - wavelength and bandwidth (in m), visibility and error for flux data (.spec): - wavelength and bandwidth (in m), flux and error (in W.m^-2.mu^-1) for coherent flux data (.coh): - wavelength and bandwidth (in m), coherent flux and error (in W.m^-2.mu^-1), for bispectral data (.bisp): - wavelength and bandwidth (in m), bispectrum real part and error, bispectrum imaginary part and error (all in W^3.m^6.mu^-3) for sed data (.sed): - wavelength and bandwidth (in m), flux and error (in W.m^-2.mu^-1) LOCAL PROCEDURE CALLED: ENGELKE GET_SYN_REF MODEL_DATA_FUNCT_PROJ MODEL_SPECTRUM PLANCK RESET_PLOT LOCAL FUNCTION USED: COSD EXTRACT_PROHEADER FUNCTPROJ LM_FIT MAKE_TAB3 SIND TRAP LOCAL SYSTEM VARIABLE USED: EPSILON MARCS_RES MAS2RADIAN NB_BASE_STEP NB_DATA_MAX NB_LAMBDA_MAX NB_MAX_PARAM NB_OB_MAX NB_PAIR_MAX NB_RES_STEP OBS_PATH PLOT_DEV SPIDAST_PATH SYNTHE_PATH REVISION HISTORY: Written by pcr 2006/09/22 last modification by pcr 2011/01/13