[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 = \ |
---|
[a40be8c] | 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 |
---|
[a40be8c] | 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 | } |
---|
[a40be8c] | 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 | } |
---|
[a40be8c] | 91 | SASDATA_IDATA_I = {"units_optional" : False, |
---|
| 92 | "storeas" : "float", |
---|
| 93 | "unit" : "y_unit", |
---|
| 94 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 95 | } |
---|
[a40be8c] | 96 | SASDATA_IDATA_IDEV = {"units_optional" : False, |
---|
| 97 | "storeas" : "float", |
---|
[682c432] | 98 | "unit" : "y_unit", |
---|
[a40be8c] | 99 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 100 | } |
---|
[a40be8c] | 101 | SASDATA_IDATA_QDEV = {"units_optional" : False, |
---|
| 102 | "storeas" : "float", |
---|
[682c432] | 103 | "unit" : "x_unit", |
---|
[a40be8c] | 104 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 105 | } |
---|
[a40be8c] | 106 | SASDATA_IDATA_DQL = {"units_optional" : False, |
---|
| 107 | "storeas" : "float", |
---|
[682c432] | 108 | "unit" : "x_unit", |
---|
[a40be8c] | 109 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 110 | } |
---|
[a40be8c] | 111 | SASDATA_IDATA_DQW = {"units_optional" : False, |
---|
| 112 | "storeas" : "float", |
---|
[682c432] | 113 | "unit" : "x_unit", |
---|
[a40be8c] | 114 | "attributes" : {"unit" : {"storeas" : "content"}}, |
---|
[682c432] | 115 | } |
---|
[a40be8c] | 116 | SASDATA_IDATA_QMEAN = {"unit" : "x_unit", |
---|
| 117 | "attributes" : {"unit" : {}}, |
---|
[682c432] | 118 | } |
---|
[a40be8c] | 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 | } |
---|
[a40be8c] | 132 | SASDATA = {"attributes" : {"name" : {}}, |
---|
[682c432] | 133 | "variable" : None, |
---|
| 134 | "children" : {"Idata" : SASDATA_IDATA, |
---|
| 135 | "<any>" : ANY |
---|
| 136 | } |
---|
| 137 | } |
---|
[a40be8c] | 138 | SASTRANSSPEC_TDATA_LAMDBA = {"storeas" : "float", |
---|
[682c432] | 139 | "unit" : "wavelength_unit", |
---|
[a40be8c] | 140 | "attributes" : {"unit" : {"storeas" : "content"}} |
---|
[682c432] | 141 | } |
---|
[a40be8c] | 142 | SASTRANSSPEC_TDATA_T = {"storeas" : "float", |
---|
[682c432] | 143 | "unit" : "transmission_unit", |
---|
[a40be8c] | 144 | "attributes" : {"unit" : {"storeas" : "content"}} |
---|
[682c432] | 145 | } |
---|
[a40be8c] | 146 | SASTRANSSPEC_TDATA_TDEV = {"storeas" : "float", |
---|
[682c432] | 147 | "unit" : "transmission_deviation_unit", |
---|
[a40be8c] | 148 | "attributes" : {"unit" :{"storeas" : "content"}} |
---|
[682c432] | 149 | } |
---|
[a40be8c] | 150 | SASTRANSSPEC_TDATA = {"children" : {"Lambda" : SASTRANSSPEC_TDATA_LAMDBA, |
---|
[682c432] | 151 | "T" : SASTRANSSPEC_TDATA_T, |
---|
| 152 | "Tdev" : SASTRANSSPEC_TDATA_TDEV, |
---|
| 153 | "<any>" : ANY, |
---|
| 154 | } |
---|
| 155 | } |
---|
[a40be8c] | 156 | SASTRANSSPEC = {"children" : {"Tdata" : SASTRANSSPEC_TDATA, |
---|
[682c432] | 157 | "<any>" : ANY, |
---|
| 158 | }, |
---|
[a40be8c] | 159 | "attributes" : {"name" :{}, "timestamp" : {},} |
---|
[682c432] | 160 | } |
---|
[a40be8c] | 161 | SASSAMPLE_THICK = {"unit" : "thickness_unit", |
---|
[682c432] | 162 | "storeas" : "float", |
---|
[a40be8c] | 163 | "attributes" : {"unit" :{}}, |
---|
[682c432] | 164 | } |
---|
[a40be8c] | 165 | SASSAMPLE_TRANS = {"storeas" : "float",} |
---|
| 166 | SASSAMPLE_TEMP = {"unit" : "temperature_unit", |
---|
[682c432] | 167 | "storeas" : "float", |
---|
[a40be8c] | 168 | "attributes" :{"unit" :{}}, |
---|
[682c432] | 169 | } |
---|
[a40be8c] | 170 | SASSAMPLE_POS_ATTR = {"unit" : {}} |
---|
| 171 | SASSAMPLE_POS_X = {"unit" : "position_unit", |
---|
[682c432] | 172 | "storeas" : "float", |
---|
| 173 | "attributes" : SASSAMPLE_POS_ATTR |
---|
| 174 | } |
---|
[a40be8c] | 175 | SASSAMPLE_POS_Y = {"unit" : "position_unit", |
---|
[682c432] | 176 | "storeas" : "float", |
---|
| 177 | "attributes" : SASSAMPLE_POS_ATTR |
---|
| 178 | } |
---|
[a40be8c] | 179 | SASSAMPLE_POS_Z = {"unit" : "position_unit", |
---|
[682c432] | 180 | "storeas" : "float", |
---|
| 181 | "attributes" : SASSAMPLE_POS_ATTR |
---|
| 182 | } |
---|
[a40be8c] | 183 | SASSAMPLE_POS = {"children" : {"x" : SASSAMPLE_POS_X, |
---|
[682c432] | 184 | "y" : SASSAMPLE_POS_Y, |
---|
| 185 | "z" : SASSAMPLE_POS_Z, |
---|
| 186 | }, |
---|
| 187 | } |
---|
[a40be8c] | 188 | SASSAMPLE_ORIENT_ATTR = {"unit" :{}} |
---|
| 189 | SASSAMPLE_ORIENT_ROLL = {"unit" : "orientation_unit", |
---|
[682c432] | 190 | "storeas" : "float", |
---|
| 191 | "attributes" : SASSAMPLE_ORIENT_ATTR |
---|
| 192 | } |
---|
[a40be8c] | 193 | SASSAMPLE_ORIENT_PITCH = {"unit" : "orientation_unit", |
---|
[682c432] | 194 | "storeas" : "float", |
---|
| 195 | "attributes" : SASSAMPLE_ORIENT_ATTR |
---|
| 196 | } |
---|
[a40be8c] | 197 | SASSAMPLE_ORIENT_YAW = {"unit" : "orientation_unit", |
---|
[682c432] | 198 | "storeas" : "float", |
---|
| 199 | "attributes" : SASSAMPLE_ORIENT_ATTR |
---|
| 200 | } |
---|
[a40be8c] | 201 | SASSAMPLE_ORIENT = {"children" : {"roll" : SASSAMPLE_ORIENT_ROLL, |
---|
[682c432] | 202 | "pitch" : SASSAMPLE_ORIENT_PITCH, |
---|
| 203 | "yaw" : SASSAMPLE_ORIENT_YAW, |
---|
| 204 | }, |
---|
| 205 | } |
---|
| 206 | SASSAMPLE = {"attributes" : |
---|
[a40be8c] | 207 | {"name" : {},}, |
---|
| 208 | "children" : {"ID" : {}, |
---|
[682c432] | 209 | "thickness" : SASSAMPLE_THICK, |
---|
| 210 | "transmission" : SASSAMPLE_TRANS, |
---|
| 211 | "temperature" : SASSAMPLE_TEMP, |
---|
| 212 | "position" : SASSAMPLE_POS, |
---|
| 213 | "orientation" : SASSAMPLE_ORIENT, |
---|
[a40be8c] | 214 | "details" : {}, |
---|
[682c432] | 215 | "<any>" : ANY |
---|
| 216 | }, |
---|
| 217 | } |
---|
[a40be8c] | 218 | SASINSTR_SRC_BEAMSIZE_ATTR = {"unit" : ""} |
---|
| 219 | SASINSTR_SRC_BEAMSIZE_X = {"unit" : "beam_size_unit", |
---|
[682c432] | 220 | "storeas" : "float", |
---|
| 221 | "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR |
---|
| 222 | } |
---|
[a40be8c] | 223 | SASINSTR_SRC_BEAMSIZE_Y = {"unit" : "beam_size_unit", |
---|
[682c432] | 224 | "storeas" : "float", |
---|
| 225 | "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR |
---|
| 226 | } |
---|
[a40be8c] | 227 | SASINSTR_SRC_BEAMSIZE_Z = {"unit" : "beam_size_unit", |
---|
[682c432] | 228 | "storeas" : "float", |
---|
| 229 | "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR |
---|
| 230 | } |
---|
[a40be8c] | 231 | SASINSTR_SRC_BEAMSIZE = {"attributes" : {"name" : {}}, |
---|
[682c432] | 232 | "children" : {"x" : SASINSTR_SRC_BEAMSIZE_X, |
---|
| 233 | "y" : SASINSTR_SRC_BEAMSIZE_Y, |
---|
| 234 | "z" : SASINSTR_SRC_BEAMSIZE_Z, |
---|
| 235 | } |
---|
| 236 | } |
---|
[a40be8c] | 237 | SASINSTR_SRC_WL = {"unit" : "wavelength_unit", |
---|
[682c432] | 238 | "storeas" : "float", |
---|
[a40be8c] | 239 | "attributes" : {"unit" :{}, |
---|
[682c432] | 240 | } |
---|
| 241 | } |
---|
[a40be8c] | 242 | SASINSTR_SRC_WL_MIN = {"unit" : "wavelength_min_unit", |
---|
[682c432] | 243 | "storeas" : "float", |
---|
[a40be8c] | 244 | "attributes" : {"unit" :{"storeas" : "content"},} |
---|
[682c432] | 245 | } |
---|
[a40be8c] | 246 | SASINSTR_SRC_WL_MAX = {"unit" : "wavelength_max_unit", |
---|
[682c432] | 247 | "storeas" : "float", |
---|
[a40be8c] | 248 | "attributes" : {"unit" :{"storeas" : "content"},} |
---|
[682c432] | 249 | } |
---|
[a40be8c] | 250 | SASINSTR_SRC_WL_SPR = {"unit" : "wavelength_spread_unit", |
---|
[682c432] | 251 | "storeas" : "float", |
---|
[a40be8c] | 252 | "attributes" : {"unit" : {"storeas" : "content"},} |
---|
[682c432] | 253 | } |
---|
[a40be8c] | 254 | SASINSTR_SRC = {"attributes" : {"name" : {}}, |
---|
| 255 | "children" : {"radiation" : {}, |
---|
[682c432] | 256 | "beam_size" : SASINSTR_SRC_BEAMSIZE, |
---|
[a40be8c] | 257 | "beam_shape" : {}, |
---|
[682c432] | 258 | "wavelength" : SASINSTR_SRC_WL, |
---|
| 259 | "wavelength_min" : SASINSTR_SRC_WL_MIN, |
---|
| 260 | "wavelength_max" : SASINSTR_SRC_WL_MAX, |
---|
| 261 | "wavelength_spread" : SASINSTR_SRC_WL_SPR, |
---|
| 262 | }, |
---|
| 263 | } |
---|
[a40be8c] | 264 | SASINSTR_COLL_APER_ATTR = {"unit" : {}} |
---|
| 265 | SASINSTR_COLL_APER_X = {"unit" : "size_unit", |
---|
[682c432] | 266 | "storeas" : "float", |
---|
| 267 | "attributes" : SASINSTR_COLL_APER_ATTR |
---|
| 268 | } |
---|
[a40be8c] | 269 | SASINSTR_COLL_APER_Y = {"unit" : "size_unit", |
---|
[682c432] | 270 | "storeas" : "float", |
---|
| 271 | "attributes" : SASINSTR_COLL_APER_ATTR |
---|
| 272 | } |
---|
[a40be8c] | 273 | SASINSTR_COLL_APER_Z = {"unit" : "size_unit", |
---|
[682c432] | 274 | "storeas" : "float", |
---|
| 275 | "attributes" : SASINSTR_COLL_APER_ATTR |
---|
| 276 | } |
---|
[a40be8c] | 277 | SASINSTR_COLL_APER_SIZE = {"attributes" : {"unit" : {}}, |
---|
[682c432] | 278 | "children" : {"storeas" : "float", |
---|
| 279 | "x" : SASINSTR_COLL_APER_X, |
---|
| 280 | "y" : SASINSTR_COLL_APER_Y, |
---|
| 281 | "z" : SASINSTR_COLL_APER_Z, |
---|
| 282 | } |
---|
| 283 | } |
---|
| 284 | SASINSTR_COLL_APER_DIST = {"storeas" : "float", |
---|
[a40be8c] | 285 | "attributes" : {"unit" : {}}, |
---|
[682c432] | 286 | "unit" : "distance_unit", |
---|
| 287 | } |
---|
[a40be8c] | 288 | SASINSTR_COLL_APER = {"attributes" : {"name" : {}, "type" : {}, }, |
---|
[682c432] | 289 | "children" : {"size" : SASINSTR_COLL_APER_SIZE, |
---|
| 290 | "distance" : SASINSTR_COLL_APER_DIST |
---|
| 291 | } |
---|
| 292 | } |
---|
[a40be8c] | 293 | SASINSTR_COLL = {"attributes" : {"name" : {}}, |
---|
[682c432] | 294 | "children" : |
---|
[a40be8c] | 295 | {"length" : |
---|
| 296 | {"unit" : "length_unit", |
---|
| 297 | "storeas" : "float", |
---|
| 298 | "attributes" : {"storeas" : "content", "unit" : {}}, |
---|
| 299 | }, |
---|
| 300 | "aperture" : SASINSTR_COLL_APER, |
---|
| 301 | }, |
---|
[682c432] | 302 | } |
---|
[a40be8c] | 303 | SASINSTR_DET_SDD = {"storeas" : "float", |
---|
[682c432] | 304 | "unit" : "distance_unit", |
---|
[a40be8c] | 305 | "attributes" : {"unit" :{}}, |
---|
[682c432] | 306 | } |
---|
[a40be8c] | 307 | SASINSTR_DET_OFF_ATTR = {"unit" : {"storeas" : "content" }} |
---|
| 308 | SASINSTR_DET_OFF_X = {"storeas" : "float", |
---|
[682c432] | 309 | "unit" : "offset_unit", |
---|
| 310 | "attributes" : SASINSTR_DET_OFF_ATTR |
---|
| 311 | } |
---|
[a40be8c] | 312 | SASINSTR_DET_OFF_Y = {"storeas" : "float", |
---|
[682c432] | 313 | "unit" : "offset_unit", |
---|
| 314 | "attributes" : SASINSTR_DET_OFF_ATTR |
---|
| 315 | } |
---|
[a40be8c] | 316 | SASINSTR_DET_OFF_Z = {"storeas" : "float", |
---|
[682c432] | 317 | "unit" : "offset_unit", |
---|
| 318 | "attributes" : SASINSTR_DET_OFF_ATTR |
---|
| 319 | } |
---|
[a40be8c] | 320 | SASINSTR_DET_OFF = {"children" : {"x" : SASINSTR_DET_OFF_X, |
---|
[682c432] | 321 | "y" : SASINSTR_DET_OFF_Y, |
---|
| 322 | "z" : SASINSTR_DET_OFF_Z, |
---|
| 323 | } |
---|
| 324 | } |
---|
[a40be8c] | 325 | SASINSTR_DET_OR_ATTR = {} |
---|
| 326 | SASINSTR_DET_OR_ROLL = {"storeas" : "float", |
---|
[682c432] | 327 | "unit" : "orientation_unit", |
---|
| 328 | "attributes" : SASINSTR_DET_OR_ATTR |
---|
| 329 | } |
---|
[a40be8c] | 330 | SASINSTR_DET_OR_PITCH = {"storeas" : "float", |
---|
[682c432] | 331 | "unit" : "orientation_unit", |
---|
| 332 | "attributes" : SASINSTR_DET_OR_ATTR |
---|
| 333 | } |
---|
[a40be8c] | 334 | SASINSTR_DET_OR_YAW = {"storeas" : "float", |
---|
[682c432] | 335 | "unit" : "orientation_unit", |
---|
| 336 | "attributes" : SASINSTR_DET_OR_ATTR |
---|
| 337 | } |
---|
[a40be8c] | 338 | SASINSTR_DET_OR = {"children" : {"roll" : SASINSTR_DET_OR_ROLL, |
---|
[682c432] | 339 | "pitch" : SASINSTR_DET_OR_PITCH, |
---|
| 340 | "yaw" : SASINSTR_DET_OR_YAW, |
---|
| 341 | } |
---|
| 342 | } |
---|
[a40be8c] | 343 | SASINSTR_DET_BC_X = {"storeas" : "float", |
---|
[682c432] | 344 | "unit" : "beam_center_unit", |
---|
[a40be8c] | 345 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 346 | } |
---|
[a40be8c] | 347 | SASINSTR_DET_BC_Y = {"storeas" : "float", |
---|
[682c432] | 348 | "unit" : "beam_center_unit", |
---|
[a40be8c] | 349 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 350 | } |
---|
[a40be8c] | 351 | SASINSTR_DET_BC_Z = {"storeas" : "float", |
---|
[682c432] | 352 | "unit" : "beam_center_unit", |
---|
[a40be8c] | 353 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 354 | } |
---|
[a40be8c] | 355 | SASINSTR_DET_BC = {"children" : {"x" : SASINSTR_DET_BC_X, |
---|
[682c432] | 356 | "y" : SASINSTR_DET_BC_Y, |
---|
[a40be8c] | 357 | "z" : SASINSTR_DET_BC_Z,} |
---|
[682c432] | 358 | } |
---|
[a40be8c] | 359 | SASINSTR_DET_PIXEL_X = {"storeas" : "float", |
---|
[682c432] | 360 | "unit" : "pixel_size_unit", |
---|
[a40be8c] | 361 | "attributes" : {"storeas" : "content" } |
---|
[682c432] | 362 | } |
---|
[a40be8c] | 363 | SASINSTR_DET_PIXEL_Y = {"storeas" : "float", |
---|
[682c432] | 364 | "unit" : "pixel_size_unit", |
---|
[a40be8c] | 365 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 366 | } |
---|
[a40be8c] | 367 | SASINSTR_DET_PIXEL_Z = {"storeas" : "float", |
---|
[682c432] | 368 | "unit" : "pixel_size_unit", |
---|
[a40be8c] | 369 | "attributes" : {"storeas" : "content"} |
---|
[682c432] | 370 | } |
---|
[a40be8c] | 371 | SASINSTR_DET_PIXEL = {"children" : {"x" : SASINSTR_DET_PIXEL_X, |
---|
[682c432] | 372 | "y" : SASINSTR_DET_PIXEL_Y, |
---|
| 373 | "z" : SASINSTR_DET_PIXEL_Z, |
---|
| 374 | } |
---|
| 375 | } |
---|
[a40be8c] | 376 | SASINSTR_DET_SLIT = {"storeas" : "float", |
---|
[682c432] | 377 | "unit" : "slit_length_unit", |
---|
[a40be8c] | 378 | "attributes" : {"unit" : {}} |
---|
[682c432] | 379 | } |
---|
[a40be8c] | 380 | SASINSTR_DET = {"attributes" : {"name" : {"storeas" : "content"}}, |
---|
| 381 | "children" : {"name" : {"storeas" : "content"}, |
---|
[682c432] | 382 | "SDD" : SASINSTR_DET_SDD, |
---|
| 383 | "offset" : SASINSTR_DET_OFF, |
---|
| 384 | "orientation" : SASINSTR_DET_OR, |
---|
| 385 | "beam_center" : SASINSTR_DET_BC, |
---|
| 386 | "pixel_size" : SASINSTR_DET_PIXEL, |
---|
| 387 | "slit_length" : SASINSTR_DET_SLIT, |
---|
| 388 | } |
---|
| 389 | } |
---|
[a40be8c] | 390 | SASINSTR = {"children" : |
---|
| 391 | {"name" : {}, |
---|
[682c432] | 392 | "SASsource" : SASINSTR_SRC, |
---|
| 393 | "SAScollimation" : SASINSTR_COLL, |
---|
| 394 | "SASdetector" : SASINSTR_DET, |
---|
| 395 | }, |
---|
| 396 | } |
---|
| 397 | CANSAS_FORMAT = {"SASentry" : |
---|
| 398 | {"units_optional" : True, |
---|
| 399 | "storeas" : "content", |
---|
[a40be8c] | 400 | "attributes" : {"name" : {}}, |
---|
[682c432] | 401 | "children" : {"Title" : TITLE, |
---|
| 402 | "Run" : RUN, |
---|
| 403 | "SASdata" : SASDATA, |
---|
| 404 | "SAStransmission_spectrum" : SASTRANSSPEC, |
---|
| 405 | "SASsample" : SASSAMPLE, |
---|
| 406 | "SASinstrument" : SASINSTR, |
---|
| 407 | "SASprocess" : SASPROCESS, |
---|
| 408 | "SASnote" : SASNOTE, |
---|
| 409 | "<any>" : ANY, |
---|
| 410 | } |
---|
| 411 | } |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | |
---|
| 415 | class CurrentLevel(object): |
---|
| 416 | """ |
---|
| 417 | A helper class to hold information on where you are in the constants tree |
---|
| 418 | """ |
---|
| 419 | |
---|
| 420 | current_level = '' |
---|
| 421 | ns_datatype = '' |
---|
| 422 | ns_optional = True |
---|
| 423 | |
---|
| 424 | def __init__(self): |
---|
| 425 | self.current_level = {} |
---|
| 426 | self.ns_datatype = "content" |
---|
| 427 | self.ns_optional = True |
---|
| 428 | |
---|
| 429 | def get_current_level(self): |
---|
| 430 | """ |
---|
| 431 | Helper method to get the current_level map |
---|
| 432 | """ |
---|
| 433 | return self.current_level |
---|
| 434 | |
---|
| 435 | def get_data_type(self): |
---|
| 436 | """ |
---|
| 437 | Helper method to get the ns_datatype label |
---|
| 438 | """ |
---|
| 439 | return self.ns_datatype |
---|
| 440 | |
---|
| 441 | def get_variable(self): |
---|
| 442 | """ |
---|
| 443 | Helper method to get the ns_variable label |
---|
| 444 | """ |
---|
| 445 | return self.ns_variable |
---|