Codebase list drms / 573b948
New upstream version 0.5.7 Ole Streicher 4 years ago
17 changed file(s) with 555 addition(s) and 100 deletion(s). Raw diff Collapse all Expand all
0 Copyright (c) 2014-2019 Kolja Glogowski and others.
1 See AUTHORS.txt for a list of contributors.
0 Copyright (c) 2014-2019 Kolja Glogowski and others (see AUTHORS.txt)
21
32 Permission is hereby granted, free of charge, to any person obtaining a copy
43 of this software and associated documentation files (the "Software"), to deal
00 Metadata-Version: 1.1
11 Name: drms
2 Version: 0.5.6
2 Version: 0.5.7
33 Summary: Access HMI, AIA and MDI data with Python
44 Home-page: https://github.com/sunpy/drms
55 Author: Kolja Glogowski
99 drms
1010 ====
1111
12 `Docs <http://drms.readthedocs.io/>`_ |
13 `Tutorial <https://drms.readthedocs.io/en/latest/tutorial.html>`_ |
12 `Docs <https://docs.sunpy.org/projects/drms>`_ |
13 `Tutorial <https://docs.sunpy.org/projects/drms/en/latest/tutorial.html>`_ |
1414 `Github <https://github.com/sunpy/drms>`_ |
15 `PyPI <https://pypi.python.org/pypi/drms>`_
15 `PyPI <https://pypi.python.org/pypi/drms>`_
16
17 .. image:: https://zenodo.org/badge/58651845.svg
18 :target: https://zenodo.org/badge/latestdoi/58651845
1619
1720 The ``drms`` module provides an easy-to-use interface for accessing HMI,
1821 AIA and MDI data with Python. It uses the publicly accessible
1922 `JSOC <http://jsoc.stanford.edu/>`_ DRMS server by default, but can also
2023 be used with local `NetDRMS <http://jsoc.stanford.edu/netdrms/>`_ sites.
21 More information, including a detailed tutorial is available on
22 `Read the Docs <http://drms.readthedocs.io/>`_.
24 More information, including a detailed tutorial, is available in the
25 `Documentation <https://docs.sunpy.org/projects/drms>`_.
2326
2427
2528 Requirements
3942 Installation
4043 ------------
4144
42 The ``drms`` Python package can be installed from
43 `PyPI <https://pypi.python.org/pypi/drms>`_ using
45 If you are using `Anaconda`_, it is recommended to use the `conda-forge`_
46 package::
47
48 conda config --append channels conda-forge
49 conda install drms
50
51 Otherwise the ``drms`` Python package can be installed from `PyPI`_ using
4452
4553 ::
4654
4755 pip install drms
4856
49 To upgrade an already existing installation to the latest release, you
50 can write::
51
52 pip install -U drms
53
54
55 Note: If you do not use a Python distribution, like
56 `Anaconda <https://www.continuum.io/downloads>`_,
57 and did not create an isolated Python environment using
58 `Virtualenv <https://virtualenv.pypa.io/en/stable/>`_,
57 Note: If you do not use a Python distribution, like `Anaconda`_,
58 and did not create an isolated Python environment using `Virtualenv`_,
5959 you might need to add ``--user`` to the ``pip`` command::
6060
6161 pip install --user drms
62
63
64 .. _PyPI: https://pypi.python.org/pypi/drms
65 .. _conda-forge: https://anaconda.org/conda-forge/drms
66 .. _Anaconda: https://www.anaconda.com/distribution/
67 .. _Virtualenv: https://virtualenv.pypa.io
68
69
70 Running Tests
71 -------------
72
73 In order to run any unit tests, `pytest`_ needs to be installed.
74
75 Basic tests for the currently installed ``drms`` package can be run using::
76
77 python -m drms.tests
78
79 To perform online tests against the JSOC servers, use the ``--run-jsoc`` flag::
80
81 python -m drms.tests --run-jsoc
82
83 To also include additional email verification and JSOC export tests,
84 you need to specify a `registered email address`_, e.g.::
85
86 python -m drms.tests --run-jsoc --email name@example.com
87
88 .. _pytest: https://pypi.org/project/pytest/
89 .. _registered email address: http://jsoc.stanford.edu/ajax/register_email.html
90
91
92 Getting Help
93 ------------
94
95 This is a SunPy-affiliated package. For more information or to ask questions
96 about drms or SunPy, check out:
97
98 - `drms Documentation`_
99 - `SunPy Matrix Channel`_
100 - `SunPy Mailing List`_
101
102 .. _drms Documentation: https://docs.sunpy.org/projects/drms/en/latest/
103 .. _SunPy Matrix Channel: https://riot.im/app/#/room/#sunpy:matrix.org
104 .. _SunPy Mailing List: https://groups.google.com/forum/#!forum/sunpy
105
106
107 Contributing
108 ------------
109
110 If you would like to get involved, start by joining the `SunPy mailing list`_
111 and check out the `Developers Guide`_ section of the SunPy docs. Stop by our
112 chat room `#sunpy:matrix.org`_ if you have any questions.
113 Help is always welcome so let us know what you like to work on, or check out
114 the `issues page`_ for the list of known outstanding items.
115
116 For more information on contributing to SunPy, please read our
117 `Newcomers' guide`_.
118
119 .. _SunPy mailing list: https://groups.google.com/forum/#!forum/sunpy
120 .. _Developers Guide: https://docs.sunpy.org/en/latest/dev_guide/index.html
121 .. _`#sunpy:matrix.org`: https://riot.im/app/#/room/#sunpy:matrix.org
122 .. _issues page: https://github.com/sunpy/drms/issues
123 .. _Newcomers' guide: https://docs.sunpy.org/en/latest/dev_guide/newcomers.html
124
125
126 Code of Conduct
127 ---------------
128
129 When you are interacting with the SunPy community you are asked to follow
130 our `Code of Conduct`_.
131
132 .. _Code of Conduct: https://docs.sunpy.org/en/latest/code_of_conduct.html
62133
63134
64135 Acknowledgements
67138 The main author of this project has received funding from the European
68139 Research Council under the European Union's Seventh Framework Programme
69140 (FP/2007-2013) / ERC Grant Agreement no. 307117.
141
142 Parts of this file were adopted from the SunPy README file,
143 Copyright (c) 2013-2019 The SunPy developers.
70144
71145 See AUTHORS.txt for a list of contributors.
72146
11 drms
22 ====
33
4 `Docs <http://drms.readthedocs.io/>`_ |
5 `Tutorial <https://drms.readthedocs.io/en/latest/tutorial.html>`_ |
4 `Docs <https://docs.sunpy.org/projects/drms>`_ |
5 `Tutorial <https://docs.sunpy.org/projects/drms/en/latest/tutorial.html>`_ |
66 `Github <https://github.com/sunpy/drms>`_ |
7 `PyPI <https://pypi.python.org/pypi/drms>`_
7 `PyPI <https://pypi.python.org/pypi/drms>`_
8
9 .. image:: https://zenodo.org/badge/58651845.svg
10 :target: https://zenodo.org/badge/latestdoi/58651845
811
912 The ``drms`` module provides an easy-to-use interface for accessing HMI,
1013 AIA and MDI data with Python. It uses the publicly accessible
1114 `JSOC <http://jsoc.stanford.edu/>`_ DRMS server by default, but can also
1215 be used with local `NetDRMS <http://jsoc.stanford.edu/netdrms/>`_ sites.
13 More information, including a detailed tutorial is available on
14 `Read the Docs <http://drms.readthedocs.io/>`_.
16 More information, including a detailed tutorial, is available in the
17 `Documentation <https://docs.sunpy.org/projects/drms>`_.
1518
1619
1720 Requirements
3134 Installation
3235 ------------
3336
34 The ``drms`` Python package can be installed from
35 `PyPI <https://pypi.python.org/pypi/drms>`_ using
37 If you are using `Anaconda`_, it is recommended to use the `conda-forge`_
38 package::
39
40 conda config --append channels conda-forge
41 conda install drms
42
43 Otherwise the ``drms`` Python package can be installed from `PyPI`_ using
3644
3745 ::
3846
3947 pip install drms
4048
41 To upgrade an already existing installation to the latest release, you
42 can write::
43
44 pip install -U drms
45
46
47 Note: If you do not use a Python distribution, like
48 `Anaconda <https://www.continuum.io/downloads>`_,
49 and did not create an isolated Python environment using
50 `Virtualenv <https://virtualenv.pypa.io/en/stable/>`_,
49 Note: If you do not use a Python distribution, like `Anaconda`_,
50 and did not create an isolated Python environment using `Virtualenv`_,
5151 you might need to add ``--user`` to the ``pip`` command::
5252
5353 pip install --user drms
54
55
56 .. _PyPI: https://pypi.python.org/pypi/drms
57 .. _conda-forge: https://anaconda.org/conda-forge/drms
58 .. _Anaconda: https://www.anaconda.com/distribution/
59 .. _Virtualenv: https://virtualenv.pypa.io
60
61
62 Running Tests
63 -------------
64
65 In order to run any unit tests, `pytest`_ needs to be installed.
66
67 Basic tests for the currently installed ``drms`` package can be run using::
68
69 python -m drms.tests
70
71 To perform online tests against the JSOC servers, use the ``--run-jsoc`` flag::
72
73 python -m drms.tests --run-jsoc
74
75 To also include additional email verification and JSOC export tests,
76 you need to specify a `registered email address`_, e.g.::
77
78 python -m drms.tests --run-jsoc --email name@example.com
79
80 .. _pytest: https://pypi.org/project/pytest/
81 .. _registered email address: http://jsoc.stanford.edu/ajax/register_email.html
82
83
84 Getting Help
85 ------------
86
87 This is a SunPy-affiliated package. For more information or to ask questions
88 about drms or SunPy, check out:
89
90 - `drms Documentation`_
91 - `SunPy Matrix Channel`_
92 - `SunPy Mailing List`_
93
94 .. _drms Documentation: https://docs.sunpy.org/projects/drms/en/latest/
95 .. _SunPy Matrix Channel: https://riot.im/app/#/room/#sunpy:matrix.org
96 .. _SunPy Mailing List: https://groups.google.com/forum/#!forum/sunpy
97
98
99 Contributing
100 ------------
101
102 If you would like to get involved, start by joining the `SunPy mailing list`_
103 and check out the `Developers Guide`_ section of the SunPy docs. Stop by our
104 chat room `#sunpy:matrix.org`_ if you have any questions.
105 Help is always welcome so let us know what you like to work on, or check out
106 the `issues page`_ for the list of known outstanding items.
107
108 For more information on contributing to SunPy, please read our
109 `Newcomers' guide`_.
110
111 .. _SunPy mailing list: https://groups.google.com/forum/#!forum/sunpy
112 .. _Developers Guide: https://docs.sunpy.org/en/latest/dev_guide/index.html
113 .. _`#sunpy:matrix.org`: https://riot.im/app/#/room/#sunpy:matrix.org
114 .. _issues page: https://github.com/sunpy/drms/issues
115 .. _Newcomers' guide: https://docs.sunpy.org/en/latest/dev_guide/newcomers.html
116
117
118 Code of Conduct
119 ---------------
120
121 When you are interacting with the SunPy community you are asked to follow
122 our `Code of Conduct`_.
123
124 .. _Code of Conduct: https://docs.sunpy.org/en/latest/code_of_conduct.html
54125
55126
56127 Acknowledgements
60131 Research Council under the European Union's Seventh Framework Programme
61132 (FP/2007-2013) / ERC Grant Agreement no. 307117.
62133
134 Parts of this file were adopted from the SunPy README file,
135 Copyright (c) 2013-2019 The SunPy developers.
136
63137 See AUTHORS.txt for a list of contributors.
4141 Installation
4242 ------------
4343
44 The ``drms`` Python package can be installed from
45 `PyPI <https://pypi.python.org/pypi/drms>`_ using
44 If you are using `Anaconda`_, it is recommended to use the `conda-forge`_
45 package::
46
47 conda config --append channels conda-forge
48 conda install drms
49
50 Otherwise the ``drms`` Python package can be installed from `PyPI`_ using
4651
4752 ::
4853
4954 pip install drms
5055
51 To upgrade an already existing installation to the latest release, you
52 can write::
53
54 pip install -U drms
55
5656
5757 .. note::
58 If you do not use a Python distribution, like
59 `Anaconda <https://www.continuum.io/downloads>`_,
60 and did not create an isolated Python environment using
61 `Virtualenv <https://virtualenv.pypa.io/en/stable/>`_,
58 If you do not use a Python distribution, like `Anaconda`_,
59 and did not create an isolated Python environment using `Virtualenv`_,
6260 you might need to add ``--user`` to the ``pip`` command::
6361
6462 pip install --user drms
63
64
65 .. _PyPI: https://pypi.python.org/pypi/drms
66 .. _conda-forge: https://anaconda.org/conda-forge/drms
67 .. _Anaconda: https://www.anaconda.com/distribution/
68 .. _Virtualenv: https://virtualenv.pypa.io
6569
6670
6771 Acknowledgements
88
99 version_json = '''
1010 {
11 "date": "2019-02-17T19:39:21+0100",
11 "date": "2019-08-16T20:00:17+0200",
1212 "dirty": false,
1313 "error": null,
14 "full-revisionid": "d4ab3b35adba43123dd2b130c05450305f07e5ab",
15 "version": "0.5.6"
14 "full-revisionid": "478957d8c6f61c1ef2d63587eb06566940e09f47",
15 "version": "0.5.7"
1616 }
1717 ''' # END VERSION_JSON
1818
00 Metadata-Version: 1.1
11 Name: drms
2 Version: 0.5.6
2 Version: 0.5.7
33 Summary: Access HMI, AIA and MDI data with Python
44 Home-page: https://github.com/sunpy/drms
55 Author: Kolja Glogowski
99 drms
1010 ====
1111
12 `Docs <http://drms.readthedocs.io/>`_ |
13 `Tutorial <https://drms.readthedocs.io/en/latest/tutorial.html>`_ |
12 `Docs <https://docs.sunpy.org/projects/drms>`_ |
13 `Tutorial <https://docs.sunpy.org/projects/drms/en/latest/tutorial.html>`_ |
1414 `Github <https://github.com/sunpy/drms>`_ |
15 `PyPI <https://pypi.python.org/pypi/drms>`_
15 `PyPI <https://pypi.python.org/pypi/drms>`_
16
17 .. image:: https://zenodo.org/badge/58651845.svg
18 :target: https://zenodo.org/badge/latestdoi/58651845
1619
1720 The ``drms`` module provides an easy-to-use interface for accessing HMI,
1821 AIA and MDI data with Python. It uses the publicly accessible
1922 `JSOC <http://jsoc.stanford.edu/>`_ DRMS server by default, but can also
2023 be used with local `NetDRMS <http://jsoc.stanford.edu/netdrms/>`_ sites.
21 More information, including a detailed tutorial is available on
22 `Read the Docs <http://drms.readthedocs.io/>`_.
24 More information, including a detailed tutorial, is available in the
25 `Documentation <https://docs.sunpy.org/projects/drms>`_.
2326
2427
2528 Requirements
3942 Installation
4043 ------------
4144
42 The ``drms`` Python package can be installed from
43 `PyPI <https://pypi.python.org/pypi/drms>`_ using
45 If you are using `Anaconda`_, it is recommended to use the `conda-forge`_
46 package::
47
48 conda config --append channels conda-forge
49 conda install drms
50
51 Otherwise the ``drms`` Python package can be installed from `PyPI`_ using
4452
4553 ::
4654
4755 pip install drms
4856
49 To upgrade an already existing installation to the latest release, you
50 can write::
51
52 pip install -U drms
53
54
55 Note: If you do not use a Python distribution, like
56 `Anaconda <https://www.continuum.io/downloads>`_,
57 and did not create an isolated Python environment using
58 `Virtualenv <https://virtualenv.pypa.io/en/stable/>`_,
57 Note: If you do not use a Python distribution, like `Anaconda`_,
58 and did not create an isolated Python environment using `Virtualenv`_,
5959 you might need to add ``--user`` to the ``pip`` command::
6060
6161 pip install --user drms
62
63
64 .. _PyPI: https://pypi.python.org/pypi/drms
65 .. _conda-forge: https://anaconda.org/conda-forge/drms
66 .. _Anaconda: https://www.anaconda.com/distribution/
67 .. _Virtualenv: https://virtualenv.pypa.io
68
69
70 Running Tests
71 -------------
72
73 In order to run any unit tests, `pytest`_ needs to be installed.
74
75 Basic tests for the currently installed ``drms`` package can be run using::
76
77 python -m drms.tests
78
79 To perform online tests against the JSOC servers, use the ``--run-jsoc`` flag::
80
81 python -m drms.tests --run-jsoc
82
83 To also include additional email verification and JSOC export tests,
84 you need to specify a `registered email address`_, e.g.::
85
86 python -m drms.tests --run-jsoc --email name@example.com
87
88 .. _pytest: https://pypi.org/project/pytest/
89 .. _registered email address: http://jsoc.stanford.edu/ajax/register_email.html
90
91
92 Getting Help
93 ------------
94
95 This is a SunPy-affiliated package. For more information or to ask questions
96 about drms or SunPy, check out:
97
98 - `drms Documentation`_
99 - `SunPy Matrix Channel`_
100 - `SunPy Mailing List`_
101
102 .. _drms Documentation: https://docs.sunpy.org/projects/drms/en/latest/
103 .. _SunPy Matrix Channel: https://riot.im/app/#/room/#sunpy:matrix.org
104 .. _SunPy Mailing List: https://groups.google.com/forum/#!forum/sunpy
105
106
107 Contributing
108 ------------
109
110 If you would like to get involved, start by joining the `SunPy mailing list`_
111 and check out the `Developers Guide`_ section of the SunPy docs. Stop by our
112 chat room `#sunpy:matrix.org`_ if you have any questions.
113 Help is always welcome so let us know what you like to work on, or check out
114 the `issues page`_ for the list of known outstanding items.
115
116 For more information on contributing to SunPy, please read our
117 `Newcomers' guide`_.
118
119 .. _SunPy mailing list: https://groups.google.com/forum/#!forum/sunpy
120 .. _Developers Guide: https://docs.sunpy.org/en/latest/dev_guide/index.html
121 .. _`#sunpy:matrix.org`: https://riot.im/app/#/room/#sunpy:matrix.org
122 .. _issues page: https://github.com/sunpy/drms/issues
123 .. _Newcomers' guide: https://docs.sunpy.org/en/latest/dev_guide/newcomers.html
124
125
126 Code of Conduct
127 ---------------
128
129 When you are interacting with the SunPy community you are asked to follow
130 our `Code of Conduct`_.
131
132 .. _Code of Conduct: https://docs.sunpy.org/en/latest/code_of_conduct.html
62133
63134
64135 Acknowledgements
67138 The main author of this project has received funding from the European
68139 Research Council under the European Union's Seventh Framework Programme
69140 (FP/2007-2013) / ERC Grant Agreement no. 307117.
141
142 Parts of this file were adopted from the SunPy README file,
143 Copyright (c) 2013-2019 The SunPy developers.
70144
71145 See AUTHORS.txt for a list of contributors.
72146
4848 drms/tests/online/test_jsoc_info.py
4949 drms/tests/online/test_jsoc_query.py
5050 drms/tests/online/test_kis_basic.py
51 examples/create_joss_figure.py
5152 examples/example_helpers.py
5253 examples/export_as_is.py
5354 examples/export_fits.py
0 """
1 This example creates the figure shown in the JOSS paper.
2 """
3 from __future__ import absolute_import, division, print_function
4 import os.path
5 import numpy as np
6 import matplotlib.pyplot as plt
7 from matplotlib import dates
8 from astropy.io import fits
9 import example_helpers
10 import drms
11
12 import pandas
13 pandas_version = tuple(map(int, pandas.__version__.split('.')[:2]))
14 if pandas_version >= (0, 22):
15 # Since pandas v0.22, we need to explicitely register matplotlib
16 # converters to use pandas.Timestamp objects in plots.
17 pandas.plotting.register_matplotlib_converters()
18
19
20 def read_fits_data(fname):
21 """Reads FITS data and fixes/ignores any non-standard FITS keywords."""
22 hdulist = fits.open(fname)
23 hdulist.verify('silentfix+warn')
24 return hdulist[1].data
25
26 # Print the doc string of this example.
27 print(__doc__)
28
29 # This example requires a registered export email address. You can register
30 # JSOC exports at: http://jsoc.stanford.edu/ajax/register_email.html
31 #
32 # You will be asked for your registered email address during execution of
33 # this example. If you don't want to enter it every time you run this script,
34 # you can set the environment variable JSOC_EXPORT_EMAIL or the variable
35 # below to your registered email address.
36 email = ''
37
38 # Should the plots been shown and/or saved?
39 save_plots = True
40 show_plots = True
41
42 # Series, harpnum and segment selection
43 series = 'hmi.sharp_720s'
44 sharpnum = 4315
45 segments = ['magnetogram', 'continuum']
46 fname_fmt_str = '{series}.{sharpnum}.{tstr}.{segment}.fits'
47
48 # Download directory
49 out_dir = os.path.join('downloads', 'sharp_joss')
50
51 # Create download directory if it does not exist yet.
52 if not os.path.exists(out_dir):
53 os.makedirs(out_dir)
54
55 # Keywords to be queried
56 kwlist = ['T_REC', 'LON_FWT', 'CROTA2', 'AREA_ACR', 'USFLUX', 'ERRVF',
57 'CRPIX1', 'CRPIX2', 'CDELT1', 'CDELT2', 'CRVAL1', 'CRVAL2']
58
59 # Create DRMS client, use debug=True to see the query URLs.
60 c = drms.Client(verbose=True)
61
62 print('Querying metadata...')
63 kw = c.query('%s[%d]' % (series, sharpnum), key=kwlist, rec_index=True)
64 t = drms.to_datetime(kw.T_REC)
65
66 print('Finding central meridian crossing...')
67 rec_cm = kw.LON_FWT.abs().idxmin()
68 k_cm = kw.loc[rec_cm]
69 t_cm = drms.to_datetime(kw.T_REC[rec_cm])
70 print('-> rec_cm:', rec_cm, '@', kw.LON_FWT[rec_cm], 'deg')
71
72 # Check if any files were already downloaded.
73 fnames = {}
74 download_segments = []
75 t_cm_str = t_cm.strftime('%Y%m%d_%H%M%S_TAI')
76 for s in segments:
77 fnames[s] = fname_fmt_str.format(
78 series=series, sharpnum=sharpnum, tstr=t_cm_str, segment=s)
79 if not os.path.exists(os.path.join(out_dir, fnames[s])):
80 download_segments.append(s)
81
82 # Only download missing files.
83 if download_segments:
84 print()
85 if not email:
86 email = example_helpers.get_export_email()
87 if not email or not c.check_email(email):
88 raise RuntimeError('Email address is not valid or not registered.')
89 print('Downloading files...')
90 export_query = '%s{%s}' % (rec_cm, ','.join(download_segments))
91 r = c.export(export_query, email=email)
92 dl = r.download(out_dir)
93 print()
94
95 print('Reading image files...')
96 data_mag = read_fits_data(os.path.join(out_dir, fnames['magnetogram']))
97 data_cont = read_fits_data(os.path.join(out_dir, fnames['continuum']))
98
99 print('Creating plots...')
100 plt.rc('figure', figsize=(11, 6.75))
101 plt.rc('axes', titlesize='medium')
102 plt.rc('axes.formatter', use_mathtext=True)
103 plt.rc('mathtext', default='regular')
104 plt.rc('legend', fontsize='medium', framealpha=1.0)
105 plt.rc('image', origin='lower', interpolation='none', cmap='gray')
106
107 # Convert pixel to world coordinates using WCS keywords
108 ny, nx = data_mag.shape
109 xmin = (1 - k_cm.CRPIX1)*k_cm.CDELT1 + k_cm.CRVAL1
110 xmax = (nx - k_cm.CRPIX1)*k_cm.CDELT1 + k_cm.CRVAL1
111 ymin = (1 - k_cm.CRPIX2)*k_cm.CDELT2 + k_cm.CRVAL2
112 ymax = (ny - k_cm.CRPIX2)*k_cm.CDELT2 + k_cm.CRVAL2
113
114 # We assume a CROTA2 value close to 180 degree, so we can approximate the
115 # rotation by inverting the image axes.
116 if abs(180 - k_cm.CROTA2) < 0.1:
117 data_mag = data_mag[::-1, ::-1]
118 data_cont = data_cont[::-1, ::-1]
119 xmin, xmax = -xmax, -xmin
120 ymin, ymax = -ymax, -ymin
121 else:
122 raise RuntimeError('CROTA2 = %.2f value not supported.' % k_cm.CROTA2)
123
124 # Compute the image extent used for imshow
125 extent = (xmin - abs(k_cm.CDELT1)/2, xmax + abs(k_cm.CDELT1)/2,
126 ymin - abs(k_cm.CDELT2)/2, ymax + abs(k_cm.CDELT2)/2)
127
128 # Create figure with 2x2 axes, with enough space for colorbars on the right
129 fig, ax = plt.subplots(
130 2, 2, num=1, clear=True,
131 gridspec_kw={'width_ratios': (2, 2.5)})
132 ax_meta, ax_img = ax[:, 0], ax[:, 1]
133
134 # Create metadata line plots in the left column
135 # Note: t.values is used for errorbar() because of an issue with pandas < 0.24
136 axi = ax_meta[0]
137 axi.errorbar(t.values, kw.USFLUX/1e22, yerr=kw.ERRVF/1e22, fmt='.', ms=2,
138 capsize=0, label='USFLUX')
139 axi.set_title('Total unsigned flux')
140 axi.set_ylabel(r'Mx $\times 10^{\minus 22}$')
141
142 axi = ax_meta[1]
143 axi.plot(t, kw.AREA_ACR/1e3, '.', ms=2, label='AREA_ACR')
144 axi.set_title('LoS area of active pixels')
145 axi.set_ylabel(r'$\mu$Hem $\times 1000$')
146
147 ax_meta[0].set_xticklabels([])
148 ax_meta[1].xaxis.set_major_locator(dates.AutoDateLocator())
149 ax_meta[1].xaxis.set_major_formatter(dates.DateFormatter('%b\n%d'))
150 ax_meta[1].set_xlabel('Date')
151
152 for axi in ax_meta:
153 axi.axvline(t_cm, ls='--', color='tab:orange')
154 axi.legend(loc='upper left', numpoints=1)
155
156 # Create image plots in the right column
157 axi = ax_img[0]
158 axi.set_title('Continuum intensity')
159 im = axi.imshow(data_cont/1e3, extent=extent, vmax=61)
160 cb = plt.colorbar(im, ax=axi, label=r'$I_{\mathrm{c}}$ [kDN/s]', pad=0.03)
161
162 axi = ax_img[1]
163 axi.set_title('LoS magnetogram')
164 im = axi.imshow(data_mag/1e3, extent=extent, vmin=-1, vmax=1)
165 cb = plt.colorbar(im, ax=axi, label=r'$B_{\mathrm{los}}$ [kG]', pad=0.03)
166 cb.set_ticks([-1, -0.5, 0, 0.5, 1, 2])
167
168 for axi in ax_img:
169 axi.set_xlim(-130, 141)
170 axi.set_ylim(-262, -86)
171 axi.locator_params(axis='y', nbins=4)
172
173 ax_img[0].set_xticklabels([])
174 ax_img[1].set_xlabel('Solar X [arcsec]')
175 ax_img[0].set_ylabel('Solar Y [arcsec]')
176 ax_img[1].set_ylabel('Solar Y [arcsec]')
177
178 # Make better use of figure space
179 fig.tight_layout(pad=1.2, w_pad=2)
180 plt.draw()
181
182 if save_plots:
183 print('Saving figure...')
184 fig.savefig('joss_figure.pdf', dpi=200)
185
186 if show_plots:
187 print('Showing figure...')
188 plt.show()
1616 email = ''
1717 print()
1818 return email
19
20
21 def get_export_email():
22 """
23 Get export email address from the JSOC_EXPORT_EMAIL environ variable, or
24 ask the the user to enter their address if JSOC_EXPORT_EMAIL is not set.
25 """
26 email = os.environ.get('JSOC_EXPORT_EMAIL')
27 return email if email is not None else ask_for_export_email()
1928
2029
2130 def python_path_prepend(reldir):
1313 print(__doc__)
1414
1515
16 # If you don't want to enter your email address during program execution, you
17 # can set this variable to the email address you have registered for JSOC data
18 # exports. If you have not registered your email yet, you can do this on the
19 # JSOC website at: http://jsoc.stanford.edu/ajax/register_email.html
16 # This example requires a registered export email address. You can register
17 # JSOC exports at: http://jsoc.stanford.edu/ajax/register_email.html
18 #
19 # You will be asked for your registered email address during execution of
20 # this example. If you don't want to enter it every time you run this script,
21 # you can set the environment variable JSOC_EXPORT_EMAIL or the variable
22 # below to your registered email address.
2023 email = ''
2124
2225 # Series, harpnum, timespan and segment selection
3841 # Check if the email address was set at the top of this script. If not, ask for
3942 # a registered email address.
4043 if not email:
41 email = example_helpers.ask_for_export_email()
44 email = example_helpers.get_export_email()
4245 if not email or not c.check_email(email):
4346 raise RuntimeError('Email address is not valid or not registered.')
4447
1212 print(__doc__)
1313
1414
15 # If you don't want to enter your email address during program execution, you
16 # can set this variable to the email address you have registered for JSOC data
17 # exports. If you have not registered your email yet, you can do this on the
18 # JSOC website at: http://jsoc.stanford.edu/ajax/register_email.html
15 # This example requires a registered export email address. You can register
16 # JSOC exports at: http://jsoc.stanford.edu/ajax/register_email.html
17 #
18 # You will be asked for your registered email address during execution of
19 # this example. If you don't want to enter it every time you run this script,
20 # you can set the environment variable JSOC_EXPORT_EMAIL or the variable
21 # below to your registered email address.
1922 email = ''
2023
2124 # Use 'as-is' instead of 'fits', if record keywords are not needed in the
4245 # Check if the email address was set at the top of this script. If not, ask for
4346 # a registered email address.
4447 if not email:
45 email = example_helpers.ask_for_export_email()
48 email = example_helpers.get_export_email()
4649 if not email or not c.check_email(email):
4750 raise RuntimeError('Email address is not valid or not registered.')
4851
1313 print(__doc__)
1414
1515
16 # If you don't want to enter your email address during program execution, you
17 # can set this variable to the email address you have registered for JSOC data
18 # exports. If you have not registered your email yet, you can do this on the
19 # JSOC website at: http://jsoc.stanford.edu/ajax/register_email.html
16 # This example requires a registered export email address. You can register
17 # JSOC exports at: http://jsoc.stanford.edu/ajax/register_email.html
18 #
19 # You will be asked for your registered email address during execution of
20 # this example. If you don't want to enter it every time you run this script,
21 # you can set the environment variable JSOC_EXPORT_EMAIL or the variable
22 # below to your registered email address.
2023 email = ''
2124
2225 # Series, timespan, wavelength and segment
4750 # Check if the email address was set at the top of this script. If not, ask for
4851 # a registered email address.
4952 if not email:
50 email = example_helpers.ask_for_export_email()
53 email = example_helpers.get_export_email()
5154 if not email or not c.check_email(email):
5255 raise RuntimeError('Email address is not valid or not registered.')
5356
1313 print(__doc__)
1414
1515
16 # If you don't want to enter your email address during program execution, you
17 # can set this variable to the email address you have registered for JSOC data
18 # exports. If you have not registered your email yet, you can do this on the
19 # JSOC website at: http://jsoc.stanford.edu/ajax/register_email.html
16 # This example requires a registered export email address. You can register
17 # JSOC exports at: http://jsoc.stanford.edu/ajax/register_email.html
18 #
19 # You will be asked for your registered email address during execution of
20 # this example. If you don't want to enter it every time you run this script,
21 # you can set the environment variable JSOC_EXPORT_EMAIL or the variable
22 # below to your registered email address.
2023 email = ''
2124
2225 # Series, timespan and segment
4649 # Check if the email address was set at the top of this script. If not, ask for
4750 # a registered email address.
4851 if not email:
49 email = example_helpers.ask_for_export_email()
52 email = example_helpers.get_export_email()
5053 if not email or not c.check_email(email):
5154 raise RuntimeError('Email address is not valid or not registered.')
5255
99 print(__doc__)
1010
1111
12 # If you don't want to enter your email address during program execution, you
13 # can set this variable to the email address you have registered for JSOC data
14 # exports. If you have not registered your email yet, you can do this on the
15 # JSOC website at: http://jsoc.stanford.edu/ajax/register_email.html
12 # This example requires a registered export email address. You can register
13 # JSOC exports at: http://jsoc.stanford.edu/ajax/register_email.html
14 #
15 # You will be asked for your registered email address during execution of
16 # this example. If you don't want to enter it every time you run this script,
17 # you can set the environment variable JSOC_EXPORT_EMAIL or the variable
18 # below to your registered email address.
1619 email = ''
1720
1821 # Data export query string
2427 # Check if the email address was set at the top of this script. If not, ask for
2528 # a registered email address.
2629 if not email:
27 email = example_helpers.ask_for_export_email()
30 email = example_helpers.get_export_email()
2831 if not email or not c.check_email(email):
2932 raise RuntimeError('Email address is not valid or not registered.')
3033
1515 print(__doc__)
1616
1717
18 # If you don't want to enter your email address during program execution, you
19 # can set this variable to the email address you have registered for JSOC data
20 # exports. If you have not registered your email yet, you can do this on the
21 # JSOC website at: http://jsoc.stanford.edu/ajax/register_email.html
18 # This example requires a registered export email address. You can register
19 # JSOC exports at: http://jsoc.stanford.edu/ajax/register_email.html
20 #
21 # You will be asked for your registered email address during execution of
22 # this example. If you don't want to enter it every time you run this script,
23 # you can set the environment variable JSOC_EXPORT_EMAIL or the variable
24 # below to your registered email address.
2225 email = ''
2326
2427 # Series, Carrington rotation, Carrington longitude and data segments
4043 # Check if the email address was set at the top of this script. If not, ask for
4144 # a registered email address.
4245 if not email:
43 email = example_helpers.ask_for_export_email()
46 email = example_helpers.get_export_email()
4447 if not email or not c.check_email(email):
4548 raise RuntimeError('Email address is not valid or not registered.')
4649
11 import matplotlib.pyplot as plt
22 import example_helpers
33 import drms
4
5 import pandas
6 pandas_version = tuple(map(int, pandas.__version__.split('.')[:2]))
7 if pandas_version >= (0, 22):
8 # Since pandas v0.22, we need to explicitely register matplotlib
9 # converters to use pandas.Timestamp objects in plots.
10 pandas.plotting.register_matplotlib_converters()
411
512
613 # Series name and timespan
33 import pandas as pd
44 import example_helpers
55 import drms
6
7 pandas_version = tuple(map(int, pd.__version__.split('.')[:2]))
8 if pandas_version >= (0, 22):
9 # Since pandas v0.22, we need to explicitely register matplotlib
10 # converters to use pandas.Timestamp objects in plots.
11 pd.plotting.register_matplotlib_converters()
612
713
814 # Series name, time range and time steps
3339
3440 # Compute 30d moving average and standard deviation using a boxcar window
3541 win_size = int(30*24*3600/dt.total_seconds())
36 if tuple(map(int, pd.__version__.split('.')[:2])) >= (0, 18):
42 if pandas_version >= (0, 18):
3743 a_avg = a.rolling(win_size, min_periods=1, center=True).mean()
3844 a_std = a.rolling(win_size, min_periods=1, center=True).std()
3945 else: