Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit abe09232 authored by Qusai Al Shidi's avatar Qusai Al Shidi 💬
Browse files

Merge branch 'carrington_rotation' into 'master'

Carrington rotation

See merge request !7
parents 8e18ac86 6110364e
...@@ -5,15 +5,24 @@ Changelog: ...@@ -5,15 +5,24 @@ Changelog:
Contributors: Contributors:
------------- -------------
131 Qusai Al Shidi 137 Qusai Al Shidi
2 Camilla D. K. Harris 2 Camilla D. K. Harris
1 Gabor Toth 2 Gabor Toth
1 Camilla Dodge Koslowsky Harris
1 TKeebler 1 TKeebler
Changes: Changes:
-------- --------
- 05ac345 **(2020-06-19, Qusai Al Shidi)**: _C:HEAD -> master, origin/master, origin/HEAD:_ merged amendment :s - 23c6e26 **(2020-08-05, Gabor Toth)**: _C:HEAD -> carrington_rotation:_ Carrington Rotation function added and sunpy dependency removed
- 8e18ac8 **(2020-08-04, Qusai Al Shidi)**: _C:origin/master, origin/HEAD, master:_ Fixed LaTeX citation string
- 8211554 **(2020-08-04, Qusai Al Shidi)**: _C::_ Fixed install swmfpy line
- f1724e7 **(2020-08-04, Qusai Al Shidi)**: _C::_ Added instructions for python venv and also snippets to contributing page.
- d0a8308 **(2020-07-06, Qusai Al Shidi)**: _C:pybatstools:_ Fixed up `CONTRIBUTING.markdown` to be better and added issues guidelines
- 9549026 **(2020-07-06, Qusai Al Shidi)**: _C::_ Should be `shell` and not `bash` for markdown language alias
- 178dd8e **(2020-06-22, Qusai Al Shidi)**: _C::_ Merge branch 'tecplot-doc-update' into 'master'
- facad25 **(2020-06-22, Camilla Dodge Koslowsky Harris)**: _C::_ Tecplot documentation update
- 05ac345 **(2020-06-19, Qusai Al Shidi)**: _C::_ merged amendment :s
- 8d04c39 **(2020-06-19, Qusai Al Shidi)**: _C::_ optional requires `tecplot` - 8d04c39 **(2020-06-19, Qusai Al Shidi)**: _C::_ optional requires `tecplot`
- 3e676fa **(2020-06-19, Qusai Al Shidi)**: _C::_ optional requires `tecplot` - 3e676fa **(2020-06-19, Qusai Al Shidi)**: _C::_ optional requires `tecplot`
- 991a3a2 **(2020-06-19, Qusai Al Shidi)**: _C:tag: v2020.5:_ v2020.5 commit - 991a3a2 **(2020-06-19, Qusai Al Shidi)**: _C:tag: v2020.5:_ v2020.5 commit
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
* [replace\_command](#.swmfpy.paramin.replace_command) * [replace\_command](#.swmfpy.paramin.replace_command)
* [read\_command](#.swmfpy.paramin.read_command) * [read\_command](#.swmfpy.paramin.read_command)
* [swmfpy.tools](#.swmfpy.tools) * [swmfpy.tools](#.swmfpy.tools)
* [carrington\_rotation\_number](#.swmfpy.tools.carrington_rotation_number)
* [swmfpy.tecplottools](#.swmfpy.tecplottools) * [swmfpy.tecplottools](#.swmfpy.tecplottools)
* [apply\_equations](#.swmfpy.tecplottools.apply_equations) * [apply\_equations](#.swmfpy.tecplottools.apply_equations)
...@@ -157,13 +158,6 @@ Downloads HMI vector magnetogram fits files. ...@@ -157,13 +158,6 @@ Downloads HMI vector magnetogram fits files.
This will download vector magnetogram FITS files from This will download vector magnetogram FITS files from
Joint Science Operations Center (JSOC) near a certain hour. Joint Science Operations Center (JSOC) near a certain hour.
This unfortunately depends on sunpy and drms, if you don't have it try,
```bash
pip install -U --user sunpy drms
```
**Arguments**: **Arguments**:
- `mag_time` _datetime.datetime_ - Time after which to find - `mag_time` _datetime.datetime_ - Time after which to find
...@@ -506,6 +500,25 @@ values for the parameters. ...@@ -506,6 +500,25 @@ values for the parameters.
Tools to be used in swmfpy functions and classes. Some of the functions are Tools to be used in swmfpy functions and classes. Some of the functions are
*hidden functions*. *hidden functions*.
<a name=".swmfpy.tools.carrington_rotation_number"></a>
#### carrington\_rotation\_number
```python
carrington_rotation_number(the_time='now')
```
Returns the carrington rotation
**Arguments**:
- `the_time` _datetime.datetime/str_ - The time to convert to carrington
rotation.
**Returns**:
- `(int)` - Carrington Rotation
<a name=".swmfpy.tecplottools"></a> <a name=".swmfpy.tecplottools"></a>
## swmfpy.tecplottools ## swmfpy.tecplottools
......
...@@ -13,7 +13,7 @@ with open('requirements.txt') as fh_requirements: ...@@ -13,7 +13,7 @@ with open('requirements.txt') as fh_requirements:
setuptools.setup( setuptools.setup(
name='swmfpy', name='swmfpy',
version='2020.5', version='2020.6',
author='Qusai Al Shidi', author='Qusai Al Shidi',
author_email='qusai@umich.edu', author_email='qusai@umich.edu',
description='''A collection of tools for the Space Weather Modelling description='''A collection of tools for the Space Weather Modelling
......
...@@ -18,7 +18,7 @@ These are automatically imported. ...@@ -18,7 +18,7 @@ These are automatically imported.
""" """
__author__ = 'Qusai Al Shidi' __author__ = 'Qusai Al Shidi'
__license__ = 'MIT' __license__ = 'MIT'
__version__ = '2020.5' __version__ = '2020.6'
__maintainer__ = 'Qusai Al Shidi' __maintainer__ = 'Qusai Al Shidi'
__email__ = 'qusai@umich.edu' __email__ = 'qusai@umich.edu'
......
...@@ -5,6 +5,25 @@ ...@@ -5,6 +5,25 @@
__author__ = 'Qusai Al Shidi' __author__ = 'Qusai Al Shidi'
__email__ = 'qusai@umich.edu' __email__ = 'qusai@umich.edu'
import datetime as dt
def carrington_rotation_number(the_time='now'):
"""Returns the carrington rotation
Args:
the_time (datetime.datetime/str): The time to convert to carrington
rotation.
Returns:
(int): Carrington Rotation
"""
if the_time == 'now':
return carrington_rotation_number(dt.datetime.now())
if isinstance(the_time, str):
return carrington_rotation_number(dt.datetime.fromisoformat(the_time))
return int((the_time.toordinal() - 676715.2247)/27.2753)
def _import_error_string(library): def _import_error_string(library):
return ( return (
......
...@@ -18,8 +18,7 @@ import urllib ...@@ -18,8 +18,7 @@ import urllib
from dateutil import rrule from dateutil import rrule
import drms import drms
import numpy as np import numpy as np
from sunpy.coordinates.sun import carrington_rotation_number from .tools import _nearest, carrington_rotation_number
from .tools import _nearest
# Global defines # Global defines
# This is straight from the format guide on spdf with nicer names as second col # This is straight from the format guide on spdf with nicer names as second col
...@@ -268,12 +267,6 @@ def download_magnetogram_hmi(mag_time, hmi_map='hmi.B_720s', **kwargs): ...@@ -268,12 +267,6 @@ def download_magnetogram_hmi(mag_time, hmi_map='hmi.B_720s', **kwargs):
This will download vector magnetogram FITS files from This will download vector magnetogram FITS files from
Joint Science Operations Center (JSOC) near a certain hour. Joint Science Operations Center (JSOC) near a certain hour.
This unfortunately depends on sunpy and drms, if you don't have it try,
```bash
pip install -U --user sunpy drms
```
Args: Args:
mag_time (datetime.datetime): Time after which to find mag_time (datetime.datetime): Time after which to find
vector magnetograms. vector magnetograms.
...@@ -363,8 +356,8 @@ def _get_urls_hmi_b_synoptic_small(client, mag_time): ...@@ -363,8 +356,8 @@ def _get_urls_hmi_b_synoptic_small(client, mag_time):
suffix url of magnetogram suffix url of magnetogram
""" """
cr_number = int(round(carrington_rotation_number(mag_time))) cr_number = carrington_rotation_number(mag_time)
query_string = f'hmi.b_synoptic_small[{int(round(cr_number))}]' query_string = f'hmi.b_synoptic_small[{cr_number}]'
components = ['Bp', 'Bt', 'Br'] components = ['Bp', 'Bt', 'Br']
data = client.query(query_string, seg=components) data = client.query(query_string, seg=components)
# Generator to find the nearest time # Generator to find the nearest time
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment