aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/apphot/fitsky/aphgmsub.x
blob: ae969bbaecb93a2de4a2494e39f2cfc390dee784 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# AP_HGMSUB -- Procedure to subtract a point from an existing  histogram.

procedure ap_hgmsub (hgm, nbins, z1, z2, skypix)

real	hgm[ARB]		# histogram
int	nbins			# number of bins
real	z1, z2			# range of histogram
real	skypix	               	# sky value

int	bin
real	dh

begin
	if (skypix < z1 || skypix > z2)
	    return
	dh = real (nbins - 1) / (z2 - z1)
	bin = int ((skypix - z1) * dh) + 1
	hgm[bin] = hgm[bin] - 1.0
end


# AP_HGMSUB2 -- Procedure to subract points from the accumulated sums
# and the existing histogram.

procedure ap_hgmsub2 (hgm, nbins, z1, z2, skypix, sky_zero, sumpx, sumsqpx,
	sumcbpx)

real	hgm[ARB]		# histogram
int	nbins			# number of bins
real	z1, z2			# range of histogram
real	skypix	               	# sky value
real	sky_zero		# sky zero point for moment analysis
double	sumpx			# sum of the sky pixel values
double	sumsqpx			# sum of the squares of the sky pixel values
double	sumcbpx			# sum of the cubes of the sky pixel values

double	dsky
int	bin
real	dh

begin
	if (skypix < z1 || skypix > z2)
	    return
	dsky = skypix - sky_zero
	sumpx = sumpx - dsky
	sumsqpx = sumsqpx - dsky ** 2
	sumcbpx = sumcbpx - dsky ** 3
	dh = real (nbins - 1) / (z2 - z1)
	bin = int ((skypix - z1) * dh) + 1
	hgm[bin] = hgm[bin] - 1.0
end