[682c432] | 1 | """ |
---|
| 2 | Information relating to the CanSAS data format. These constants are used in |
---|
| 3 | the cansas_reader.py file to read in any version of the cansas format. |
---|
| 4 | """ |
---|
| 5 | class CansasConstants(object): |
---|
| 6 | """ |
---|
| 7 | The base class to define where all of the data is to be saved by |
---|
| 8 | cansas_reader.py. |
---|
| 9 | """ |
---|
| 10 | names = '' |
---|
| 11 | format = '' |
---|
| 12 | |
---|
| 13 | def __init__(self): |
---|
| 14 | self.names = self.CANSAS_NS |
---|
| 15 | self.format = self.CANSAS_FORMAT |
---|
| 16 | |
---|
| 17 | def iterate_namespace(self, namespace): |
---|
| 18 | """ |
---|
| 19 | Method to iterate through a cansas constants tree based on a list of |
---|
| 20 | names |
---|
| 21 | |
---|
| 22 | :param namespace: A list of names that match the tree structure of |
---|
| 23 | cansas_constants |
---|
| 24 | """ |
---|
| 25 | # The current level to look through in cansas_constants. |
---|
| 26 | return_me = CurrentLevel() |
---|
| 27 | return_me.current_level = self.CANSAS_FORMAT.get("SASentry") |
---|
| 28 | # Defaults for variable and datatype |
---|
| 29 | return_me.ns_datatype = "content" |
---|
| 30 | return_me.ns_optional = True |
---|
| 31 | for name in namespace: |
---|
| 32 | try: |
---|
| 33 | if name != "SASentry": |
---|
| 34 | return_me.current_level = \ |
---|
| 35 | return_me.current_level.get("children").get(name, "") |
---|
| 36 | if return_me.current_level == "": |
---|
| 37 | return_me.current_level = \ |
---|
| 38 | return_me.current_level.get("<any>", "") |
---|
| 39 | cl_datatype = return_me.current_level.get("storeas", "") |
---|
| 40 | cl_units_optional = \ |
---|
[250fec92] | 41 | return_me.current_level.get("units_optional", "") |
---|
[682c432] | 42 | # Where are how to store the variable for the given |
---|
| 43 | # namespace CANSAS_CONSTANTS tree is hierarchical, so |
---|
| 44 | # is no value, inherit |
---|
| 45 | return_me.ns_datatype = cl_datatype if cl_datatype != "" \ |
---|
| 46 | else return_me.ns_datatype |
---|
| 47 | return_me.ns_optional = cl_units_optional if \ |
---|
| 48 | cl_units_optional != return_me.ns_optional \ |
---|
| 49 | else return_me.ns_optional |
---|
| 50 | except AttributeError: |
---|
| 51 | return_me.ns_datatype = "content" |
---|
| 52 | return_me.ns_optional = True |
---|
| 53 | return return_me |
---|
| 54 | |
---|
| 55 | def get_namespace_map(self): |
---|
| 56 | """ |
---|
| 57 | Helper method to get the names namespace list |
---|
| 58 | """ |
---|
| 59 | return self.names |
---|
| 60 | |
---|
| 61 | # CANSAS_NS holds the base namespace and default schema file information |
---|
| 62 | CANSAS_NS = {"1.0" : {"ns" : "cansas1d/1.0", |
---|
| 63 | "schema" : "cansas1d_v1_0.xsd" |
---|
| 64 | }, |
---|
| 65 | "1.1" : {"ns" : "urn:cansas1d:1.1", |
---|
| 66 | "schema" : "cansas1d_v1_1.xsd" |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | # The constants below hold information on where to store the CanSAS data |
---|
| 71 | # when loaded in using sasview |
---|
[250fec92] | 72 | ANY = {"storeas" : "content"} |
---|
| 73 | TITLE = {} |
---|
| 74 | SASNOTE = {} |
---|
| 75 | SASPROCESS_TERM = {"attributes" : {"unit" : {}, "name" : {}}} |
---|
| 76 | SASPROCESS_SASPROCESSNOTE = {"children" : {"<any>" : ANY}} |
---|
| 77 | SASPROCESS = {"children" : {"name" : {}, |
---|
| 78 | "date" : {}, |
---|
| 79 | "description" : {}, |
---|
[682c432] | 80 | "term" : SASPROCESS_TERM, |
---|
| 81 | "SASprocessnote" : SASPROCESS_SASPROCESSNOTE, |
---|
| 82 | "<any>" : ANY |
---|
| 83 | }, |
---|
| 84 | } |
---|
[250fec92] | 85 | RUN = {"attributes" : {"name" :{}}} |
---|
| 86 | SASDATA_IDATA_Q = {"units_optional" : False, |
---|
| 87 | "storeas" : "float", |
---|
| 88 | "unit" : "x_unit", |
---|
| 89 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 90 | } |
---|
[250fec92] | 91 | SASDATA_IDATA_I = {"units_optional" : False, |
---|
| 92 | "storeas" : "float", |
---|
| 93 | "unit" : "y_unit", |
---|
| 94 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 95 | } |
---|
[250fec92] | 96 | SASDATA_IDATA_IDEV = {"units_optional" : False, |
---|
| 97 | "storeas" : "float", |
---|
[682c432] | 98 | "unit" : "y_unit", |
---|
[250fec92] | 99 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 100 | } |
---|
[250fec92] | 101 | SASDATA_IDATA_QDEV = {"units_optional" : False, |
---|
| 102 | "storeas" : "float", |
---|
[682c432] | 103 | "unit" : "x_unit", |
---|
[250fec92] | 104 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 105 | } |
---|
[250fec92] | 106 | SASDATA_IDATA_DQL = {"units_optional" : False, |
---|
| 107 | "storeas" : "float", |
---|
[682c432] | 108 | "unit" : "x_unit", |
---|
[250fec92] | 109 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 110 | } |
---|
[250fec92] | 111 | SASDATA_IDATA_DQW = {"units_optional" : False, |
---|
| 112 | "storeas" : "float", |
---|
[682c432] | 113 | "unit" : "x_unit", |
---|
[250fec92] | 114 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 115 | } |
---|
[250fec92] | 116 | SASDATA_IDATA_QMEAN = {"unit" : "x_unit", |
---|
| 117 | "attributes" : {"unit" : {}}, |
---|
[682c432] | 118 | } |
---|
[250fec92] | 119 | SASDATA_IDATA_SHADOWFACTOR = {} |
---|
| 120 | SASDATA_IDATA = {"attributes" : {"name" : {},"timestamp" : {"storeas" : "timestamp"}}, |
---|
[682c432] | 121 | "children" : {"Q" : SASDATA_IDATA_Q, |
---|
| 122 | "I" : SASDATA_IDATA_I, |
---|
| 123 | "Idev" : SASDATA_IDATA_IDEV, |
---|
| 124 | "Qdev" : SASDATA_IDATA_QDEV, |
---|
| 125 | "dQw" : SASDATA_IDATA_DQW, |
---|
| 126 | "dQl" : SASDATA_IDATA_DQL, |
---|
| 127 | "Qmean" : SASDATA_IDATA_QMEAN, |
---|
| 128 | "Shadowfactor" : SASDATA_IDATA_SHADOWFACTOR, |
---|
| 129 | "<any>" : ANY |
---|
| 130 | } |
---|
| 131 | } |
---|
[250fec92] | 132 | SASDATA = {"attributes" : {"name" : {}}, |
---|
[682c432] | 133 | "variable" : None, |
---|
| 134 | "children" : {"Idata" : SASDATA_IDATA, |
---|
[ad4632c] | 135 | "Sesans": {"storeas": "content"}, |
---|
| 136 | "zacceptance": {"storeas": "float"}, |
---|
[682c432] | 137 | "<any>" : ANY |
---|
| 138 | } |
---|
| 139 | } |
---|
[250fec92] | 140 | SASTRANSSPEC_TDATA_LAMDBA = {"storeas" : "float", |
---|
[682c432] | 141 | "unit" : "wavelength_unit", |
---|
[250fec92] | 142 | "attributes" : {"unit" : {"storeas" : "content"}} |
---|
[682c432] | 143 | } |
---|
[250fec92] | 144 | SASTRANSSPEC_TDATA_T = {"storeas" : "float", |
---|
[682c432] | 145 | "unit" : "transmission_unit", |
---|
[250fec92] | 146 | "attributes" : {"unit" : {"storeas" : "content"}} |
---|
[682c432] | 147 | } |
---|
[250fec92] | 148 | SASTRANSSPEC_TDATA_TDEV = {"storeas" : "float", |
---|
[682c432] | 149 | "unit" : "transmission_deviation_unit", |
---|
[250fec92] | 150 | "attributes" : {"unit" :{"storeas" : "content"}} |
---|
[682c432] | 151 | } |
---|
[250fec92] | 152 | SASTRANSSPEC_TDATA = {"children" : {"Lambda" : SASTRANSSPEC_TDATA_LAMDBA, |
---|
[682c432] | 153 | "T" : SASTRANSSPEC_TDATA_T, |
---|
| 154 | "Tdev" : SASTRANSSPEC_TDATA_TDEV, |
---|
| 155 | "<any>" : ANY, |
---|
| 156 | } |
---|
| 157 | } |
---|
[250fec92] | 158 | SASTRANSSPEC = {"children" : {"Tdata" : SASTRANSSPEC_TDATA, |
---|
[682c432] | 159 | "<any>" : ANY, |
---|
| 160 | }, |
---|
[250fec92] | 161 | "attributes" : {"name" :{}, "timestamp" : {},} |
---|
[682c432] | 162 | } |
---|
[250fec92] | 163 | SASSAMPLE_THICK = {"unit" : "thickness_unit", |
---|
[682c432] | 164 | "storeas" : "float", |
---|
[250fec92] | 165 | "attributes" : {"unit" :{}}, |
---|
[682c432] | 166 | } |
---|
[250fec92] | 167 | SASSAMPLE_TRANS = {"storeas" : "float",} |
---|
| 168 | SASSAMPLE_TEMP = {"unit" : "temperature_unit", |
---|
[682c432] | 169 | "storeas" : "float", |
---|
[250fec92] | 170 | "attributes" :{"unit" :{}}, |
---|
[682c432] | 171 | } |
---|
[250fec92] | 172 | SASSAMPLE_POS_ATTR = {"unit" : {}} |
---|
| 173 | SASSAMPLE_POS_X = {"unit" : "position_unit", |
---|
[682c432] | 174 | "storeas" : "float", |
---|
| 175 | "attributes" : SASSAMPLE_POS_ATTR |
---|
| 176 | } |
---|
[250fec92] | 177 | SASSAMPLE_POS_Y = {"unit" : "position_unit", |
---|
[682c432] | 178 | "storeas" : "float", |
---|
| 179 | "attributes" : SASSAMPLE_POS_ATTR |
---|
| 180 | } |
---|
[250fec92] | 181 | SASSAMPLE_POS_Z = {"unit" : "position_unit", |
---|
[682c432] | 182 | "storeas" : "float", |
---|
| 183 | "attributes" : SASSAMPLE_POS_ATTR |
---|
| 184 | } |
---|
[250fec92] | 185 | SASSAMPLE_POS = {"children" : {"x" : SASSAMPLE_POS_X, |
---|
[682c432] | 186 | "y" : SASSAMPLE_POS_Y, |
---|
| 187 | "z" : SASSAMPLE_POS_Z, |
---|
| 188 | }, |
---|
| 189 | } |
---|
[250fec92] | 190 | SASSAMPLE_ORIENT_ATTR = {"unit" :{}} |
---|
| 191 | SASSAMPLE_ORIENT_ROLL = {"unit" : "orientation_unit", |
---|
[682c432] | 192 | "storeas" : "float", |
---|
| 193 | "attributes" : SASSAMPLE_ORIENT_ATTR |
---|
| 194 | } |
---|
[250fec92] | 195 | SASSAMPLE_ORIENT_PITCH = {"unit" : "orientation_unit", |
---|
[682c432] | 196 | "storeas" : "float", |
---|
| 197 | "attributes" : SASSAMPLE_ORIENT_ATTR |
---|
| 198 | } |
---|
[250fec92] | 199 | SASSAMPLE_ORIENT_YAW = {"unit" : "orientation_unit", |
---|
[682c432] | 200 | "storeas" : "float", |
---|
| 201 | "attributes" : SASSAMPLE_ORIENT_ATTR |
---|
| 202 | } |
---|
[250fec92] | 203 | SASSAMPLE_ORIENT = {"children" : {"roll" : SASSAMPLE_ORIENT_ROLL, |
---|
[682c432] | 204 | "pitch" : SASSAMPLE_ORIENT_PITCH, |
---|
| 205 | "yaw" : SASSAMPLE_ORIENT_YAW, |
---|
| 206 | }, |
---|
| 207 | } |
---|
| 208 | SASSAMPLE = {"attributes" : |
---|
[250fec92] | 209 | {"name" : {},}, |
---|
| 210 | "children" : {"ID" : {}, |
---|
[682c432] | 211 | "thickness" : SASSAMPLE_THICK, |
---|
| 212 | "transmission" : SASSAMPLE_TRANS, |
---|
| 213 | "temperature" : SASSAMPLE_TEMP, |
---|
| 214 | "position" : SASSAMPLE_POS, |
---|
| 215 | "orientation" : SASSAMPLE_ORIENT, |
---|
[250fec92] | 216 | "details" : {}, |
---|
[682c432] | 217 | "<any>" : ANY |
---|
| 218 | }, |
---|
| 219 | } |
---|
[250fec92] | 220 | SASINSTR_SRC_BEAMSIZE_ATTR = {"unit" : ""} |
---|
| 221 | SASINSTR_SRC_BEAMSIZE_X = {"unit" : "beam_size_unit", |
---|
[682c432] | 222 | "storeas" : "float", |
---|
| 223 | "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR |
---|
| 224 | } |
---|
[250fec92] | 225 | SASINSTR_SRC_BEAMSIZE_Y = {"unit" : "beam_size_unit", |
---|
[682c432] | 226 | "storeas" : "float", |
---|
| 227 | "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR |
---|
| 228 | } |
---|
[250fec92] | 229 | SASINSTR_SRC_BEAMSIZE_Z = {"unit" : "beam_size_unit", |
---|
[682c432] | 230 | "storeas" : "float", |
---|
| 231 | "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR |
---|
| 232 | } |
---|
[250fec92] | 233 | SASINSTR_SRC_BEAMSIZE = {"attributes" : {"name" : {}}, |
---|
[682c432] | 234 | "children" : {"x" : SASINSTR_SRC_BEAMSIZE_X, |
---|
| 235 | "y" : SASINSTR_SRC_BEAMSIZE_Y, |
---|
| 236 | "z" : SASINSTR_SRC_BEAMSIZE_Z, |
---|
| 237 | } |
---|
| 238 | } |
---|
[250fec92] | 239 | SASINSTR_SRC_WL = {"unit" : "wavelength_unit", |
---|
[682c432] | 240 | "storeas" : "float", |
---|
[250fec92] | 241 | "attributes" : {"unit" :{}, |
---|
[682c432] | 242 | } |
---|
| 243 | } |
---|
[250fec92] | 244 | SASINSTR_SRC_WL_MIN = {"unit" : "wavelength_min_unit", |
---|
[682c432] | 245 | "storeas" : "float", |
---|
[250fec92] | 246 | "attributes" : {"unit" :{"storeas" : "content"},} |
---|
[682c432] | 247 | } |
---|
[250fec92] | 248 | SASINSTR_SRC_WL_MAX = {"unit" : "wavelength_max_unit", |
---|
[682c432] | 249 | "storeas" : "float", |
---|
[250fec92] | 250 | "attributes" : {"unit" :{"storeas" : "content"},} |
---|
[682c432] | 251 | } |
---|
[250fec92] | 252 | SASINSTR_SRC_WL_SPR = {"unit" : "wavelength_spread_unit", |
---|
[682c432] | 253 | "storeas" : "float", |
---|
[250fec92] | 254 | "attributes" : {"unit" : {"storeas" : "content"},} |
---|
[682c432] | 255 | } |
---|
[250fec92] | 256 | SASINSTR_SRC = {"attributes" : {"name" : {}}, |
---|
| 257 | "children" : {"radiation" : {}, |
---|
[682c432] | 258 | "beam_size" : SASINSTR_SRC_BEAMSIZE, |
---|
[250fec92] | 259 | "beam_shape" : {}, |
---|
[682c432] | 260 | "wavelength" : SASINSTR_SRC_WL, |
---|
| 261 | "wavelength_min" : SASINSTR_SRC_WL_MIN, |
---|
| 262 | "wavelength_max" : SASINSTR_SRC_WL_MAX, |
---|
| 263 | "wavelength_spread" : SASINSTR_SRC_WL_SPR, |
---|
| 264 | }, |
---|
| 265 | } |
---|
[250fec92] | 266 | SASINSTR_COLL_APER_ATTR = {"unit" : {}} |
---|
| 267 | SASINSTR_COLL_APER_X = {"unit" : "size_unit", |
---|
[682c432] | 268 | "storeas" : "float", |
---|
| 269 | "attributes" : SASINSTR_COLL_APER_ATTR |
---|
| 270 | } |
---|
[250fec92] | 271 | SASINSTR_COLL_APER_Y = {"unit" : "size_unit", |
---|
[682c432] | 272 | "storeas" : "float", |
---|
| 273 | "attributes" : SASINSTR_COLL_APER_ATTR |
---|
| 274 | } |
---|
[250fec92] | 275 | SASINSTR_COLL_APER_Z = {"unit" : "size_unit", |
---|
[682c432] | 276 | "storeas" : "float", |
---|
| 277 | "attributes" : SASINSTR_COLL_APER_ATTR |
---|
| 278 | } |
---|
[250fec92] | 279 | SASINSTR_COLL_APER_SIZE = {"attributes" : {"unit" : {}}, |
---|
[682c432] | 280 | "children" : {"storeas" : "float", |
---|
| 281 | "x" : SASINSTR_COLL_APER_X, |
---|
| 282 | "y" : SASINSTR_COLL_APER_Y, |
---|
| 283 | "z" : SASINSTR_COLL_APER_Z, |
---|
| 284 | } |
---|
| 285 | } |
---|
| 286 | SASINSTR_COLL_APER_DIST = {"storeas" : "float", |
---|
[250fec92] | 287 | "attributes" : {"unit" : {}}, |
---|
[682c432] | 288 | "unit" : "distance_unit", |
---|
| 289 | } |
---|
[250fec92] | 290 | SASINSTR_COLL_APER = {"attributes" : {"name" : {}, "type" : {}, }, |
---|
[682c432] | 291 | "children" : {"size" : SASINSTR_COLL_APER_SIZE, |
---|
| 292 | "distance" : SASINSTR_COLL_APER_DIST |
---|
| 293 | } |
---|
| 294 | } |
---|
[250fec92] | 295 | SASINSTR_COLL = {"attributes" : {"name" : {}}, |
---|
[682c432] | 296 | "children" : |
---|
[250fec92] | 297 | {"length" : |
---|
| 298 | {"unit" : "length_unit", |
---|
| 299 | "storeas" : "float", |
---|
| 300 | "attributes" : {"storeas" : "content", "unit" : {}}, |
---|
| 301 | }, |
---|
| 302 | "aperture" : SASINSTR_COLL_APER, |
---|
| 303 | }, |
---|
[682c432] | 304 | } |
---|
[250fec92] | 305 | SASINSTR_DET_SDD = {"storeas" : "float", |
---|
[682c432] | 306 | "unit" : "distance_unit", |
---|
[250fec92] | 307 | "attributes" : {"unit" :{}}, |
---|
[682c432] | 308 | } |
---|
[250fec92] | 309 | SASINSTR_DET_OFF_ATTR = {"unit" : {"storeas" : "content" }} |
---|
| 310 | SASINSTR_DET_OFF_X = {"storeas" : "float", |
---|
[682c432] | 311 | "unit" : "offset_unit", |
---|
| 312 | "attributes" : SASINSTR_DET_OFF_ATTR |
---|
| 313 | } |
---|
[250fec92] | 314 | SASINSTR_DET_OFF_Y = {"storeas" : "float", |
---|
[682c432] | 315 | "unit" : "offset_unit", |
---|
| 316 | "attributes" : SASINSTR_DET_OFF_ATTR |
---|
| 317 | } |
---|
[250fec92] | 318 | SASINSTR_DET_OFF_Z = {"storeas" : "float", |
---|
[682c432] | 319 | "unit" : "offset_unit", |
---|
| 320 | "attributes" : SASINSTR_DET_OFF_ATTR |
---|
| 321 | } |
---|
[250fec92] | 322 | SASINSTR_DET_OFF = {"children" : {"x" : SASINSTR_DET_OFF_X, |
---|
[682c432] | 323 | "y" : SASINSTR_DET_OFF_Y, |
---|
| 324 | "z" : SASINSTR_DET_OFF_Z, |
---|
| 325 | } |
---|
| 326 | } |
---|
[250fec92] | 327 | SASINSTR_DET_OR_ATTR = {} |
---|
| 328 | SASINSTR_DET_OR_ROLL = {"storeas" : "float", |
---|
[682c432] | 329 | "unit" : "orientation_unit", |
---|
| 330 | "attributes" : SASINSTR_DET_OR_ATTR |
---|
| 331 | } |
---|
[250fec92] | 332 | SASINSTR_DET_OR_PITCH = {"storeas" : "float", |
---|
[682c432] | 333 | "unit" : "orientation_unit", |
---|
| 334 | "attributes" : SASINSTR_DET_OR_ATTR |
---|
| 335 | } |
---|
[250fec92] | 336 | SASINSTR_DET_OR_YAW = {"storeas" : "float", |
---|
[682c432] | 337 | "unit" : "orientation_unit", |
---|
| 338 | "attributes" : SASINSTR_DET_OR_ATTR |
---|
| 339 | } |
---|
[250fec92] | 340 | SASINSTR_DET_OR = {"children" : {"roll" : SASINSTR_DET_OR_ROLL, |
---|
[682c432] | 341 | "pitch" : SASINSTR_DET_OR_PITCH, |
---|
| 342 | "yaw" : SASINSTR_DET_OR_YAW, |
---|
| 343 | } |
---|
| 344 | } |
---|
[250fec92] | 345 | SASINSTR_DET_BC_X = {"storeas" : "float", |
---|
[682c432] | 346 | "unit" : "beam_center_unit", |
---|
[250fec92] | 347 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 348 | } |
---|
[250fec92] | 349 | SASINSTR_DET_BC_Y = {"storeas" : "float", |
---|
[682c432] | 350 | "unit" : "beam_center_unit", |
---|
[250fec92] | 351 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 352 | } |
---|
[250fec92] | 353 | SASINSTR_DET_BC_Z = {"storeas" : "float", |
---|
[682c432] | 354 | "unit" : "beam_center_unit", |
---|
[250fec92] | 355 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 356 | } |
---|
[250fec92] | 357 | SASINSTR_DET_BC = {"children" : {"x" : SASINSTR_DET_BC_X, |
---|
[682c432] | 358 | "y" : SASINSTR_DET_BC_Y, |
---|
[250fec92] | 359 | "z" : SASINSTR_DET_BC_Z,} |
---|
[682c432] | 360 | } |
---|
[250fec92] | 361 | SASINSTR_DET_PIXEL_X = {"storeas" : "float", |
---|
[682c432] | 362 | "unit" : "pixel_size_unit", |
---|
[250fec92] | 363 | "attributes" : {"storeas" : "content" } |
---|
[682c432] | 364 | } |
---|
[250fec92] | 365 | SASINSTR_DET_PIXEL_Y = {"storeas" : "float", |
---|
[682c432] | 366 | "unit" : "pixel_size_unit", |
---|
[250fec92] | 367 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 368 | } |
---|
[250fec92] | 369 | SASINSTR_DET_PIXEL_Z = {"storeas" : "float", |
---|
[682c432] | 370 | "unit" : "pixel_size_unit", |
---|
[250fec92] | 371 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 372 | } |
---|
[250fec92] | 373 | SASINSTR_DET_PIXEL = {"children" : {"x" : SASINSTR_DET_PIXEL_X, |
---|
[682c432] | 374 | "y" : SASINSTR_DET_PIXEL_Y, |
---|
| 375 | "z" : SASINSTR_DET_PIXEL_Z, |
---|
| 376 | } |
---|
| 377 | } |
---|
[250fec92] | 378 | SASINSTR_DET_SLIT = {"storeas" : "float", |
---|
[682c432] | 379 | "unit" : "slit_length_unit", |
---|
[250fec92] | 380 | "attributes" : {"unit" : {}} |
---|
[682c432] | 381 | } |
---|
[250fec92] | 382 | SASINSTR_DET = {"attributes" : {"name" : {"storeas" : "content"}}, |
---|
| 383 | "children" : {"name" : {"storeas" : "content"}, |
---|
[682c432] | 384 | "SDD" : SASINSTR_DET_SDD, |
---|
| 385 | "offset" : SASINSTR_DET_OFF, |
---|
| 386 | "orientation" : SASINSTR_DET_OR, |
---|
| 387 | "beam_center" : SASINSTR_DET_BC, |
---|
| 388 | "pixel_size" : SASINSTR_DET_PIXEL, |
---|
| 389 | "slit_length" : SASINSTR_DET_SLIT, |
---|
| 390 | } |
---|
| 391 | } |
---|
[250fec92] | 392 | SASINSTR = {"children" : |
---|
| 393 | {"name" : {}, |
---|
[682c432] | 394 | "SASsource" : SASINSTR_SRC, |
---|
| 395 | "SAScollimation" : SASINSTR_COLL, |
---|
| 396 | "SASdetector" : SASINSTR_DET, |
---|
| 397 | }, |
---|
| 398 | } |
---|
| 399 | CANSAS_FORMAT = {"SASentry" : |
---|
| 400 | {"units_optional" : True, |
---|
| 401 | "storeas" : "content", |
---|
[250fec92] | 402 | "attributes" : {"name" : {}}, |
---|
[682c432] | 403 | "children" : {"Title" : TITLE, |
---|
| 404 | "Run" : RUN, |
---|
| 405 | "SASdata" : SASDATA, |
---|
| 406 | "SAStransmission_spectrum" : SASTRANSSPEC, |
---|
| 407 | "SASsample" : SASSAMPLE, |
---|
| 408 | "SASinstrument" : SASINSTR, |
---|
| 409 | "SASprocess" : SASPROCESS, |
---|
| 410 | "SASnote" : SASNOTE, |
---|
| 411 | "<any>" : ANY, |
---|
| 412 | } |
---|
| 413 | } |
---|
| 414 | } |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | class CurrentLevel(object): |
---|
| 418 | """ |
---|
| 419 | A helper class to hold information on where you are in the constants tree |
---|
| 420 | """ |
---|
| 421 | |
---|
| 422 | current_level = '' |
---|
| 423 | ns_datatype = '' |
---|
| 424 | ns_optional = True |
---|
| 425 | |
---|
| 426 | def __init__(self): |
---|
| 427 | self.current_level = {} |
---|
| 428 | self.ns_datatype = "content" |
---|
| 429 | self.ns_optional = True |
---|
| 430 | |
---|
| 431 | def get_current_level(self): |
---|
| 432 | """ |
---|
| 433 | Helper method to get the current_level map |
---|
| 434 | """ |
---|
| 435 | return self.current_level |
---|
| 436 | |
---|
| 437 | def get_data_type(self): |
---|
| 438 | """ |
---|
| 439 | Helper method to get the ns_datatype label |
---|
| 440 | """ |
---|
| 441 | return self.ns_datatype |
---|
| 442 | |
---|
| 443 | def get_variable(self): |
---|
| 444 | """ |
---|
| 445 | Helper method to get the ns_variable label |
---|
| 446 | """ |
---|
| 447 | return self.ns_variable |
---|