Skip to content
Snippets Groups Projects
Commit 927e5417 authored by simon-ast's avatar simon-ast
Browse files

Documentation

parent 977c1368
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
File added
...@@ -13,7 +13,7 @@ def cdf_slice(cdf_file, key: str): ...@@ -13,7 +13,7 @@ def cdf_slice(cdf_file, key: str):
:param cdf_file: Name of cdf file :param cdf_file: Name of cdf file
:param key: Name of desired key from cdf file :param key: Name of desired key from cdf file
:return: Datta slice :return: Data slice
""" """
return cdf_file[key][...] return cdf_file[key][...]
......
...@@ -42,3 +42,13 @@ def wp_to_temp(thermal_speed: np.ndarray) -> np.ndarray: ...@@ -42,3 +42,13 @@ def wp_to_temp(thermal_speed: np.ndarray) -> np.ndarray:
wp_si = thermal_speed * 1e3 wp_si = thermal_speed * 1e3
return wp_si ** 2 * m_p.value / (2 * k_B.value) return wp_si ** 2 * m_p.value / (2 * k_B.value)
def abs_to_rel_time(epoch_array: np.ndarray) -> np.ndarray:
"""DOC"""
start = epoch_array[0]
end = epoch_array[-1]
rel_array = (epoch_array - start) / (end - start)
return rel_array
import sys
import numpy as np
import matplotlib.pyplot as plt
# NECESSARY GLOBALS
PLOT_SAVE_DIR = f"{sys.path[0]}/PLOTS"
def theta_time_analysis(theta_list: list,
rel_time: list,
label: list) -> None:
"""DOC"""
# Necessary parameters
theta_full = np.concatenate(np.array(theta_list, dtype="object"))
theta_mean = np.mean(theta_full)
theta_stddev = np.std(theta_full)
# Plot each theta_array individually
fig, ax = plt.subplots(figsize=(7, 5))
num_arr = len(theta_list)
for i in range(num_arr):
ax.scatter(rel_time[i], theta_list[i], label=label[i],
s=5, zorder=100)
# Add median and stddev
ax.axhline(theta_mean, ls="--", lw=2, color="black",
label=f"MEAN = {theta_mean:.3f}",
zorder=2)
ax.axhspan(ymin=theta_mean - theta_stddev,
ymax=theta_mean + theta_stddev,
color="grey", alpha=0.5,
zorder=1)
# Plot cleanup
ax.set(xlabel="$\\Delta$t [0: START - 1: END]",
ylabel="Heliolatitude [deg]",
title=f"STDDEV = {theta_stddev:.3f}")
plt.legend()
plt.savefig(f"{PLOT_SAVE_DIR}/HELIOLAT_eval.png", dpi=300)
No preview for this file type
PLOTS/HELIOLAT_eval.png

131 KiB

...@@ -5,6 +5,7 @@ from spacepy import pycdf ...@@ -5,6 +5,7 @@ from spacepy import pycdf
from MODULES.PSPops import data_quality as dq from MODULES.PSPops import data_quality as dq
from MODULES.PSPops import data_transformation as dt from MODULES.PSPops import data_transformation as dt
from MODULES.PSPops import data_handling as dh from MODULES.PSPops import data_handling as dh
from MODULES.PSPops import miscellaneous as misc
from MODULES.Plotting import plot_settings as ps from MODULES.Plotting import plot_settings as ps
from MODULES.Statistics import data_binning as db from MODULES.Statistics import data_binning as db
from MODULES.Statistics import stats as st from MODULES.Statistics import stats as st
...@@ -33,6 +34,11 @@ def main(): ...@@ -33,6 +34,11 @@ def main():
# Total array initialization # Total array initialization
r_tot = vr_tot = temp_tot = np_tot = np.array([]) r_tot = vr_tot = temp_tot = np_tot = np.array([])
# Specifically for heliolatitude and epoch, lists are necessary
theta_tot = []
epoch_tot = []
label = []
# Loop over all files in the desired encounter folder(s), sorted # Loop over all files in the desired encounter folder(s), sorted
# in ascending order of name (equal to date) # in ascending order of name (equal to date)
for folder in ENCOUNTER_NUM: for folder in ENCOUNTER_NUM:
...@@ -51,6 +57,10 @@ def main(): ...@@ -51,6 +57,10 @@ def main():
# Generate sub-total arrays for encounters individually # Generate sub-total arrays for encounters individually
r_file = vr_file = temp_file = np_file = np.array([]) r_file = vr_file = temp_file = np_file = np.array([])
# Specifically for heliolatitude and epoch
theta_file = epoch_file = np.array([])
label.append(folder)
for file in sorted(os.listdir(data_location)): for file in sorted(os.listdir(data_location)):
# Sanity check: print current file name # Sanity check: print current file name
...@@ -78,6 +88,11 @@ def main(): ...@@ -78,6 +88,11 @@ def main():
vr_file = np.append(vr_file, data["vr"]) vr_file = np.append(vr_file, data["vr"])
np_file = np.append(np_file, data["np"]) np_file = np.append(np_file, data["np"])
temp_file = np.append(temp_file, data["Temp"]) temp_file = np.append(temp_file, data["Temp"])
# Specifically for heliolatitude and epoch
data["theta"] = 90 - data["theta"] * 180 / np.pi
theta_file = np.append(theta_file, data["theta"])
epoch_file = np.append(epoch_file, data["epoch"])
# After all files of an individual encounter are handled, # After all files of an individual encounter are handled,
# generate the approach/recession divide and append to the # generate the approach/recession divide and append to the
...@@ -95,6 +110,13 @@ def main(): ...@@ -95,6 +110,13 @@ def main():
np_tot = np.append(np_tot, np_file) np_tot = np.append(np_tot, np_file)
temp_tot = np.append(temp_tot, temp_file) temp_tot = np.append(temp_tot, temp_file)
# Specifically for heliolatitude and epoch
theta_tot.append(theta_file)
epoch_tot.append(dt.abs_to_rel_time(epoch_file))
# Intermezzo: PLOT AND EVALUATE THETA WITH TIME
misc.theta_time_analysis(theta_tot, epoch_tot, label)
# Create distance bins and determine indices of data arrays that # Create distance bins and determine indices of data arrays that
# correspond to the respective distance bins. Some of these # correspond to the respective distance bins. Some of these
# sub-arrays might be empty and have to be handled accordingly # sub-arrays might be empty and have to be handled accordingly
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment