Layers
Diffusion in heterogeneous environments
Data Structures | Functions
fit-layer.c File Reference

Fits the 3-layer model to RTI data to determine alpha, theta, and kappa of the SP layer. More...

#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include <gsl/gsl_multimin.h>
#include "header.h"
Include dependency graph for fit-layer.c:

Go to the source code of this file.

Data Structures

struct  param_struct_type
 Typedef for struct for passing parameters and arrays to mse function. More...
 

Functions

double calc_mse_fit_layer (const gsl_vector *x, void *params)
 Mean squared error function for simplex fitting. More...
 
int main (int argc, char *argv[])
 Main program.
 

Detailed Description

Fits the 3-layer model to RTI data to determine alpha, theta, and kappa of the SP layer.

Usage:

    fit-layer [options] \<input_file\>

where <input_file> is the name of the input data file. The output file will have the same basename as the input file but will have the extension '.dat'. The input file should not have the extension '.dat'.

To get a list of options, run fit-layer with no input filename.

The input data file consists of:

Notes:

Author
David Lewis, CABI, NKI
Date
2012-2013

Definition in file fit-layer.c.

Function Documentation

double calc_mse_fit_layer ( const gsl_vector *  x,
void *  params 
)

Mean squared error function for simplex fitting.

Calls calc_diffusion_curve_layer_fit_layer(), which calculates the diffusion curve from the layer model. Calculates and returns the MSE between the model curve and the data from experiment.

Note that the data typically has about 1000 samples, but the model curve generally has several thousand points. In order to calculate the mean squared error, the model curve is downsampled to the same number of sample points as in the data.

Author
Dave Lewis, CABI, NKI
Parameters
[in,out]xVector of parameters to fit (alpha, theta, kappa of SP)
[in,out]paramsStruct of parameters and arrays (e.g., geometry of environment, nt, time array, data array, model curve array)
Returns
Mean squared error between model and data; the model data is returned in an array in the params struct

Definition at line 116 of file fit-layer.c.

Here is the call graph for this function:

Here is the caller graph for this function: