Data format¶
The HDF5 file format is used as a container for all data in INTEGRATE. Each HDF5 file can contain multiple data sets (typically arranged in matrix format) with associated attributes that describe the data. HDF View is useful to inspect the content of HDF5 files.
The following HDF files are used for any INTEGRATE project
DATA.h5 : Stores observed data, and its associated geometry.
PRIOR.h5: Stores realizations of the prior model, and corresponding forward response
POST.h5: stores index of posterior realizations, as well as posterior statistics
DATA.h5¶
DATA.h5 contains observed data, and its associated geometry. The observed data can be of many types, such as TEM data and well-log data
A DATA.h5 file can be created from an AarhusInv-style XYZ data file and its
corresponding GEX system file using integrate.integrate_io.xyz_to_h5(), which reads
both formats with the libaarhusxyz library [libaarhusxyz].
xyz_to_h5 also reads the data of a Workbench inversion node, i.e. the
*_dat.xyz (observed data used in the inversion) and *_syn.xyz (forward
response of the inverted models) exports. These hold the gates of all moments
in one merged block; the gates are mapped onto the used gates of the GEX file by
gate time, and soundings processed with another GEX file are dropped. See
Validate the EM forward models against Aarhus Workbench (tTEM).
By default, observed data in /D1 is compared with prior data in /D1, /D2 with /D2, etc.
To compare observed data with a different prior dataset, set the /D1/id_prior field.
For example, setting /D1/id_prior=2 will compare observed /D1 with prior /D2.
Note
When save_data_multinomial() is called without an explicit id=, it
auto-assigns the next free /D{id} slot by scanning ids 1 through 99. A
DATA.h5 file can therefore currently hold at most 99 auto-numbered
/D{id} datasets — once /D1-/D99 all exist, further calls
without an explicit id= will silently overwrite /D99 instead of
creating a new dataset. If you need more than 99 data types in one file,
pass an explicit id= (e.g. id=100), which has no such limit.
Dimensions used in the tables below:
Np: number of data locations (typically one set of data per unique X-Y location)Ndi: number of data pointsNdper data typeiper locationNclass: number of classes
The datasets UTMX, UTMY, ELEVATION, and LINE are mandatory for most plotting routines in INTEGRATE,
but are not used in the inversion itself.
The attribute D1/noise_model is mandatory for all data types, and describes the noise model used for the data.
All data sets (/Dn in DATA.h5 and PRIOR.h5, and /Mn in PRIOR.h5) can have the optional attributes
name, label and unit, which are used by the plotting routines:
name: short human-readable name, used in titles (e.g.'Resistivity','dBdT').label: text used on axes and colorbars. If not set,nameis used.unit: unit of the quantity (e.g.'ohm-m','V/Am^4'). Axes are labelled"LABEL (UNIT)", or"LABEL"if no unit is set. A trailing^nin the unit is shown as a superscript; LaTeX math ($...$) can also be used.
They can be given when saving (e.g. ig.save_data_gaussian(..., label='dB/dt', unit='V/Am^4')),
and set, changed or removed later with ig.data_set(f_h5, id=1, ...) for /Dn (DATA.h5 or PRIOR.h5)
and ig.prior_set(f_prior_h5, im=1, ...) for /Mn.
If none of them are set, axes are labelled with the name of the group: M1 for a model /M1,
D3 for prior data /D3, and D1_obs (D1_std) for observed data /D1 in DATA.h5.
Dataset |
Format |
Attribute |
Mandatory |
Description |
|---|---|---|---|---|
/UTMX |
[Np,1] |
(*) |
X - location of data points |
|
/UTMY |
[Np,1] |
(*) |
Y - location of data points |
|
/ELEVATION |
[Np,1] |
(*) |
Elevation at data points |
|
/LINE |
[Np,1] |
(*) |
Linenumber at data points |
|
/D1/noise_model |
[string] |
A string describing the noise model used for the data. |
||
/D1/id_prior |
[integer] |
The prior dataset ID to compare against. Observed data in /D1 will be compared with prior data in /D{id_prior} during inversion. If not set, defaults to the same ID as the observed data (D1→D1, D2→D2, etc.) |
||
/D1/name |
[string] |
Optional name of this dataset (e.g. |
||
/D1/label |
[string] |
Optional axis/colorbar label of the data (e.g. |
||
/D1/unit |
[string] |
Optional unit of the data (e.g. |
||
/D1/i_use |
[NP,1] int [0/1] |
Determines whether a data point should be used or not. All data are used by default |
The format of the observed data, and the associate uncertainty, depends on the type of data, and the choice of noise model.
See the function integrate.integrate_io.load_data() for an example of how to read DATA.h5 files.
Gaussian noise - continuous data¶
For continuous data and the multivariate Gaussian noise model can be chosen by setting the attribute D1/noise_model=gaussian
Dataset |
Format |
Attribute |
Mandatory |
Description |
|---|---|---|---|---|
/D1/noise_model |
[string]=’gaussian’ |
A string describing the noise model used for the data. Here |
||
/D1/d_obs |
[Np,Nd1] |
Observed data (#1) |
||
/D1/d_std |
[Np,Nd1] |
Standard deviation of observed data (db/dT). Is the size is [1,Nd], the same |
||
/D1/Cd |
[Nd1,Nd1] or [Np,Nd1,Nd1] |
Correlated noise matrix. Shared by all data when [Nd1,Nd1]; each data observation has its own when [Np,Nd1,Nd1]. |
||
/D1/i_lm |
[Nlm,1] |
0-indexed gate numbers used for the low moment (written by |
||
/D1/i_hm |
[Nhm,1] |
0-indexed gate numbers used for the high moment (written by |
||
/D1 attribute |
string |
Path of the GEX system file that was used to read the data. |
||
– |
Multinomial noise - discrete data¶
For discrete data the multinomial distribution can be used as likelihood by setting the attribute D1/noise_model=multinomial
Dataset |
Format |
Attribute |
Mandatory |
Description |
|---|---|---|---|---|
/D2/noise_model |
[string]=’multinomial’ |
The multinomial distribution is used as likelihood model for the data. |
||
/D2/d_obs |
[Np,Nclass,Nm] |
Observed data (class probabilities) |
||
/D2/i_use |
[Np,1] |
Binary indicator of whether a data point should be used or not |
PRIOR.h5¶
PRIOR.h5 contains N realizations of a prior model (represented as potentially multiple types of model parameters, such as resistivity, lithology, grainsize,….), and corresponding data (consisting of potentially multiple types of data, such as tTEM, SkyTEM, WellData,..)
N: Number of realizations of the prior model
Nm1: Number of model parameters of type 1
Nm2: Number of model parameters of type 2
NmX: Number of model parameters of type X
Dataset |
Format |
attribute |
Mandatory |
Description |
|---|---|---|---|---|
/M1 |
[N,Nm1] |
N realizations of model parameter 1, each consisting of Nm1 model parameters |
||
/M1/x |
[nm] |
Array of values describing each value in M1 (e.g. depth to top of layer) |
||
/M1/name |
[string] |
Name of model parameter /M1, used in titles |
||
/M1/label |
[string] |
Axis/colorbar label of /M1 (default: |
||
/M1/unit |
[string] |
Unit of /M1 (e.g. |
||
/M1/is_discrete |
[nm] |
[0/1] described whether /M1 is a discrete or continuous parameter |
||
/M1/class_id |
[1,n_class] |
A list of |
||
/M1/class_name |
[1,n_class] |
A list of |
||
/M1/clim |
[1,2] |
Min and maximum value for colorbar |
||
/M1/cmap |
[3,nlev] |
Colormap with |
||
/M2 |
[N,Nm2] |
N realizations of model parameter 2, each consisting of Nm2 model parameters |
||
/Mx |
[N,NmX] |
N realizations of model parameter X, each consisting of NmX model parameters |
Dataset |
Format |
attribute |
Mandatory |
Description |
|---|---|---|---|---|
/D1 |
[N,Nd1] |
N realizations of data number 1,
each consisting of |
||
/D1/name, /D1/label, /D1/unit |
[string] |
Optional, as for DATA.h5 (see name, label and unit). |
||
/D1/f5_forward |
[string] |
Set to |
||
/D1/with_noise |
[1] |
Indicates whether noise was added to the data[1] or not[0]. |
||
/D2 |
[N,Nd2] |
N realizations of data number 2,
each consisting of |
/D1 is only mandatory when PRIOR.h5 is used for inversion
All the mandatory attributes specified for /M1 are also mandatory for other attributes, i.e. /M1, /M2, … .
Forward model attributes on /D<id>¶
The EM forward backends (see integrate.integrate.prior_data_em()) record
how the data were computed as attributes of each /D<id> dataset:
Attribute |
Value |
Meaning |
|---|---|---|
|
|
Time-domain EM data. |
|
|
Forward backend that computed the data (see Prior Data Generation). |
|
integer |
Model and data index. |
|
bool |
Whether the data are stored as log10 values. |
|
string, integer |
Torch device and batch size used. |
|
integer |
Hankel and frequency sampling of the GA-AEM run. |
Identity data written by integrate.integrate.prior_data_identity() have
no method attribute. Their /D<id> carries f5_forward='none' and
with_noise=0 instead.
Note
The method values 'tdem' and 'log' that appeared in earlier
versions of this page do not exist. The forward model is selected by the
method= keyword of prior_data_em, not read from a FORWARD.h5 file.
POST.h5¶
At the very minimum POST.h5 needs to contain the index (in PRIOR.h5) of realizations from the posterior.
Statistics are written by integrate.integrate.integrate_posterior_stats().
Np: Number of data locations.
Nr: Number of posterior realizations per location.
Nm: Number of model parameters (e.g. depth layers) for a given model type.
Nclass: Number of discrete classes for a given model type.
Dataset |
Format |
Attribute |
Mandatory |
Description |
|---|---|---|---|---|
/i_use |
[Np, Nr] |
Indices (into PRIOR.h5) of posterior realizations for each data location. |
||
/T |
[Np, 1] |
Annealing temperature used during inversion. |
||
/EV |
[Np, 1] |
Log-evidence at each data location. |
||
/EV_post |
[Np, Nr] |
Log-evidence of each posterior realization (written by |
||
/EV_post_mean |
[Np, 1] |
Mean of |
||
/CHI2 |
[Np, Nd] |
Reduced chi-squared (χ²/ν) goodness-of-fit metric per data type. Values near 1 indicate good fit; >1 underfit; <1 overfit. |
||
/N_UNIQUE |
[Np] |
Number of unique prior realizations used at each data location. Written by |
||
/UTMX |
[Np] |
X-coordinate, copied from DATA.h5 (written when |
||
/UTMY |
[Np] |
Y-coordinate, copied from DATA.h5. |
||
/ELEVATION |
[Np] |
Elevation, copied from DATA.h5. |
||
/LINE |
[Np] |
Line number, copied from DATA.h5. |
The file-level attributes of POST.h5 record the inputs of the run:
Attribute |
Meaning |
|---|---|
|
Path of the PRIOR HDF5 file used. |
|
Path of the DATA HDF5 file used. |
|
Number of prior realizations used. |
|
Start and end time, and elapsed time of the rejection run. |
Continuous parameters¶
Written for each continuous model parameter /Mx (is_discrete=0) by
integrate.integrate.integrate_posterior_stats().
Dataset |
Format |
Written |
Description |
|---|---|---|---|
/Mx/Mean |
[Np, Nm] |
always |
Arithmetic mean of the posterior realizations at each location and depth. |
/Mx/LogMean |
[Np, Nm] |
always |
Geometric mean: exp(mean(log(values))). Appropriate for log-normally distributed parameters such as resistivity. |
/Mx/Median |
[Np, Nm] |
always |
Median of the posterior realizations. |
/Mx/Std |
[Np, Nm] |
always |
Standard deviation of the posterior realizations in linear (parameter) space. Units match the parameter (e.g. Ohm-m for resistivity). |
/Mx/LogStd |
[Np, Nm] |
always |
Standard deviation of log10(posterior). Dimensionless measure of spread on the logarithmic scale. Use this for visualisation of uncertainty in log-normally distributed parameters such as resistivity. |
/Mx/HarmonicMean |
[Np, Nm] |
always |
Trimmed harmonic mean: posterior samples are converted to conductivity (1/resistivity), trimmed 10% from each tail, averaged, then inverted back to resistivity. More robust to high-resistivity outliers than the arithmetic mean. |
/Mx/KL |
[Np, Nm] |
|
KL divergence D_KL(posterior ∥ prior) in bits (log base 2), estimated from log10-space histograms (50 bins). No fixed upper bound for continuous parameters. |
Discrete parameters¶
Written for each discrete model parameter /Mx (is_discrete=1) by
integrate.integrate.integrate_posterior_stats().
Dataset |
Format |
Written |
Description |
|---|---|---|---|
/Mx/Mode |
[Np, Nm] |
always |
Most probable class (class_id value) at each location and depth. |
/Mx/Entropy |
[Np, Nm] |
always |
Shannon entropy of the posterior class probabilities, normalised by log(Nclass). Range [0, 1]: 0 = certain, 1 = maximally uncertain. |
/Mx/P |
[Np, Nclass, Nm] |
always |
Posterior probability of each class at each location and depth. |
/Mx/KL |
[Np, Nm] |
|
KL divergence D_KL(posterior ∥ prior) normalised to [0, 1] using log_base = Nclass (read from |
Compression in HDF5 files¶
HDF5 files written by INTEGRATE are compressed by default to reduce file sizes while keeping I/O reasonable. The default is gzip level 1:
Default:
gziplevel 1 (about 3.5× file size reduction, about 78% faster than level 9)Performance: Write overhead of about 3× compared to no compression, but much smaller files
Customizable: Set
compressionandcompression_optsper call. The defaults differ by function, see below.
Per-function Configuration¶
Example usage:
import integrate as ig
# Use default compression (gzip level 1)
ig.prior_model_layered(N=50000)
# Custom compression level
ig.prior_model_layered(N=50000, compression='gzip', compression_opts=4)
# Fast LZF compression
ig.prior_model_layered(N=50000, compression='lzf')
# Disable compression for temporary files
ig.prior_model_layered(N=50000, compression=False)
# Same parameters work for data functions
ig.save_data_gaussian(D_obs, compression='gzip', compression_opts=9)
The prior-file writers save_prior_model and save_prior_data default to
gzip level 1. prior_model_layered passes compression on only when
you give it. To compress prior files differently, pass the setting explicitly.
Global Default Configuration¶
The module-wide defaults in integrate_io.py are used only by the data
writers save_data_gaussian and save_data_multinomial when no
compression argument is given:
import integrate.integrate_io as io
io.DEFAULT_COMPRESSION = 'lzf' # Options: 'gzip', 'lzf', or None
io.DEFAULT_COMPRESSION_OPTS = 4 # For gzip: 1-9 (1=fastest, 9=smallest)
# Uses lzf from now on
ig.save_data_gaussian(D_obs)
# Prior files are not affected; they still default to gzip level 1
ig.prior_model_layered(N=50000)
Compression Performance Comparison¶
Based on benchmarks with N=50,000 models:
Setting |
Write Speed |
File Size |
Best For |
|---|---|---|---|
|
Fastest |
19.7 MB |
Temporary files |
|
Fast |
5.6 MB (3.5×) |
Default (best balance) |
|
Very Fast |
~6-7 MB (2-3×) |
Speed-critical workflows |
|
Medium |
5.5 MB (3.6×) |
Good alternative |
|
Slowest (1.51s) |
5.5 MB (3.6×) |
Long-term archival (diminishing returns) |
Note: The difference between gzip levels 1 and 9 is only ~2% in file size but 4.6× difference in write time. Level 1 is recommended for most use cases.
Functions Supporting Compression¶
All HDF5 write functions accept compression and compression_opts parameters:
save_prior_model()- Model parameter arrays (default gzip level 1)save_prior_data()- Forward-modeled data (default gzip level 1)save_data_gaussian()- Observed data with Gaussian noise model (module default)save_data_multinomial()- Observed data with multinomial noise model (module default)prior_model_layered()- Passescompressionandcompression_optsto its internal saves when given
Examples¶
Examples that write and read these files: