Read Entire IDS
This example focuses on reading whole IDS from entry.
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 | // We are storing and reading back an IDS - equilibrium. Data are stored inside MDS+ file.
public static void readEntireIDS() throws Exception {
try {
// NOTE: this block of code uses 'FORCE_CREATE_PULSE' mode in order to create example data
int dataEntry = imas.open("imas:mdsplus?path=./testdb_mdsplus", LowLevel.FORCE_CREATE_PULSE);
// fill IDS with example data
imas.equilibrium emptyEquilibrium = new imas.equilibrium();
emptyEquilibrium.ids_properties.homogeneous_time = LowLevel.IDS_TIME_MODE_HOMOGENEOUS;
double[] timeArray = {1.0, 2.0, 3.0};
double[] b0Array = {1.0, 2.0, 3.0};
emptyEquilibrium.time = new Vect1DDouble(timeArray);
emptyEquilibrium.vacuum_toroidal_field.b0 = new Vect1DDouble(b0Array);
emptyEquilibrium.put(dataEntry, "equilibrium", emptyEquilibrium);
imas.close(dataEntry);
// NOTE: this block of code uses 'OPEN_PULSE' mode in order to read example data
int dataEntry1 = imas.open("imas:mdsplus?path=./testdb_mdsplus", LowLevel.OPEN_PULSE);
imas.equilibrium savedEquilibrium = imas.equilibrium.get(dataEntry1, "equilibrium");
// here you can access content of the IDS equilibrium
// someVariable = savedEquilibrium.some_element
// savedEquilibrium.some_element = ...
// etc.
// one may check if IDS was filled with data using <ids>.isDefined() method
System.out.println("\nis equilibrium defined?: " + savedEquilibrium.isDefined());
imas.close(dataEntry1);
} catch (Exception e) {
System.err.println("Following exception occurred\n" + e.getMessage());
throw e;
}
}
|