Skip to content

Commit

Permalink
Merge pull request #48 from cljdevitre/main
Browse files Browse the repository at this point in the history
Added data and pickles for CMASS (EG's lab)
  • Loading branch information
PennyWieser authored Oct 17, 2023
2 parents 2da1613 + ec42256 commit 9b09f23
Show file tree
Hide file tree
Showing 15 changed files with 690 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,13 @@
],
"source": [
"CI=0.67\n",
"pf.plot_and_save_CO2cali_pickle(cali_data=T37C, 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)\n",
"pf.plot_and_save_CO2cali_pickle(cali_data=T37C, 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)\n",
"pf.plot_and_save_CO2cali_pickle(cali_data=T37C, 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)"
"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,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 All @@ -351,6 +355,14 @@
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "10c30235",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.

24 changes: 17 additions & 7 deletions src/DiadFit/densimeter_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,29 @@ 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):
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':
lowcut=0.17
midcut_low=0.12
midcut_high=0.72
highcut=0.65
elif eq_division=='cmass':
lowcut=0.20
midcut_low=0.13
midcut_high=0.70
highcut=0.65
if density_range == 'Low':
cali_data = cali_data[cali_data[CO2_dens_col] < 0.17]
cali_data = cali_data[cali_data[CO2_dens_col] < lowcut]

prefix='Lowrho_'
elif density_range == 'Medium':
cali_data = cali_data[cali_data[CO2_dens_col].between(0.12, 0.72)]
cali_data = cali_data[cali_data[CO2_dens_col].between(midcut_low, midcut_high)]

prefix='Mediumrho_'
elif density_range == 'High':
cali_data = cali_data[cali_data[CO2_dens_col] > 0.65]
cali_data = cali_data[cali_data[CO2_dens_col] > highcut]

prefix='Highrho_'
else:
Expand Down Expand Up @@ -105,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 @@ -152,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 9b09f23

Please sign in to comment.