Skip to content

Commit

Permalink
Starts a new i18 loader and fixes centering propogation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nicwade committed Apr 25, 2016
1 parent e9b97a6 commit 6c4671c
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 30 deletions.
4 changes: 0 additions & 4 deletions savu/data/data_structures/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@ def __getitem__(self, index):
size = [len(np.arange(i.start, i.stop, i.step)) for i in index]
data = np.empty(size)
tiffidx = [i for i in range(len(index)) if i not in self.frame_dim]
# print "original = ", index
index, frameidx = self.__get_indices(index, size)

for i in range(len(frameidx)):
# print "amended = ", index[i]
# print frameidx[i], [index[i][n] for n in tiffidx]
data[index[i]] = \
self.start_file.getframe(self.start_no + frameidx[i])\
.data[[index[i][n] for n in tiffidx]]
Expand All @@ -74,7 +71,6 @@ def __get_file_name(self, folder):
self.nFrames = len(files)
fname = sorted(files)[0]
self.start_no = [int(s) for s in re.findall(r'\d+', fname)][-1]
print "start number is", self.start_no
return folder + "/" + fname

def get_shape(self):
Expand Down
2 changes: 1 addition & 1 deletion savu/data/data_structures/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def __add_preview_defaults(self, plist):
def _unset_preview(self):
""" Unset preview (revert=True) if it was only required in the plugin.
"""
self.set_preview([])
self._data_obj.set_shape(self.revert_shape)
self.set_preview([])
self.revert_shape = None

def __set_starts_stops_steps(self, starts, stops, steps, chunks,
Expand Down
1 change: 0 additions & 1 deletion savu/plugins/driver/plugin_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"""
import logging
import copy
import numpy as np
from mpi4py import MPI

Expand Down
1 change: 0 additions & 1 deletion savu/plugins/filters/vo_centering.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def _scan(self, cor_positions, in_sino):
return cor_positions[vv.argmin()]

def filter_frames(self, data):
print "in filter frames of centering algorithm", data[0].shape
data = data[0][::self.parameters['step']]
width = data.shape[1]/16
step = width/10.
Expand Down
36 changes: 20 additions & 16 deletions savu/plugins/loaders/i18_mm_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,26 @@ def setup(self):
# logging.debug('This file contains an fluo')
# except:
# logging.warn('This file does not contain an fluo')
try:
self.setup_loader(I18xrdLoader(), self.parameters.copy())
logging.debug('This file contains an xrd')
except:
logging.warn('This file does not contain an xrd')
try:
self.setup_loader(I18stxmLoader(), self.parameters.copy())
logging.debug('This file contains an stxm')
except:
logging.warn('This file does not contain an stxm')

try:
self.setup_loader(I18monitorLoader(), self.parameters.copy())
logging.debug('This file contains a monitor')
except:
logging.warn('This file does not contain an monitor')

print self.parameters.copy()
self.setup_loader(I18xrdLoader(), self.parameters.copy())

# try:
# self.setup_loader(I18xrdLoader(), self.parameters.copy())
# logging.debug('This file contains an xrd')
# except:
# logging.warn('This file does not contain an xrd')
# try:
# self.setup_loader(I18stxmLoader(), self.parameters.copy())
# logging.debug('This file contains an stxm')
# except:
# logging.warn('This file does not contain an stxm')
#
# try:
# self.setup_loader(I18monitorLoader(), self.parameters.copy())
# logging.debug('This file contains a monitor')
# except:
# logging.warn('This file does not contain an monitor')

def setup_loader(self, loader, params):
logging.debug('I am here')
Expand Down
28 changes: 28 additions & 0 deletions savu/plugins/loaders/multi_modal_loaders/i18_loaders/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2014 Diamond Light Source Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
All the plugin architecture for Savu is contained here
.. moduleauthor:: Mark Basham <scientificsoftware@diamond.ac.uk>
"""

from os.path import dirname, basename, isfile
import glob
modules = glob.glob(dirname(__file__)+"/*.py")
__all__ = [ basename(f)[:-3] for f in modules if isfile(f)]
print __all__

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
from savu.plugins.utils import register_plugin
import h5py
import tempfile
import os

import savu.test.test_utils as tu


@register_plugin
Expand Down Expand Up @@ -75,7 +78,7 @@ def setup(self):
self.add_patterns_based_on_acquisition(data_obj, 'xrd')
self.set_data_reduction_params(data_obj)

calibrationfile = h5py.File(self.parameters['calibration_path'], 'r')
calibrationfile = h5py.File(self.get_cal_path(), 'r')

mData = data_obj.meta_data
det_str = 'entry/instrument/detector'
Expand All @@ -91,7 +94,14 @@ def setup(self):
mData.set_meta_data("x_pixel_size",
calibrationfile[det_str + '/x_pixel_size'].value)
mData.set_meta_data("detector_orientation",
calibrationfile[det_str + '/detector_orientation'].value)
calibrationfile[det_str +
'/detector_orientation'].value)

self.set_data_reduction_params(data_obj)
calibrationfile.close()

def get_cal_path(self):
path = self.parameters['calibration_path']
if path.split(os.sep)[0] == 'Savu':
path = tu.get_test_data_path(path.split('/test_data/data')[1])
return path
2 changes: 1 addition & 1 deletion savu/plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class docstring such as this
"""
for clazz in inspect.getmro(self.__class__)[::-1]:
if clazz != object:
full_description = pu.find_args(clazz)
full_description = pu.find_args(clazz, self)
for item in full_description:
self.parameters[item['name']] = item['default']
self.parameters_types[item['name']] = item['dtype']
Expand Down
13 changes: 11 additions & 2 deletions savu/plugins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,22 @@ def check_nDatasets(exp, names, plugin_dict, nSets, dtype):
return names


def find_args(dclass):
def find_args(dclass, inst=None):
"""
Finds the parameters list from the docstring
"""
docstring = None
if not dclass.__doc__:
if inst:
inst._override_class_docstring()
docstring = dclass._override_class_docstring.__doc__
else:
docstring = dclass.__doc__

if not docstring:
return []
lines = dclass.__doc__.split('\n')

lines = docstring.split('\n')
param_regexp = re.compile('^:param (?P<param>\w+):\s?(?P<doc>\w.*[^ ])\s' +
'?Default:\s?(?P<default>.*[^ ])$')
args = [param_regexp.findall(line.strip(' .')) for line in lines]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class I13FluoLoaderTest(unittest.TestCase):

# @unittest.skip("something missing from the .nxs file?")
@unittest.skip("Process file missing?")
def test_i13_fluo(self):
data_file = '/dls/i13-1/data/2016/mt12519-1/raw/77332.nxs'
process_file = '/home/clb02321/DAWN_stable/Savu2/Savu/test_data/test_process_lists/basic_fluo_process_i13.nxs'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@


class I18FluoLoaderTest(unittest.TestCase):

@unittest.skip("currently working on this")
def test_i18_mm(self):
data_file = tu.get_test_data_path('i18_test_data.nxs')
process_file = tu.get_test_process_path('MM_i18_test.nxs')
#process_file = tu.get_test_process_path('MM_i18_test.nxs')
process_file = '/home/qmm55171/Documents/Git/git_repos/Savu/scripts/config_generator/test.nxs'
run_protected_plugin_runner(tu.set_options(data_file,
process_file=process_file))

Expand Down

0 comments on commit 6c4671c

Please sign in to comment.