PEATDB/Ekin/Ekin_CD.py
def import_CD_tempscan(self):
        """Import a temperature scan from a Jasco CD spec"""
        import tkFileDialog, os
        filename=tkFileDialog.askopenfilename(defaultextension='.txt',initialdir=os.getcwd(),
                                              filetypes=[("Jasco txt","*.txt"),
                                                         ("All files","*.*")],
                                              parent=self.ekin_win)
        if not filename:
            return
        #
        # If we got a filename then read the stuff
        #
        import os
        if not os.path.isfile(filename):
            import tkMessageBox
            tkMessageBox.showwarning('File not found',
                                     'I could not find %s' %filename,
                                     parent=self.ekin_win)
            return
        #
        # Open and read file
        #
        fd=open(filename)
        lines=fd.readlines()
        fd.close()
        #
        # Parse file
        #
        # Format is:
        # 00 TITLE	0.6mg/ml hewl sigma
        # 01 DATA TYPE
        # 02 ORIGIN	JASCO
        # 03 OWNER
        # 04 DATE	06/10/17
        # 05 TIME	17:59:52
        # 06 SPECTROMETER/DATA SYSTEM	J-810
        # 07 DELTAT	0
        # 08 TUNITS	Temperature [C]
        # 09 FIRSTT	25
        # 10 LASTT	35
        # 11 NPOINTST	3
        # 12 DELTAX	-0.5
        # 13 XUNITS	Wavelength [nm]
        # 14 YUNITS	CD[mdeg]
        # 15 YUNITS2	HT[V]
        # 16 FIRSTX	350
        # 17 LASTX	250
        # 18 NPOINTS	201
        # 19 XYDATA1	25	30	35
	#
        # For a file with scans of three temperatures
        #
        data={}
        data['TITLE']=lines[0]
        data['ORIGIN']=lines[1]
        data['DATE']=lines[4]+lines[5]
        data['SPEC']=lines[6]
        #
        # Get the range of temps
        #
        t_temps=lines[19].split()[1:]
        temps=[]
        for t in t_temps:
            temps.append(float(t))
        #
        # Get the number of wavelengths
        #
        lambda_points=int(lines[18].split()[-1])
        #
        # Read the data
        #
        raw_data={}
        for x in range(lambda_points):
            line=lines[x+20]
            line=line.split()
            wavlen=float(line[0])
            count=0
            for temp in temps:
                count=count+1
                mdeg=float(line[count])
                if not raw_data.has_key(temp):
                    raw_data[temp]=[]
                raw_data[temp].append([wavlen,mdeg])
        #
        # Insert the tabs
        #
        temp1=temps[0]
        dps=len(raw_data[temp1])
        for temp in temps:
            newtab_num=self.add_datalist('CD(T'+str(temp)+')',data_points=dps)
            count=0
            for wavlen,mdeg in raw_data[temp]:
                self.data[newtab_num][0][count]['var'].set(wavlen)
                self.data[newtab_num][1][count]['var'].set(mdeg)
                count=count+1
        self.mode_var.set(5)
        self.update_mode()
        self.redraw_graph(fitting=1)

        return
Import a temperature scan from a Jasco CD spec
Import a temperature scan from a Jasco CD spec
Import a temperature scan from a Jasco CD spec
def import_CD_tempscan(self):
        import tkFileDialog, os
        filename=tkFileDialog.askopenfilename(defaultextension='.txt',initialdir=os.getcwd(),
                                              filetypes=[("Jasco txt","*.txt"),
                                                         ("All files","*.*")],
                                              parent=self.ekin_win)
        if not filename:
            return
         If we got a filename then read the stuff
        import os
        if not os.path.isfile(filename):
            import tkMessageBox
            tkMessageBox.showwarning('File not found',
                                     'I could not find %s' %filename,
                                     parent=self.ekin_win)
            return
         Open and read file
        fd=open(filename)
        lines=fd.readlines()
        fd.close()
         Parse file
         Format is:
         00 TITLE	0.6mg/ml hewl sigma
         01 DATA TYPE
         02 ORIGIN	JASCO
         03 OWNER
         04 DATE	06/10/17
         05 TIME	17:59:52
         06 SPECTROMETER/DATA SYSTEM	J-810
         07 DELTAT	0
         08 TUNITS	Temperature [C]
         09 FIRSTT	25
         10 LASTT	35
         11 NPOINTST	3
         12 DELTAX	-0.5
         13 XUNITS	Wavelength [nm]
         14 YUNITS	CD[mdeg]
         15 YUNITS2	HT[V]
         16 FIRSTX	350
         17 LASTX	250
         18 NPOINTS	201
         19 XYDATA1	25	30	35
         For a file with scans of three temperatures
        data={}
        data['TITLE']=lines[0]
        data['ORIGIN']=lines[1]
        data['DATE']=lines[4]+lines[5]
        data['SPEC']=lines[6]
         Get the range of temps
        t_temps=lines[19].split()[1:]
        temps=[]
        for t in t_temps:
            temps.append(float(t))
         Get the number of wavelengths
        lambda_points=int(lines[18].split()[-1])
         Read the data
        raw_data={}
        for x in range(lambda_points):
            line=lines[x+20]
            line=line.split()
            wavlen=float(line[0])
            count=0
            for temp in temps:
                count=count+1
                mdeg=float(line[count])
                if not raw_data.has_key(temp):
                    raw_data[temp]=[]
                raw_data[temp].append([wavlen,mdeg])
         Insert the tabs
        temp1=temps[0]
        dps=len(raw_data[temp1])
        for temp in temps:
            newtab_num=self.add_datalist('CD(T'+str(temp)+')',data_points=dps)
            count=0
            for wavlen,mdeg in raw_data[temp]:
                self.data[newtab_num][0][count]['var'].set(wavlen)
                self.data[newtab_num][1][count]['var'].set(mdeg)
                count=count+1
        self.mode_var.set(5)
        self.update_mode()
        self.redraw_graph(fitting=1)
        return
