def read_data(self): """ Read the data from the individual directories into individual dictionaries. Arranged as: [ana_dir] - {state_label} - {key} """ self.data = [] self.main_header = '' for ana_dir in self['ana_dirs']: sfile = lib_file.summ_file(os.path.join(ana_dir, self['ana_file'])) header = sfile.ret_header() ddict = sfile.ret_ddict() if self.main_header == '': self.main_header = header self.data.append(ddict)
def make_spec(self): sfile = lib_file.summ_file(self['ana_file']) header = sfile.ret_header() ddict = sfile.ret_ddict() state_labels = sfile.ret_state_labels() for state in state_labels: try: f = ddict[state]['f'] except KeyError: f = 0. self.spec.add(f, ddict[state]['dE(eV)']) self.spec.normalize() self.spec.ascii_file() if do_plots: self.spec.plot(xunit='eV', pname='spectrum_eV.png') self.spec.plot(xunit='nm', pname='spectrum_nm.png')
def write_table(self): sfile = lib_file.summ_file(self['ana_file']) header = sfile.ret_header() ddict = sfile.ret_ddict() state_labels = sfile.ret_state_labels() if self['prop_list'] == []: self['prop_list'] = header[1:] if self['output_format'] == 'html': wfile = lib_file.htmlfile wtable = lib_file.htmltable elif self['output_format'] == 'latex': wfile = lib_file.latexfile wtable = lib_file.latextable else: raise error_handler.ElseError(self['output_format'], 'output_format') wf = wfile(self['fname']) wf.pre(title='TheoDORE data') wt = wtable(ncol=len(self['prop_list']) + 1) wt.add_row(['State'] + self['prop_list']) for state in state_labels: if not self['lformula']: wt.add_el(state) else: wt.add_el('$%s$' % (state.replace('(', '^').replace(')', ''))) for prop in self['prop_list']: try: wt.add_el(self['fformat'] % ddict[state][prop]) except KeyError: wt.add_el('-') wf.write(wt.ret_table()) wf.post(lvprt=1)
def write_table(self): sfile = lib_file.summ_file(self['ana_file']) header = sfile.ret_header() ddict = sfile.ret_ddict() state_labels = sfile.ret_state_labels() if self['prop_list'] == []: self['prop_list'] = header[1:] if self['output_format'] == 'html': wfile = lib_file.htmlfile wtable = lib_file.htmltable elif self['output_format'] == 'latex': wfile = lib_file.latexfile wtable = lib_file.latextable else: raise error_handler.ElseError(self['output_format'], 'output_format') wf = wfile(self['fname']) wf.pre(title='TheoDORE data') wt = wtable(ncol = len(self['prop_list']) + 1) wt.add_row(['State'] + self['prop_list']) for state in state_labels: if not self['lformula']: wt.add_el(state) else: wt.add_el('$%s$'%(state.replace('(', '^').replace(')', ''))) for prop in self['prop_list']: try: wt.add_el(self['fformat']%ddict[state][prop]) except KeyError: wt.add_el('-') wf.write(wt.ret_table()) wf.post(lvprt=1)