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 23c6e26f authored by Gabor Toth's avatar Gabor Toth
Browse files

Carrington Rotation function added and sunpy dependency removed

parent 8e18ac86
......@@ -13,7 +13,7 @@ with open('requirements.txt') as fh_requirements:
setuptools.setup(
name='swmfpy',
version='2020.5',
version='2020.6',
author='Qusai Al Shidi',
author_email='qusai@umich.edu',
description='''A collection of tools for the Space Weather Modelling
......
......@@ -18,7 +18,7 @@ These are automatically imported.
"""
__author__ = 'Qusai Al Shidi'
__license__ = 'MIT'
__version__ = '2020.5'
__version__ = '2020.6'
__maintainer__ = 'Qusai Al Shidi'
__email__ = 'qusai@umich.edu'
......
......@@ -5,6 +5,16 @@
__author__ = 'Qusai Al Shidi'
__email__ = 'qusai@umich.edu'
import datetime as dt
def carrington_rotation_number(the_time='now'):
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):
return (
......
......@@ -18,8 +18,7 @@ import urllib
from dateutil import rrule
import drms
import numpy as np
from sunpy.coordinates.sun import carrington_rotation_number
from .tools import _nearest
from .tools import _nearest, carrington_rotation_number
# Global defines
# This is straight from the format guide on spdf with nicer names as second col
......@@ -363,8 +362,8 @@ def _get_urls_hmi_b_synoptic_small(client, mag_time):
suffix url of magnetogram
"""
cr_number = int(round(carrington_rotation_number(mag_time)))
query_string = f'hmi.b_synoptic_small[{int(round(cr_number))}]'
cr_number = carrington_rotation_number(mag_time)
query_string = f'hmi.b_synoptic_small[{cr_number}]'
components = ['Bp', 'Bt', 'Br']
data = client.query(query_string, seg=components)
# 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