Created
November 12, 2013 16:06
-
-
Save jwiggins/7433488 to your computer and use it in GitHub Desktop.
A short example of a processing step...
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
ARRAYS = { | |
'2D_VSLICE': ('/vslice', | |
{'chunked': True, | |
'title': "Vertical slice of enhanced data"}), | |
'2D_VSLICE_ORIGINAL': ('/vslice_original', | |
{'chunked': True, | |
'title': "Vertical slice of original data"}), | |
'VSLICE_LOD_N': ('/lod_{0}', | |
{'chunked': True, | |
'title': "Vertical slice LOD"}), | |
} | |
class ExampleAlgorithm(Algorithm): | |
input_variables = ['2D_VSLICE_ORIGINAL'] | |
output_variables = ['VSLICE_LOD_N'] | |
def get_subdivider(self, data): | |
return FileSubdivider(data=data, array_info=ARRAYS, | |
input_keys=self.input_variables, | |
output_keys=self.output_variables) | |
def __call__(self, context, data_bounds): | |
img_arr = context['2D_VSLICE_ORIGINAL'][:] | |
for i, img in enumerate(levels_of_detail(img_arr, max_layer=10)): | |
name = 'VSLICE_LOD_{}'.format(i) | |
context[name] = img | |
add_depth_transform(context[name], data_bounds) | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('h5_files', nargs='+', help='HDF5 data files.') | |
args = parser.parse_args() | |
data = Data(args.h5_files) | |
data_stepper = DataStepper(data=data) | |
algorithm = ExampleAlgorithm() | |
data_stepper.run_algorithm(algorithm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment