lib/transient.py
def export_file_csv(self, directory):
        """
        save Transient() to a .txt file in csv format (data)
        Metadata header is in tab separated values, generated as 'name': 'value' 'unit'
        data is comma separated values, as raw_time, raw_trace, time, trace.

        Metadata is obtained from get_metadata(), resulting in all non0 parameters available.
        """
        # ----------- metadata -----------


        # self.give_name()  # creates a name for the file
        print('Exporting {0}'.format(self.name))
        metadata = self.get_metadata()
        logDict = metadata.pop('analysis_log', None)  # separate log, will be printed later
        logDict.pop('', None)  # remove the useless empty entry
        name = metadata.pop('name', None)
        original_filepath = metadata.pop('original_filepath', None)

        # open file with name self.name in overwrite mode
        file = open(directory + name + '.txt', 'w+')
        # make a title in the header
        file.write('RedRed Scan\n\nMetadata\n\n')
        # write metadata as: parameter: value unit
        for key in metadata:
            try:
                line = (key + ': ' +
                        str(metadata[key]) + ' ' +
                        self.get_unit(key) + '\n')
                file.write(line)
            except TypeError:
                print("Type error for " + key + 'when writing to file: ' +
                      self.name)
        # write analysis log as function: values
        file.write('\nAnalysis\n')
        for key in logDict:
            line = key + ': ' + str(logDict[key]) + '\n'
            file.write(line)

            # ----------- Data -----------
            # Data header followed by column heads:
        file.write('\n\nData\n\n')
        file.write('raw_time, raw_trace, time, trace\n')

        for i in range(len(self.raw_time)):
            line = str(self.raw_time[i]) + ',' + str(self.raw_trace[i])
            try:  # try appending analysied data, or skip if it is finished
                # this because of the deleting of initial and final data
                line += ',' + str(self.time[i]) + ',' + str(self.trace[i])
            except IndexError:
                pass
            finally:
                line += '\n'

            file.write(line)
        file.close()

        save Transient() to a .txt file in csv format (data)
        Metadata header is in tab separated values, generated as 'name': 'value' 'unit'
        data is comma separated values, as raw_time, raw_trace, time, trace.

        Metadata is obtained from get_metadata(), resulting in all non0 parameters available.
        


Metadata is obtained from get_metadata(), resulting in all non0 parameters available.
Metadata is obtained from get_metadata () resulting in all non0 parameters available .
def export_file_csv(self, directory):
        print('Exporting {0}'.format(self.name))
        metadata = self.get_metadata()
        logDict = metadata.pop('analysis_log', None)  
        logDict.pop('', None)  
        name = metadata.pop('name', None)
        original_filepath = metadata.pop('original_filepath', None)
        file = open(directory + name + '.txt', 'w+')
        file.write('RedRed Scan\n\nMetadata\n\n')
        for key in metadata:
            try:
                line = (key + ': ' +
                        str(metadata[key]) + ' ' +
                        self.get_unit(key) + '\n')
                file.write(line)
            except TypeError:
                print("Type error for " + key + 'when writing to file: ' +
                      self.name)
        file.write('\nAnalysis\n')
        for key in logDict:
            line = key + ': ' + str(logDict[key]) + '\n'
            file.write(line)
        file.write('\n\nData\n\n')
        file.write('raw_time, raw_trace, time, trace\n')
        for i in range(len(self.raw_time)):
            line = str(self.raw_time[i]) + ',' + str(self.raw_trace[i])
            try:  
                line += ',' + str(self.time[i]) + ',' + str(self.trace[i])
            except IndexError:
                pass
            finally:
                line += '\n'
            file.write(line)
        file.close()
def export_file_csv ( self , directory ) : print ( 'Exporting {0}' . format ( self . name ) ) metadata = self . get_metadata ( ) logDict = metadata . pop ( 'analysis_log' , None ) logDict . pop ( '' , None ) name = metadata . pop ( 'name' , None ) original_filepath = metadata . pop ( 'original_filepath' , None ) file = open ( directory + name + '.txt' , 'w+' ) file . write ( 'RedRed Scan\n\nMetadata\n\n' ) for key in metadata : try : line = ( key + ': ' + str ( metadata [ key ] ) + ' ' + self . get_unit ( key ) + '\n' ) file . write ( line ) except TypeError : print ( "Type error for " + key + 'when writing to file: ' + self . name ) file . write ( '\nAnalysis\n' ) for key in logDict : line = key + ': ' + str ( logDict [ key ] ) + '\n' file . write ( line ) file . write ( '\n\nData\n\n' ) file . write ( 'raw_time, raw_trace, time, trace\n' ) for i in range ( len ( self . raw_time ) ) : line = str ( self . raw_time [ i ] ) + ',' + str ( self . raw_trace [ i ] ) try : line += ',' + str ( self . time [ i ] ) + ',' + str ( self . trace [ i ] ) except IndexError : pass finally : line += '\n' file . write ( line ) file . close ( )
save Transient() to a .txt file in csv format (data)
Metadata header is in tab separated values, generated as 'name': 'value' 'unit'
data is comma separated values, as raw_time, raw_trace, time, trace.
save Transient () to a . txt file in csv format ( data ) Metadata header is in tab separated values generated as ' name ' : ' value ' ' unit ' data is comma separated values as raw_time raw_trace time trace .
"""
        save Transient() to a .txt file in csv format (data)
        Metadata header is in tab separated values, generated as 'name': 'value' 'unit'
        data is comma separated values, as raw_time, raw_trace, time, trace.

        Metadata is obtained from get_metadata(), resulting in all non0 parameters available.
        """ # ----------- metadata ----------- # self.give_name()  # creates a name for the file # separate log, will be printed later # remove the useless empty entry # open file with name self.name in overwrite mode # make a title in the header # write metadata as: parameter: value unit # write analysis log as function: values # ----------- Data ----------- # Data header followed by column heads: # try appending analysied data, or skip if it is finished # this because of the deleting of initial and final data
self
directory