Пример #1
0
Файл: tga.py Проект: ralesi/rex
    def __init__(self,
            xlfile=EXPERIMENT_DB(),
            sheet='TGA',
            prompt=None,
            debug=0):

        delim = ',' #@UnusedVariable

        self._raw_columns = {'time:sec' : [0, 'Relative Time [s]'],
                'mass' : [1, 'Mass [mg]'],
                'temp' : [2, 'Temperature [C]'],
                'change' : [3, 'Weight Change [%]']
                }

        # After defining the key parameters, we execute our superclasses init
        # which access excel file, pulls info into self._row, and then parses data into self._data_array
        Experiment.__init__(self,
                xlfile = xlfile,
                sheet = sheet,
                prompt = prompt,
                delim = ',',
                txt_col = 6,
                debug = debug)

        # save information from Excel file
        self._curves.add('time:hr', self._curves['time:sec']/3600., 'Time / hr')
Пример #2
0
Файл: dsc.py Проект: ralesi/rex
    def __init__(self,
            xlfile=EXPERIMENT_DB(),
            sheet='DSC',
            prompt=None,
            debug=0):


        # self._raw_columns = {
        #     'Curve', [column, 'label']
        # }



        Experiment.__init__(self,
                xlfile = xlfile,
                sheet = sheet,
                prompt = prompt,
                delim = '\t',
                txt_col = 6,
                debug = debug)

        self._raw_columns = {
            'time:min' : [0, 'Time (min)'],
            'heat:flow' : [1, 'Heat Flow (mW)'],
            'temp:set' : [3, 'Set Point Temperature ($\degree$C)'],
            'temp:act' : [4, 'Temperature ($\degree$C)'],
            'heat:cal' : [6, 'Heat Flow Calibration']
        }

        self._ascii_file = self._path + os.sep + 'data' + os.sep + self.p.get('txt:file')
        self._baseline_file = self._path + os.sep + 'data' + os.sep + self.p.get('baseline:file')

        self._data_array = remove_with_blanks(
            io.parse_ascii(self._ascii_file , '\t')[1:]
        )

        self._baseline_array = remove_with_blanks(
            io.parse_ascii(self._baseline_file, '\t')[1:]
        )

        # if we have defined _raw_columns then add all of those curves (defined for each exp type)
        if hasattr(self, '_raw_columns'):
            self._curves = Curve(self._data_array,self._raw_columns)
            self._baseline = Curve(self._baseline_array,self._raw_columns)
        else:
            self._curves = Curve(self._data_array)
            self._baseline = Curve(self._baseline_array)

        if hasattr(self, '_curves'):
            self._curves.add('time:sec', self._curves['time:min']*60., 'Time (sec)')
            self._curves.add('time:hr', self._curves['time:sec']/3600., 'Time (hr)')

            self.subtract_baseline()
            self.c = self._curves
            self.pl = self._curves.ex_plot
            self.twin = self._curves.ex_twinplot
            self.sub = self._curves.ex_subplot
Пример #3
0
Файл: tgms.py Проект: ralesi/rex
    def __init__(self,
            xlfile=EXPERIMENT_DB,
            sheet='TGMS',
            prompt=None,
            debug=0):


#        self._raw_columns = {'Curve', [column, 'label']
#                }

        self._raw_columns = {'rel_sec' : [0, 'Relative Time [s]'],
                'mass' : [1, 'Mass [mg]'],
                'temp' : [2, 'Temperature [C]'],
                'change' : [3, 'Weight Change [%]']
                }

        Experiment.__init__(self,
                xlfile = xlfile,
                sheet = sheet,
                prompt = prompt,
                delim = ',',
                txt_col = 6,
                dat = None,
                debug = debug)

        # save information from Excel file
        row = self._row

        row_params = {
            }

        self.init_param(row_params)

        # construct experiment name
        self.set_param('Name', '%s-%s.%i' % (row[1], row[2], row[3]))

        # initial date and time (for reference)
        dcol = 1 # date column in txt file @UnusedVariable
        tcol = 2 # time column in txt file @UnusedVariable

        # we do all plots based off relative time
        self.add_curve('rel_hr',[float(sec)/3600 for sec in self._curves['rel_sec']], 'Relative Time [hr]')

        self._labels = {}
