InstrumentParameters.java
5.97 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package osp;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
/*
* Class to read or to configure the instrument parameters.
*/
public class InstrumentParameters {
public static double _PXSZ; // detector pixel size projected in the CSU, in mm/px
public static double _PLTSC; // GTC plate scale in arcseg/mm
public static double _OFFSET_X; // shift in virt. pixs between the CSU and detector
public static double _SAFE_PARAMETER; // safe parameter to safety unused slits opening for detector
public static double _OFFSET_IPA; // offset Angle
// columns nb for the Emir parameters file
public static int _nbColFi0=1;
// lines nb for the Emir parameters file
public static int _nbLiFi0=5;
// columns nb for the Yv_barras parameters file
public static int _nbColFi1=3;
// lines nb for the Yv_barras parameters file
public static int _nbLiFi1=111;
// columns nb for the X calibrations values parameters file
public static int _nbColFi2=111;
//lines nb for the X calibrations values parameters file
public static int _nbLiFi2=2056;
private String filter;
private String grism;
public boolean filterSet;
public boolean grismSet;
private double tabParams [][];
private double tabYVirtuals [][];
private double tabXVirtuals [][];
private int nbcol=0;
private int nbli=0;
/**
*
* @param projectCompletePath : path for the config files.
*/
public InstrumentParameters(String projectCompletePath)
{
// loads instruments parameters
String fileName="calibration/EMIR_parameters.dat";
nbcol=_nbColFi0;
nbli=_nbLiFi0;
File fiTelescope= new File(fileName);
tabParams=loadInstrumentParameters(fiTelescope, nbcol, nbli);
_PXSZ=tabParams[0][0];
_PLTSC=tabParams[0][1];
_OFFSET_X=tabParams[0][2];
_SAFE_PARAMETER=tabParams[0][3];
_OFFSET_IPA=tabParams[0][4];
//System.out.println("Inst param tab "+ tabParams[0][0]+ " "+ tabParams[0][1]+ " "+tabParams[0][2]+ " "+tabParams[0][3]+ " "+tabParams[0][4]);
// Load Y bars
fileName="calibration/EMIR_yv_bars.dat";
nbcol=_nbColFi1;
nbli=_nbLiFi1;
File fiy= new File(fileName);
tabYVirtuals=loadInstrumentParameters(fiy, nbcol, nbli);
//System.out.println("Inst param tab "+ tabYVirtuals[2][10]+ " "+ tabYVirtuals[0][100]);
// load CSU values
fileName="calibration/EMIR_CSUcal.dat";
//System.out.println("Inst param tab file : "+fileName);
File fix= new File(fileName);
nbcol=_nbColFi2;
nbli=_nbLiFi2;
tabXVirtuals=loadInstrumentParameters(fix, nbcol, nbli);
//System.out.println("Inst param tab "+ tabXVirtuals[110][2040]+" "+tabXVirtuals[1][2001]);
}
public double[][] getTabX()
{
return tabXVirtuals;
}
public double getTabY(int i, int j)
{
return tabYVirtuals[i][j];
}
public double [][] loadInstrumentParameters(File catFile, int nbcol, int nbli)
{
double tab[][]=new double [nbcol][nbli];
// boolean paramFile=false;
try
{
// Prepare to read from the file, using a Scanner object
Scanner in = new Scanner(catFile);
String line=null;
int liNb=0;
int colNb=0;
// Read each line until end of file is reached
while (in.hasNextLine())
{
// Read an entire line, which contains all the details for 1 account
line = in.nextLine();
// if (paramFile) System.out.println("LoadParam line read "+line);
// Make a Scanner object to break up this line into parts
Scanner lineBreaker = new Scanner(line);
String firstChar = null;
String firstField = null;
boolean read=true;
if (lineBreaker.hasNext())
{
firstField=lineBreaker.next();
firstChar=firstField.substring(0,1);
}
if ((!firstChar.isEmpty()) && (!firstChar.equals("#")))
{
// 1st part is the account number
tab[colNb][liNb]=Double.parseDouble(firstField);
colNb++;
try
{
while (lineBreaker.hasNext())
{
String field = null;
field=lineBreaker.next();
firstChar=field.substring(0,1);
if (firstChar.equals("#"))
{
read=false;
}
if (read)
{
Double d=Double.parseDouble(field);
tab[colNb][liNb]=d;
//tab[colNb][liNb]=lineBreaker.nextDouble();
// System.out.println("Inst Param field "+tab[colNb][liNb]);
colNb++;
}
}
// tab[colNb][liNb]=lineBreaker.nextDouble();
liNb++;
colNb=0;
}
catch (InputMismatchException e)
{
System.out.println("File "+ catFile.getName() +" got pbs in loading");
}
catch (NoSuchElementException e)
{
System.out.println("File "+ catFile.getName() +" not found.2");
}
}
lineBreaker.close();
} // End while
// bip = bip +" li "+liNb;
//System.out.println("IntsrumParam loadInstrum "+bip);
in.close();
}
catch (FileNotFoundException e)
{
System.out.println("File "+ catFile.getAbsoluteFile() +" not found.0");
} // Make an ArrayList to store all the accounts we will make
return tab;
} // End LoadIntrumentParameters
}