def import_hdf_nist_special(pth, filename, dset, output_cls_instance): """ Import data from HDF File as specified by NIST-specific settings Returns ------- Success : bool Whether import was successful """ print('\n') import_success = _hdf_import_data(pth, filename, dset, output_cls_instance) if import_success is False: raise ValueError('hdf_import_data failed') return False _meta_process(_snb(), output_cls_instance) return True
def import_hdf_nist_special_ooc(pth, filename, dset, output_cls_instance): """ Import data from HDF File (OUT-OF-CORE) as specified by NIST-specific settings Returns ------- Success : bool Whether import was successful """ print('\n') try: fid = lazy5.utils.FidOrFile(lazy5.utils.fullpath(filename, pth=pth)).fid output_cls_instance._data = fid[dset] output_cls_instance.meta = lazy5.inspect.get_attrs_dset(fid, dset) _meta_process(_snb(), output_cls_instance) except: raise ValueError('hdf_import_data failed') return False else: return fid
def import_hdf_nist_special(pth, filename, dset, output_cls_instance): """ Import data from HDF File as specified by NIST-specific settings Returns ------- Success : bool Whether import was successful """ print('\n') try: import_success = _hdf_import_data(pth, filename, dset, output_cls_instance) if import_success is None or import_success is False: raise ValueError('hdf_import_data returned None') _meta_process(_snb(), output_cls_instance) except: print('Something failed in import_hdf_nist_special') return False else: print('\n') return True
meta = _lazy5.inspect.get_attrs_dset(fid, dname) else: data = _np.vstack( (data, fid[dname][:].astype(dset_dtype_import))) ret = [data, meta] else: raise TypeError('output_cls must be Spectrum, Spectra, or Hsi') fid.close() return ret if __name__ == '__main__': # pragma: no cover from crikit.io.meta_configs import (special_nist_bcars2 as _snb) rosetta = _snb() pth = '../' filename = 'mP2_w_small.h5' dset = '/Spectra/Dark_3_5ms_2' tester = _lazy5.inspect.valid_dsets(pth=pth, file='fake.h5', dset_list='fake') assert not tester tester = _lazy5.inspect.valid_dsets(pth=pth, file='fake.h5', dset_list='fake_dset') assert not tester
# dset.attrs.create(attr_key,bc_attr_dict[attr_key]) # except: # print('Could not create attribute') except: print('Something went wrong while saving') else: print('Saved without issues') finally: f_out.close() if __name__ == '__main__': # pragma: no cover from crikit.io.meta_configs import (special_nist_bcars2 as _snb) rosetta = _snb() pth = '../../../' filename = 'mP2_w_small.h5' dset = '/Spectra/Dark_3_5ms_2' tester = hdf_is_valid_dsets(pth, 'fake.h5','fake') assert tester == False tester = hdf_is_valid_dsets(pth, filename,'fake_dset') assert tester == False tester = hdf_is_valid_dsets(pth, filename,['fake_dset1','fake_dset2']) assert tester == False tester = hdf_is_valid_dsets(pth, filename,dset)