Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion multi_inst_plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Options:
A class for displaying and storing plot options.
"""
def __init__(self):

self.offline = False
self.spacecraft = w.Dropdown(value=None, description="Spacecraft",
options=["Parker Solar Probe", "Solar Orbiter", "L1 (Wind/SOHO)", "STEREO"],
style=_style)
Expand Down
14 changes: 9 additions & 5 deletions multi_inst_plots/l1_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from seppy.loader.soho import soho_load
from seppy.tools import resample_df
# from other_loaders_py3 import wind_3dp_av_en #, wind_mfi_loader, ERNE_HED_loader
from urllib.error import URLError

from multi_inst_plots.other_tools import polarity_rtn, mag_angles, load_goes_xrs, \
load_solo_stix, plot_goes_xrs, plot_solo_stix, make_fig_axs
Expand Down Expand Up @@ -105,7 +106,7 @@ def download_wind_waves_cdf(freq, startdate, enddate, path=None):
if not os.path.exists(f):
dl.download(url=url, path=f)

except (RuntimeError, IndexError):
except (RuntimeError, IndexError, URLError):
print(f'Unable to obtain Wind WAVES {freq} data for {startdate}-{enddate}!')
downloaded_files = []

Expand Down Expand Up @@ -253,6 +254,7 @@ def load_data(options):
enddate = options.enddt
path = options.path
stix_ltc = options.stix_ltc.value
offline = options.offline

options.plot_start = None
options.plot_end = None
Expand Down Expand Up @@ -285,14 +287,16 @@ def load_data(options):
resample=None,
multi_index=False,
path=path,
threshold=options.wind_flux_thres_e)
threshold=options.wind_flux_thres_e,
offline=offline)
pdic_, meta_p = wind3dp_load(dataset="WI_SOSP_3DP",
startdate=startdate,
enddate=enddate,
resample=None,
multi_index=False,
path=path,
threshold=options.wind_flux_thres_p)
threshold=options.wind_flux_thres_p,
offline=offline)

data["3dp_e"] = edic_
data["3dp_p"] = pdic_
Expand Down Expand Up @@ -322,7 +326,7 @@ def load_data(options):
print(f"Loading SOHO/EPHIN data... (dataset {dataset_index}/{dataset_num})")
try:
ephin_, meta_ephin = soho_load(dataset="SOHO_COSTEP-EPHIN_L2-1MIN", startdate=startdate, enddate=enddate,
path=path, resample=None)
path=path, resample=None, offline=offline)
except UnboundLocalError:
# soho_ephin_loader throws this error since it
# tries to access a variable (cs_e300) that hasn't been set
Expand All @@ -337,7 +341,7 @@ def load_data(options):
if options.l1_erne.value == True:
print(f"Loading SOHO/ERNE data... (dataset {dataset_index}/{dataset_num})")
erne_p_, meta_erne = soho_load(dataset="SOHO_ERNE-HED_L2-1MIN", startdate=startdate, enddate=enddate,
path=path, resample=None)
path=path, resample=None, offline=offline)

data["erne"] = erne_p_
metadata["erne"] = meta_erne
Expand Down
16 changes: 13 additions & 3 deletions multi_inst_plots/other_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from matplotlib import ticker
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from stixdcpy.quicklook import LightCurves
from requests.exceptions import ConnectionError as RequestsConnectionError
from seppy.tools import resample_df
from sunpy import timeseries as ts
from sunpy.net import Fido
Expand Down Expand Up @@ -174,8 +175,11 @@ def load_solo_stix(start, end, ltc=True, resample=None):
if resample != "0min" and resample is not None:
df_stix = resample_df(df_stix, resample=resample, pos_timestamp=None, cols_unc=[])

except (TypeError, KeyError):
print("Unable to load STIX data!")
except RequestsConnectionError:
print("Unable to obtain SolO/STIX data: no internet connection or host unreachable.")
df_stix = []
except (TypeError, KeyError) as e:
print(f"Unable to obtain SolO/STIX data: {e}")
df_stix = []

return df_stix
Expand Down Expand Up @@ -222,7 +226,13 @@ def load_goes_xrs(start, end, man_select=False, resample=None, path=None):
satellite number for which data was returned
"""

