Skip to content

Commit

Permalink
Merge pull request #209 from EhsanGharibNezhad/main
Browse files Browse the repository at this point in the history
update clean-codes from main
  • Loading branch information
EhsanGharibNezhad authored May 6, 2024
2 parents 4f3a26a + c82a490 commit 0f493db
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions TelescopeML/IO_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def load_or_dump_trained_model_CNN(
# weights_path = self.create_generic_path(f'{indicator}_weights')

if load_or_dump == 'dump':
trained_model.trained_model.save(path_architecture)
trained_model.trained_model.save_weights(path_weights)
trained_model.trained_ML_model.save(path_architecture)
trained_model.trained_ML_model.save_weights(path_weights)

with open(path_history, 'wb') as file:
pk.dump(trained_model.history.history, file)
Expand Down
24 changes: 19 additions & 5 deletions TelescopeML/StatVisAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,14 @@ def plot_scatter_x_y (x, y,
# Show the plot
show(p)

def plot_filtere_data(dataset, filter_bounds, feature_to_plot, title_label, wl_synthetic,output_names, __reference_data__):
def plot_filtere_data(dataset,
filter_bounds,
feature_to_plot,
title_label,
wl_synthetic,
output_names,
__reference_data__,
__save_plots__=False):
"""
Plot a DataFrame with a single x-axis (using column names) and multiple y-axes.
Expand Down Expand Up @@ -1189,7 +1196,7 @@ def plot_filtere_data(dataset, filter_bounds, feature_to_plot, title_label, wl_s

# print(filtered_data.T[col][:4].values[0])
ax.set_xlabel('Wavelength [$\mu$m]', fontsize = 12)
ax.set_ylabel(r'F$_{\nu}$ [erg/cm$^2$/s/Hz]', fontsize = 12)
ax.set_ylabel(r'TOA F$_{\nu}^{\rm Syn}$ [erg/cm$^2$/s/Hz]', fontsize = 12)
dict_features = {'temperature': 'Effective Temperature', 'gravity': 'Gravity', 'metallicity': 'Metallicity',
'c_o_ratio': 'Carbon-to-oxygen ratio'}
ax.set_title(dict_features[feature_to_plot] + " " + title_label, fontsize = 14)
Expand All @@ -1208,8 +1215,9 @@ def plot_filtere_data(dataset, filter_bounds, feature_to_plot, title_label, wl_s
dict_features = {'temperature': 'T$_{eff}$ [K]', 'gravity': 'log$g$', 'metallicity': '[M/H]', 'c_o_ratio': 'C/O'}
cbar.set_label(dict_features[feature_to_plot], fontsize = 12)

# plt.savefig(os.path.join(__reference_data__, 'figures', feature_to_plot + "_trainin_examples.pdf"), dpi=500,
# bbox_inches='tight')
if __save_plots__:
plt.savefig(os.path.join(__reference_data__, 'figures', feature_to_plot + "_training_examples.pdf"), dpi=500,
bbox_inches='tight')

plt.show()

Expand Down Expand Up @@ -1325,7 +1333,8 @@ def plot_ML_model_loss(trained_ML_model_history=None, title=None):

def plot_boxplot(data,
title=None, xlabel='Wavelength [$\mu$m]', ylabel='Scaled Values',
xticks_list=None, fig_size=(14, 3)):
xticks_list=None, fig_size=(14, 3),
__save_plots__=False):
"""
Make a boxplot with the scaled features.
Expand Down Expand Up @@ -1363,6 +1372,11 @@ def plot_boxplot(data,
ax.set_xticks(xtick_positions[::i])
ax.set_xticklabels(xticks_list[::i])

# if __save_plots__:
# plt.savefig(os.path.join(__reference_data__, 'figures', feature_to_plot + "_training_examples.pdf"),
# dpi=500,
# bbox_inches='tight')

plt.tight_layout()
plt.show()

Expand Down
6 changes: 5 additions & 1 deletion TelescopeML/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# %% VERSIONS
# Default/Latest/Current version
__version__ = '0.0.3'
__version__ = '0.0.4'
# Cleaned the codes and included more specific names for the parameters
# Edited the notebooks and transferred all funcs into the StatVisAnalyzer module
# Edited the name of functions in StatVisAnalyzer
# Added a module named DeepTuner to BOHB tuning the DNN hyperparameters
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[metadata]

name = TelescopeML
version = 0.0.3
version = 0.0.4
summary = Deep Convolutional Neural Networks and Machine Learning Models for Analyzing Stellar and Exoplanetary Telescope Spectra
description_file = README.md
keywords = Astronomy, Stars, Telescope, CNN, Deep Learning, Machine Learning
Expand Down

0 comments on commit 0f493db

Please sign in to comment.