Skip to content

Commit ea7f3c8

Browse files
author
Lijun Zhang
committed
DM-7783: add HistogramTest class, add the unit tests and end to end test
1 parent 6a15922 commit ea7f3c8

File tree

2 files changed

+377
-15
lines changed

2 files changed

+377
-15
lines changed

src/firefly/java/edu/caltech/ipac/visualize/plot/Histogram.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class Histogram {
2525

2626
private int[] hist;
2727
private double histMin;
28-
private double histBinsiz;
28+
private double histBinsize;
2929
private double irafMin;
3030
private double irafMax;
3131

@@ -62,7 +62,7 @@ public Histogram(float[] float1dArray, double datamin, double datamax) {
6262
while (true) {
6363

6464
boolean redo_flag = false;
65-
histBinsiz =getHistBinSize(histMax );
65+
histBinsize =getHistBinSize(histMax );
6666
//reintialize the hist to 0
6767
Arrays.fill(hist, 0);
6868
int underflowCount = 0;
@@ -71,7 +71,7 @@ public Histogram(float[] float1dArray, double datamin, double datamax) {
7171
{
7272
if (!Double.isNaN(float1dArray[k]))
7373
{
74-
int i = (int) ((float1dArray[k] - histMin) / histBinsiz);
74+
int i = (int) ((float1dArray[k] - histMin) / histBinsize);
7575
if (i<0)
7676
{
7777
//redo_flag = true; /* hist_min was bad */
@@ -123,8 +123,8 @@ else if (i>HISTSIZ2)
123123

124124
if ((histMaxIndex - histMinIndex) < HISTSIZ) {
125125

126-
histMax = (histMaxIndex * histBinsiz) + histMin;
127-
histMin = (histMinIndex * histBinsiz) + histMin;
126+
histMax = (histMaxIndex * histBinsize) + histMin;
127+
histMin = (histMinIndex * histBinsize) + histMin;
128128
redo_flag = true; /* we can spread it out by factor of 2 */
129129
}
130130
} else {
@@ -203,7 +203,7 @@ private void printeDebugInfo(double hist_max, int underFlowCount, int overFlowCo
203203
if (SUTDebug.isDebug()) {
204204
System.out.println("histMin = " + histMin);
205205
System.out.println("hist_max = " + hist_max);
206-
System.out.println("histBinsiz = " + histBinsiz);
206+
System.out.println("histBinsize = " + histBinsize);
207207

208208

209209
System.out.println("underFlowCount = " + underFlowCount +
@@ -261,12 +261,12 @@ public double get_pct(double ra_value, boolean round_up) {
261261
System.out.println("goodpix = " + goodpix
262262
+ " goal = " + goal
263263
+ " i = " + i
264-
+ " histBinsiz = " + histBinsiz);
264+
+ " histBinsize = " + histBinsize);
265265
}
266266
if (round_up)
267-
return ((i + 1.0) * histBinsiz + histMin);
267+
return ((i + 1.0) * histBinsize + histMin);
268268
else
269-
return ((i) * histBinsiz + histMin);
269+
return ((i) * histBinsize + histMin);
270270
}
271271

272272
/**
@@ -298,15 +298,15 @@ public double getDNMax() {
298298
* @return The DN value in the image corresponding to the specified bin
299299
*/
300300
public double getDNfromBin(int bin) {
301-
return (bin * histBinsiz + histMin);
301+
return (bin * histBinsize + histMin);
302302
}
303303

304304
/**
305305
* @param dn The DN value
306306
* @return The histogram index corresponding to the DN value
307307
*/
308308
public int getBinfromDN(double dn) {
309-
int bin = (int) ((dn - histMin) / histBinsiz);
309+
int bin = (int) ((dn - histMin) / histBinsize);
310310
if (bin >= HISTSIZ2)
311311
bin = HISTSIZ2 - 1;
312312
if (bin < 0)
@@ -321,7 +321,7 @@ public int getBinfromDN(double dn) {
321321
*/
322322
public int getBINfromPercentile(double pct, boolean round_up) {
323323
double dn = get_pct(pct, round_up);
324-
int bin = (int) ((dn - histMin) / histBinsiz);
324+
int bin = (int) ((dn - histMin) / histBinsize);
325325
if (bin >= HISTSIZ2)
326326
bin = HISTSIZ2 - 1;
327327
if (bin < 0)
@@ -336,7 +336,7 @@ public int getBINfromPercentile(double pct, boolean round_up) {
336336
*/
337337
public int getBINfromSigma(double sigma, boolean round_up) {
338338
double dn = get_sigma(sigma, round_up);
339-
int bin = (int) ((dn - histMin) / histBinsiz);
339+
int bin = (int) ((dn - histMin) / histBinsize);
340340
if (bin >= HISTSIZ2)
341341
bin = HISTSIZ2 - 1;
342342
if (bin < 0)
@@ -361,14 +361,14 @@ public double[] getTblArray() {
361361
while (hist_index < HISTSIZ2 && tblindex < 255) {
362362

363363
if (accum >= next_goal) {
364-
tbl[tblindex++] = (hist_index * histBinsiz + histMin);
364+
tbl[tblindex++] = (hist_index * histBinsize + histMin);
365365
next_goal += goodpix_255;
366366
} else {
367367
accum += hist[hist_index++];
368368
}
369369
}
370370
while (tblindex < 255)
371-
tbl[tblindex++] = hist_index * histBinsiz + histMin;
371+
tbl[tblindex++] = hist_index * histBinsize + histMin;
372372
tbl[255] = Double.MAX_VALUE;
373373
return tbl;
374374
}

0 commit comments

Comments
 (0)