Пример #4
0
    def __init__(self,
            xlfile=EXPERIMENT_DB,
            sheet='',
            prompt=None,
            debug=0):


        # self._raw_columns = {
        #     'Curve', [column, 'label']
        # }

        Experiment.__init__(self,
                xlfile = xlfile,
                sheet = sheet,
                prompt = prompt,
                delim = '\t',
                txt_col = 6,
                debug = debug)

        # save information from Excel file
        row = self._row

        row_params = {
            }

        if hasattr(self, '_curves'):
            self._curves.add('time:hr', self._curves['time:sec']/3600., 'Time (hr)')
            self._curves.add('time:min', self._curves['time:sec']/60., 'Time (min)')

        # initial date and time (for reference)
        dcol = 1 # date column in txt file
        tcol = 2 # time column in txt file

        self.get_init(self._data_array[dcol][0], self._data_array[tcol][0])

        # we do all plots based off relative time
        self.get_reltimes()
        self.add_curve('rel_hr',[float(sec)/3600 for sec in self._curves['rel_sec']], 'Relative Time [hr]')

        self._labels = {}
Пример #5
0
    def __init__(self,
            xlfile=EXPERIMENT_DB,
            sheet='TGA',
            prompt=None,
            debug=0):

        delim = ','

        self._raw_columns = {'rel_sec' : [0, 'Relative Time [s]'],
                'mass' : [1, 'Mass [mg]'],
                'temp' : [2, 'Temperature [C]'],
                'change' : [3, 'Weight Change [%]']
                }

        # After defining the key parameters, we execute our superclasses init
        # which access excel file, pulls info into self._row, and then parses data into self._data_array
        Experiment.__init__(self,
                xlfile = xlfile,
                sheet = sheet,
                prompt = prompt,
                delim = ',',
                txt_col = 6,
                dat = None,
                debug = debug)

        # save information from Excel file
        row = self._row

        row_params = {
                }

        self.add_curve('rel_hr',[float(sec)/3600 for sec in self._curves['rel_sec']], 'Relative Time [hr]')

        # Construct experiment name
        self.set_param('Name', '%s-%s.%s' % (row[1], row[2], row[3]))

        self._labels = {'N':'\n',
        'n':self.get_param('Name')}
Пример #6
0
Файл: ir.py Проект: ralesi/rex
    def __init__(self,
            xlfile=EXPERIMENT_DB(),
            sheet='IR',
            prompt=None,
            debug=0):

        Experiment.__init__(self,
                xlfile = xlfile,
                sheet = sheet,
                prompt = prompt,
                delim = '\t',
                txt_col = 8,
                debug = debug)

        # save information from Excel file
        row = self._row

        self._raw_columns = {'wave_uc' : [0, 'Wavenumber (cm$^{-1}$)'],
                'wave' : [1, 'Wavenumber (cm$^{-1}$)'],
                'trans' : [2, 'Transmitance'],
                'abs' : [3, 'Absorbance (A.U)'],
                'n_trans' : [4, 'Transmitance (%)'],
                'n_absl' : [5, 'Absorbance (%)']
            }

        self._data_array = io.parse_jdx(self._ascii_file)
        self._curves = Curve(self._data_array,self._raw_columns)

        # important parameter in excel file
        self._row_params = {
            }

        # construct experiment name
        self._params.set('Name', '%s-%s.%s' % (row[1], row[2], row[3]))

        self._curves._labels = {'N':'\n',
            'n':self._params.get('Name'),
                }
Пример #7
0
    def __init__(self,
            xlfile=EXPERIMENT_DB(),
            sheet='LABVIEW',
            prompt=None,
            debug=0,
            autoload=False):

        self._raw_columns = {
        'time:sec' :          [ 0, 'Time (s)' ],
        'flow:dig' :          [ 1, 'Flow (ccm)' ],
        'flow:inert' :        [ 2, 'Flow (ccm)' ],
        'flow:rxn' :          [ 3, 'Flow (ccm)' ],
        'press:in' :          [ 4, 'Pin (psig)' ],
        'press:out' :         [ 5, 'Pout (psig)' ],
        'temp:in' :           [ 6, 'Temperature of Inlet ($\degree$C)' ],
        'temp:rxn' :          [ 7, 'Temperature of Reactor ($\degree$C)' ],
        'ms:14' :             [ 8, '14' ],
        'ms:18' :             [ 9, '18' ],
        'ms:28' :             [ 10, '28' ],
        'ms:32' :             [ 11, '32' ],
        'ms:40' :             [ 12, '40' ],
        'ms:44' :             [ 13, '44' ],
        'int:h2o' :           [ 14, 'Intensity (a.u)' ],
        'int:n2' :            [ 15, 'Intensity (a.u)' ],
        'int:o2' :            [ 16, 'Intensity (a.u)' ],
        'int:ar' :            [ 17, 'Intensity (a.u)' ],
        'int:co2' :           [ 18, 'Intensity (a.u)' ],
        'conc:a:co2' :        [ 24, 'Concentration (mol %)' ]
        }

        # After defining the key parameters, we execute our superclasses init
        # which access excel file, pulls info into self._row, and then parses data into self._data_array
        Experiment.__init__(self,
                xlfile=xlfile,
                sheet=sheet,
                prompt=prompt,
                delim = ',',
                txt_col = 6,
                debug=debug,
                autoload=autoload)

        if hasattr(self, '_curves'):
            self._curves.add('time:hr', self._curves['time:sec']/3600., 'Time (hr)')
            self._curves.add('time:min', self._curves['time:sec']/60., 'Time (min)')

            """
            lower case is adsorption
            n = name
            N = new line
            t, T = temp
            r = ramp rate
            D = temp change
            p, P = pressure
            h = water concentration
            b = book number
            """

        # TODO define better checks and do error proofing
        # most likely with try statements

        if (os.path.isfile(self._pick_file) and autoload is True) or (not os.path.isfile(self._ascii_file)) or (self._params.get('status') == 'No'):
            pass
        else:

            # FIXME is this the best way?
            # try:
            # construct experiment name
            p = self._params
            p.set('name', '%s-%s-%s' % (p['sorbent'], p['exp'],p['run']))


            self.prompt = prompt

            # find new way to determine stage
            self.get_stage()

            # save mass settings
            self.cal_curves()

            self.__check__('Experimental notes: ' , p['notes'])

            self.get_flux()
            if type(self.p.get('loading')) is float:
                self.get_coverage()

            """
            c, C = coverage (corrected)
            z, Z = trapezoidal capacity
            m, M = mid point capacity (uncorrected)
            i, I = mid point capacity (corrected)
            """

            new_labels = {}

            self._curves._labels.update(new_labels)
