Skip to content

Commit

Permalink
PyIRoGlass v0.2.0 release!
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahshi committed Sep 24, 2023
1 parent 487a2d3 commit ac39bc9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions UnitTests/test_concentration.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def test_concentration(self): # OL53
density_epsilon, mega_spreadsheet = pig.Concentration_Output(self.PH, self.N, self.thickness, self.MI_Composition, self.T_room, self.P_room)
expected_H2O = 4.03892743514451
expected_CO2 = 713.3372363302
self.assertAlmostEqual(float(mega_spreadsheet['H2OT_MEAN']), expected_H2O, self.decimalPlace, msg="H2Ot test values from the Concentration_Output equation do not agree")
self.assertAlmostEqual(float(mega_spreadsheet['CO2_MEAN']), expected_CO2, self.decimalPlace, msg="CO2m test values from the Concentration_Output equation do not agree")
self.assertAlmostEqual(float(mega_spreadsheet['H2OT_MEAN'].iloc[0]), expected_H2O, self.decimalPlace, msg="H2Ot test values from the Concentration_Output equation do not agree")
self.assertAlmostEqual(float(mega_spreadsheet['CO2_MEAN'].iloc[0]), expected_CO2, self.decimalPlace, msg="CO2m test values from the Concentration_Output equation do not agree")

class test_conc_outputs_saturated(unittest.TestCase): # OL49

Expand Down
6 changes: 3 additions & 3 deletions UnitTests/test_density_epsilon.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def test_density_calculation(self):
def test_epsilon_calculation(self):

epsilon = pig.Epsilon_Calculation(self.MI_Composition_dry, self.T_room, self.P_room)
tau = float(epsilon['Tau'])
tau = float(epsilon['Tau'].iloc[0])
expected_tau = 0.682894853
epsilon_h2ot = float(epsilon['epsilon_H2OT_3550'])
epsilon_h2ot = float(epsilon['epsilon_H2OT_3550'].iloc[0])
expected_epsilon_h2ot = 64.4628687805379
sigma_epsilon_h2ot = float(epsilon['sigma_epsilon_H2OT_3550'])
sigma_epsilon_h2ot = float(epsilon['sigma_epsilon_H2OT_3550'].iloc[0])
expected_sigma_epsilon_h2ot = 7.40123952105104
self.assertAlmostEqual(tau, expected_tau, self.decimalPlace, msg="Tau test and expected values from the Epsilon_Calc function do not agree")
self.assertAlmostEqual(epsilon_h2ot, expected_epsilon_h2ot, self.decimalPlace, msg="epsilon_H2Ot test and expected values from the Epsilon_Calc function do not agree")
Expand Down
6 changes: 3 additions & 3 deletions UnitTests/test_fittingfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ def test_MCMC(self):

Volatiles_DF, failures = pig.Run_All_Spectra(self.dfs_dict, None)

result_H2Om_5200 = float(Volatiles_DF['PH_5200_M'])
result_H2Om_5200 = float(Volatiles_DF['PH_5200_M'].iloc[0])
expected_H2Om_5200 = 0.00895907201720743

result_H2Ot_3550 = float(Volatiles_DF['PH_3550_M'])
result_H2Ot_3550 = float(Volatiles_DF['PH_3550_M'].iloc[0])
expected_H2Ot_3550 = 1.52334293070956

result_CO2_1515 = float(Volatiles_DF['PH_1515_BP'])
result_CO2_1515 = float(Volatiles_DF['PH_1515_BP'].iloc[0])
expected_CO2_1515 = 0.057289618537916066

self.assertAlmostEqual(result_H2Om_5200, expected_H2Om_5200, self.decimalPlace, msg="H2Om_5200 peak height test and expected values from the Run_All_Spectra function do not agree")
Expand Down
18 changes: 9 additions & 9 deletions UnitTests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def test_trace_savefile(self, mock_savefig):
pnames = ['B_mean','B_PC1','B_PC2','B_PC3','B_PC4','G1430_peak','G1430_std','G1430_amp',
'G1515_peak','G1515_std','G1515_amp','H1635_mean','H1635_PC1','H1635_PC2','m','b']

