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

Fixed PEP-8 of get_omni_data, fixed CONTRIBUTING

parent 41dc03e9
...@@ -20,7 +20,7 @@ Please write readable code. Make sure your function names well describes your fu ...@@ -20,7 +20,7 @@ Please write readable code. Make sure your function names well describes your fu
Metadata Metadata
-------- --------
Include metadata if you made a new function or module. Name and email will suffice. For example: Include metadata if you made a new function or module. Name and email will suffice. Use the variable names `__author__` and `__email__` for modules and comments for functions that you add to someone else's module. For example:
mynewpackage.py: mynewpackage.py:
...@@ -28,16 +28,18 @@ mynewpackage.py: ...@@ -28,16 +28,18 @@ mynewpackage.py:
"""A new package for swmfpy """A new package for swmfpy
""" """
__all__ = ['funcs', 'to', 'export'] __all__ = ['funcs', 'to', 'export']
__author__ = "Rita Hayworth" __author__ = 'Rita Hayworth'
__email__ = "rita@umich.edu" __email__ = 'rita@umich.edu'
``` ```
Or for a function: Or for a function:
```python ```python
def my_new_func(some_args): def my_new_func(some_args):
# my docstring """my docstring
__author__ = "Diane Selwyn" """
__email__ = "diane@umich.edu" # Author: Diane Selwyn
# Email: diane@umich.edu
# function body # function body
``` ```
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
swmfpy.spdf swmfpy.spdf
=========== ===========
Here are a collection of tools to get date from Here are a collection of tools to get data from
NASA Goddard's Space Physics Data Facility. NASA Goddard's Space Physics Data Facility website.
""" """
__author__ = 'Qusai Al Shidi' __author__ = 'Qusai Al Shidi'
__email__ = 'qusai@umich.edu' __email__ = 'qusai@umich.edu'
...@@ -41,8 +41,11 @@ def get_omni_data(time_from, time_to, **kwargs): ...@@ -41,8 +41,11 @@ def get_omni_data(time_from, time_to, **kwargs):
data = swmfpy.spdf.get_omni_data(from, to) data = swmfpy.spdf.get_omni_data(from, to)
``` ```
""" """
# Author: Qusai Al Shidi
# Email: qusai@umich.edu
# This is straight from the format guide on spdf # This is straight from the format guide on spdf
col_names = ['ID for IMF spacecraft', col_names = ('ID for IMF spacecraft',
'ID for SW Plasma spacecraft', 'ID for SW Plasma spacecraft',
'# of points in IMF averages', '# of points in IMF averages',
'# of points in Plasma averages', '# of points in Plasma averages',
...@@ -74,7 +77,7 @@ def get_omni_data(time_from, time_to, **kwargs): ...@@ -74,7 +77,7 @@ def get_omni_data(time_from, time_to, **kwargs):
'Z(s/c), GSE, Re', 'Z(s/c), GSE, Re',
'BSN location, Xgse, Re', 'BSN location, Xgse, Re',
'BSN location, Ygse, Re', 'BSN location, Ygse, Re',
'BSN location, Zgse, Re'] 'BSN location, Zgse, Re')
# Set the url # Set the url
omni_url = 'https://spdf.gsfc.nasa.gov/pub/data/omni/' omni_url = 'https://spdf.gsfc.nasa.gov/pub/data/omni/'
...@@ -97,11 +100,10 @@ def get_omni_data(time_from, time_to, **kwargs): ...@@ -97,11 +100,10 @@ def get_omni_data(time_from, time_to, **kwargs):
for line in data: for line in data:
cols = line.decode('ascii').split() cols = line.decode('ascii').split()
# Time uses day of year which must be parsed # Time uses day of year which must be parsed
year, doy, hour, minute = cols[0], cols[1], cols[2], cols[3] time = dt.datetime.strptime(cols[0] + ' ' + # year
time = dt.datetime.strptime(year + ' ' + cols[1] + ' ' + # day of year
doy + ' ' + cols[2] + ' ' + # hour
hour + ' ' + cols[3], # minute
minute,
'%Y %j %H %M') '%Y %j %H %M')
if time >= time_from and time <= time_to: if time >= time_from and time <= time_to:
omni_data['Time [UT]'].append(time) omni_data['Time [UT]'].append(time)
...@@ -109,4 +111,4 @@ def get_omni_data(time_from, time_to, **kwargs): ...@@ -109,4 +111,4 @@ def get_omni_data(time_from, time_to, **kwargs):
for num, value in enumerate(cols[4:len(col_names)+4]): for num, value in enumerate(cols[4:len(col_names)+4]):
omni_data[col_names[num]].append(float(value)) omni_data[col_names[num]].append(float(value))
return omni_data return omni_data # dictionary with omni values where index is the row
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