Commit c162ce07 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

new signal

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1792
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent e1374064
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sigfit.cc,v 1.19 2004-09-24 15:36:33 tforb Exp $
* $Id: sigfit.cc,v 1.20 2005-07-01 13:57:16 tforb Exp $
* \author Thomas Forbriger
* \date 28/01/2004
*
......@@ -29,7 +29,7 @@
#define SIGFIT_VERSION \
"SIGFIT V1.4 fit signal by trial-signals"
#define SIGFIT_CVSID \
"$Id: sigfit.cc,v 1.19 2004-09-24 15:36:33 tforb Exp $"
"$Id: sigfit.cc,v 1.20 2005-07-01 13:57:16 tforb Exp $"
#include <fstream>
#include <iostream>
......@@ -48,6 +48,7 @@
#include <linearxx/lapackxx.h>
typedef std::list<std::string> Tnamelist;
// double precision time series bundle
typedef ts::TDsfftimeseries Tbundle;
typedef Tbundle::Tseries Tseries;
typedef std::vector<Tbundle> Tbundlevec;
......
c this is <siggen.f>
c------------------------------------------------------------------------------
c ($Id: siggen.f,v 1.12 2005-04-18 11:27:09 tforb Exp $)
c ($Id: siggen.f,v 1.13 2005-07-01 13:57:16 tforb Exp $)
c
c 24/10/2001 by Thomas Forbriger (IMGF Frankfurt)
c
......@@ -12,27 +12,28 @@ c 02/11/2001 V1.1 boxcar
c 20/11/2001 V1.2 Gerhards weight-drop source signal
c 21/11/2001 V1.3 added first sine half-period
c 28/08/2002 V1.4 added noise
c 01/07/2002 V1.5 added test triangle
c
c==============================================================================
c
program siggen
c
character*(*) version
parameter(version='SIGGEN V1.4 SIGnal GENerator')
parameter(version='SIGGEN V1.5 SIGnal GENerator')
character*(*) SIGGEN_CVS_ID
parameter(SIGGEN_CVS_ID=
& '$Id: siggen.f,v 1.12 2005-04-18 11:27:09 tforb Exp $')
& '$Id: siggen.f,v 1.13 2005-07-01 13:57:16 tforb Exp $')
c
c parameters
integer nsig,ncyc
double precision f,t,a,d,ta,te,td,tm,f1,f2,expo
double precision f,t,a,d,ta,te,td,tm,f1,f2,expo,b,c
logical overwrite
character*80 filename
c functions
real tf_rand
c internal parameters
integer nsamples,i
double precision ti,tend,b
double precision ti,tend,bx,tx,dx
double precision myexpo
real pi
parameter(pi= 3.1415926535897)
......@@ -45,7 +46,7 @@ c data space
c commandline
integer maxopt, lastarg, iargc
character*80 argument
parameter(maxopt=15)
parameter(maxopt=17)
character*3 optid(maxopt)
character*40 optarg(maxopt)
logical optset(maxopt), opthasarg(maxopt)
......@@ -53,10 +54,11 @@ c debugging
logical debug, verbose
c here are the keys to our commandline options
data optid/2h-D, 2h-v, 2h-o, 2h-f, 2h-T, 2h-a, 2h-d,
& 3h-Ta,3h-Te,2h-n,3h-Td,3h-Tm,3h-f1,3h-f2,2h-e/
data opthasarg/3*.FALSE.,12*.TRUE./
& 3h-Ta,3h-Te,2h-n,3h-Td,3h-Tm,3h-f1,3h-f2,2h-e,
& 2h-b,2h-c/
data opthasarg/3*.FALSE.,14*.TRUE./
data optarg/3*1h-,3h20.,2*2h1.,4h.001,2h0.,3h.02,1h5,5h1.e20,4h.005,
& 2*3h20.,1h1/
& 2*3h20.,3*1h1/
c
c------------------------------------------------------------------------------
c basic information
......@@ -68,7 +70,7 @@ c
print *,version
print *,'Usage: siggen type file [-v] [-o] [-f f] [-T T] [-a a] [-d d]'
print *,' [-Ta Ta] [-Te Te] [-Td Td] [-Tm Tm]'
print *,' [-n n] [-f1 f1] [-f2 f2]'
print *,' [-n n] [-f1 f1] [-f2 f2] [-b b] [-c c]'
print *,' or: siggen -help'
if (argument(1:5).ne.'-help') stop 'ERROR: wrong number of arguments'
print *,' '
......@@ -89,6 +91,8 @@ c
print *,'-a a set amplitude parameter to ''a'' '
print *,' this is the signal amplitude'
print *,' (default: ',optarg(6)(1:3),')'
print *,'-b b set parameter ''b'' '
print *,'-c c set parameter ''c'' '
print *,' '
print *,'-f f set frequency parameter to ''f''Hz'
print *,' this is the fundamental signal frequency'
......@@ -214,6 +218,15 @@ c
print *,' '
print *,'12 white noise'
print *,' '
print *,'13 triangle test signal'
print *,' If D(t) is a triangle signal with 2*a peak'
print *,' to peak amplitude an period 1/f, the output'
print *,' signal will be'
print *,' '
print *,' f(t)=D(t)+b+c*t'
print *,' '
print *,' Choosing a=0 will result in a linear ramp.'
print *,' '
print *,SIGGEN_CVS_ID
stop
endif
......@@ -242,6 +255,8 @@ c
read(optarg(13), *) f1
read(optarg(14), *) f2
read(optarg(15), *) expo
read(optarg(16), *) b
read(optarg(17), *) c
c
c------------------------------------------------------------------------------
......@@ -357,22 +372,22 @@ c
endif
nsamples=int(t/d)
tend=ta+2.*ncyc/(f1+f2)
b=(f2**2-f1**2)/(4.*ncyc)
bx=(f2**2-f1**2)/(4.*ncyc)
if (verbose) then
print *,'derived parameters:'
print 52,'number of samples',nsamples,' '
print 53,'end of signal',tend,'s'
print 53,'frequency modulation slope',b,'Hz/s'
print 53,'frequency modulation slope',bx,'Hz/s'
print 53,'initial frequency',f1,'Hz'
print 53,'final frequency',f1+2.*b*(tend-ta),'Hz'
print 53,'total cycles',(f1+b*(tend-ta))*(tend-ta),' '
print 53,'final frequency',f1+2.*bx*(tend-ta),'Hz'
print 53,'total cycles',(f1+bx*(tend-ta))*(tend-ta),' '
endif
do i=1,nsamples
ti=d*float(i-1)
if (ti.lt.ta) then
data(i)=0.
elseif(ti.le.tend) then
data(i)=a*(sin(2*pi*(f1+b*(ti-ta))*(ti-ta))*
data(i)=a*(sin(2*pi*(f1+bx*(ti-ta))*(ti-ta))*
& exp(-(ti-Ta)/Td))
else
data(i)=0.
......@@ -391,23 +406,23 @@ c
print 50,'damping time constant','Td',td,'s'
endif
nsamples=int(t/d)
b=log(0.5)/log(1.-(Tm-ta)/(te-ta))
bx=log(0.5)/log(1.-(Tm-ta)/(te-ta))
if (verbose) then
print *,'derived parameters:'
print 52,'number of samples',nsamples,' '
print 53,'frequency modulation exponent',b,' '
print 53,'phase at ta',(1.-myexpo(dble(1.-(ta-ta)/(te-ta)),b)),'2pi'
print 53,'phase at tm',(1.-myexpo(dble(1.-(tm-ta)/(te-ta)),b)),'2pi'
print 53,'phase at te',(1.-myexpo(dble(1.-(te-ta)/(te-ta)),b)),'2pi'
print 53,'frequency modulation exponent',bx,' '
print 53,'phase at ta',(1.-myexpo(dble(1.-(ta-ta)/(te-ta)),bx)),'2pi'
print 53,'phase at tm',(1.-myexpo(dble(1.-(tm-ta)/(te-ta)),bx)),'2pi'
print 53,'phase at te',(1.-myexpo(dble(1.-(te-ta)/(te-ta)),bx)),'2pi'
print 53,'frequency at te',
& b/(te-ta)*myexpo(dble(1.-(te-ta)/(te-ta)),(b-1.)),'Hz'
& bx/(te-ta)*myexpo(dble(1.-(te-ta)/(te-ta)),(bx-1.)),'Hz'
endif
do i=1,nsamples
ti=d*float(i-1)
if (ti.lt.ta) then
data(i)=0.
elseif(ti.le.te) then
data(i)=a*(sin(2*pi*(1.-myexpo(dble(1.-(ti-ta)/(te-ta)),b)))*
data(i)=a*(sin(2*pi*(1.-myexpo(dble(1.-(ti-ta)/(te-ta)),bx)))*
& exp(-(ti-Ta)/Td))
else
data(i)=0.
......@@ -425,20 +440,20 @@ c
print 50,'damping time constant','Td',td,'s'
endif
nsamples=int(t/d)
b=log(2./3.)/log(1.-Tm/te)
bx=log(2./3.)/log(1.-Tm/te)
if (verbose) then
print *,'derived parameters:'
print 52,'number of samples',nsamples,' '
print 53,'frequency modulation exponent',b,' '
print 53,'phase at tm',1.5*(1.-myexpo(dble(1.-tm/te),b)),'pi'
print 53,'phase at te',1.5*(1.-myexpo(dble(1.-te/te),b)),'pi'
print 53,'frequency modulation exponent',bx,' '
print 53,'phase at tm',1.5*(1.-myexpo(dble(1.-tm/te),bx)),'pi'
print 53,'phase at te',1.5*(1.-myexpo(dble(1.-te/te),bx)),'pi'
print 53,'frequency at te',
& (b*3./(4.*te))*myexpo(dble(1.-te/te),(b-1.)),'Hz'
& (bx*3./(4.*te))*myexpo(dble(1.-te/te),(bx-1.)),'Hz'
endif
do i=1,nsamples
ti=d*float(i-1)
if(ti.le.te) then
data(i)=a*(cos(1.5*pi*(1.-myexpo(dble(1.-ti/te),b)))*
data(i)=a*(cos(1.5*pi*(1.-myexpo(dble(1.-ti/te),bx)))*
& exp(-ti/Td))
else
data(i)=0.
......@@ -569,6 +584,38 @@ c
do i=1,nsamples
data(i)=a*(2.*tf_rand()-1.)
enddo
elseif (nsig.eq.13) then
if (verbose) then
print *,'triangle with trend and offset superimposed'
print *,'parameters:'
print 50,'amplitude','a',a,' '
print 50,'sampling interval','d',d,'s'
print 50,'time series lentgh','T',t,'s'
print 50,'frequency','f',f,'Hz'
print 50,'offset','b',b,' '
print 50,'trend','c',c,'1/s'
endif
c half period
bx=1/(2.*f)
nsamples=int(t/d)
if (verbose) then
print *,'derived parameters:'
print 52,'number of samples',nsamples,' '
print 53,'half period',bx,' '
endif
do i=1,nsamples
c time of sample
ti=(i-1)*d
c time of next root
tx=bx*nint(ti/bx)
if (cos(ti*pi*2.*f).gt.0.) then
c slope
dx=2.*a/bx
else
dx=-2.*a/bx
endif
data(i)=dx*(ti-tx)+b+c*ti
enddo
else
stop 'ERROR: unknown signal'
endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment