|
1
|
|
|
# Copyright 2014 Diamond Light Source Ltd. |
|
2
|
|
|
# |
|
3
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
4
|
|
|
# you may not use this file except in compliance with the License. |
|
5
|
|
|
# You may obtain a copy of the License at |
|
6
|
|
|
# |
|
7
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
8
|
|
|
# |
|
9
|
|
|
# Unless required by applicable law or agreed to in writing, software |
|
10
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
|
11
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12
|
|
|
# See the License for the specific language governing permissions and |
|
13
|
|
|
# limitations under the License. |
|
14
|
|
|
|
|
15
|
|
|
""" |
|
16
|
|
|
.. module:: plugin_template4 |
|
17
|
|
|
:platform: Unix |
|
18
|
|
|
:synopsis: A template for a plugin that takes in two datasets and returns\ |
|
19
|
|
|
one dataset. |
|
20
|
|
|
|
|
21
|
|
|
.. moduleauthor:: Developer Name <[email protected]> |
|
22
|
|
|
|
|
23
|
|
|
""" |
|
24
|
|
|
|
|
25
|
|
|
from savu.plugins.plugin import Plugin |
|
26
|
|
|
from savu.plugins.driver.cpu_plugin import CpuPlugin |
|
27
|
|
|
from savu.plugins.utils import register_plugin |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
@register_plugin |
|
31
|
|
|
class PluginTemplate4(Plugin, CpuPlugin): |
|
32
|
|
|
|
|
33
|
|
|
def __init__(self): |
|
34
|
|
|
super(PluginTemplate4, self).__init__('PluginTemplate4') |
|
35
|
|
|
|
|
36
|
|
|
def nInput_datasets(self): |
|
37
|
|
|
return 2 |
|
38
|
|
|
|
|
39
|
|
|
def nOutput_datasets(self): |
|
40
|
|
|
return 1 |
|
41
|
|
|
|
|
42
|
|
|
def setup(self): |
|
43
|
|
|
in_dataset, out_dataset = self.get_datasets() |
|
44
|
|
|
out_dataset[0].create_dataset(in_dataset[0]) |
|
45
|
|
|
|
|
46
|
|
|
in_pData, out_pData = self.get_plugin_datasets() |
|
47
|
|
|
|
|
48
|
|
|
# example of getting information from the dataset metadata dictionary |
|
49
|
|
|
# this may have been populated by a previous plugin |
|
50
|
|
|
mData = in_dataset[0].meta_data |
|
51
|
|
|
if 'PeakEnergy' in list(mData.get_dictionary().keys()): |
|
52
|
|
|
nChannels = mData.get('PeakEnergy') |
|
53
|
|
|
else: |
|
54
|
|
|
nChannels = 4096 # for test data |
|
55
|
|
|
|
|
56
|
|
|
self.set_preview(in_dataset[1], self.parameters['preview']) |
|
57
|
|
|
|
|
58
|
|
|
print(out_dataset[0].get_axis_labels()) |
|
59
|
|
|
|
|
60
|
|
|
in_pData[0].plugin_data_setup('SINOGRAM', nChannels) |
|
61
|
|
|
in_pData[1].plugin_data_setup('SINOGRAM', 'single') |
|
62
|
|
|
out_pData[0].plugin_data_setup('SINOGRAM', nChannels) |
|
63
|
|
|
|
|
64
|
|
|
def pre_process(self): |
|
65
|
|
|
pass |
|
66
|
|
|
|
|
67
|
|
|
def process_frames(self, data): |
|
68
|
|
|
# do some processing here with data[0] and data[1] |
|
69
|
|
|
return data[0] |
|
70
|
|
|
|
|
71
|
|
|
def post_process(self): |
|
72
|
|
|
pass |
|
73
|
|
|
|