Ignore:
Timestamp:
Sep 15, 2016 8:33:57 AM (8 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
158cb9e
Parents:
2a08cb6
git-author:
Jeff Krzywon <krzywon@…> (08/18/16 12:52:59)
git-committer:
Piotr Rozyczko <rozyczko@…> (09/15/16 08:33:57)
Message:

Closes #596: Major rewrite to canSAS XML reader to create separate Data1D objects for each SASdata. Also fixed a few bugs that were present in the reader, that were not caught until now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/cansas_constants.py

    rd398285 ra40be8c  
    2727        return_me.current_level = self.CANSAS_FORMAT.get("SASentry") 
    2828        # Defaults for variable and datatype 
    29         return_me.ns_variable = "{0}.meta_data[\"{2}\"] = \"{1}\"" 
    3029        return_me.ns_datatype = "content" 
    3130        return_me.ns_optional = True 
     
    3837                        return_me.current_level = \ 
    3938                                return_me.current_level.get("<any>", "") 
    40                     cl_variable = return_me.current_level.get("variable", "") 
    4139                    cl_datatype = return_me.current_level.get("storeas", "") 
    4240                    cl_units_optional = \ 
    43                              return_me.current_level.get("units_required", "") 
     41                             return_me.current_level.get("units_optional", "") 
    4442                    # Where are how to store the variable for the given 
    4543                    # namespace CANSAS_CONSTANTS tree is hierarchical, so 
    4644                    # is no value, inherit 
    47                     return_me.ns_variable = cl_variable if cl_variable != "" \ 
    48                         else return_me.ns_variable 
    4945                    return_me.ns_datatype = cl_datatype if cl_datatype != "" \ 
    5046                        else return_me.ns_datatype 
     
    5349                                        else return_me.ns_optional 
    5450            except AttributeError: 
    55                 return_me.ns_variable = "{0}.meta_data[\"{2}\"] = \"{1}\"" 
    5651                return_me.ns_datatype = "content" 
    5752                return_me.ns_optional = True 
     
    7570    # The constants below hold information on where to store the CanSAS data 
    7671    # when loaded in using sasview 
    77     META_DATA = "{0}.meta_data[\"{2}\"] = \"{1}\"" 
    78     ANY = {"variable" : "{0}.meta_data[\"{2}\"] = \'{1}\'", 
    79            "storeas" : "content", 
    80           } 
    81     TITLE = {"variable" : "{0}.title = \"{1}\""} 
    82     SASNOTE = {"variable" : "{0}.notes.append(\'{1}\')"} 
    83     SASPROCESS_TERM = {"variable" : None, 
    84                        "attributes" : {"unit" : {"variable" : None}, 
    85                                        "name" : {"variable" : None} 
    86                                       } 
    87                       } 
    88     SASPROCESS_SASPROCESSNOTE = {"variable" : None, 
    89                                  "children" : {"<any>" : ANY} 
    90                                 } 
    91     SASPROCESS = {"variable" : None, 
    92                   "children" : {"name" : {"variable" : "{0}.name = \'{1}\'"}, 
    93                                 "date" : {"variable" : "{0}.date = \'{1}\'"}, 
    94                                 "description" : 
    95                                 {"variable" : "{0}.description = \'{1}\'"}, 
     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" : {}, 
    9680                                "term" : SASPROCESS_TERM, 
    9781                                "SASprocessnote" : SASPROCESS_SASPROCESSNOTE, 
     
    9983                               }, 
    10084                 } 
    101     RUN = {"variable" : "{0}.run.append(\"{1}\")", 
    102            "attributes" : {"name" : 
    103                            {"variable" : "{0}.run_name[\"{3}\"] = \"{1}\""}} 
    104           } 
    105     SASDATA_IDATA_Q = {"variable" : "{0}.x = numpy.append({0}.x, {1})", 
    106                        "unit" : "x_unit", 
    107                        "attributes" : {"unit" : 
    108                                        {"variable" : "{0}.xaxis(\"Q\", \'{1}\')", 
    109                                         "storeas" : "content" 
    110                                        } 
    111                                       }, 
    112                       } 
    113     SASDATA_IDATA_I = {"variable" : "{0}.y = numpy.append({0}.y, {1})", 
    114                        "unit" : "y_unit", 
    115                        "attributes" : {"unit" : 
    116                                        {"variable" : "{0}.yaxis(\"Intensity\", \'{1}\')", 
    117                                         "storeas" : "content" 
    118                                        } 
    119                                       }, 
    120                       } 
    121     SASDATA_IDATA_IDEV = {"variable" : "{0}.dy = numpy.append({0}.dy, {1})", 
     85    RUN = {"attributes" : {"name" :{}}} 
     86    SASDATA_IDATA_Q = {"units_optional" : False, 
     87                       "storeas" : "float", 
     88                        "unit" : "x_unit", 
     89                       "attributes" : {"unit" : {"storeas" : "content"}}, 
     90                      } 
     91    SASDATA_IDATA_I = {"units_optional" : False, 
     92                       "storeas" : "float", 
     93                        "unit" : "y_unit", 
     94                       "attributes" : {"unit" : {"storeas" : "content"}}, 
     95                      } 
     96    SASDATA_IDATA_IDEV = {"units_optional" : False, 
     97                          "storeas" : "float", 
    12298                          "unit" : "y_unit", 
    123                           "attributes" : {"unit" : 
    124                                           {"variable" : META_DATA, 
    125                                            "storeas" : "content" 
    126                                           } 
    127                                          }, 
    128                          } 
    129     SASDATA_IDATA_QDEV = {"variable" : "{0}.dx = numpy.append({0}.dx, {1})", 
     99                          "attributes" : {"unit" : {"storeas" : "content"}}, 
     100                         } 
     101    SASDATA_IDATA_QDEV = {"units_optional" : False, 
     102                          "storeas" : "float", 
    130103                          "unit" : "x_unit", 
    131                           "attributes" : {"unit" : 
    132                                           {"variable" : META_DATA, 
    133                                            "storeas" : "content" 
    134                                           } 
    135                                          }, 
    136                          } 
    137     SASDATA_IDATA_DQL = {"variable" : "{0}.dxl = numpy.append({0}.dxl, {1})", 
     104                          "attributes" : {"unit" : {"storeas" : "content"}}, 
     105                         } 
     106    SASDATA_IDATA_DQL = {"units_optional" : False, 
     107                         "storeas" : "float", 
    138108                         "unit" : "x_unit", 
    139                          "attributes" : {"unit" : 
    140                                          {"variable" : META_DATA, 
    141                                           "storeas" : "content" 
    142                                          } 
    143                                         }, 
    144                         } 
    145     SASDATA_IDATA_DQW = {"variable" : "{0}.dxw = numpy.append({0}.dxw, {1})", 
     109                         "attributes" : {"unit" : {"storeas" : "content"}}, 
     110                        } 
     111    SASDATA_IDATA_DQW = {"units_optional" : False, 
     112                         "storeas" : "float", 
    146113                         "unit" : "x_unit", 
    147                          "attributes" : {"unit" : 
    148                                          {"variable" : META_DATA, 
    149                                           "storeas" : "content" 
    150                                          } 
    151                                         }, 
    152                         } 
    153     SASDATA_IDATA_QMEAN = {"storeas" : "content", 
    154                            "unit" : "x_unit", 
    155                            "variable" : META_DATA, 
    156                            "attributes" : {"unit" : {"variable" : META_DATA}}, 
     114                         "attributes" : {"unit" : {"storeas" : "content"}}, 
     115                        } 
     116    SASDATA_IDATA_QMEAN = {"unit" : "x_unit", 
     117                           "attributes" : {"unit" : {}}, 
    157118                          } 
    158     SASDATA_IDATA_SHADOWFACTOR = {"variable" : META_DATA, 
    159                                   "storeas" : "content", 
    160                                  } 
    161     SASDATA_IDATA = {"storeas" : "float", 
    162                      "units_optional" : False, 
    163                      "variable" : None, 
    164                      "attributes" : {"name" : {"variable" : META_DATA, 
    165                                                "storeas" : "content", 
    166                                               }, 
    167                                      "timestamp" : {"variable" : META_DATA, 
    168                                                     "storeas" : "timestamp", 
    169                                                    } 
    170                                     }, 
     119    SASDATA_IDATA_SHADOWFACTOR = {} 
     120    SASDATA_IDATA = {"attributes" : {"name" : {},"timestamp" : {"storeas" : "timestamp"}}, 
    171121                     "children" : {"Q" : SASDATA_IDATA_Q, 
    172122                                   "I" : SASDATA_IDATA_I, 
     
    180130                                  } 
    181131                    } 
    182     SASDATA = {"attributes" : {"name" : {"variable" : META_DATA,}}, 
     132    SASDATA = {"attributes" : {"name" : {}}, 
    183133               "variable" : None, 
    184134               "children" : {"Idata" : SASDATA_IDATA, 
     
    186136                            } 
    187137              } 
    188     SASTRANSSPEC_TDATA_LAMDBA = {"variable" : "{0}.wavelength.append({1})", 
     138    SASTRANSSPEC_TDATA_LAMDBA = {"storeas" : "float", 
    189139                                 "unit" : "wavelength_unit", 
    190                                  "attributes" : 
    191                                  {"unit" : 
    192                                   {"variable" : "{0}.wavelength_unit = \"{1}\"", 
    193                                    "storeas" : "content" 
    194                                   } 
    195                                  } 
     140                                 "attributes" : {"unit" : {"storeas" : "content"}} 
    196141                                } 
    197     SASTRANSSPEC_TDATA_T = {"variable" : "{0}.transmission.append({1})", 
     142    SASTRANSSPEC_TDATA_T = {"storeas" : "float", 
    198143                            "unit" : "transmission_unit", 
    199                             "attributes" : 
    200                             {"unit" : 
    201                              {"variable" : "{0}.transmission_unit = \"{1}\"", 
    202                               "storeas" : "content" 
    203                              } 
    204                             } 
    205                            } 
    206     SASTRANSSPEC_TDATA_TDEV = {"variable" : 
    207                                "{0}.transmission_deviation.append({1})", 
     144                            "attributes" : {"unit" : {"storeas" : "content"}} 
     145                           } 
     146    SASTRANSSPEC_TDATA_TDEV = {"storeas" : "float", 
    208147                               "unit" : "transmission_deviation_unit", 
    209                                "attributes" : 
    210                                {"unit" : 
    211                                 {"variable" : 
    212                                  "{0}.transmission_deviation_unit = \"{1}\"", 
    213                                  "storeas" : "content" 
    214                                 } 
    215                                } 
    216                               } 
    217     SASTRANSSPEC_TDATA = {"storeas" : "float", 
    218                           "variable" : None, 
    219                           "children" : {"Lambda" : SASTRANSSPEC_TDATA_LAMDBA, 
     148                               "attributes" : {"unit" :{"storeas" : "content"}} 
     149                              } 
     150    SASTRANSSPEC_TDATA = {"children" : {"Lambda" : SASTRANSSPEC_TDATA_LAMDBA, 
    220151                                        "T" : SASTRANSSPEC_TDATA_T, 
    221152                                        "Tdev" : SASTRANSSPEC_TDATA_TDEV, 
     
    223154                                       } 
    224155                         } 
    225     SASTRANSSPEC = {"variable" : None, 
    226                     "children" : {"Tdata" : SASTRANSSPEC_TDATA, 
     156    SASTRANSSPEC = {"children" : {"Tdata" : SASTRANSSPEC_TDATA, 
    227157                                  "<any>" : ANY, 
    228158                                 }, 
    229                     "attributes" : 
    230                     {"name" : 
    231                      {"variable" : "{0}.name = \"{1}\""}, 
    232                      "timestamp" : 
    233                      {"variable" : "{0}.timestamp = \"{1}\""}, 
    234                     } 
     159                    "attributes" : {"name" :{}, "timestamp" : {},} 
    235160                   } 
    236     SASSAMPLE_THICK = {"variable" : "{0}.sample.thickness = {1}", 
    237                        "unit" : "sample.thickness_unit", 
    238                        "storeas" : "float", 
    239                        "attributes" : 
    240                        {"unit" : 
    241                         {"variable" : "{0}.sample.thickness_unit = \"{1}\"", 
    242                          "storeas" : "content" 
    243                         } 
    244                        }, 
    245                       } 
    246     SASSAMPLE_TRANS = {"variable" : "{0}.sample.transmission = {1}", 
    247                        "storeas" : "float", 
    248                       } 
    249     SASSAMPLE_TEMP = {"variable" : "{0}.sample.temperature = {1}", 
    250                       "unit" : "sample.temperature_unit", 
     161    SASSAMPLE_THICK = {"unit" : "thickness_unit", 
     162                       "storeas" : "float", 
     163                       "attributes" : {"unit" :{}}, 
     164                      } 
     165    SASSAMPLE_TRANS = {"storeas" : "float",} 
     166    SASSAMPLE_TEMP = {"unit" : "temperature_unit", 
    251167                      "storeas" : "float", 
    252                       "attributes" : 
    253                       {"unit" : 
    254                        {"variable" : "{0}.sample.temperature_unit = \"{1}\"", 
    255                         "storeas" : "content" 
    256                        } 
    257                       }, 
     168                      "attributes" :{"unit" :{}}, 
    258169                     } 
    259     SASSAMPLE_POS_ATTR = {"unit" : {"variable" : 
    260                                     "{0}.sample.position_unit = \"{1}\"", 
    261                                     "storeas" : "content" 
    262                                    } 
    263                          } 
    264     SASSAMPLE_POS_X = {"variable" : "{0}.sample.position.x = {1}", 
    265                        "unit" : "sample.position_unit", 
     170    SASSAMPLE_POS_ATTR = {"unit" : {}} 
     171    SASSAMPLE_POS_X = {"unit" : "position_unit", 
    266172                       "storeas" : "float", 
    267173                       "attributes" : SASSAMPLE_POS_ATTR 
    268174                      } 
    269     SASSAMPLE_POS_Y = {"variable" : "{0}.sample.position.y = {1}", 
    270                        "unit" : "sample.position_unit", 
     175    SASSAMPLE_POS_Y = {"unit" : "position_unit", 
    271176                       "storeas" : "float", 
    272177                       "attributes" : SASSAMPLE_POS_ATTR 
    273178                      } 
    274     SASSAMPLE_POS_Z = {"variable" : "{0}.sample.position.z = {1}", 
    275                        "unit" : "sample.position_unit", 
     179    SASSAMPLE_POS_Z = {"unit" : "position_unit", 
    276180                       "storeas" : "float", 
    277181                       "attributes" : SASSAMPLE_POS_ATTR 
    278182                      } 
    279     SASSAMPLE_POS = {"children" : {"variable" : None, 
    280                                    "x" : SASSAMPLE_POS_X, 
     183    SASSAMPLE_POS = {"children" : {"x" : SASSAMPLE_POS_X, 
    281184                                   "y" : SASSAMPLE_POS_Y, 
    282185                                   "z" : SASSAMPLE_POS_Z, 
    283186                                  }, 
    284187                    } 
    285     SASSAMPLE_ORIENT_ATTR = {"unit" : 
    286                              {"variable" : 
    287                               "{0}.sample.orientation_unit = \"{1}\"", 
    288                               "storeas" : "content" 
    289                              } 
    290                             } 
    291     SASSAMPLE_ORIENT_ROLL = {"variable" : "{0}.sample.orientation.x = {1}", 
    292                              "unit" : "sample.orientation_unit", 
     188    SASSAMPLE_ORIENT_ATTR = {"unit" :{}} 
     189    SASSAMPLE_ORIENT_ROLL = {"unit" : "orientation_unit", 
    293190                             "storeas" : "float", 
    294191                             "attributes" : SASSAMPLE_ORIENT_ATTR 
    295192                            } 
    296     SASSAMPLE_ORIENT_PITCH = {"variable" : "{0}.sample.orientation.y = {1}", 
    297                               "unit" : "sample.orientation_unit", 
     193    SASSAMPLE_ORIENT_PITCH = {"unit" : "orientation_unit", 
    298194                              "storeas" : "float", 
    299195                              "attributes" : SASSAMPLE_ORIENT_ATTR 
    300196                             } 
    301     SASSAMPLE_ORIENT_YAW = {"variable" : "{0}.sample.orientation.z = {1}", 
    302                             "unit" : "sample.orientation_unit", 
     197    SASSAMPLE_ORIENT_YAW = {"unit" : "orientation_unit", 
    303198                            "storeas" : "float", 
    304199                            "attributes" : SASSAMPLE_ORIENT_ATTR 
    305200                           } 
    306     SASSAMPLE_ORIENT = {"variable" : None, 
    307                         "children" : {"roll" : SASSAMPLE_ORIENT_ROLL, 
     201    SASSAMPLE_ORIENT = {"children" : {"roll" : SASSAMPLE_ORIENT_ROLL, 
    308202                                      "pitch" : SASSAMPLE_ORIENT_PITCH, 
    309203                                      "yaw" : SASSAMPLE_ORIENT_YAW, 
     
    311205                       } 
    312206    SASSAMPLE = {"attributes" : 
    313                  {"name" : {"variable" : "{0}.sample.name = \"{1}\""},}, 
    314                  "variable" : None, 
    315                  "children" : {"ID" : {"variable" : "{0}.sample.ID = \"{1}\""}, 
     207                 {"name" : {},}, 
     208                 "children" : {"ID" : {}, 
    316209                               "thickness" : SASSAMPLE_THICK, 
    317210                               "transmission" : SASSAMPLE_TRANS, 
     
    319212                               "position" : SASSAMPLE_POS, 
    320213                               "orientation" : SASSAMPLE_ORIENT, 
    321                                "details" : 
    322                                {"variable" : 
    323                                 "{0}.sample.details.append(\"{1}\")"}, 
     214                               "details" : {}, 
    324215                               "<any>" : ANY 
    325216                              }, 
    326217                } 
    327     SASINSTR_SRC_BEAMSIZE_ATTR = {"unit" : 
    328                                   "{0}.source.beam_size_unit = \"{1}\"", 
    329                                   "storeas" : "content" 
    330                                  } 
    331     SASINSTR_SRC_BEAMSIZE_X = {"variable" : "{0}.source.beam_size.x = {1}", 
    332                                "unit" : "source.beam_size_unit", 
     218    SASINSTR_SRC_BEAMSIZE_ATTR = {"unit" : ""} 
     219    SASINSTR_SRC_BEAMSIZE_X = {"unit" : "beam_size_unit", 
    333220                               "storeas" : "float", 
    334221                               "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR 
    335222                              } 
    336     SASINSTR_SRC_BEAMSIZE_Y = {"variable" : "{0}.source.beam_size.y = {1}", 
    337                                "unit" : "source.beam_size_unit", 
     223    SASINSTR_SRC_BEAMSIZE_Y = {"unit" : "beam_size_unit", 
    338224                               "storeas" : "float", 
    339225                               "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR 
    340226                              } 
    341     SASINSTR_SRC_BEAMSIZE_Z = {"variable" : "{0}.source.beam_size.z = {1}", 
    342                                "unit" : "source.beam_size_unit", 
     227    SASINSTR_SRC_BEAMSIZE_Z = {"unit" : "beam_size_unit", 
    343228                               "storeas" : "float", 
    344229                               "attributes" : SASINSTR_SRC_BEAMSIZE_ATTR 
    345230                              } 
    346     SASINSTR_SRC_BEAMSIZE = {"attributes" : 
    347                              {"name" : {"variable" : 
    348                                         "{0}.source.beam_size_name = \"{1}\""}}, 
    349                              "variable" : None, 
     231    SASINSTR_SRC_BEAMSIZE = {"attributes" : {"name" : {}}, 
    350232                             "children" : {"x" : SASINSTR_SRC_BEAMSIZE_X, 
    351233                                           "y" : SASINSTR_SRC_BEAMSIZE_Y, 
     
    353235                                          } 
    354236                            } 
    355     SASINSTR_SRC_WL = {"variable" : "{0}.source.wavelength = {1}", 
    356                        "unit" : "source.wavelength_unit", 
    357                        "storeas" : "float", 
    358                        "attributes" : 
    359                        {"unit" : 
    360                         {"variable" : "{0}.source.wavelength_unit = \"{1}\"", 
    361                          "storeas" : "content" 
    362                         }, 
     237    SASINSTR_SRC_WL = {"unit" : "wavelength_unit", 
     238                       "storeas" : "float", 
     239                       "attributes" : {"unit" :{}, 
    363240                       } 
    364241                      } 
    365     SASINSTR_SRC_WL_MIN = {"variable" : "{0}.source.wavelength_min = {1}", 
    366                            "unit" : "source.wavelength_min_unit", 
     242    SASINSTR_SRC_WL_MIN = {"unit" : "wavelength_min_unit", 
    367243                           "storeas" : "float", 
    368                            "attributes" : 
    369                            {"unit" : 
    370                             {"variable" : 
    371                              "{0}.source.wavelength_min_unit = \"{1}\"", 
    372                              "storeas" : "content" 
    373                             }, 
    374                            } 
     244                           "attributes" : {"unit" :{"storeas" : "content"},} 
    375245                          } 
    376     SASINSTR_SRC_WL_MAX = {"variable" : "{0}.source.wavelength_max = {1}", 
    377                            "unit" : "source.wavelength_max_unit", 
     246    SASINSTR_SRC_WL_MAX = {"unit" : "wavelength_max_unit", 
    378247                           "storeas" : "float", 
    379                            "attributes" : 
    380                            {"unit" : 
    381                             {"variable" : 
    382                              "{0}.source.wavelength_max_unit = \"{1}\"", 
    383                              "storeas" : "content" 
    384                             }, 
    385                            } 
     248                           "attributes" : {"unit" :{"storeas" : "content"},} 
    386249                          } 
    387     SASINSTR_SRC_WL_SPR = {"variable" : "{0}.source.wavelength_spread = {1}", 
    388                            "unit" : "source.wavelength_spread_unit", 
     250    SASINSTR_SRC_WL_SPR = {"unit" : "wavelength_spread_unit", 
    389251                           "storeas" : "float", 
    390                            "attributes" : 
    391                            {"unit" : 
    392                             {"variable" : 
    393                              "{0}.source.wavelength_spread_unit = \"{1}\"", 
    394                              "storeas" : "content" 
    395                             }, 
    396                            } 
     252                           "attributes" : {"unit" : {"storeas" : "content"},} 
    397253                          } 
    398     SASINSTR_SRC = {"attributes" : {"name" : {"variable" : 
    399                                               "{0}.source.name = \"{1}\""}}, 
    400                     "variable" : None, 
    401                     "children" : {"radiation" : 
    402                                   {"variable" : 
    403                                    "{0}.source.radiation = \"{1}\""}, 
     254    SASINSTR_SRC = {"attributes" : {"name" : {}}, 
     255                    "children" : {"radiation" : {}, 
    404256                                  "beam_size" : SASINSTR_SRC_BEAMSIZE, 
    405                                   "beam_shape" : 
    406                                   {"variable" : 
    407                                    "{0}.source.beam_shape = \"{1}\""}, 
     257                                  "beam_shape" : {}, 
    408258                                  "wavelength" : SASINSTR_SRC_WL, 
    409259                                  "wavelength_min" : SASINSTR_SRC_WL_MIN, 
     
    412262                                 }, 
    413263                   } 
    414     SASINSTR_COLL_APER_ATTR = {"unit" : {"variable" : "{0}.size_unit = \"{1}\"", 
    415                                          "storeas" : "content" 
    416                                         }, 
    417                               } 
    418     SASINSTR_COLL_APER_X = {"variable" : "{0}.size.x = {1}", 
    419                             "unit" : "size_unit", 
     264    SASINSTR_COLL_APER_ATTR = {"unit" : {}} 
     265    SASINSTR_COLL_APER_X = {"unit" : "size_unit", 
    420266                            "storeas" : "float", 
    421267                            "attributes" : SASINSTR_COLL_APER_ATTR 
    422268                           } 
    423     SASINSTR_COLL_APER_Y = {"variable" : "{0}.size.y = {1}", 
    424                             "unit" : "size_unit", 
     269    SASINSTR_COLL_APER_Y = {"unit" : "size_unit", 
    425270                            "storeas" : "float", 
    426271                            "attributes" : SASINSTR_COLL_APER_ATTR 
    427272                           } 
    428     SASINSTR_COLL_APER_Z = {"variable" : "{0}.size.z = {1}", 
    429                             "unit" : "size_unit", 
     273    SASINSTR_COLL_APER_Z = {"unit" : "size_unit", 
    430274                            "storeas" : "float", 
    431275                            "attributes" : SASINSTR_COLL_APER_ATTR 
    432276                           } 
    433     SASINSTR_COLL_APER_SIZE = {"attributes" : 
    434                                {"unit" : {"variable" : 
    435                                           "{0}.size_unit = \"{1}\""}}, 
     277    SASINSTR_COLL_APER_SIZE = {"attributes" : {"unit" : {}}, 
    436278                               "children" : {"storeas" : "float", 
    437279                                             "x" : SASINSTR_COLL_APER_X, 
     
    441283                              } 
    442284    SASINSTR_COLL_APER_DIST = {"storeas" : "float", 
    443                                "attributes" : 
    444                                {"storeas" : "content", 
    445                                 "unit" : {"variable" : 
    446                                           "{0}.distance_unit = \"{1}\""} 
    447                                }, 
    448                                "variable" : "{0}.distance = {1}", 
     285                               "attributes" : {"unit" : {}}, 
    449286                               "unit" : "distance_unit", 
    450287                              } 
    451     SASINSTR_COLL_APER = {"variable" : None, 
    452                           "attributes" : {"name" : {"variable" : 
    453                                                     "{0}.name = \"{1}\""}, 
    454                                           "type" : {"variable" : 
    455                                                     "{0}.type = \"{1}\""}, 
    456                                          }, 
     288    SASINSTR_COLL_APER = {"attributes" : {"name" : {}, "type" : {}, }, 
    457289                          "children" : {"size" : SASINSTR_COLL_APER_SIZE, 
    458290                                        "distance" : SASINSTR_COLL_APER_DIST 
    459291                                       } 
    460292                         } 
    461     SASINSTR_COLL = {"attributes" : 
    462                      {"name" : {"variable" : "{0}.name = \"{1}\""}}, 
    463                      "variable" : None, 
     293    SASINSTR_COLL = {"attributes" : {"name" : {}}, 
    464294                     "children" : 
    465                      {"length" : 
    466                       {"variable" : "{0}.length = {1}", 
    467                        "unit" : "length_unit", 
    468                        "storeas" : "float", 
    469                        "attributes" : 
    470                        {"storeas" : "content", 
    471                         "unit" : {"variable" : "{0}.length_unit = \"{1}\""} 
    472                        }, 
    473                       }, 
    474                       "aperture" : SASINSTR_COLL_APER, 
    475                      }, 
     295                         {"length" : 
     296                          {"unit" : "length_unit", 
     297                           "storeas" : "float", 
     298                           "attributes" : {"storeas" : "content", "unit" : {}}, 
     299                          }, 
     300                          "aperture" : SASINSTR_COLL_APER, 
     301                         }, 
    476302                    } 
    477     SASINSTR_DET_SDD = {"variable" : "{0}.distance = {1}", 
     303    SASINSTR_DET_SDD = {"storeas" : "float", 
    478304                        "unit" : "distance_unit", 
    479                         "attributes" : 
    480                         {"unit" : 
    481                          {"variable" : "{0}.distance_unit = \"{1}\"", 
    482                           "storeas" : "content" 
    483                          } 
    484                         }, 
     305                        "attributes" : {"unit" :{}}, 
    485306                       } 
    486     SASINSTR_DET_OFF_ATTR = {"unit" : {"variable" : "{0}.offset_unit = \"{1}\"", 
    487                                        "storeas" : "content" 
    488                                       }, 
    489                             } 
    490     SASINSTR_DET_OFF_X = {"variable" : "{0}.offset.x = {1}", 
     307    SASINSTR_DET_OFF_ATTR = {"unit" : {"storeas" : "content" }} 
     308    SASINSTR_DET_OFF_X = {"storeas" : "float", 
    491309                          "unit" : "offset_unit", 
    492310                          "attributes" : SASINSTR_DET_OFF_ATTR 
    493311                         } 
    494     SASINSTR_DET_OFF_Y = {"variable" : "{0}.offset.y = {1}", 
     312    SASINSTR_DET_OFF_Y = {"storeas" : "float", 
    495313                          "unit" : "offset_unit", 
    496314                          "attributes" : SASINSTR_DET_OFF_ATTR 
    497315                         } 
    498     SASINSTR_DET_OFF_Z = {"variable" : "{0}.offset.z = {1}", 
     316    SASINSTR_DET_OFF_Z = {"storeas" : "float", 
    499317                          "unit" : "offset_unit", 
    500318                          "attributes" : SASINSTR_DET_OFF_ATTR 
    501319                         } 
    502     SASINSTR_DET_OFF = {"variable" : None, 
    503                         "children" : {"x" : SASINSTR_DET_OFF_X, 
     320    SASINSTR_DET_OFF = {"children" : {"x" : SASINSTR_DET_OFF_X, 
    504321                                      "y" : SASINSTR_DET_OFF_Y, 
    505322                                      "z" : SASINSTR_DET_OFF_Z, 
    506323                                     } 
    507324                       } 
    508     SASINSTR_DET_OR_ATTR = {"unit" : "{0}.orientation_unit = \"{1}\"", 
    509                             "storeas" : "content" 
    510                            } 
    511     SASINSTR_DET_OR_ROLL = {"variable" : "{0}.orientation.x = {1}", 
     325    SASINSTR_DET_OR_ATTR = {} 
     326    SASINSTR_DET_OR_ROLL = {"storeas" : "float", 
    512327                            "unit" : "orientation_unit", 
    513328                            "attributes" : SASINSTR_DET_OR_ATTR 
    514329                           } 
    515     SASINSTR_DET_OR_PITCH = {"variable" : "{0}.orientation.y = {1}", 
     330    SASINSTR_DET_OR_PITCH = {"storeas" : "float", 
    516331                             "unit" : "orientation_unit", 
    517332                             "attributes" : SASINSTR_DET_OR_ATTR 
    518333                            } 
    519     SASINSTR_DET_OR_YAW = {"variable" : "{0}.orientation.z = {1}", 
     334    SASINSTR_DET_OR_YAW = {"storeas" : "float", 
    520335                           "unit" : "orientation_unit", 
    521336                           "attributes" : SASINSTR_DET_OR_ATTR 
    522337                          } 
    523     SASINSTR_DET_OR = {"variable" : None, 
    524                        "children" : {"roll" : SASINSTR_DET_OR_ROLL, 
     338    SASINSTR_DET_OR = {"children" : {"roll" : SASINSTR_DET_OR_ROLL, 
    525339                                     "pitch" : SASINSTR_DET_OR_PITCH, 
    526340                                     "yaw" : SASINSTR_DET_OR_YAW, 
    527341                                    } 
    528342                      } 
    529     SASINSTR_DET_BC_X = {"variable" : "{0}.beam_center.x = {1}", 
     343    SASINSTR_DET_BC_X = {"storeas" : "float", 
    530344                         "unit" : "beam_center_unit", 
    531                          "attributes" : 
    532                          {"unit" : "{0}.beam_center_unit = \"{1}\"", 
    533                           "storeas" : "content" 
    534                          } 
    535                         } 
    536     SASINSTR_DET_BC_Y = {"variable" : "{0}.beam_center.y = {1}", 
     345                         "attributes" : {"storeas" : "content"} 
     346                        } 
     347    SASINSTR_DET_BC_Y = {"storeas" : "float", 
    537348                         "unit" : "beam_center_unit", 
    538                          "attributes" : 
    539                          {"unit" : "{0}.beam_center_unit = \"{1}\"", 
    540                           "storeas" : "content" 
    541                          } 
    542                         } 
    543     SASINSTR_DET_BC_Z = {"variable" : "{0}.beam_center.z = {1}", 
     349                         "attributes" : {"storeas" : "content"} 
     350                        } 
     351    SASINSTR_DET_BC_Z = {"storeas" : "float", 
    544352                         "unit" : "beam_center_unit", 
    545                          "attributes" : 
    546                          {"unit" : "{0}.beam_center_unit = \"{1}\"", 
    547                           "storeas" : "content" 
    548                          } 
    549                         } 
    550     SASINSTR_DET_BC = {"variable" : None, 
    551                        "children" : {"x" : SASINSTR_DET_BC_X, 
     353                         "attributes" : {"storeas" : "content"} 
     354                        } 
     355    SASINSTR_DET_BC = {"children" : {"x" : SASINSTR_DET_BC_X, 
    552356                                     "y" : SASINSTR_DET_BC_Y, 
    553                                      "z" : SASINSTR_DET_BC_Z, 
    554                                     } 
    555                       } 
    556     SASINSTR_DET_PIXEL_X = {"variable" : "{0}.pixel_size.x = {1}", 
     357                                     "z" : SASINSTR_DET_BC_Z,} 
     358                      } 
     359    SASINSTR_DET_PIXEL_X = {"storeas" : "float", 
    557360                            "unit" : "pixel_size_unit", 
    558                             "attributes" : 
    559                             {"unit" : "{0}.pixel_size_unit = \"{1}\"", 
    560                              "storeas" : "content" 
    561                             } 
    562                            } 
    563     SASINSTR_DET_PIXEL_Y = {"variable" : "{0}.pixel_size.y = {1}", 
     361                            "attributes" : {"storeas" : "content" } 
     362                           } 
     363    SASINSTR_DET_PIXEL_Y = {"storeas" : "float", 
    564364                            "unit" : "pixel_size_unit", 
    565                             "attributes" : 
    566                             {"unit" : "{0}.pixel_size_unit = \"{1}\"", 
    567                              "storeas" : "content" 
    568                             } 
    569                            } 
    570     SASINSTR_DET_PIXEL_Z = {"variable" : "{0}.pixel_size.z = {1}", 
     365                            "attributes" : {"storeas" : "content"} 
     366                           } 
     367    SASINSTR_DET_PIXEL_Z = {"storeas" : "float", 
    571368                            "unit" : "pixel_size_unit", 
    572                             "attributes" : 
    573                             {"unit" : "{0}.pixel_size_unit = \"{1}\"", 
    574                              "storeas" : "content" 
    575                             } 
    576                            } 
    577     SASINSTR_DET_PIXEL = {"variable" : None, 
    578                           "children" : {"x" : SASINSTR_DET_PIXEL_X, 
     369                            "attributes" : {"storeas" : "content"} 
     370                           } 
     371    SASINSTR_DET_PIXEL = {"children" : {"x" : SASINSTR_DET_PIXEL_X, 
    579372                                        "y" : SASINSTR_DET_PIXEL_Y, 
    580373                                        "z" : SASINSTR_DET_PIXEL_Z, 
    581374                                       } 
    582375                         } 
    583     SASINSTR_DET_SLIT = {"variable" : "{0}.slit_length = {1}", 
     376    SASINSTR_DET_SLIT = {"storeas" : "float", 
    584377                         "unit" : "slit_length_unit", 
    585                          "attributes" : 
    586                          {"unit" : 
    587                           {"variable" : "{0}.slit_length_unit = \"{1}\"", 
    588                            "storeas" : "content" 
    589                           } 
    590                          } 
    591                         } 
    592     SASINSTR_DET = {"storeas" : "float", 
    593                     "variable" : None, 
    594                     "attributes" : {"name" : 
    595                                     {"storeas" : "content", 
    596                                      "variable" : "{0}.name = \"{1}\"", 
    597                                     } 
    598                                    }, 
    599                     "children" : {"name" : {"storeas" : "content", 
    600                                             "variable" : "{0}.name = \"{1}\"", 
    601                                            }, 
     378                         "attributes" : {"unit" : {}} 
     379                        } 
     380    SASINSTR_DET = {"attributes" : {"name" : {"storeas" : "content"}}, 
     381                    "children" : {"name" : {"storeas" : "content"}, 
    602382                                  "SDD" : SASINSTR_DET_SDD, 
    603383                                  "offset" : SASINSTR_DET_OFF, 
     
    608388                                 } 
    609389                   } 
    610     SASINSTR = {"variable" : None, 
    611                 "children" : 
    612                 {"variable" : None, 
    613                  "name" : {"variable" : "{0}.instrument = \"{1}\""}, 
     390    SASINSTR = {"children" : 
     391                {"name" : {}, 
    614392                 "SASsource" : SASINSTR_SRC, 
    615393                 "SAScollimation" : SASINSTR_COLL, 
     
    619397    CANSAS_FORMAT = {"SASentry" : 
    620398                     {"units_optional" : True, 
    621                       "variable" : None, 
    622399                      "storeas" : "content", 
    623                       "attributes" : {"name" : 
    624                                       {"variable" : 
    625                                        "{0}.run_name[\"{3}\"] = \"{1}\""}}, 
     400                      "attributes" : {"name" : {}}, 
    626401                      "children" : {"Title" : TITLE, 
    627402                                    "Run" : RUN, 
     
    644419 
    645420    current_level = '' 
    646     ns_variable = '' 
    647421    ns_datatype = '' 
    648422    ns_optional = True 
     
    650424    def __init__(self): 
    651425        self.current_level = {} 
    652         self.ns_variable = '' 
    653426        self.ns_datatype = "content" 
    654427        self.ns_optional = True 
Note: See TracChangeset for help on using the changeset viewer.