-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSinglePulseGainCalibService.java
More file actions
66 lines (54 loc) · 1.72 KB
/
SinglePulseGainCalibService.java
File metadata and controls
66 lines (54 loc) · 1.72 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package fact.calibrationservice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import stream.annotations.Parameter;
import stream.io.SourceURL;
import stream.io.CsvStream;
import stream.Data;
import fact.Constants;
import stream.service.Service;
/**
*
**/
public class SinglePulseGainCalibService implements Service {
Logger log = LoggerFactory.getLogger(SinglePulseGainCalibService.class);
boolean isInit = false;
public double[] integralSinglePulseGain;
@Parameter(
required = false,
description = "The path to the integral single pulse gain file."
)
SourceURL integralGainFile;
public void init() {
integralSinglePulseGain = new double[Constants.NUMBEROFPIXEL];
Data integralGainData = null;
try {
CsvStream stream = new CsvStream(integralGainFile, " ");
stream.setHeader(false);
stream.init();
integralGainData = stream.readNext();
for (int i = 0 ; i < Constants.NUMBEROFPIXEL ; i++){
String key = "column:" + (i);
integralSinglePulseGain[i] = (Double) integralGainData.get(key);
}
} catch (Exception e) {
log.error(
"Failed to load the integral single pulse gain file: {}",
e.getMessage());
e.printStackTrace();
}
}
public double[] getIntegralSinglePulseGain() {
if (isInit == false){
init();
isInit = true;
}
return integralSinglePulseGain;
}
@Override
public void reset() throws Exception {
}
public void setIntegralGainFile(SourceURL integralGainFile) {
this.integralGainFile = integralGainFile;
}
}