Пример #8
0
Файл: pfr.py Проект: ralesi/rex
    def __init__(self,
            xlfile=EXPERIMENT_DB(),
            sheet='PFR',
            prompt=None,
            debug=0,
            autoload=True):

        self._raw_columns = {
            'time:sec' : [3, 'Time / s'],
            'raw:he' : [4,'He Concentration / %'],
            'raw:h2o' : [5, 'H$_2$O Concentration / %'],
            'raw:co2' : [6, 'CO$_2$ Concentration / %'],
            'int:he' : [7, 'He Intensity [m/z]'],
            'int:h2o' : [8, 'H20 Intensity [m/z]'],
            'int:co2' : [9, 'CO2 Intensity [m/z]']
        }

        self._row_params = {'#' : 0,
                'book' : 4,
                'status' : 7,
                'Name' : 1,
                'date' : 6,
                'time:dry' : 24,
                'Run' : 3,
                'conc:He' : 6,
                'conc:H2O' : 9,
                'conc:CO2' : 10,
                'flow:in' : 11,
                'flow:rxn' : 12,
                'timing:abs' : range(13,18),
                'temp:ads' : 20,
                'temp:des' : 21,
                'temp:spg' : 22,
                'temp:ramp' : 23,
                'comment' : 29,
                'loading' : 27,
                'mass:1' : 25,
                'mass:2' : 26
                }


        # After defining the key parameters, we execute our superclasses init
        # which access excel file, pulls info into self._row, and then parses data into self._data_array
        Experiment.__init__(self,
                xlfile=xlfile,
                sheet=sheet,
                prompt=prompt,
                delim = '\t',
                txt_col = 5,
                debug=debug,
                autoload=autoload)

        if hasattr(self, '_curves'):
            self._curves.add('time:hr', self._curves['time:sec']/3600., 'Time / hr')
            self._curves.add('time:hr', self._curves['time:sec']/3600., 'Time / hr')

            """
            lower case is adsorption
            n = name
            N = new line
            t, T = temp
            r = ramp rate
            D = temp change
            p, P = pressure
            h = water concentration
            b = book number
            """

            self._curves._labels = {
                'N':'\n',
                'b':self._params.get('Book'),
                'n':self._params.get('Name'),
                't':'$\mathrm{T}_{ADS} :$ \t\t$%0.1f\,^{\circ}\mathrm{C}$' % (self._params.get('temp:ads')),
                'T':'$\mathrm{T}_{DES} :$ \t\t$%0.1f\,^{\circ}\mathrm{C}$' % (self._params.get('temp:des')),
                'r':'$\mathrm{Ramp:}$ \t$%s\,^{\circ}\mathrm{C/min}$' % (self._params.get('temp:ramp')),
                'D':'$\Delta\mathrm{T:}$ \t$%0.1f\,^{\circ}\mathrm{C}$' % (self._params.get('temp:des') - self._params.get('temp:ads')),
                'p':'$p_{CO_2}$/$p_0:$ \t$0.1$',
                'P':'p$_{CO_2}$/p$_0:$ \t$0.1$ -> $0.0$',
                'h':'%0.1f%% H$_{2}$O' % (100.0*self._params.get('conc:H2O'))
            }

        if (os.path.isfile(self._pick_file) and autoload is True) or (not os.path.isfile(self._ascii_file)) or (self._params.get('status') == 'No'):
            pass
        else:
            #save parameter information from row of excel file
            row = self._row

            # construct experiment name
            self._params.set('Name', '%s-%s.%s' % (row[1], row[2], row[3]))

            # Flux correction from run 11
            self._params.set('Void', PBR_VOID_SPACE)

            self.prompt = prompt

            date = self._curves._raw[1][0]
            time = self._curves._raw[2][0]

            # Parse date into Year Month Day
            # M/D/Y -> Y, M, D
            init_date = [[int(v) for v in date.split('/')][i] for i in [2,0,1]]

            #Parse time into a list of hour, minutes, and seconds
            init_time = [int(a) for a in time.split()[0].split(':')]
            if time.split()[1] == 'PM' and init_time[0] != 12:
                init_time[0] += 12
            init = init_date + [int(v) for v in init_time]

            # Create datetime object for first point (which we will use as our baseline when evaluating relative time)
            self._init = datetime.datetime(*init)
            rel = []
            # TODO is there a more obvious way / modular to do this?
            for time in self._params.get('timing:abs'):
                rel_abs = list(self._init.timetuple()[0:3]) + [int(v) for v in time.split(':')]
                # print rel_abs
                # create datetime object for each point
                rel_abs = datetime.datetime(*rel_abs)
                rel.append(float((rel_abs - self._init).seconds)/3600.)
            self._params.set('timing:rel',rel)

            # stage needs time:hr to complete
            self.get_stage()

            # save mass settings
            m1 = self._params.get('mass:1')
            m2 = self._params.get('mass:2')

            try:
                self._params.set('mass:dm',float(m1)- float(m2))
            except ValueError:
                pass
            try:
                self._params.set('mass:act',float(m1))
            except ValueError:
                pass
            try:
                self._params.set('mass:act',float(m2))
            except ValueError:
                pass

            self.get_temp()
            self.get_flux()
            self.get_coverage()

            # TODO add additional method abbreviations for quick access: i.e. self.c = self._curves.get

            """
            c, C = coverage (corrected)
            z, Z = trapezoidal capacity
            m, M = mid point capacity (uncorrected)
            i, I = mid point capacity (corrected)
            """

            new_labels = {
                'i':'$\mathrm{Mol}_{ADS}\ :$ \t$%0.2f$ $\mathrm{mol\ }CO_2/kg$' % (abs(self._params.get('capc:ads_mid'))),
                'I':'$\mathrm{Mol}_{DES}\ :$ \t$%0.2f$ $\mathrm{mol\ }CO_2/kg$' % (abs(self._params.get('capc:des_mid'))),
                'm':'$\mathrm{Mol}_{ADS}:$ \t$%0.2f$ $\mathrm{mol\ }CO_2/kg$' % (self._params.get('cap:ads_mid')),
                'M':'$\mathrm{Mol}_{DES}:$ \t$%0.2f$ $\mathrm{mol\ }CO_2/kg$' % (self._params.get('cap:des_mid')),
                'c':'$\mathrm{Eff}_{ADS}:$ \t$%0.2f$ $\mathrm{mol\ }CO_2/\mathrm{mol\ }N$' % (self._params.get('effc:ads')),
                'C':'$\mathrm{Eff}_{DES}:$ \t$%0.2f$ $\mathrm{mol\ }CO_2/\mathrm{mol\ }N$' % (self._params.get('effc:des')),
                'z':'$\mathrm{Mol}_{ADS}:$ \t$%0.2f$ $\mathrm{mol\ }CO_2/kg$' % (self._params.get('cap:ads_trap')),
                'X':'$\mathrm{Mol}_{PDES}:$ \t$%0.2f$ $\mathrm{mol\ }CO_2/kg$' % (self._params.get('cap:desp_trap')),
                'Y':'$\mathrm{Mol}_{TDES}:$ \t$%0.2f$ $\mathrm{mol\ }CO_2/kg$' % (self._params.get('cap:dest_trap'))
            }

            self._curves._labels.update(new_labels)
            self._save()