diff --git a/README.md b/README.md index 1b4f7fe7..214e68c6 100644 --- a/README.md +++ b/README.md @@ -65,9 +65,7 @@ from prospect.fitting import fit_model output = fit_model(observations, model, sps, **config) ``` -Another change is that spectral response functions (i.e. calibration vectors) are now handled by specialized sub-classes of these `Observation` classes. See `spectra`_ for details. - -.. _spectra: docs/spectra.rst +Another change is that spectral response functions (i.e. calibration vectors) are now handled by specialized sub-classes of these `Observation` classes. See the [spectroscopy docs](docs/spectra.rst) for details. Finally, the output chain or samples is now stored as a structured array, where each row corresponds to a sample, and each column is a parameter (possibly diff --git a/prospect/io/write_results.py b/prospect/io/write_results.py index cf3d312c..2d27c67a 100644 --- a/prospect/io/write_results.py +++ b/prospect/io/write_results.py @@ -5,10 +5,11 @@ to HDF5 files as well as to pickles. """ -import os, time, warnings -from copy import deepcopy -import pickle, json, base64 +import warnings +import pickle, json import numpy as np +from numpy.lib.recfunctions import structured_to_unstructured, unstructured_to_structured + try: import h5py _has_h5py_ = True @@ -223,6 +224,11 @@ def write_sampling_h5(hf, chain, extras): sdat = hf.create_group('sampling') sdat.create_dataset('chain', data=chain) + try: + uchain = structured_to_unstructured(chain) + sdat.create_dataset("unstructured_chain", data=uchain) + except: + pass for k, v in extras.items(): try: sdat.create_dataset(k, data=v) @@ -279,8 +285,7 @@ def chain_to_struct(chain, model=None, names=None, **extras): struct : A structured ndarray of parameter values. """ - indict = isinstance(chain, dict) - if indict: + if isinstance(chain, dict): return dict_to_struct(chain) else: n = np.prod(chain.shape[:-1]) @@ -296,6 +301,7 @@ def chain_to_struct(chain, model=None, names=None, **extras): dt += [(str(k), "