Created
January 22, 2016 16:46
-
-
Save antonl/a05b5a4559a7a4fce3bb to your computer and use it in GitHub Desktop.
Glueviz config file for opening transient grating datasets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from glue.config import data_factory | |
from glue.core import Data, Component | |
from h5py import File | |
import numpy as np | |
def is_nudie_file(filename, **kwargs): | |
'''checks that the given file is a nudie file''' | |
if not filename.endswith('.h5'): | |
return False | |
with File(filename) as f: | |
if 'nudie version' in f.attrs: | |
return True | |
return False | |
def null_loader(f): | |
raise RuntimeError('unknown experiment type') | |
@data_factory('nudie analysis file loader', identifier=is_nudie_file, priority=110) | |
def read_nudie(filename): | |
with File(filename) as f: | |
# dispatch to appropriate loader | |
datas = nudie_loader_map.get(f.attrs['experiment type'], null_loader)(f) | |
return datas | |
def _load_stark_tg(f): | |
data = Data(label=f.attrs['batch_name']) | |
data.add_component(np.real(f['phased transient-grating'][:, 0, :]), | |
'field-on') | |
data.add_component(np.real(f['phased transient-grating'][:, 1, :]), | |
'field-off') | |
det_axes = Data(label=f.attrs['batch_name']+'-det-axes') | |
det_axes.add_component(np.array(f['axes/detection wavelength']), 'detection wavelength') | |
return [data, det_axes] | |
nudie_loader_map = {'stark transient-grating': _load_stark_tg,} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment