Mac binaries
[jabaws.git] / website / archive / binaries / mac / src / disembl / Tisean_3.0.1 / source_f / stp.f
1 c===========================================================================
2 c
3 c   This file is part of TISEAN
4
5 c   Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber
6
7 c   TISEAN is free software; you can redistribute it and/or modify
8 c   it under the terms of the GNU General Public License as published by
9 c   the Free Software Foundation; either version 2 of the License, or
10 c   (at your option) any later version.
11 c
12 c   TISEAN is distributed in the hope that it will be useful,
13 c   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 c   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 c   GNU General Public License for more details.
16 c
17 c   You should have received a copy of the GNU General Public License
18 c   along with TISEAN; if not, write to the Free Software
19 c   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 c
21 c===========================================================================
22 c   space time separation plot
23 c   see  H. Kantz, T. Schreiber, Nonlinear Time Series Analysis, Cambridge
24 c      University Press (1997,2004)
25 c   author T. Schreiber (1998) based on earlier version
26 c==========================================================================
27       parameter(nx=1000000,mdt=500,mfrac=100)
28       dimension x(nx), stp(mfrac,mdt)
29       character*72 file, fout
30       data idt/1/, perc/0.05/, ndt/100/
31       data iverb/1/
32
33       call whatido("space-time separation plot",iverb)
34       id=imust("d")
35       m=imust("m")
36       idt=ican("#",idt)
37       ndt=min(ican("t",ndt),mdt)
38       perc=fcan("%",perc)
39       nfrac=min(mfrac,int(1/perc))
40       perc=1./real(nfrac)
41       nmax=ican("l",nx)
42       nexcl=ican("x",0)
43       jcol=ican("c",0)
44       isout=igetout(fout,iverb)
45       if(iv_io(iverb).eq.1) write(istderr(),*) "computing ", nfrac, 
46      .   " levels at fractions ", perc, 2*perc, "..."
47
48       call nthstring(1,file)
49       call readfile(nmax,x,nexcl,jcol,file,iverb)
50       call minmax(nmax,x,xmin,xmax)
51       call stplot(nmax,x,id,m,xmax-xmin,stp,nfrac,ndt,idt)
52       if(isout.eq.1) call addsuff(fout,file,"_stp")
53       call outfile(fout,iunit,iverb)
54       do 10 iper=1,mfrac
55          do 20 it=1,ndt
56  20         write(iunit,*) it*idt, stp(iper,it)
57  10      write(iunit,'()')
58       end
59
60       subroutine usage()
61 c usage message
62       
63       call whatineed(
64      .   " -d# -m# [-## -t# -%# -o outfile -l# -x# -c# -V# -h] file")
65       call popt("d","delay")
66       call popt("m","embedding dimension")
67       call popt("#","time resolution (1)")
68       call popt("t","time steps (100, <500)")
69       call popt("%","fraction at wich to create levels (0.05, >0.01)")
70       call popt("l","number of values to be read (all)")
71       call popt("x","number of values to be skipped (0)")
72       call popt("c","column to be read (1 or file,#)")
73       call pout("file_stp")
74       call pall()
75       stop
76       end
77
78       subroutine stplot(nmax,y,id,m,epsmax,stp,nfrac,mdt,idt)
79       parameter(meps=1000,mfrac=100)
80       dimension y(nmax),stp(mfrac,mdt),ihist(meps)
81
82       do 10 it=1,mdt
83          do 20 ieps=1,meps
84  20         ihist(ieps)=0
85          do 30 n=it*idt+(m-1)*id+1,nmax
86             dis=0                            ! compute distance in m dimensions
87             do 40 me=0,m-1
88  40            dis=max(dis,abs(y(n-me*id)-y(n-me*id-it*idt)))
89             ih=min(int(meps*dis/epsmax)+1,meps)
90  30         ihist(ih)=ihist(ih)+1
91          do 10 ifrac=1,nfrac
92             need=(nmax-it*idt-(m-1)*id)*ifrac/real(nfrac)
93             is=0
94             do 50 ieps=1,meps
95                is=is+ihist(ieps)
96  50            if(is.ge.need) goto 1
97  1          stp(ifrac,it)=ieps*epsmax/meps
98  10      continue
99       end
100
101
102
103
104