#include /* #define MAX_OBS 32768 */ #define MAX_OBS 300000 #define MAXSIZE MAX_OBS*2+2 #define MAX_PARAM 30 typedef struct { int shortterm; /* short term filter cutoff specified in days */ int longterm; /* long term filter cutoff specified in days */ int numpolyterms; /* number of polynomial terms to use */ int numharmonics; /* number of harmonic terms to use */ float timezero; /* year for y intercept of coefficients */ float sampleinterval; /* evenly spaced sample interval specified in days */ float pm[MAX_PARAM]; /* coefficients of function */ int numpm; /* number of parameters used in function */ float varf1; /* variance of short term filter */ float varf2; /* variance of long term filter */ float funcvar; /* variance of function */ float chisq; /* chi squared value of function fit */ float rsd1; /* residual standard deviation about function */ float rsd2; /* residual standard deviation about smooth curve */ } FilterData; typedef struct { double startdate; int cal_format; int use_hour; int user; int outfile1; int outfile2; int orig; int func; int poly; int sm; int tr; int detrend; int smcycle; int harm; int res; int smres; int trres; int ressm; int gr; int stats; char *format; } ExportData; void filter_data ( double x[], double y[], double sig[], int n0, int cutoff1, int cutoff2, float interval, int numpoly, int numharm, float pm[], double **covar, int *numpm, double xfilt[], double smooth[], double trend[], double deriv[], int *nfilt, float *varf1, float *varf2, float *chisq, float *rsd1 ); void spline_f ( double x[], double y[], int n, double domain[], double func[], double deriv[], int narg ); double userfunc ( float p[], double x, int nh, int nt ); double polyv ( float pm[], double x, int numpt ); double yearharmonic ( float pm[], double x, int numpt, int numh ); double varnce ( double **covar, int n, double x ); void means ( double a[], float *rmean, float *sdev, int n ); void lfit( double x[], double y[], double sig[], int ndat, float a[], double **covar, int ma, float *chisq, void (*funcs)() ); void partial ( double x, double der[], int numpm ); float filtvar ( float cutoff, float dinterv, double xfilt[], double filt[], int nfilt, double x[], double y[], int n ); void fit( double x[], double y[], int ndata, float *a, float *b, float *siga, float *sigb, float *chi2 ); void filter ( double x[], double work1[], int n0, float rinterval, float cutoff, double xfilt[], double work2[], int *nfilt ); void spline( double x[], double y[], int n, double y2[] ); void splint ( double xa[], double ya[], double y2a[], int n, double x, double *y, double *yd ); void realft( double data[], int n, int isign ); void four1( double data[], int nn, int isign ); float fnfilt ( float freq, float sigma, int power ); double interpolate ( double x[], double y[], int n, double s2[], double xp ); void export_sample_dates( FILE *fp, ExportData export, double xp[], double yp[], double smooth2[], double trend2[], double deriv2[], int np, FilterData filter ); void export_equally_spaced( FILE *fp, ExportData export, double xfilt[], double smooth[], double trend[], double deriv[], int nfilt, FilterData filter ); void export_user( char *userfile, FILE *fp, ExportData export, double xfilt[], double smooth[], double trend[], double deriv[], int nfilt, FilterData filter ); double **dmatrix(long nrl, long nrh, long ncl, long nch); void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);