Skip to content

Commit

Permalink
change deprecated delim_whitespace to sep keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
MichielsenM committed Apr 21, 2024
1 parent c673e91 commit b19fd7b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion foam/additional_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def surface_constraint(
evolution_step: float
Change in the evolutionary parameter from one step to the next (negative if quantity decreases, e.g. central hydrogen content Xc)
"""
obs_dataframe = pd.read_table(observations_file, delim_whitespace=True, header=0, index_col="index")
obs_dataframe = pd.read_table(observations_file, sep="\s+", header=0, index_col="index")
dataframe_theory = pd.read_hdf(merit_values_file)

if "Teff" in obs_dataframe.columns:
Expand Down
2 changes: 1 addition & 1 deletion foam/build_optimised_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def construct_theoretical_puls_pattern(
Number of worker processes to use in multiprocessing. The default 'None' will use the number returned by os.cpu_count().
"""
# Read in the files with observed and theoretical frequencies as pandas DataFrames
obs_dataframe = pd.read_table(observations_file, delim_whitespace=True, header=0, index_col="index")
obs_dataframe = pd.read_table(observations_file, sep="\s+", header=0, index_col="index")
theory_dataframe = pd.read_hdf(pulsation_grid_file)

obs = np.asarray(obs_dataframe[which_observable])
Expand Down
18 changes: 5 additions & 13 deletions foam/functions_for_mesa.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ def read_mesa_file(file_path, index_col=None):
return sf.read_hdf5(file_path)

else: # assumes the default MESA output format
header_df = pd.read_table(file_path, delim_whitespace=True, nrows=1, header=1)
data_df = pd.read_table(
file_path, delim_whitespace=True, skiprows=3, header=1, index_col=index_col
)
header_df = pd.read_table(file_path, sep="\s+", nrows=1, header=1)
data_df = pd.read_table(file_path, sep="\s+", skiprows=3, header=1, index_col=index_col)

header = {}
for k in header_df.keys():
Expand Down Expand Up @@ -87,9 +85,7 @@ def calculate_number_densities(hist_file):

average_atomic_mass = inverse_average_atomic_mass ** (-1)
for key in element_list.keys():
number_densities.update(
{key.replace("_per_Mass_tot", "_per_N_tot"): element_list[key] * average_atomic_mass}
)
number_densities.update({key.replace("_per_Mass_tot", "_per_N_tot"): element_list[key] * average_atomic_mass})

return number_densities

Expand Down Expand Up @@ -122,13 +118,9 @@ def extract_surface_grid(
# Make list of extra observables requested by the user
if additional_observables is None:
additional_observables = []
extras_to_be_extracted = [
x for x in additional_observables if x not in ["logTeff", "logL", "logg", "age"]
]
extras_to_be_extracted = [x for x in additional_observables if x not in ["logTeff", "logL", "logg", "age"]]

extract_func = partial(
info_from_profiles, parameters=parameters, extra_header_items=extras_to_be_extracted
)
extract_func = partial(info_from_profiles, parameters=parameters, extra_header_items=extras_to_be_extracted)
# Glob all the files, then iteratively send them to a pool of processors
profiles = glob.iglob(mesa_profiles)
with multiprocessing.Pool(nr_cpu) as p:
Expand Down
2 changes: 1 addition & 1 deletion foam/maximum_likelihood_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def calculate_likelihood(
elif "P" or "dP" in observables:
observed_quantity = "period"
# Read in the observed data and make an array of the observed observables
obs_dataframe = pd.read_table(obs_path, delim_whitespace=True, header=0, index_col="index")
obs_dataframe = pd.read_table(obs_path, sep="\s+", header=0, index_col="index")
obs, obs_err, file_suffix_observables = create_obs_observables_array(obs_dataframe, observables)

# set the name of the output file
Expand Down
2 changes: 1 addition & 1 deletion foam/pipeline/pipe4_AICc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
if merit == "CS":
df_AICc = pd.DataFrame(data=[], columns=["method", "AICc"])
elif merit == "MD":
df_AICc = pd.read_table(f"V_matrix/{config.star}_determinant_conditionNr.tsv", delim_whitespace=True, header=0)
df_AICc = pd.read_table(f"V_matrix/{config.star}_determinant_conditionNr.tsv", sep="\s+", header=0)

for grid in config.grids:
for method in config.pattern_methods:
Expand Down
2 changes: 1 addition & 1 deletion foam/pipeline/pipe5_best_model_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def likelihood_chi2(chi2):

def likelihood_md(md):
"""Likelihood function of the mahalanobis distance"""
df_aicc_md = pd.read_table(f"V_matrix/{config.star}_determinant_conditionNr.tsv", delim_whitespace=True, header=0)
df_aicc_md = pd.read_table(f"V_matrix/{config.star}_determinant_conditionNr.tsv", sep="\s+", header=0)
ln_det_v = float((df_aicc_md.loc[df_aicc_md["method"] == f"{config.star}_{analysis}", "ln(det(V))"]).iloc[0])
return np.exp(-0.5 * (md + config.k * np.log(2 * np.pi) + ln_det_v))

Expand Down
2 changes: 1 addition & 1 deletion foam/pipeline/pipe7_table_best_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
for merit in config.merit_functions:
# Get the pre-calculated AICc values from another file
df_AICc = pd.read_table(
f"{directory_prefix}output_tables/{config.star}_AICc-values_{merit}.tsv", delim_whitespace=True, header=0
f"{directory_prefix}output_tables/{config.star}_AICc-values_{merit}.tsv", sep='\s+', header=0
)
with open(f"{directory_prefix}output_tables/{config.star}_best-model-table_{merit}.txt", "w") as outfile:
params = ""
Expand Down
4 changes: 2 additions & 2 deletions foam/plot_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def corner_plot(
}
CustomCMap = LinearSegmentedColormap("CustomMap", cdict)
# theoretical models within the error ellipse
dataframe_theory_error_ellipse = pd.read_hdf(merit_values_file_error_ellipse, delim_whitespace=True, header=0)
dataframe_theory_error_ellipse = pd.read_hdf(merit_values_file_error_ellipse, sep="\s+", header=0)
dataframe_theory_error_ellipse = dataframe_theory_error_ellipse.sort_values(
"meritValue", ascending=False
) # Order from high to low, to plot lowest values last
Expand Down Expand Up @@ -333,7 +333,7 @@ def corner_plot(

# Observations
if n_sigma_box != None:
obs_dataframe = pd.read_table(observations_file, delim_whitespace=True, header=0, index_col="index")
obs_dataframe = pd.read_table(observations_file, sep="\s+", header=0, index_col="index")
if (("logL" in obs_dataframe.columns) or ("logg" in obs_dataframe.columns)) and (
"Teff" in obs_dataframe.columns
):
Expand Down

0 comments on commit b19fd7b

Please sign in to comment.