Skip to content

Commit

Permalink
Added some comparisons for cornell densimeters and clarified some pic…
Browse files Browse the repository at this point in the history
…kle production things.
  • Loading branch information
cljdevitre committed Oct 17, 2023
1 parent ca030a8 commit ec42256
Show file tree
Hide file tree
Showing 10 changed files with 300 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 1,
"id": "f86e8a63",
"metadata": {},
"outputs": [
Expand All @@ -22,7 +22,7 @@
"'0.0.77'"
]
},
"execution_count": 5,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -46,7 +46,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"id": "2c0358b6-b8f5-4148-aaf9-ba86279eb651",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -288,7 +288,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 3,
"id": "e54a3b1b",
"metadata": {},
"outputs": [],
Expand All @@ -302,7 +302,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"id": "f87dc78c",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -341,22 +341,11 @@
"CI=0.67\n",
"df=T37C\n",
"eq_division='ccmr'\n",
"save_suffix='_CCMR'\n",
"\n",
"pf.plot_and_save_CO2cali_pickle(cali_data=df, Split_col=Split_col, CO2_dens_col=CO2_dens_col, split_error=split_error,CO2_dens_error=CO2_dens_error, density_range='Low',N_poly=1, CI=CI, std_error=True,save_fig=True,eq_division=eq_division)\n",
"pf.plot_and_save_CO2cali_pickle(cali_data=df, Split_col=Split_col, CO2_dens_col=CO2_dens_col, split_error=split_error,CO2_dens_error=CO2_dens_error, density_range='Medium',N_poly=3, CI=CI, std_error=True,save_fig=True,eq_division=eq_division)\n",
"pf.plot_and_save_CO2cali_pickle(cali_data=df, Split_col=Split_col, CO2_dens_col=CO2_dens_col, split_error=split_error,CO2_dens_error=CO2_dens_error, density_range='High',N_poly=2, CI=CI, std_error=True,save_fig=True,eq_division=eq_division)\n",
"\n",
"import os\n",
"if os.path.exists('Lowrho_polyfit_data_CCMR.pkl'):\n",
" os.remove('Lowrho_polyfit_data_CCMR.pkl')\n",
"if os.path.exists('Mediumrho_polyfit_data_CCMR.pkl'):\n",
" os.remove('Mediumrho_polyfit_data_CCMR.pkl')\n",
"if os.path.exists('Highrho_polyfit_data_CCMR.pkl'):\n",
" os.remove('Highrho_polyfit_data_CCMR.pkl')\n",
"\n",
"os.rename('Lowrho_polyfit_data.pkl', 'Lowrho_polyfit_data_CCMR.pkl')\n",
"os.rename('Mediumrho_polyfit_data.pkl', 'Mediumrho_polyfit_data_CCMR.pkl')\n",
"os.rename('Highrho_polyfit_data.pkl', 'Highrho_polyfit_data_CCMR.pkl')"
"pf.plot_and_save_CO2cali_pickle(cali_data=df, Split_col=Split_col, CO2_dens_col=CO2_dens_col, split_error=split_error,CO2_dens_error=CO2_dens_error, density_range='Low',N_poly=1, CI=CI, std_error=True,save_fig=True,eq_division=eq_division,save_suffix=save_suffix)\n",
"pf.plot_and_save_CO2cali_pickle(cali_data=df, Split_col=Split_col, CO2_dens_col=CO2_dens_col, split_error=split_error,CO2_dens_error=CO2_dens_error, density_range='Medium',N_poly=3, CI=CI, std_error=True,save_fig=True,eq_division=eq_division,save_suffix=save_suffix)\n",
"pf.plot_and_save_CO2cali_pickle(cali_data=df, Split_col=Split_col, CO2_dens_col=CO2_dens_col, split_error=split_error,CO2_dens_error=CO2_dens_error, density_range='High',N_poly=2, CI=CI, std_error=True,save_fig=True,eq_division=eq_division,save_suffix=save_suffix)"
]
},
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

216 changes: 216 additions & 0 deletions docs/Cornell_Densimeter_fitting/Cornell_densimeter_comparisons.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/DiadFit/densimeter_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def calculate_generic_std_err_values(*, pickle_str, new_x, CI=0.67):

return df

def plot_and_save_CO2cali_pickle(*, cali_data, CO2_dens_col='rho',Split_col='Split', split_error='split_err',CO2_dens_error='dens_err', density_range, N_poly=3, CI=0.67, std_error=True, save_fig=False,eq_division='paper'):
def plot_and_save_CO2cali_pickle(*, cali_data, CO2_dens_col='rho',Split_col='Split', split_error='split_err',CO2_dens_error='dens_err', density_range, N_poly=3, CI=0.67, std_error=True, save_fig=False,eq_division='ccmr',save_suffix=''):
# Define the x and y values
try:
if eq_division=='ccmr':
Expand Down Expand Up @@ -115,12 +115,12 @@ def plot_and_save_CO2cali_pickle(*, cali_data, CO2_dens_col='rho',Split_col='Spl

# Save the model and the data to a pickle file
data = {'model': Pf, 'x': x, 'y': y}
with open(prefix+'polyfit_data.pkl', 'wb') as f:
with open(prefix+'polyfit_data'+save_suffix+'.pkl', 'wb') as f:
pickle.dump(data, f)

if std_error is True:
new_x_plot = np.linspace(np.min(x), np.max(x), 100)
new_calidf = calculate_generic_std_err_values(pickle_str=prefix+'polyfit_data.pkl',
new_calidf = calculate_generic_std_err_values(pickle_str=prefix+'polyfit_data'+save_suffix+'.pkl',
new_x=pd.Series(new_x_plot), CI=CI)
# Calculate R-squared and p-value
residuals = y - Pf(x)
Expand Down Expand Up @@ -162,4 +162,4 @@ def plot_and_save_CO2cali_pickle(*, cali_data, CO2_dens_col='rho',Split_col='Spl


if save_fig is True:
fig.savefig(prefix+'cali_line.png')
fig.savefig(prefix+'cali_line'+save_suffix+'.png')

0 comments on commit ec42256

Please sign in to comment.