COSMOS v7.655  COSMOSv7655
(AirShowerMC)
ksmooth.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine ksmooth (x, intvx, y, intvy, n, jin, repeat, cgap, icon)
 

Function/Subroutine Documentation

◆ ksmooth()

subroutine ksmooth ( real*8, dimension(intvx, n x,
integer  intvx,
real*8, dimension(intvy, n y,
integer  intvy,
integer  n,
integer  jin,
integer  repeat,
real*8  cgap,
integer  icon 
)

Definition at line 3 of file ksmooth.f.

References d0.

Referenced by proctime().

3 ! very simple smoothing of data
4 ! This is intended to smooth arrival time distribution
5 ! which is integrated from smaller time side and normalized
6 ! to be 1 at the largest time.
7 ! In many cases, the distribution has long tail approaching to 1.
8 ! The smooting is tried until the maximum gap of current y values
9 ! and those after smoothing becomes < cgap/Neff. ( y is updated
10 ! at each smoothing). Where Neff
11 ! is the effective number of data points. Neff is defined as
12 ! the data number which lie below y=0.95. (This is to avoid the
13 ! effect of long tail close to y=1.0).
14  implicit none
15  integer intvx ! input see below
16  integer intvy ! input see below. Normally these two are 1
17  integer n ! input number of data point
18  real*8 x(intvx, n) ! input. data points are given at
19  ! x(1, i), i=1,...n
20  real*8 y(intvy, n) ! input/output. data to be smoothed at x.
21  integer jin ! input. 0. no smoothing for the 1 st and last points
22  ! 1. smoothing is tried also to the 1st and last
23  ! For time distribution, 0 is ok
24 
25  integer repeat ! input. The maximum number of smoothing.
26  ! smooting is ceased at this number even cgap/Neff
27  ! condtion is not satisfied. Normally 500~1000 is ok
28 !
29 ! if repeat is large, this procedure gives a straight line.
30 !
31  real*8 cgap ! input. critical value to judge the max gap. As explained
32 ! above. 0.03~0.2.
33  integer icon ! output. number of smoothing actually tried.
34  ! -1 means no success.
35 
36 ! take 3 data points from smallest x, and get average of
37 ! 3 y's and make it to be the value of 2nd y.
38 ! Then, extract next 3 x's until the 3rd point becomes then
39 ! n-th point. if jin==1,
40 
41  integer i, j
42  real*8 sum, y2, y3, yn1, yn2, r, dy1, dy2, dy3
43  real*8 temp
44  real*8 gap
45  integer neff
46  neff = 0
47  do i = 1, n
48  if(y(1,i) .gt. 0.95 ) exit
49  neff = neff+ 1
50  enddo
51  if(neff .lt. 3) then
52  neff= n
53  endif
54 
55  if( n .le. 2) then
56  icon = -1
57  else
58  icon = 0
59  do i = 1, repeat
60  icon = icon + 1
61  gap = 0.
62  if(jin .eq. 1) then
63  y2 = y(1, 2)
64  y3 = y(1, 3)
65  yn1 = y(1, n-1)
66  yn2 = y(1, n-2)
67  endif
68 
69  do j = 2, n-1
70  r =(x(1,j)-x(1,j-1))/(x(1,j+1)-x(1,j))
71  sum = y(1, j-1) + y(1,j) +
72  * y(1,j+1)*r
73  if( j .eq. 2) then
74  temp = sum/(2.0d0 + r)
75  else
76  if(gap .lt. abs(temp-y(1,j-1)) ) then
77  gap = abs(temp-y(1,j-1))
78  endif
79  y(1,j-1) = temp
80  temp = sum/(2.0d0 + r)
81  endif
82  enddo
83  y(1,n-1) = temp
84  if( jin .eq. 1) then
85  dy3= y3-y(1,3)
86  dy2 = y2-y(1,2)
87  y(1, 1) = (dy3-dy2)/(x(1,3)-x(1,2)) *
88  * (x(1,1)-x(1,2)) + dy2 + y(1, 1)
89 
90  dy1 = yn1 - y(1, n-1)
91  dy2 = yn2 - y(1, n-2)
92  y(1,n) =(dy2-dy1)/(x(1,n-2)-x(1,n-1))*
93  * (x(1,n)-x(1,n-1)) + dy1 + y(1,n)
94  endif
95  if(gap .lt. cgap/neff) exit
96  enddo
97  endif
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz r
Definition: ZavoidUnionMap.h:1
nodes i
********************block data cblkHeavy ********************integer j data *HeavyG2symbol *data *HeavyG2code kiron data j
Definition: cblkHeavy.h:36
real(4), dimension(:), allocatable, save temp
Definition: cNRLAtmos.f:29
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
real(8), save repeat
Definition: csoftenPiK.f:40
latitude latitude this system is used *****************************************************************! type coord sequence union map real y
Definition: Zcoord.h:25
integer n
Definition: Zcinippxc.h:1
! structure defining a particle at production ! Basic idea of what is to be contained in ! the particle structue is that dynamical ones should be included those derivable from the particle code ! is not included ******************************************************type fmom momentum sequence union map real e endmap map real * x
Definition: Zptcl.h:21
Here is the caller graph for this function: