/* * This file is part of TISEAN * * Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber * * TISEAN is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * TISEAN is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TISEAN; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /*Author: Rainer Hegger Last modified: Nov 30, 2000 */ /*Changes: 12/11/05: Going multivariate */ #include #include #include #include #include #include "routines/tsa.h" #define WID_STR "Performs simple noise reduction." #define BOX (unsigned int)512 unsigned long length=ULONG_MAX,exclude=0; unsigned int comp=1,embed=5,delay=1,iterations=1,alldim; unsigned int verbosity=0x3; char *column=NULL; double eps=1.0e-3,epsvar; char *outfile=NULL,epsset=0,stdo=1,epsvarset=0; char *infile=NULL; double **series,**corr,*interval,*min,*hcor; long **box,*list,**nf; unsigned int **indexes; char dimset=0; void show_options(char *progname) { what_i_do(progname,WID_STR); fprintf(stderr," Usage: %s [Options]\n",progname); fprintf(stderr," Options:\n"); fprintf(stderr,"Everything not being a valid option will be interpreted" " as a possible" " datafile.\nIf no datafile is given stdin is read. Just - also" " means stdin\n"); fprintf(stderr,"\t-l # of data to use [default: whole file]\n"); fprintf(stderr,"\t-x # of lines to be ignored [default: 0]\n"); fprintf(stderr,"\t-c column to read [default: 1]\n"); fprintf(stderr,"\t-m no. of comp.,embedding dim. [default: %u,%u]\n", comp,embed); fprintf(stderr,"\t-d delay [default: 1]\n"); fprintf(stderr,"\t-i iterations [default: 1]\n"); fprintf(stderr,"\t-r neighborhoud size [default: (interval of data)/1000]\n"); fprintf(stderr,"\t-v neighborhoud size (in units of the std. dev. of the " "data \n\t\t(overwrites -r) [default: not set]\n"); fprintf(stderr,"\t-o output file name [Default: 'datafile'.laz.n," "\n\t\twhere n is the number of the last iteration," "\n\t\twithout -o the last iteration is written to stdout.]\n"); fprintf(stderr,"\t-V verbosity level [Default: 3]\n\t\t" "0='only panic messages'\n\t\t" "1='+ input/output messages'\n\t\t" "2='+ write output of all iterations to files'\n\t\t" "4='+ write the number of neighbors found for each point\n"); fprintf(stderr,"\t-h show these options\n"); exit(0); } void scan_options(int n,char **in) { char *out; if ((out=check_option(in,n,'l','u')) != NULL) sscanf(out,"%lu",&length); if ((out=check_option(in,n,'x','u')) != NULL) sscanf(out,"%lu",&exclude); if ((out=check_option(in,n,'c','c')) != NULL) { column=out; dimset=1; } if ((out=check_option(in,n,'m','2')) != NULL) sscanf(out,"%u,%u",&comp,&embed); if ((out=check_option(in,n,'d','u')) != NULL) sscanf(out,"%u",&delay); if ((out=check_option(in,n,'i','u')) != NULL) sscanf(out,"%u",&iterations); if ((out=check_option(in,n,'r','f')) != NULL) { epsset=1; sscanf(out,"%lf",&eps); } if ((out=check_option(in,n,'V','u')) != NULL) sscanf(out,"%u",&verbosity); if ((out=check_option(in,n,'v','f')) != NULL) { epsvarset=1; sscanf(out,"%lf",&epsvar); } if ((out=check_option(in,n,'o','o')) != NULL) { stdo=0; if (strlen(out) > 0) outfile=out; } } unsigned int correct(unsigned long n) { int i,i1,i2,j,j1,k; int ibox=BOX-1; unsigned int hdel,hcomp; double epsinv,dx; long element,nfound=0; epsinv=1./eps; for (i=0;i eps) break; } if (k == alldim) { nfound++; for (k=0;k maxinterval) maxinterval=interval[i]; variance(series[i],length,&dav,&dvar); if (dvar > maxdvar) maxdvar=dvar; } alldim=comp*embed; check_alloc(nmf=(unsigned int*)malloc(sizeof(int)*length)); check_alloc(list=(long*)malloc(sizeof(long)*length)); check_alloc(box=(long**)malloc(sizeof(long*)*BOX)); for (n=0;n