Create IDS with Arrays of Structures (AoS)ΒΆ
This example focuses on creating empty IDS and allocating arrays inside IDS structure.
See also
API documentation for Vect1DDouble
public static void creatingCompletlyNewIDS() throws Exception {
try {
// empty IDS structures can be created without opening data entry
// all you have to do is to instantiate IDS object
imas.core_profiles emptyCoreProfiles = new imas.core_profiles();
// Note! Every IDS must have <ids>/ids_properties/homogeneous_time field set with one of possible values
// possible homogeneous_time values are:
// IDS_TIME_MODE_HETEROGENEOUS: All time-dependent quantities in the IDS may have different time coordinates.
// IDS_TIME_MODE_HOMOGENEOUS: All time-dependent quantities in this IDS use the same time coordinate, namely <ids>/time
// IDS_TIME_MODE_INDEPENDENT: The IDS stores no time-dependent data.
emptyCoreProfiles.ids_properties.homogeneous_time = LowLevel.IDS_TIME_MODE_HOMOGENEOUS;
// it is also recommended to provide basic information regarding data source
// even though this information is not required to store IDS, it is highly recommended
// to fill these fields.
// <ids>/ids_properties/comment
// <ids>/ids_properties/provider
// <ids>/ids_properties/creation_date
// when ids_properties.homogeneous_time is set to IDS_TIME_MODE_HOMOGENEOUS,
// all time-dependent fields values correspond to <ids>.time vector.
double[] timeArray = {1.0, 2.0, 3.0};
emptyCoreProfiles.time = new Vect1DDouble(timeArray);
// size of time dependent variables must be equal to the size of time vector
emptyCoreProfiles.global_quantities.ip = new Vect1DDouble(timeArray);
// IDSs fields can be printed.
System.out.println("\nSaved values of emptyCoreProfiles from creatingCompletlyNewIDS() function");
System.out.println("time: \n" + emptyCoreProfiles.time);
System.out.println("ip: \n" + emptyCoreProfiles.global_quantities.ip);
// some fields are automatically written by AL during 'put' procedure
// AL adds some information behind your back. This is particularly important
// in case you want later on find out what particular version of AL was used when data were stored.
// examples of this type of fields are <ids>/ids_properties/version_put and <ids>/ids_properties/plugins
// in Java we don't have to delate objects. Java garbage collector will do that for us.
} catch (Exception e) {
System.err.println("Following exception occurred\n" + e.getMessage());
throw e;
}
}
Output
Saved values of emptyCoreProfiles from creatingCompletlyNewIDS() function
time:
[1.0,2.0,3.0]
ip:
[1.0,2.0,3.0]