Commit af024050 authored by Roger.Grau.Haro's avatar Roger.Grau.Haro
Browse files

Ferran's update

parent 15228be8
Pipeline #7011 canceled with stages
......@@ -250,9 +250,13 @@ class AtmosphericProfiles():
try:
plt.savefig("images/" + self.atmospheric_reader.name + "/" + "metrics.png")
except FileNotFoundError:
os.mkdir(os.listdir(os.path.join(os.getcwd(), "images", self.atmospheric_reader.name)))
plt.savefig("images/" + self.atmospheric_reader.name + "/" + "metrics.png")
try:
d = os.path.join(os.getcwd(), "images", self.atmospheric_reader.name)
if not os.path.exists(d):
os.makedirs(d)
plt.savefig("images/" + self.atmospheric_reader.name + "/" + "metrics.png")
except Exception as e:
AtmosphericProfilesError(e)
def _plot_metrics(self) -> None:
"""Save plot to images/atmospheric_reader.name/chi2*.png of the chi2 histogram"""
......@@ -275,8 +279,13 @@ class AtmosphericProfiles():
try:
plt.savefig("images/" + self.atmospheric_reader.name + "/" + ("chi2_hist_of_" + filename + ".png").replace("/", ""))
except FileNotFoundError:
os.mkdir(os.listdir(os.path.join(os.getcwd(), "images", self.atmospheric_reader.name)))
plt.savefig("images/" + self.atmospheric_reader.name + "/" + ("chi2_hist_of_" + self.atmospheric_reader.filename + ".png").replace("/", ""))
try:
d = os.path.join(os.getcwd(), "images", self.atmospheric_reader.name)
if not os.path.exists(d):
os.makedirs(d)
plt.savefig("images/" + self.atmospheric_reader.name + "/" + ("chi2_hist_of_" + filename + ".png").replace("/", ""))
except Exception as e:
AtmosphericProfilesError(e)
plt.close()
......@@ -654,7 +663,7 @@ class AtmosphericProfiles():
ax.scatter(x_data, y_data, label="Real Data")
#plot vertical line
ax.axvline(x=self.H0_LIDAR, color="black", linestyle="--")
ax.axvline(x=self.H0_LIDAR.value, color="black", linestyle="--")
for model_name in models:
#Drop astropy units for all the elements in list
......@@ -674,16 +683,15 @@ class AtmosphericProfiles():
try:
plt.savefig("images/" + self.atmospheric_reader.name + "/" + date.strftime("%Y_%m_%d_%H") + plt_title.replace(" ", "").replace("-", "_") + '.png')
except FileNotFoundError:
try:
os.mkdir(os.path.join(os.getcwd(), "images"))
try:
d = os.path.join(os.getcwd(), "images", self.atmospheric_reader.name)
if not os.path.exists(d):
os.makedirs(d)
plt.savefig("images/" + self.atmospheric_reader.name + "/" + date.strftime("%Y_%m_%d_%H") + plt_title.replace(" ", "").replace("-", "_") + '.png')
except Exception as e:
try:
os.mkdir(os.path.join(os.getcwd(), "images", self.atmospheric_reader.name))
plt.savefig("images/" + self.atmospheric_reader.name + "/" + date.strftime("%Y_%m_%d_%H") + plt_title.replace(" ", "").replace("-", "_") + '.png')
except Exception as e:
AtmosphericProfilesError(e)
AtmosphericProfilesError(e)
plt.close(fig)
def get_block_elements_at_plevel(
......@@ -943,7 +951,7 @@ class AtmosphericProfiles():
return self.eval_strato(date, h)
##NOT tested
def eval_f(self, date: datetime, lo: u.km, h: u.km, costheta: float, beta_mol_0: 1/u.km, H0: u.km):
def eval_f(self, date: datetime, lo: u.km, h: np.ndarray, costheta: float, beta_mol_0: 1/u.km, H0: u.km):
try:
h = h.to(u.km)
lo = lo.to(u.km)
......@@ -1025,20 +1033,3 @@ class AtmosphericProfiles():
print("Model info")
print(self.entry_data[date]["models"])
np.set_printoptions(**oldoptions)
if __name__ == "__main__":
from gdas_reader import GDASReader
OBS = "data_files/ObservatoryData.json"
OBSNAME = "magic1"
obs = Observatory(OBS, OBSNAME)
# Instantiate Gdas
FILENAME = [ "data_files/gdas1.feb19.w1_magic1"]
gdas = GDASReader(FILENAME, obs)
# Instantiate AtmosphericProfiles
ap = AtmosphericProfiles("data_files/entry_data_gdas.json", gdas)
ap.calculate_results_for_all_profiles(plot=True, save_to_file=False, metrics=False)
date = list(ap.entry_data.keys())[0]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment