File: data_struct.py

package info (click to toggle)
mantis-xray 3.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,488 kB
  • sloc: python: 22,421; sh: 8; makefile: 3
file content (250 lines) | stat: -rwxr-xr-x 6,861 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# 
#   This file is part of Mantis, a Multivariate ANalysis Tool for Spectromicroscopy.
# 
#   Copyright (C) 2011 Mirna Lerotic, 2nd Look
#   http://2ndlookconsulting.com
#   License: GNU GPL v3
#
#   Mantis is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   any later version.
#
#   Mantis is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details <http://www.gnu.org/licenses/>.


#    This module is used to pass data between routines and is based on 
#    https://confluence.aps.anl.gov/display/NX/Data+Exchange+Basics


class Descr(object):

    def __get__(self, instance, owner):
        # Check if the value has been set
        if (not hasattr(self, "_value")):
            return None
        # print "Getting value: %s" % self._value
        return self._value

    def __set__(self, instance, value):
        # print "Setting to %s" % value
        self._value = value

    def __delete__(self, instance):
        del (self._value)


### Information HDF5 Group
# ----------------------------------------------------------------------
class ids(object):
    proposal = Descr()
    activity = Descr()
    esaf = Descr()


# ----------------------------------------------------------------------
class experimenter(object):
    name = Descr()
    role = Descr()
    affiliation = Descr()
    address = Descr()
    phone = Descr()
    email = Descr()
    facility_user_id = Descr()


# ----------------------------------------------------------------------
class sample(object):
    name = Descr()
    description = Descr()
    #   preparation_date [string - ISO 8601 format]
    preparation_datetime = Descr()
    #   chemical_formula [string - abbreviated CIF format]
    chemical_formula = Descr()
    environment = Descr()
    temperature = Descr()
    temperature_units = Descr()
    pressure = Descr()
    pressure_units = Descr()


# ----------------------------------------------------------------------
class objective(object):
    manufacturer = Descr()
    model = Descr()
    comment = Descr()
    magnification = Descr()


# ----------------------------------------------------------------------
class scintillator(object):
    name = Descr()
    type = Descr()
    comment = Descr()
    scintillating_thickness = Descr()
    scintillating_thickness_units = Descr()
    substrate_thickness = Descr()
    substrate_thickness_units = Descr()


# ----------------------------------------------------------------------
class facility(object):
    name = Descr()
    beamline = Descr()


# ----------------------------------------------------------------------
class accelerator(object):
    ring_current = Descr()
    ring_current_units = Descr()
    primary_beam_energy = Descr()
    primary_beam_energy_units = Descr()
    monostripe = Descr()


# ----------------------------------------------------------------------
class pixel_size(object):
    horizontal = Descr()
    horizontal_units = Descr()
    vertical = Descr()
    vertical_units = Descr()


# ----------------------------------------------------------------------
class dimensions(object):
    horizontal = Descr()
    vertical = Descr()


# ----------------------------------------------------------------------
class binning(object):
    horizontal = Descr()
    vertical = Descr()


# ----------------------------------------------------------------------
class axis_directions(object):
    horizontal = Descr()
    vertical = Descr()


# ----------------------------------------------------------------------
class roi(object):
    x1 = Descr()
    y1 = Descr()
    x2 = Descr()
    y2 = Descr()


# ----------------------------------------------------------------------
class detector(object):
    manufacturer = Descr()
    model = Descr()
    serial_number = Descr()
    bit_depth = Descr()
    operating_temperature = Descr()
    operating_temperature_units = Descr()
    exposure_time = Descr()
    exposure_time_units = Descr()
    frame_rate = Descr()

    pixel_size = pixel_size()
    dimensions = dimensions()
    binning = binning()
    axis_directions = axis_directions()
    roi = roi()


# ----------------------------------------------------------------------
class information(object):
    title = Descr()
    comment = Descr()
    file_creation_datetime = Descr()

    ids = ids()
    experimenter = experimenter()
    sample = sample()
    objective = objective()
    scintillator = scintillator()
    facility = facility()
    accelerator = accelerator()
    detector = detector()


# Exchange HDF5 group
# ----------------------------------------------------------------------
class exchange(object):
    title = Descr()
    comment = Descr()
    data_collection_datetime = Descr()

    # n-dimensional dataset
    data = Descr()

    data_signal = Descr()
    data_description = Descr()
    data_units = Descr()
    data_axes = Descr()
    data_detector = Descr()

    # These are described in data attribute axes 'x:y:z' but can be arbitrary
    x = Descr()
    x_units = Descr()
    y = Descr()
    y_units = Descr()
    z = Descr()
    z_units = Descr()

    energy = Descr()
    energy_units = Descr()

    theta = Descr()
    theta_units = Descr()

    white_data = Descr()
    white_data_units = Descr()
    dark_data = Descr()
    dark_data_units = Descr()
    rotation = Descr()


# Spectromicroscopy HDF5 Group
# ----------------------------------------------------------------------
class normalization(object):
    white_spectrum = Descr()
    white_spectrum_units = Descr()
    white_spectrum_energy = Descr()
    white_spectrum_energy_units = Descr()


# ----------------------------------------------------------------------
class spectromicroscopy(object):
    positions = Descr()
    positions_units = Descr()
    positions_names = Descr()

    normalization = normalization()

    optical_density = Descr()

    data_dwell = Descr()
    i0_dwell = Descr()

    xshifts = Descr()
    yshifts = Descr()


# HDF5 Root Group
# ----------------------------------------------------------------------
class h5(object):
    # implements [string] comma separated string that tells the user which entries file contains
    implements = Descr()
    version = Descr()

    information = information()
    exchange = exchange()
    spectromicroscopy = spectromicroscopy()