<jupyter_start><jupyter_text>* Fetch $[O^+]$ from the '$O^+$' simulation file.* Plot $[O^+]$ with time ($\tau$).* Calculate and plot $\frac{\partial [O^+]}{\partial \tau}$ at $h_{F_1}=150$ km and $h_{F_2}=240$ km altitudes.* Include linear interpolations for negative terms in transport phenomena.* Compare uniform hPa unit based plots.* Substract $\vec{E}\times \vec{B}$, $D_{\alpha}$, and $D_{wind}$ from $\frac{\partial [O^+]}{\partial \tau}$ to get $p-l$ term in $O^+$ continuity equation.> * Extract & plot $\vec{E}\times \vec{B}$, $D_{\alpha}$, and $D_{wind}$.> * Multiply $n_e$ with each of the above components to extimate rates.<jupyter_code># Import all libs
import numpy as np
import matplotlib.pyplot as plt
plt.style.use(["science", "ieee"])
import datetime as dt
import sys
sys.path.extend(["code/", "code/rt/", "code/sd/"])
from fetch_simulated_data import *
from plots import *
# O+ density
lat, lon = 40.015, -105.2705
dat = extract_parameters(dt.datetime(2017,8,21), lat, lon, 
                         [dt.datetime(2017,8,21,16), dt.datetime(2017,8,21,20)],
                         ["OpDens"], ["dataset/20170821_opden.nc"], ["ecl"], mult=1.)
_ = create_ts_label_plots(dat["ecl"]["T"], [dat["ecl"]["OpDens"]], dat["ecl"]["H"], 
                      ylabel=r"$[O^+]$, (in $cm^{-3}$)", ylim=[1e3,1e6], yscale="log")
# Caculate dO+/dt density
dtau = (dat["ecl"]["T"][1]-dat["ecl"]["T"][0]).total_seconds()
dOpDens_dt = np.zeros_like(dat["ecl"]["OpDens"])
scale = 1.
for j in range(dOpDens_dt.shape[1]):
    dOpDens_dt[:,j] = scale*np.diff(dat["ecl"]["OpDens"][:,j], 
                                    prepend=dat["ecl"]["OpDens"][0,j])/dtau
dat["ecl"]["dOpDens_dt"] = dOpDens_dt
ylab = r"$\frac{\partial [O^+]}{\partial \tau}$, (in $cm^{-3}s^{-1}$)"
_, ax = create_ts_label_plots(dat["ecl"]["T"], [dat["ecl"]["dOpDens_dt"]], dat["ecl"]["H"], 
                              ylabel=ylab, ylim=[-100,100])
_ = ax.axhline(0, ls="--", color="k", lw=0.4)
fnames = ["dataset/20170821_dfield_dwind.nc", "dataset/20170823_dfield_dwind.nc"]
keys = ["ecl", "dal"]
d0 = extract_parameters(dt.datetime(2017,8,21), lat, lon,
                        [dt.datetime(2017,8,21,16), dt.datetime(2017,8,21,20)],
                        ["dfield", "dwind"], fnames, keys,
                        scale="linear")
fnames = ["dataset/20170821_opdt_diffu.nc", "dataset/20170823_diffu.nc"]
d1 = extract_parameters(dt.datetime(2017,8,21), lat, lon,
                        [dt.datetime(2017,8,21,16), dt.datetime(2017,8,21,20)],
                        ["amb_diff"], fnames, keys,
                        scale="linear")
d0["ecl"]["amb_diff"] = d1["ecl"]["amb_diff"]
d0["dal"]["amb_diff"] = d1["dal"]["amb_diff"]
del d1
_ = create_ts_label_plots(d0["ecl"]["T"], [d0["ecl"]["dfield"], d0["dal"]["dfield"]], 
                          d0["ecl"]["H"], ylabel=r"$[D_{\vec{E}\times\vec{B}}]$, (in $cm^{-3} s^{-1}$)",
                          ylim=[-40,10])
_ = create_ts_label_plots(d0["ecl"]["T"], [d0["ecl"]["dwind"],d0["dal"]["dwind"]], 
                          d0["ecl"]["H"], ylabel=r"$[D_{wind}]$, (in $cm^{-3}s^{-1}$)")
_ = create_ts_label_plots(d0["ecl"]["T"], [d0["ecl"]["amb_diff"], d0["dal"]["amb_diff"]],
                          d0["ecl"]["H"], ylabel=r"$[D_{\alpha}]$, (in $cm^{-3} s^{-1}$)",
                          ylim=[-100,50])
d0["ecl"]["prod"] = (dat["ecl"]["dOpDens_dt"] - d0["ecl"]["amb_diff"] -
                     d0["ecl"]["dwind"] - d0["ecl"]["dfield"])
ylab = r"Production Loss, (in $cm^{-3}s^{-1}$)"
_, ax = create_ts_label_plots(d0["ecl"]["T"], [d0["ecl"]["prod"]], d0["ecl"]["H"], ylabel=ylab,
                              ylim=[-100,100])
_ = ax.axhline(0, ls="--", color="k", lw=0.4)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.25073509756749535, 'fraction_numerical': 0.05586741512964448, 'mean_word_length': 3.3511627906976744, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '251292', 'license': 'MIT', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1446, 'n_words': 243, 'path': 'ModelAnalysis.ipynb', 'repo_name': 'shibaji7/SolarEclipse', 'size': '3741'}