Esempio n. 1
0
 def Data_Storage_mode(self, input):
      if sddsdata.InitializeInput(self.index, input) != 1:
          time.sleep(2)
          if sddsdata.InitializeInput(self.index, input) != 1:
               sddsdata.PrintErrors(self.SDDS_EXIT_PrintErrors)
      self_data_mode = sddsdata.GetMode(self.index)
      return self_data_mode
Esempio n. 2
0
     def load(self, input):
          """Load an SDDS file into an SDDS class."""

          try:
               #open SDDS file
               if sddsdata.InitializeInput(self.index, input) != 1:
                    time.sleep(2)
                    if sddsdata.InitializeInput(self.index, input) != 1:
                         sddsdata.PrintErrors(self.SDDS_EXIT_PrintErrors)

               #get data storage mode (SDDS_ASCII or SDDS_BINARY)
               self.mode = sddsdata.GetMode(self.index)

               #get description text and contents
               self.description = sddsdata.GetDescription(self.index)

               #get parameter names
               self.parameterName = sddsdata.GetParameterNames(self.index)
               numberOfParameters = len(self.parameterName)

               #get column names
               self.columnName = sddsdata.GetColumnNames(self.index)
               numberOfColumns = len(self.columnName)

               #get parameter definitions
               self.parameterDefinition = list(range(numberOfParameters))
               for i in range(numberOfParameters):
                    self.parameterDefinition[i] = sddsdata.GetParameterDefinition(self.index, self.parameterName[i])

               #get column definitions
               self.columnDefinition = list(range(numberOfColumns))
               for i in range(numberOfColumns):
                    self.columnDefinition[i] = sddsdata.GetColumnDefinition(self.index, self.columnName[i])

               #initialize parameter and column data
               self.parameterData = list(range(numberOfParameters))
               self.columnData = list(range(numberOfColumns))
               for i in range(numberOfParameters):
                    self.parameterData[i] = []
               for i in range(numberOfColumns):
                    self.columnData[i] = []

               #read in SDDS data
               page = sddsdata.ReadPage(self.index)
               if page != 1:
                    sddsdata.PrintErrors(self.SDDS_EXIT_PrintErrors)
               while page > 0:
                    for i in range(numberOfParameters):
                         self.parameterData[i].append(sddsdata.GetParameter(self.index,i))
                    for i in range(numberOfColumns):
                         self.columnData[i].append(sddsdata.GetColumn(self.index,i))
                    page = sddsdata.ReadPage(self.index)

               #close SDDS file
               if sddsdata.Terminate(self.index) != 1:
                    sddsdata.PrintErrors(self.SDDS_EXIT_PrintErrors)

          except:
               sddsdata.PrintErrors(self.SDDS_VERBOSE_PrintErrors)
               raise
Esempio n. 3
0
     def Load_Data(self, input):
          """Load a SDDS file into an SDDS class."""

          try:
               #open SDDS file
               if sddsdata.InitializeInput(self.index, input) != 1:
                    time.sleep(2)
                    if sddsdata.InitializeInput(self.index, input) != 1:
                         sddsdata.PrintErrors(self.SDDS_EXIT_PrintErrors)

               #get data storage mode (SDDS_ASCII or SDDS_BINARY)
               self.mode = sddsdata.GetMode(self.index)
               # if (self.mode == 0):
                    # print ()
                    # print ('Data storage mode is ', 'ASCII')
                    # print ()
               # if (self.mode == 1):
                    # print ()
                    # print ('Data storage mode is ', 'BINARY')
                    # print ()

               #get description text and contents
               self.description = sddsdata.GetDescription(self.index)
               # print ()
               # print ('Description text and contents ')
               # print (self.description)
               # print ()

               #get parameter names
               self.parameterName = sddsdata.GetParameterNames(self.index)
               # print ()
               # print ('Parameter names ')
               # print (self.parameterName)
               # print ()
               numberOfParameters = len(self.parameterName)
               # print ()
               # print ('Number of Parameters = ', numberOfParameters)
               # print ()

               #get column names
               self.columnName = sddsdata.GetColumnNames(self.index)
               # print ()
               # print ('Column names ')
               # print (self.columnName)
               # print ()
               numberOfColumns = len(self.columnName)
               # print ()
               # print ('Number of Columns = ', numberOfColumns)
               # print ()

               #get parameter definitions
               self.parameterDefinition = list(range(numberOfParameters))
               for i in range(numberOfParameters):
                    self.parameterDefinition[i] = sddsdata.GetParameterDefinition(self.index, self.parameterName[i])
               # print ()
               # print ('Parameter definitions ')
               # print (self.parameterDefinition)
               # print ()
                    
               #get column definitions
               self.columnDefinition = list(range(numberOfColumns))
               for i in range(numberOfColumns):
                    self.columnDefinition[i] = sddsdata.GetColumnDefinition(self.index, self.columnName[i])
               # print ()
               # print ('Column definitions ')
               # print (self.columnDefinition)
               # print ()

               #initialize parameter and column data     !!!! this is mentioned by River and Vasiliy !!!!
               self.parameterData = list(range(numberOfParameters))
               self.columnData = list(range(numberOfColumns))
               for i in range(numberOfParameters):
                    self.parameterData[i] = []
               for i in range(numberOfColumns):
                    self.columnData[i] = []

               #read in SDDS data
               page = sddsdata.ReadPage(self.index)
               if page != 1:
                    sddsdata.PrintErrors(self.SDDS_EXIT_PrintErrors)
               while page > 0:
                    for i in range(numberOfParameters):
                         self.parameterData[i].append(sddsdata.GetParameter(self.index,i))
                    for i in range(numberOfColumns):
                         self.columnData[i].append(sddsdata.GetColumn(self.index,i))
                    page = sddsdata.ReadPage(self.index)

                    # global x_position
                    # x_position = sddsdata.GetColumn(0,0)
                    # print (x_position[0], x_position[2], x_position[9999])
                    # global y_position
                    # y_position = sddsdata.GetColumn(0,2)
                    # print (y_position[0], y_position[2], y_position[9999])
                    # global z_position
                    # z_position = sddsdata.GetColumn(0,4)
                    # print (z_position[0], z_position[2], z_position[9999])
                    
                    # print (sddsdata.GetColumn(0,0))  # (self.index,i) = (0, 0) means all data for x position
                    # print (sddsdata.GetColumn(0,2))  # (self.index,i) = (0, 2) means all data for y position
                    # print (sddsdata.GetColumn(0,4))  # (self.index,i) = (0, 4) means all data for z position 
                    page = sddsdata.ReadPage(self.index)
                    
               #close SDDS file
               if sddsdata.Terminate(self.index) != 1:
                    sddsdata.PrintErrors(self.SDDS_EXIT_PrintErrors)

          except:
               sddsdata.PrintErrors(self.SDDS_VERBOSE_PrintErrors)
               raise