def gen_rst_table(): r"""Generate table of database contents in .rst format.""" sdb = sdoc.SDOC(mode='r') sdb.contents['id'] = sdb.contents.index sdb.contents = sdb.contents[[ 'id', 'material ID', 'material', 'subgroup', 'group', 'reference', 'state', 'phase', 'temperature', 'path' ]] data = list(sdb.contents.values) data.insert(0, [ 'id', 'material ID', 'material', 'subgroup', 'group', 'reference', 'state', 'phase', 'temperature', 'path' ]) numcolumns = len(data[0]) colsizes = [max(len(r[i]) for r in data) for i in range(numcolumns)] formatter = ' '.join('{:<%d}' % c for c in colsizes) rowsformatted = [formatter.format(*row) for row in data] line = formatter.format(*['=' * c for c in colsizes]) output = line + '\n' + rowsformatted[0] + '\n' + line + '\n' \ + '\n'.join(rowsformatted[1:]) + '\n' + line return output
""" Create an Intimate Mixture using Shkuratov model ------------------------------------------------ """ import sdoc from cana.composition import read_constant_batch, IntimateMixture import numpy as np # First load an spectrum, we will just gonna use one from the SDOC database. # See more about SDOC at https://https://github.com/depra/sdoc # Alternatively, you can read your own optical constant using: # oc = cana.read_constant('path to your optical constant file') # First initialize SDOC sdb = sdoc.SDOC(mode='r') # To see what is inside the database: sdb.contents # Here we will just show an example for a titan tholin and ice tholin ocs_label, ocs_data = sdb.get_constant_batch(['T_0', 'I_0']) ocs = read_constant_batch(ocs_data, labels=ocs_label) # Initializing the model mixture = IntimateMixture(samples=ocs, grainsizes=[30, 100], porosity=0.5) # Build the wavelentgh axis w = np.linspace(0.4, 2.3, 200)