def import_CD_tempscan ( self ) : import tkFileDialog , os filename = tkFileDialog . askopenfilename ( defaultextension = '.txt' , initialdir = os . getcwd ( ) , filetypes = [ ( "Jasco txt" , "*.txt" ) , ( "All files" , "*.*" ) ] , parent = self . ekin_win ) if not filename : return import os if not os . path . isfile ( filename ) : import tkMessageBox tkMessageBox . showwarning ( 'File not found' , 'I could not find %s' % filename , parent = self . ekin_win ) return fd = open ( filename ) lines = fd . readlines ( ) fd . close ( ) data = { } data [ 'TITLE' ] = lines [ 0 ] data [ 'ORIGIN' ] = lines [ 1 ] data [ 'DATE' ] = lines [ 4 ] + lines [ 5 ] data [ 'SPEC' ] = lines [ 6 ] t_temps = lines [ 19 ] . split ( ) [ 1 : ] temps = [ ] for t in t_temps : temps . append ( float ( t ) ) lambda_points = int ( lines [ 18 ] . split ( ) [ - 1 ] ) raw_data = { } for x in range ( lambda_points ) : line = lines [ x + 20 ] line = line . split ( ) wavlen = float ( line [ 0 ] ) count = 0 for temp in temps : count = count + 1 mdeg = float ( line [ count ] ) if not raw_data . has_key ( temp ) : raw_data [ temp ] = [ ] raw_data [ temp ] . append ( [ wavlen , mdeg ] ) temp1 = temps [ 0 ] dps = len ( raw_data [ temp1 ] ) for temp in temps : newtab_num = self . add_datalist ( 'CD(T' + str ( temp ) + ')' , data_points = dps ) count = 0 for wavlen , mdeg in raw_data [ temp ] : self . data [ newtab_num ] [ 0 ] [ count ] [ 'var' ] . set ( wavlen ) self . data [ newtab_num ] [ 1 ] [ count ] [ 'var' ] . set ( mdeg ) count = count + 1 self . mode_var . set ( 5 ) self . update_mode ( ) self . redraw_graph ( fitting = 1 ) return
Import a temperature scan from a Jasco CD spec
Import a temperature scan from a Jasco CD spec
"""Import a temperature scan from a Jasco CD spec""" # # If we got a filename then read the stuff # # # Open and read file # # # Parse file # # Format is: # 00 TITLE	0.6mg/ml hewl sigma # 01 DATA TYPE # 02 ORIGIN	JASCO # 03 OWNER # 04 DATE	06/10/17 # 05 TIME	17:59:52 # 06 SPECTROMETER/DATA SYSTEM	J-810 # 07 DELTAT	0 # 08 TUNITS	Temperature [C] # 09 FIRSTT	25 # 10 LASTT	35 # 11 NPOINTST	3 # 12 DELTAX	-0.5 # 13 XUNITS	Wavelength [nm] # 14 YUNITS	CD[mdeg] # 15 YUNITS2	HT[V] # 16 FIRSTX	350 # 17 LASTX	250 # 18 NPOINTS	201 # 19 XYDATA1	25	30	35 # # For a file with scans of three temperatures # # # Get the range of temps # # # Get the number of wavelengths # # # Read the data # # # Insert the tabs #
self