19 for(
int i = 0; i < HIST_ALLDIM; i++) {
20 abscissa_dim += hist->
axes[i].
n ? 1 : 0;
23 int* abscissa_n_slots = (
int*) malloc(abscissa_dim *
sizeof(
int));
24 double* abscissa_min = (
double*) malloc(abscissa_dim *
sizeof(
double));
25 double* abscissa_max = (
double*) malloc(abscissa_dim *
sizeof(
double));
26 char** abscissa_names = (
char**) malloc(abscissa_dim *
sizeof(
char*));
27 char** abscissa_units = (
char**) malloc(abscissa_dim *
sizeof(
char*));
30 for(
int i = 0; i < HIST_ALLDIM; i++) {
31 if(!hist->
axes[i].
n) {
34 abscissa_min[k] = hist->
axes[i].
min;
35 abscissa_max[k] = hist->
axes[i].
max;
36 abscissa_n_slots[k] = hist->
axes[i].
n;
41 abscissa_names[k] =
"r";
42 abscissa_units[k] =
"m";
45 abscissa_names[k] =
"phi";
46 abscissa_units[k] =
"deg";
51 abscissa_names[k] =
"z";
52 abscissa_units[k] =
"m";
55 abscissa_names[k] =
"rho";
56 abscissa_units[k] =
"1";
59 abscissa_names[k] =
"theta";
60 abscissa_units[k] =
"deg";
65 abscissa_names[k] =
"ppar";
66 abscissa_units[k] =
"kg*m/s";
69 abscissa_names[k] =
"pperp";
70 abscissa_units[k] =
"kg*m/s";
73 abscissa_names[k] =
"pr";
74 abscissa_units[k] =
"kg*m/s";
77 abscissa_names[k] =
"pphi";
78 abscissa_units[k] =
"kg*m/s";
81 abscissa_names[k] =
"pz";
82 abscissa_units[k] =
"kg*m/s";
85 abscissa_names[k] =
"ekin";
86 abscissa_units[k] =
"eV";
91 abscissa_names[k] =
"pitch";
92 abscissa_units[k] =
"1";
95 abscissa_names[k] =
"mu";
96 abscissa_units[k] =
"T/eV";
99 abscissa_names[k] =
"ptor";
100 abscissa_units[k] =
"kg*m/s";
103 abscissa_names[k] =
"time";
104 abscissa_units[k] =
"s";
107 abscissa_names[k] =
"charge";
108 abscissa_units[k] =
"e";
113 char* ordinate_names[] = {
"distribution" };
114 char* ordinate_units[] = {
"s/(m^5*kg^2*deg*e)" };
118 f, path, abscissa_dim, ordinate_dim, abscissa_n_slots, abscissa_min,
119 abscissa_max, abscissa_units, abscissa_names, ordinate_units,
120 ordinate_names, hist->
bins);
121 free(abscissa_n_slots);
124 free(abscissa_names);
125 free(abscissa_units);
162 hid_t f,
const char *path,
int abscissaDim,
int ordinateDim,
163 int *abscissaNslots,
double *abscissaMin,
double *abscissaMax,
164 char **abscissaUnits,
char **abscissaNames,
165 char **ordinateUnits,
char **ordinateNames,
double *ordinate) {
170 hid_t
histogram = H5Gcreate2(f, path, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
177 dims[0] = ordinateDim;
178 for (
int i=0; i<abscissaDim; i++) {
179 dims[i+1] = abscissaNslots[i];
184 err = H5LTmake_dataset_double(
histogram ,
"ordinate", abscissaDim+1,
190 for(
int i=0; i<ordinateDim; i++) {
191 sprintf(temppath,
"name_%02d", i);
192 H5LTset_attribute_string(
histogram,
"ordinate", temppath,
194 sprintf(temppath,
"unit_%02d", i);
195 H5LTset_attribute_string(
histogram,
"ordinate", temppath,
202 err = H5LTmake_dataset_int(
histogram ,
"ordinate_ndim", 1, &dimsize,
208 err = H5LTmake_dataset_int(
histogram ,
"abscissa_ndim", 1, &dimsize,
216 for (
int i=0; i<abscissaDim; i++) {
218 double* abscissavec = (
double *) malloc( (dims[i+1]+1)*
sizeof(
double) );
219 for(
int j=0; j<dims[i+1]+1; j++) {
221 abscissaMin[i] + j * ( (abscissaMax[i] - abscissaMin[i])
222 / abscissaNslots[i] );
226 char abscissapath[256];
227 sprintf(abscissapath,
"abscissa_vec_%02d",i+1);
228 hsize_t abscissasize[1] = {abscissaNslots[i]+1};
229 err = H5LTmake_dataset_double(
histogram , abscissapath, 1, abscissasize,
238 sprintf(temppath,
"abscissa_nbin_%02d", i+1);
239 err = H5LTmake_dataset_int(
histogram, temppath, 1, &dimsize,
240 &(abscissaNslots[i]));
247 sprintf(temppath,
"name_%02d", i);
248 H5LTset_attribute_string(
histogram, abscissapath, temppath,
250 sprintf(temppath,
"unit_%02d", i);
251 H5LTset_attribute_string(
histogram, abscissapath, temppath,
int hdf5_histogram_write_uniform_double(hid_t f, const char *path, int abscissaDim, int ordinateDim, int *abscissaNslots, double *abscissaMin, double *abscissaMax, char **abscissaUnits, char **abscissaNames, char **ordinateUnits, char **ordinateNames, double *ordinate)
Write a histogram with uniform grid to HDF5 file.