result_goes = Fido.search(a.Time(start, end), a.Instrument("XRS"), a.Resolution("flx1s"))
try:
result_goes = Fido.search(a.Time(start, end), a.Instrument("XRS"), a.Resolution("flx1s"))
except ConnectionError:
print("Unable to obtain GOES/XRS data: no internet connection or VSO mirrors unreachable.")
df_goes = []
sat = ''
return df_goes, sat

# No data found
if len(result_goes["xrs"]) == 0:
Expand Down
11 changes: 6 additions & 5 deletions multi_inst_plots/psp_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def load_data(options):
file_path = options.path

stix_ltc = options.stix_ltc.value
offline = options.offline

options.plot_start = None
options.plot_end = None
Expand Down Expand Up @@ -118,7 +119,7 @@ def load_data(options):
print(f"Loading EPI-Hi... (dataset {dataset_index}/{dataset_num})")

psp_het_org, psp_het_energies = psp_isois_load('PSP_ISOIS-EPIHI_L2-HET-RATES60', startdate, enddate,
path=file_path, resample=None)
path=file_path, resample=None, offline=offline)

if isinstance(psp_het_org, str) or len(psp_het_org) == 0:
psp_het_org = []
Expand Down Expand Up @@ -154,8 +155,8 @@ def load_data(options):
print(f"Loading EPI-Lo PE... (dataset {dataset_index}/{dataset_num})")

psp_epilo_org, psp_epilo_energies = psp_isois_load('PSP_ISOIS-EPILO_L2-PE', startdate, enddate,
path=file_path, resample=None, epilo_channel=epilo_pe_channel,
epilo_threshold=None)
path=file_path, resample=None, epilo_channel=epilo_pe_channel,
epilo_threshold=None, offline=offline)

if isinstance(psp_epilo_org, pd.DataFrame):
electron_countrate_keys = psp_epilo_org.filter(like='Electron_CountRate_ChanF_E').keys()
Expand All @@ -171,8 +172,8 @@ def load_data(options):
print(f"Loading EPI-Lo IC... (dataset {dataset_index}/{dataset_num})")

psp_epilo_ic_org, psp_epilo_ic_energies = psp_isois_load('PSP_ISOIS-EPILO_L2-IC', startdate, enddate,
path=file_path, resample=None, epilo_channel=epilo_ic_channel,
epilo_threshold=None)
path=file_path, resample=None, epilo_channel=epilo_ic_channel,
epilo_threshold=None, offline=offline)

data["epilo_ic"] = psp_epilo_ic_org
metadata["epilo_ic"] = psp_epilo_ic_energies
Expand Down
10 changes: 5 additions & 5 deletions multi_inst_plots/solo_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def load_data(options):
ion_conta_corr = True
viewing = options.solo_viewing.value
stix_ltc = options.stix_ltc.value

offline = options.offline

if not options.mag.value:
options.polarity.value = False
Expand All @@ -123,8 +123,8 @@ def load_data(options):
if ept_l3:
try:
df_ept_org, df_rtn_ept, df_hci_ept, energies_ept, metadata_ept = epd_load(sensor='ept', level='l3', pos_timestamp=None,
startdate=startdate, enddate=enddate,
autodownload=True, path=path)
startdate=startdate, enddate=enddate,
autodownload=not offline, path=path)
except UnboundLocalError:
df_ept_org, df_rtn_ept, df_hci_ept, energies_ept, metadata_ept = [], [], [], [], []

Expand All @@ -134,7 +134,7 @@ def load_data(options):

else:
protons_ept, electrons_ept, energies_ept = epd_load(sensor='ept', level='l2', startdate=startdate, enddate=enddate,
pos_timestamp=None,viewing=viewing, path=path, autodownload=True)
pos_timestamp=None,viewing=viewing, path=path, autodownload=not offline)
# correct EPT level 2 electron data for ion contamination:
if ion_conta_corr:
# df_electrons_ept2 = calc_EPT_corrected_e(df_electrons_ept['Electron_Flux'], df_protons_ept['Ion_Flux'])
Expand All @@ -150,7 +150,7 @@ def load_data(options):
if options.solo_het_e.value or options.solo_het_p.value:
print(f"Loading EPD/HET... (dataset {dataset_index}/{dataset_num})")
protons_het, electrons_het, energies_het = epd_load(sensor='het', level='l2', startdate=startdate, enddate=enddate,
pos_timestamp=None,viewing=viewing, path=path, autodownload=True)
pos_timestamp=None,viewing=viewing, path=path, autodownload=not offline)

data["het_e"] = electrons_het
data["het_p"] = protons_het
Expand Down
11 changes: 6 additions & 5 deletions multi_inst_plots/stereo_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def load_data(options):
sept_viewing = options.ster_sept_viewing.value
sc = options.ster_sc.value
stix_ltc = options.stix_ltc.value
offline = options.offline
goes_man_select = options.goes_man_select.value
startdate = options.startdt
enddate = options.enddt
Expand All @@ -186,13 +187,13 @@ def load_data(options):
print(f"Loading SEPT... (dataset {dataset_index}/{dataset_num})")
df_sept_electrons_orig, meta_se = stereo_load(instrument='SEPT', startdate=startdate, enddate=enddate,
sept_species='e', sept_viewing=sept_viewing,
path=path, spacecraft=sc)
path=path, spacecraft=sc, offline=offline)
data["sept_electrons"] = df_sept_electrons_orig
metadata["sept_electrons"] = meta_se

df_sept_protons_orig, meta_sp = stereo_load(instrument='SEPT', startdate=startdate, enddate=enddate,
sept_species='p', sept_viewing=sept_viewing,
path=path, spacecraft=sc)
path=path, spacecraft=sc, offline=offline)

data["sept_protons"] = df_sept_protons_orig
metadata["sept_protons"] = meta_sp
Expand All @@ -202,7 +203,7 @@ def load_data(options):
if options.ster_het_e.value == True or options.ster_het_p.value == True:
print(f"Loading HET... (dataset {dataset_index}/{dataset_num})")
df_het_orig, meta_het = stereo_load(instrument='HET', startdate=startdate, enddate=enddate,
path=path, spacecraft=sc)
path=path, spacecraft=sc, offline=offline)

data["het"] = df_het_orig
metadata["het"] = meta_het
Expand All @@ -212,7 +213,7 @@ def load_data(options):
if options.mag.value == True or options.mag_angles.value == True:
print(f"Loading MAG... (dataset {dataset_index}/{dataset_num})")
df_mag_orig, meta_mag = stereo_load(spacecraft=sc, instrument='MAG', startdate=startdate, enddate=enddate,
mag_coord='RTN', path=path)
mag_coord='RTN', path=path, offline=offline)

data["mag"] = df_mag_orig
metadata["mag"] = meta_mag
Expand All @@ -222,7 +223,7 @@ def load_data(options):
if options.Vsw.value or options.N.value or options.T.value or options.p_dyn.value or options.polarity.value:
print(f"Loading MAGPLASMA... (dataset {dataset_index}/{dataset_num})")
df_magplasma, meta_magplas = stereo_load(instrument='MAGPLASMA', startdate=startdate, enddate=enddate,
path=path, spacecraft=sc)
path=path, spacecraft=sc, offline=offline)

data["magplasma"] = df_magplasma
metadata["magplasma"] = meta_magplas
Expand Down
Loading