texnames = ['$\overline{B}$','$\overline{B}_{PC1}$','$\overline{B}_{PC2}$','$\overline{B}_{PC3}$','$\overline{B}_{PC4}$',
'$\mu_{1430}$','$\sigma_{1430}$','$a_{1430}$','$\mu_{1515}$','$\sigma_{1515}$','$a_{1515}$',
'$\overline{H_{1635}}$','$\overline{H_{1635}}_{PC1}$','$\overline{H_{1635}}_{PC2}$','$m$','$b$']
texnames = ['$\\overline{B}$','$\\overline{B}_{PC1}$','$\\overline{B}_{PC2}$','$\\overline{B}_{PC3}$','$\\overline{B}_{PC4}$',
'$\\mu_{1430}$','$\\sigma_{1430}$','$a_{1430}$','$\\mu_{1515}$','$\\sigma_{1515}$','$a_{1515}$',
'$\\overline{H_{1635}}$','$\\overline{H_{1635}}_{PC1}$','$\\overline{H_{1635}}_{PC2}$','$m$','$b$']

file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../docs/examples/transmission_ftir/NPZTXTFILES/RESULTS/AC4_OL53_101220_256s_30x30_a.npz')
mcmc_npz = np.load(file_path)
Expand All @@ -40,9 +40,9 @@ def test_trace_nosavefile(self, mock_savefig):
pnames = ['B_mean','B_PC1','B_PC2','B_PC3','B_PC4','G1430_peak','G1430_std','G1430_amp',
'G1515_peak','G1515_std','G1515_amp','H1635_mean','H1635_PC1','H1635_PC2','m','b']

texnames = ['$\overline{B}$','$\overline{B}_{PC1}$','$\overline{B}_{PC2}$','$\overline{B}_{PC3}$','$\overline{B}_{PC4}$',
'$\mu_{1430}$','$\sigma_{1430}$','$a_{1430}$','$\mu_{1515}$','$\sigma_{1515}$','$a_{1515}$',
'$\overline{H_{1635}}$','$\overline{H_{1635}}_{PC1}$','$\overline{H_{1635}}_{PC2}$','$m$','$b$']
texnames = ['$\\overline{B}$','$\\overline{B}_{PC1}$','$\\overline{B}_{PC2}$','$\\overline{B}_{PC3}$','$\\overline{B}_{PC4}$',
'$\\mu_{1430}$','$\\sigma_{1430}$','$a_{1430}$','$\\mu_{1515}$','$\\sigma_{1515}$','$a_{1515}$',
'$\\overline{H_{1635}}$','$\\overline{H_{1635}}_{PC1}$','$\\overline{H_{1635}}_{PC2}$','$m$','$b$']

file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../docs/examples/transmission_ftir/NPZTXTFILES/RESULTS/AC4_OL53_101220_256s_30x30_a.npz')
mcmc_npz = np.load(file_path)
Expand Down Expand Up @@ -77,9 +77,9 @@ def test_modelfit_savefile(self, mock_savefig):
pnames = ['B_mean','B_PC1','B_PC2','B_PC3','B_PC4','G1430_peak','G1430_std','G1430_amp',
'G1515_peak','G1515_std','G1515_amp','H1635_mean','H1635_PC1','H1635_PC2','m','b']

texnames = ['$\overline{B}$','$\overline{B}_{PC1}$','$\overline{B}_{PC2}$','$\overline{B}_{PC3}$','$\overline{B}_{PC4}$',
'$\mu_{1430}$','$\sigma_{1430}$','$a_{1430}$','$\mu_{1515}$','$\sigma_{1515}$','$a_{1515}$',
'$\overline{H_{1635}}$','$\overline{H_{1635}}_{PC1}$','$\overline{H_{1635}}_{PC2}$','$m$','$b$']
texnames = ['$\\overline{B}$','$\\overline{B}_{PC1}$','$\\overline{B}_{PC2}$','$\\overline{B}_{PC3}$','$\\overline{B}_{PC4}$',
'$\\mu_{1430}$','$\\sigma_{1430}$','$a_{1430}$','$\\mu_{1515}$','$\\sigma_{1515}$','$a_{1515}$',
'$\\overline{H_{1635}}$','$\\overline{H_{1635}}_{PC1}$','$\\overline{H_{1635}}_{PC2}$','$m$','$b$']

file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../docs/examples/transmission_ftir/NPZTXTFILES/RESULTS/AC4_OL49_021920_30x30_H2O_a.npz')
mcmc_npz = np.load(file_path)
Expand Down
14 changes: 7 additions & 7 deletions src/PyIRoGlass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def modelfit(data, uncert, indparams, model, title, nbins=75,
rax.errorbar(binindp, bindata-binmodel, binuncert, fmt='ko', ms=4)
rax.plot([indparams[0], indparams[-1]], [0,0], 'k:', lw=1.5)
rax.tick_params(labelsize=fs-1, direction='in', top=True, right=True)
rax.set_xlabel("Wavenumber $(\mathregular{cm^{-1}})$", fontsize=fs)
rax.set_xlabel("Wavenumber (cm^-1)", fontsize=fs) # $(\mathregular{cm^{-1}})$
rax.set_ylabel('Residual', fontsize=fs)
rax.invert_xaxis()

Expand Down Expand Up @@ -586,9 +586,9 @@ def MCMC(data, uncert, indparams, log, savefile):
pnames = ['B_mean','B_PC1','B_PC2','B_PC3','B_PC4','G1430_peak','G1430_std','G1430_amp',
'G1515_peak','G1515_std','G1515_amp','H1635_mean','H1635_PC1','H1635_PC2','m','b']

texnames = ['$\overline{B}$','$\overline{B}_{PC1}$','$\overline{B}_{PC2}$','$\overline{B}_{PC3}$','$\overline{B}_{PC4}$',
'$\mu_{1430}$','$\sigma_{1430}$','$a_{1430}$','$\mu_{1515}$','$\sigma_{1515}$','$a_{1515}$',
'$\overline{H_{1635}}$','$\overline{H_{1635}}_{PC1}$','$\overline{H_{1635}}_{PC2}$','$m$','$b$']
texnames = ['$\\overline{B}$','$\\overline{B}_{PC1}$','$\\overline{B}_{PC2}$','$\\overline{B}_{PC3}$','$\\overline{B}_{PC4}$',
'$\\mu_{1430}$','$\\sigma_{1430}$','$a_{1430}$','$\\mu_{1515}$','$\\sigma_{1515}$','$a_{1515}$',
'$\\overline{H_{1635}}$','$\\overline{H_{1635}}_{PC1}$','$\\overline{H_{1635}}_{PC2}$','$m$','$b$']


mc3_output = mc3.sample(data=data, uncert=uncert, func=func, params=params, indparams=indparams,
Expand Down Expand Up @@ -914,9 +914,9 @@ def Run_All_Spectra(dfs_dict, exportpath):
plt.savefig(path_beg + figurepath + files + '.pdf')
plt.close('all')

texnames = ['$\overline{B}$','$\overline{B}_{PC1}$','$\overline{B}_{PC2}$','$\overline{B}_{PC3}$','$\overline{B}_{PC4}$',
'$\mu_{1430}$','$\sigma_{1430}$','$a_{1430}$','$\mu_{1515}$','$\sigma_{1515}$','$a_{1515}$',
'$\overline{H_{1635}}$','$\overline{H_{1635}}_{PC1}$','$\overline{H_{1635}}_{PC2}$','$m$','$b$']
texnames = ['$\\overline{B}$','$\\overline{B}_{PC1}$','$\\overline{B}_{PC2}$','$\\overline{B}_{PC3}$','$\\overline{B}_{PC4}$',
'$\\mu_{1430}$','$\\sigma_{1430}$','$a_{1430}$','$\\mu_{1515}$','$\\sigma_{1515}$','$a_{1515}$',
'$\\overline{H_{1635}}$','$\\overline{H_{1635}}_{PC1}$','$\\overline{H_{1635}}_{PC2}$','$m$','$b$']

posterior, zchain, zmask = mu.burn(mc3_output)
post = mp.Posterior(posterior, texnames)
Expand Down

0 comments on commit ac39bc9

Please sign in to comment.