PyThea 0.13.0__tar.gz → 0.14.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pythea-0.13.0 → pythea-0.14.0}/CHANGELOG.md +10 -0
- {pythea-0.13.0 → pythea-0.14.0}/PKG-INFO +2 -1
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/PyThea_app.py +11 -1
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/_version.py +2 -2
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/config/__init__.py +5 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/config/selected_imagers.py +9 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/data/sample_data.py +6 -6
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/extensions/Parker_spirals/utils.py +2 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/modules.py +5 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/map/maputils.py +2 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/Pythea_test.py +3 -3
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/utils.py +9 -5
- pythea-0.14.0/PyThea/utils_database.py +93 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea.egg-info/PKG-INFO +2 -1
- {pythea-0.13.0 → pythea-0.14.0}/PyThea.egg-info/SOURCES.txt +1 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea.egg-info/requires.txt +1 -0
- {pythea-0.13.0 → pythea-0.14.0}/environment.yml +1 -0
- {pythea-0.13.0 → pythea-0.14.0}/requirements.txt +1 -0
- {pythea-0.13.0 → pythea-0.14.0}/setup.py +1 -0
- {pythea-0.13.0 → pythea-0.14.0}/.readthedocs.yaml +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/LICENSE.md +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/MANIFEST.in +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/callbacks.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/config/app_styles.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/config/config_sliders.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/config/selected_bodies.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/data/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/extensions/LICENSE_gcs_python.md +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/extensions/Parker_spirals/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/extensions/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/extensions/buttons.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/extensions/hek/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/extensions/hek/utils.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/geometrical_models.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/pythea_cli.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/sunkit_instruments/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/sunkit_instruments/aia/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/sunkit_instruments/aia/utils.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/sunkit_instruments/lasco/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/sunkit_instruments/lasco/utils.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/sunkit_instruments/stereo/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/sunkit_instruments/stereo/utils.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/map/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/__init__.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/conftest.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/figure_hashes.json +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/test_extension_utils.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/test_figures.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/test_geometrical_models.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/test_imports.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/test_remote_clients.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/test/test_utils.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea/version.py +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea.egg-info/.DS_Store +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea.egg-info/dependency_links.txt +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea.egg-info/entry_points.txt +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea.egg-info/not-zip-safe +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/PyThea.egg-info/top_level.txt +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/README.md +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/README_pypi.md +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/pyproject.toml +0 -0
- {pythea-0.13.0 → pythea-0.14.0}/setup.cfg +0 -0
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# v0.14.0 (03-Oct-2024)
|
|
2
|
+
|
|
3
|
+
## Features
|
|
4
|
+
- Adds imaging data from Solar Orbiter EUI and METIS.
|
|
5
|
+
- Implements offline fits file loading from local database.
|
|
6
|
+
|
|
7
|
+
## Minor Changes
|
|
8
|
+
- Simplifies the configuration of the database directory.
|
|
9
|
+
- Improves Parker Spiral visualization.
|
|
10
|
+
|
|
1
11
|
# v0.13.0 (14-Jul-2024)
|
|
2
12
|
|
|
3
13
|
## Features
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyThea
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: PyThea: A software package to reconstruct the 3D structure of CMEs and shock waves
|
|
5
5
|
Home-page: https://github.com/AthKouloumvakos/PyThea
|
|
6
6
|
Author: Athanasios Kouloumvakos
|
|
@@ -29,6 +29,7 @@ Requires-Dist: astroquery
|
|
|
29
29
|
Requires-Dist: jplephem
|
|
30
30
|
Requires-Dist: numexpr
|
|
31
31
|
Requires-Dist: sunpy==5.1.2
|
|
32
|
+
Requires-Dist: sunpy_soar
|
|
32
33
|
Requires-Dist: parfive==2.1.0
|
|
33
34
|
Requires-Dist: pooch
|
|
34
35
|
Requires-Dist: matplotlib
|
|
@@ -39,6 +39,7 @@ from PyThea.modules import (date_and_event_selection, figure_streamlit,
|
|
|
39
39
|
from PyThea.sunpy_dev.map.maputils import get_closest, maps_clims
|
|
40
40
|
from PyThea.utils import (download_fits, load_fits, model_fittings,
|
|
41
41
|
plot_fitting_model, single_imager_maps_process)
|
|
42
|
+
from PyThea.utils_database import get_fits_filenames_from_database
|
|
42
43
|
from PyThea.version import version
|
|
43
44
|
|
|
44
45
|
|
|
@@ -84,6 +85,7 @@ def footer_text():
|
|
|
84
85
|
More imaging data have been added:
|
|
85
86
|
- SDO/AIA images from 211A channel.
|
|
86
87
|
- PSP/WISPR inner and outer telescope images.
|
|
88
|
+
- SolO/EUI and METIS images.
|
|
87
89
|
''', icon='ℹ️')
|
|
88
90
|
st.warning('''
|
|
89
91
|
**NOTE: From PyThea >0.8.1 the JSON fitting files will be slightly different from the old ones.**
|
|
@@ -295,7 +297,15 @@ def run():
|
|
|
295
297
|
if imager not in st.session_state.map_:
|
|
296
298
|
timerange = a.Time(st.session_state.date_process + datetime.timedelta(hours=imaging_time_range[0]),
|
|
297
299
|
st.session_state.date_process + datetime.timedelta(hours=imaging_time_range[1]))
|
|
298
|
-
|
|
300
|
+
|
|
301
|
+
if st.session_state.offline_mode is False:
|
|
302
|
+
downloaded_files = download_fits(timerange, imager)
|
|
303
|
+
elif st.session_state.offline_mode is True:
|
|
304
|
+
progress_bar.desc = f'Load {imager} images from local database.'
|
|
305
|
+
event_id = st.session_state.event_selected.replace('-', '').replace(':', '').replace('|', 'D').replace('.', 'p') \
|
|
306
|
+
+ 'M' + st.session_state.geometrical_model
|
|
307
|
+
downloaded_files = get_fits_filenames_from_database(event_id, timerange, imager)
|
|
308
|
+
|
|
299
309
|
st.session_state.map_[imager] = load_fits(downloaded_files)
|
|
300
310
|
st.session_state.map_[imager] = single_imager_maps_process(st.session_state.map_[imager],
|
|
301
311
|
**selected_imagers.imager_dict[imager]['process'],
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
'''
|
|
6
6
|
import astropy.units as u
|
|
7
|
+
import sunpy_soar # noqa
|
|
7
8
|
from sunpy.net import attrs as a
|
|
8
9
|
|
|
9
10
|
imager_dict = {}
|
|
@@ -71,3 +72,11 @@ imager_dict['WISPR1'] = {'fido': (a.Instrument.wispr, a.Detector.inner),
|
|
|
71
72
|
imager_dict['WISPR2'] = {'fido': (a.Instrument.wispr, a.Detector.outer),
|
|
72
73
|
'process': {'dimensions': (960*u.pixel, 1024*u.pixel), 'processing_level': 3, 'superpixel': 2},
|
|
73
74
|
'source': 'PSP', 'instrument': 'WISPR', 'detector': 'Outer'}
|
|
75
|
+
|
|
76
|
+
imager_dict['EUI-FSI'] = {'fido': (a.Instrument('EUI'), a.soar.Product('EUI-FSI174-IMAGE'), a.Level(2)),
|
|
77
|
+
'process': {'superpixel': 1},
|
|
78
|
+
'source': 'SOLO', 'instrument': 'EUI-FSI', 'wavelength': '174'}
|
|
79
|
+
|
|
80
|
+
imager_dict['METIS'] = {'fido': (a.Instrument('METIS'), a.soar.Product('METIS-VL-TB'), a.Level(2)),
|
|
81
|
+
'process': {'dimensions': (1024*u.pixel, 1024*u.pixel), 'superpixel': 2},
|
|
82
|
+
'source': 'SOLO', 'instrument': 'METIS', 'detector': 'VLD', 'wavelength': 'TB'}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from pathlib import Path
|
|
3
2
|
|
|
4
3
|
import pooch
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
from PyThea.config import database_dir_default
|
|
6
|
+
|
|
7
7
|
github_main_url = 'https://github.com/AthKouloumvakos/PyThea-sample-data'
|
|
8
8
|
|
|
9
9
|
aia_sample_data = pooch.create(
|
|
10
|
-
path=os.path.join(
|
|
10
|
+
path=os.path.join(database_dir_default, 'sample_data'), # The cache folder
|
|
11
11
|
base_url=f'{github_main_url}/raw/main/data/', # The remote data url on Github
|
|
12
12
|
registry={
|
|
13
13
|
'aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits': 'sha256:7e88d8a277ad3dd111c1bcff3c3936d6d5ef5186e05b4bfa7749ee43c05577d5',
|
|
@@ -16,7 +16,7 @@ aia_sample_data = pooch.create(
|
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
stereo_sample_data = pooch.create(
|
|
19
|
-
path=os.path.join(
|
|
19
|
+
path=os.path.join(database_dir_default, 'sample_data'), # The cache folder
|
|
20
20
|
base_url=f'{github_main_url}/raw/main/data/', # The remote data url on Github
|
|
21
21
|
registry={
|
|
22
22
|
'20120622_235400_d4c2a.fts': 'sha256:940680fe8bea754c9859170585d8299b9b049b631155435a31ecacf5b702d9cf',
|
|
@@ -27,7 +27,7 @@ stereo_sample_data = pooch.create(
|
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
wispr_sample_data = pooch.create(
|
|
30
|
-
path=os.path.join(
|
|
30
|
+
path=os.path.join(database_dir_default, 'sample_data'), # The cache folder
|
|
31
31
|
base_url=f'{github_main_url}/raw/main/data/', # The remote data url on Github
|
|
32
32
|
registry={
|
|
33
33
|
'psp_l3_wispr_20210808t103707_v1_1211.fits': 'sha256:85035693c4677e8fa8a3e61b8051d6f0a46e96806b5b0cbdb3efa77652308bda',
|
|
@@ -36,7 +36,7 @@ wispr_sample_data = pooch.create(
|
|
|
36
36
|
)
|
|
37
37
|
|
|
38
38
|
json_fitting_file_sample_data = pooch.create(
|
|
39
|
-
path=os.path.join(
|
|
39
|
+
path=os.path.join(database_dir_default, 'sample_data'), # The cache folder
|
|
40
40
|
base_url=f'{github_main_url}/raw/main/data/', # The remote data url on Github
|
|
41
41
|
registry={
|
|
42
42
|
'FLX1p0D20211028T153500MEllipsoid.json': 'sha256:34fced8530875110117ba27a73541d3acd0c90bc8fca99367c1ec4cdfc05ce86',
|
|
@@ -41,3 +41,5 @@ def plot_parker_spiral(axis, map, bodies, sw_speed=350 * (u.km / u.second)):
|
|
|
41
41
|
axis.plot_coord(spiral_coord[0], markersize=16, linewidth=10, marker='+', color='white')
|
|
42
42
|
|
|
43
43
|
axis.plot_coord(spiral_coord[0], markersize=3, linewidth=4, marker='s', color=bodies_dict[body][1])
|
|
44
|
+
|
|
45
|
+
axis.plot_coord(spiral_coord[-1], markersize=8, linewidth=6, marker='x', color=bodies_dict[body][1])
|
|
@@ -24,6 +24,7 @@ import astropy.units as u
|
|
|
24
24
|
from sunpy.net import attrs as a
|
|
25
25
|
|
|
26
26
|
from PyThea.callbacks import change_fitting_sliders, change_long_lat_sliders
|
|
27
|
+
from PyThea.config import database_dir_default
|
|
27
28
|
from PyThea.config.config_sliders import sliders_dict as sd
|
|
28
29
|
from PyThea.extensions.hek.utils import plot_hek
|
|
29
30
|
from PyThea.extensions.Parker_spirals.utils import plot_parker_spiral
|
|
@@ -121,6 +122,10 @@ def date_and_event_selection(st):
|
|
|
121
122
|
|
|
122
123
|
st.rerun()
|
|
123
124
|
|
|
125
|
+
st.session_state.offline_mode = st.sidebar.checkbox('Work with offline mode active?', value=False)
|
|
126
|
+
if st.session_state.offline_mode:
|
|
127
|
+
st.sidebar.info(f'Fits files will be loaded from PyThea\'s database directory: {database_dir_default}', icon='ℹ️')
|
|
128
|
+
|
|
124
129
|
|
|
125
130
|
def fitting_and_slider_options_container(st):
|
|
126
131
|
"""
|
|
@@ -305,4 +305,6 @@ def maps_clims(images):
|
|
|
305
305
|
return [14., 14.]
|
|
306
306
|
elif images[1].detector == 'Inner':
|
|
307
307
|
return [13., 13.]
|
|
308
|
+
if images[1].instrument == 'Metis':
|
|
309
|
+
return [12.80, 13.00]
|
|
308
310
|
return [np.nanquantile(images[1].data, 0.20)-10, np.nanquantile(images[1].data, 0.80)+10]
|
|
@@ -8,7 +8,8 @@ export PYTHONPATH="${PYTHONPATH}:{top_level_dir_that_pythea_lives}/PyThea"
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
import os
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
from PyThea.config import database_dir_default
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def test_database_dir_exists():
|
|
@@ -20,5 +21,4 @@ def test_database_dir_exists():
|
|
|
20
21
|
print("Skipping test as it's running in GitHub Actions.")
|
|
21
22
|
return
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
assert os.path.exists(database_dir), f"PyThea's database directory '{database_dir}' does not exist."
|
|
24
|
+
assert os.path.exists(database_dir_default), f"PyThea's database directory '{database_dir_default}' does not exist."
|
|
@@ -25,7 +25,6 @@ import os
|
|
|
25
25
|
import re
|
|
26
26
|
import warnings
|
|
27
27
|
from copy import copy
|
|
28
|
-
from pathlib import Path
|
|
29
28
|
|
|
30
29
|
import astropy.units as u
|
|
31
30
|
import matplotlib.colors as colors
|
|
@@ -48,6 +47,7 @@ from sunpy.net import attrs as a
|
|
|
48
47
|
from sunpy.time import parse_time
|
|
49
48
|
from sunpy.visualization import drawing
|
|
50
49
|
|
|
50
|
+
from PyThea.config import database_dir_default
|
|
51
51
|
from PyThea.config.selected_bodies import bodies_dict as bodies_dict_default
|
|
52
52
|
from PyThea.config.selected_imagers import imager_dict as imager_dict_default
|
|
53
53
|
from PyThea.geometrical_models import ellipsoid, gcs, spheroid
|
|
@@ -56,8 +56,6 @@ from PyThea.sunpy_dev.map.maputils import (filter_maps,
|
|
|
56
56
|
prepare_maps)
|
|
57
57
|
from PyThea.version import version
|
|
58
58
|
|
|
59
|
-
database_dir_default = os.path.join(Path.home(), 'PyThea')
|
|
60
|
-
|
|
61
59
|
|
|
62
60
|
def get_hek_flare(timerange, thresshold='B1.0'):
|
|
63
61
|
"""
|
|
@@ -133,6 +131,9 @@ def make_figure(map, cmap='Greys_r', clim=[-20, 20], clip_model=True, **kwargs):
|
|
|
133
131
|
if map.instrument == 'WISPR':
|
|
134
132
|
clim = [-10**-clim[0], 10**-clim[1]]
|
|
135
133
|
|
|
134
|
+
if map.instrument == 'Metis':
|
|
135
|
+
clim = [-10**-clim[0], 10**-clim[1]]
|
|
136
|
+
|
|
136
137
|
if cmap == 'default':
|
|
137
138
|
# TODO: For plain images or when EUVIA-B are used, this does not work very well.
|
|
138
139
|
map.plot(norm=colors.Normalize(vmin=clim[0], vmax=clim[1]))
|
|
@@ -156,7 +157,8 @@ def make_figure(map, cmap='Greys_r', clim=[-20, 20], clip_model=True, **kwargs):
|
|
|
156
157
|
|
|
157
158
|
axis.set_title(re.sub(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}',
|
|
158
159
|
' $T_{AGV}:$' + parse_time(map.date_average).strftime('%Y-%m-%d %H:%M:%S'),
|
|
159
|
-
map.latex_name
|
|
160
|
+
map.latex_name.replace('VLD', 'METIS-VDL')),
|
|
161
|
+
fontsize=10, pad=8)
|
|
160
162
|
|
|
161
163
|
return fig, axis
|
|
162
164
|
|
|
@@ -275,7 +277,7 @@ def download_fits(timerange, imager, imager_dict=None, database_dir=None):
|
|
|
275
277
|
'detector' (optional), and 'wavelength' (optional). The default imager_dict is from
|
|
276
278
|
PyThea.config.selected_imagers.import imager_dict.
|
|
277
279
|
database_dir : str, optional
|
|
278
|
-
The base directory where the data will be saved. The default is
|
|
280
|
+
The base directory where the data will be saved. The default is database_dir_default from PyThea.config.
|
|
279
281
|
|
|
280
282
|
Returns
|
|
281
283
|
-------
|
|
@@ -340,6 +342,8 @@ def load_fits(files):
|
|
|
340
342
|
for file_path in files:
|
|
341
343
|
try:
|
|
342
344
|
map_ = sunpy.map.Map(file_path)
|
|
345
|
+
if isinstance(map_, list): # Added because of METIS
|
|
346
|
+
map_ = map_[0]
|
|
343
347
|
map_.meta['fits_file'] = os.path.basename(file_path)
|
|
344
348
|
maps_.append(map_)
|
|
345
349
|
except RuntimeError as err:
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""
|
|
2
|
+
PyThea: A software package to reconstruct the 3D structure of CMEs and
|
|
3
|
+
shock waves using multi-viewpoint remote-sensing observations.
|
|
4
|
+
Copyright (C) 2021 Athanasios Kouloumvakos
|
|
5
|
+
|
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU General Public License
|
|
17
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
import collections.abc
|
|
21
|
+
import json
|
|
22
|
+
import os
|
|
23
|
+
import re
|
|
24
|
+
|
|
25
|
+
from PyThea.config import database_dir_default
|
|
26
|
+
from PyThea.config.selected_imagers import imager_dict
|
|
27
|
+
from PyThea.utils import download_fits
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def create_nested_dict(k, v):
|
|
31
|
+
if len(k) == 0:
|
|
32
|
+
return v
|
|
33
|
+
else:
|
|
34
|
+
return {k[0]: create_nested_dict(k[1:], v)}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def load_nested_dict(k, d):
|
|
38
|
+
if len(k) == 0:
|
|
39
|
+
return d
|
|
40
|
+
else:
|
|
41
|
+
if k[0] in d:
|
|
42
|
+
return load_nested_dict(k[1:], d[k[0]])
|
|
43
|
+
else:
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def update_nested_dict(d, u):
|
|
48
|
+
for k, v in u.items():
|
|
49
|
+
if isinstance(v, collections.abc.Mapping):
|
|
50
|
+
d[k] = update_nested_dict(d.get(k, {}), v)
|
|
51
|
+
else:
|
|
52
|
+
d[k] = v
|
|
53
|
+
return d
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def get_fits_filenames_from_database(event_id, timerange, imager):
|
|
57
|
+
|
|
58
|
+
db_args = [imager_dict[imager]['source'],
|
|
59
|
+
imager_dict[imager]['instrument'],
|
|
60
|
+
imager_dict[imager].get('detector', imager_dict[imager].get('wavelength'))]
|
|
61
|
+
|
|
62
|
+
# name of the JSON file with the database
|
|
63
|
+
file_id = re.search(r'D(.*?)(?=T)', event_id).group(1)
|
|
64
|
+
filename = os.path.join(database_dir_default, 'data_manager', f'{file_id}_fits_filenames.json')
|
|
65
|
+
|
|
66
|
+
if not os.path.isfile(filename):
|
|
67
|
+
# create file if it doesn't exist
|
|
68
|
+
with open(filename, 'w') as f:
|
|
69
|
+
json.dump({}, f)
|
|
70
|
+
|
|
71
|
+
# load data from file
|
|
72
|
+
with open(filename, 'r') as f:
|
|
73
|
+
database_data = json.load(f)
|
|
74
|
+
|
|
75
|
+
downloaded_files = None
|
|
76
|
+
|
|
77
|
+
if str(timerange) in database_data:
|
|
78
|
+
downloaded_files = load_nested_dict(db_args, database_data[str(timerange)])
|
|
79
|
+
|
|
80
|
+
if downloaded_files is None:
|
|
81
|
+
downloaded_files = download_fits(timerange, imager)
|
|
82
|
+
|
|
83
|
+
nested_dict_ = create_nested_dict(db_args, downloaded_files.data)
|
|
84
|
+
nested_dict_ = {str(timerange): nested_dict_}
|
|
85
|
+
|
|
86
|
+
# dictionary stored in JSON file
|
|
87
|
+
database_data = update_nested_dict(database_data, nested_dict_)
|
|
88
|
+
|
|
89
|
+
# write updated data to file
|
|
90
|
+
with open(filename, 'w') as f:
|
|
91
|
+
json.dump(database_data, f, indent=4)
|
|
92
|
+
|
|
93
|
+
return downloaded_files
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyThea
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: PyThea: A software package to reconstruct the 3D structure of CMEs and shock waves
|
|
5
5
|
Home-page: https://github.com/AthKouloumvakos/PyThea
|
|
6
6
|
Author: Athanasios Kouloumvakos
|
|
@@ -29,6 +29,7 @@ Requires-Dist: astroquery
|
|
|
29
29
|
Requires-Dist: jplephem
|
|
30
30
|
Requires-Dist: numexpr
|
|
31
31
|
Requires-Dist: sunpy==5.1.2
|
|
32
|
+
Requires-Dist: sunpy_soar
|
|
32
33
|
Requires-Dist: parfive==2.1.0
|
|
33
34
|
Requires-Dist: pooch
|
|
34
35
|
Requires-Dist: matplotlib
|
|
@@ -11,6 +11,7 @@ from setuptools import find_packages, setup
|
|
|
11
11
|
if not os.path.isdir(os.path.join(Path.home(), 'PyThea')):
|
|
12
12
|
os.mkdir(os.path.join(Path.home(), 'PyThea'))
|
|
13
13
|
os.mkdir(os.path.join(Path.home(), 'PyThea', 'data'))
|
|
14
|
+
os.mkdir(os.path.join(Path.home(), 'PyThea', 'data_manager'))
|
|
14
15
|
|
|
15
16
|
with open('README_pypi.md', 'r', encoding='utf8') as f:
|
|
16
17
|
long_description = f.read()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/sunkit_instruments/lasco/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{pythea-0.13.0 → pythea-0.14.0}/PyThea/sunpy_dev/extern/sunkit_instruments/stereo/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|