New upstream version 0.5.7
Ole Streicher
4 years ago
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) | |
2 | 1 | |
3 | 2 | Permission is hereby granted, free of charge, to any person obtaining a copy |
4 | 3 | of this software and associated documentation files (the "Software"), to deal |
0 | 0 | Metadata-Version: 1.1 |
1 | 1 | Name: drms |
2 | Version: 0.5.6 | |
2 | Version: 0.5.7 | |
3 | 3 | Summary: Access HMI, AIA and MDI data with Python |
4 | 4 | Home-page: https://github.com/sunpy/drms |
5 | 5 | Author: Kolja Glogowski |
9 | 9 | drms |
10 | 10 | ==== |
11 | 11 | |
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>`_ | | |
14 | 14 | `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 | |
16 | 19 | |
17 | 20 | The ``drms`` module provides an easy-to-use interface for accessing HMI, |
18 | 21 | AIA and MDI data with Python. It uses the publicly accessible |
19 | 22 | `JSOC <http://jsoc.stanford.edu/>`_ DRMS server by default, but can also |
20 | 23 | 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>`_. | |
23 | 26 | |
24 | 27 | |
25 | 28 | Requirements |
39 | 42 | Installation |
40 | 43 | ------------ |
41 | 44 | |
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 | |
44 | 52 | |
45 | 53 | :: |
46 | 54 | |
47 | 55 | pip install drms |
48 | 56 | |
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`_, | |
59 | 59 | you might need to add ``--user`` to the ``pip`` command:: |
60 | 60 | |
61 | 61 | 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 | |
62 | 133 | |
63 | 134 | |
64 | 135 | Acknowledgements |
67 | 138 | The main author of this project has received funding from the European |
68 | 139 | Research Council under the European Union's Seventh Framework Programme |
69 | 140 | (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. | |
70 | 144 | |
71 | 145 | See AUTHORS.txt for a list of contributors. |
72 | 146 |
1 | 1 | drms |
2 | 2 | ==== |
3 | 3 | |
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>`_ | | |
6 | 6 | `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 | |
8 | 11 | |
9 | 12 | The ``drms`` module provides an easy-to-use interface for accessing HMI, |
10 | 13 | AIA and MDI data with Python. It uses the publicly accessible |
11 | 14 | `JSOC <http://jsoc.stanford.edu/>`_ DRMS server by default, but can also |
12 | 15 | 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>`_. | |
15 | 18 | |
16 | 19 | |
17 | 20 | Requirements |
31 | 34 | Installation |
32 | 35 | ------------ |
33 | 36 | |
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 | |
36 | 44 | |
37 | 45 | :: |
38 | 46 | |
39 | 47 | pip install drms |
40 | 48 | |
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`_, | |
51 | 51 | you might need to add ``--user`` to the ``pip`` command:: |
52 | 52 | |
53 | 53 | 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 | |
54 | 125 | |
55 | 126 | |
56 | 127 | Acknowledgements |
60 | 131 | Research Council under the European Union's Seventh Framework Programme |
61 | 132 | (FP/2007-2013) / ERC Grant Agreement no. 307117. |
62 | 133 | |
134 | Parts of this file were adopted from the SunPy README file, | |
135 | Copyright (c) 2013-2019 The SunPy developers. | |
136 | ||
63 | 137 | See AUTHORS.txt for a list of contributors. |
41 | 41 | Installation |
42 | 42 | ------------ |
43 | 43 | |
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 | |
46 | 51 | |
47 | 52 | :: |
48 | 53 | |
49 | 54 | pip install drms |
50 | 55 | |
51 | To upgrade an already existing installation to the latest release, you | |
52 | can write:: | |
53 | ||
54 | pip install -U drms | |
55 | ||
56 | 56 | |
57 | 57 | .. 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`_, | |
62 | 60 | you might need to add ``--user`` to the ``pip`` command:: |
63 | 61 | |
64 | 62 | 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 | |
65 | 69 | |
66 | 70 | |
67 | 71 | Acknowledgements |
8 | 8 | |
9 | 9 | version_json = ''' |
10 | 10 | { |
11 | "date": "2019-02-17T19:39:21+0100", | |
11 | "date": "2019-08-16T20:00:17+0200", | |
12 | 12 | "dirty": false, |
13 | 13 | "error": null, |
14 | "full-revisionid": "d4ab3b35adba43123dd2b130c05450305f07e5ab", | |
15 | "version": "0.5.6" | |
14 | "full-revisionid": "478957d8c6f61c1ef2d63587eb06566940e09f47", | |
15 | "version": "0.5.7" | |
16 | 16 | } |
17 | 17 | ''' # END VERSION_JSON |
18 | 18 |
0 | 0 | Metadata-Version: 1.1 |
1 | 1 | Name: drms |
2 | Version: 0.5.6 | |
2 | Version: 0.5.7 | |
3 | 3 | Summary: Access HMI, AIA and MDI data with Python |
4 | 4 | Home-page: https://github.com/sunpy/drms |
5 | 5 | Author: Kolja Glogowski |
9 | 9 | drms |
10 | 10 | ==== |
11 | 11 | |
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>`_ | | |
14 | 14 | `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 | |
16 | 19 | |
17 | 20 | The ``drms`` module provides an easy-to-use interface for accessing HMI, |
18 | 21 | AIA and MDI data with Python. It uses the publicly accessible |
19 | 22 | `JSOC <http://jsoc.stanford.edu/>`_ DRMS server by default, but can also |
20 | 23 | 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>`_. | |
23 | 26 | |
24 | 27 | |
25 | 28 | Requirements |
39 | 42 | Installation |
40 | 43 | ------------ |
41 | 44 | |
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 | |
44 | 52 | |
45 | 53 | :: |
46 | 54 | |
47 | 55 | pip install drms |
48 | 56 | |
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`_, | |
59 | 59 | you might need to add ``--user`` to the ``pip`` command:: |
60 | 60 | |
61 | 61 | 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 | |
62 | 133 | |
63 | 134 | |
64 | 135 | Acknowledgements |
67 | 138 | The main author of this project has received funding from the European |
68 | 139 | Research Council under the European Union's Seventh Framework Programme |
69 | 140 | (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. | |
70 | 144 | |
71 | 145 | See AUTHORS.txt for a list of contributors. |
72 | 146 |
48 | 48 | drms/tests/online/test_jsoc_info.py |
49 | 49 | drms/tests/online/test_jsoc_query.py |
50 | 50 | drms/tests/online/test_kis_basic.py |
51 | examples/create_joss_figure.py | |
51 | 52 | examples/example_helpers.py |
52 | 53 | examples/export_as_is.py |
53 | 54 | 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() |
16 | 16 | email = '' |
17 | 17 | print() |
18 | 18 | 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() | |
19 | 28 | |
20 | 29 | |
21 | 30 | def python_path_prepend(reldir): |
13 | 13 | print(__doc__) |
14 | 14 | |
15 | 15 | |
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. | |
20 | 23 | email = '' |
21 | 24 | |
22 | 25 | # Series, harpnum, timespan and segment selection |
38 | 41 | # Check if the email address was set at the top of this script. If not, ask for |
39 | 42 | # a registered email address. |
40 | 43 | if not email: |
41 | email = example_helpers.ask_for_export_email() | |
44 | email = example_helpers.get_export_email() | |
42 | 45 | if not email or not c.check_email(email): |
43 | 46 | raise RuntimeError('Email address is not valid or not registered.') |
44 | 47 |
12 | 12 | print(__doc__) |
13 | 13 | |
14 | 14 | |
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. | |
19 | 22 | email = '' |
20 | 23 | |
21 | 24 | # Use 'as-is' instead of 'fits', if record keywords are not needed in the |
42 | 45 | # Check if the email address was set at the top of this script. If not, ask for |
43 | 46 | # a registered email address. |
44 | 47 | if not email: |
45 | email = example_helpers.ask_for_export_email() | |
48 | email = example_helpers.get_export_email() | |
46 | 49 | if not email or not c.check_email(email): |
47 | 50 | raise RuntimeError('Email address is not valid or not registered.') |
48 | 51 |
13 | 13 | print(__doc__) |
14 | 14 | |
15 | 15 | |
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. | |
20 | 23 | email = '' |
21 | 24 | |
22 | 25 | # Series, timespan, wavelength and segment |
47 | 50 | # Check if the email address was set at the top of this script. If not, ask for |
48 | 51 | # a registered email address. |
49 | 52 | if not email: |
50 | email = example_helpers.ask_for_export_email() | |
53 | email = example_helpers.get_export_email() | |
51 | 54 | if not email or not c.check_email(email): |
52 | 55 | raise RuntimeError('Email address is not valid or not registered.') |
53 | 56 |
13 | 13 | print(__doc__) |
14 | 14 | |
15 | 15 | |
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. | |
20 | 23 | email = '' |
21 | 24 | |
22 | 25 | # Series, timespan and segment |
46 | 49 | # Check if the email address was set at the top of this script. If not, ask for |
47 | 50 | # a registered email address. |
48 | 51 | if not email: |
49 | email = example_helpers.ask_for_export_email() | |
52 | email = example_helpers.get_export_email() | |
50 | 53 | if not email or not c.check_email(email): |
51 | 54 | raise RuntimeError('Email address is not valid or not registered.') |
52 | 55 |
9 | 9 | print(__doc__) |
10 | 10 | |
11 | 11 | |
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. | |
16 | 19 | email = '' |
17 | 20 | |
18 | 21 | # Data export query string |
24 | 27 | # Check if the email address was set at the top of this script. If not, ask for |
25 | 28 | # a registered email address. |
26 | 29 | if not email: |
27 | email = example_helpers.ask_for_export_email() | |
30 | email = example_helpers.get_export_email() | |
28 | 31 | if not email or not c.check_email(email): |
29 | 32 | raise RuntimeError('Email address is not valid or not registered.') |
30 | 33 |
15 | 15 | print(__doc__) |
16 | 16 | |
17 | 17 | |
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. | |
22 | 25 | email = '' |
23 | 26 | |
24 | 27 | # Series, Carrington rotation, Carrington longitude and data segments |
40 | 43 | # Check if the email address was set at the top of this script. If not, ask for |
41 | 44 | # a registered email address. |
42 | 45 | if not email: |
43 | email = example_helpers.ask_for_export_email() | |
46 | email = example_helpers.get_export_email() | |
44 | 47 | if not email or not c.check_email(email): |
45 | 48 | raise RuntimeError('Email address is not valid or not registered.') |
46 | 49 |
1 | 1 | import matplotlib.pyplot as plt |
2 | 2 | import example_helpers |
3 | 3 | 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() | |
4 | 11 | |
5 | 12 | |
6 | 13 | # Series name and timespan |
3 | 3 | import pandas as pd |
4 | 4 | import example_helpers |
5 | 5 | 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() | |
6 | 12 | |
7 | 13 | |
8 | 14 | # Series name, time range and time steps |
33 | 39 | |
34 | 40 | # Compute 30d moving average and standard deviation using a boxcar window |
35 | 41 | 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): | |
37 | 43 | a_avg = a.rolling(win_size, min_periods=1, center=True).mean() |
38 | 44 | a_std = a.rolling(win_size, min_periods=1, center=True).std() |
39 | 45 | else: |