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 2d6c838a authored by Qusai Al Shidi's avatar Qusai Al Shidi 💬
Browse files

Merging my adapt branch

parents 3f9a436e 63fbd1ac
......@@ -10,7 +10,6 @@ TODO: Move pandas dependancy elsewhere.
import datetime as dt
import numpy as np
import pandas as pd
def read_wdc_ae(wdc_filename):
......@@ -71,6 +70,7 @@ def read_omni_csv(filename, filtering=False, **kwargs):
"""
import pandas as pd
# Read the csv files and set the index to dates
colnames = ['Time', 'Bx [nT]', 'By [nT]', 'Bz [nT]',
'Vx [km/s]', 'Vy [km/s]', 'Vz [km/s]',
......@@ -111,15 +111,16 @@ def write_imf_input(data, outfilename="IMF.dat", enable_rb=True, **kwargs):
Args:
data: pandas.DataFrame object with solar wind data
outfilename: The output file name for ballistic solar wind data. \
(default: "IMF.dat")
enable_rb: Enables solar wind input for the radiation belt model. \
(default: True)
outfilename: The output file name for ballistic solar wind data.
(default: "IMF.dat")
enable_rb: Enables solar wind input for the radiation belt model.
(default: True)
Other paramaters:
gse: (default=False)
Use GSE coordinate system for the file instead of GSM default.
"""
# Generate BATS-R-US solar wind input file
with open(outfilename, 'w') as outfile:
outfile.write("CSV files downloaded from ")
......@@ -193,6 +194,9 @@ def read_gm_log(filename, colnames=None, index_by_time=True):
geo["AL"].plot.line()
```
"""
import pandas as pd
# If column names were not specified
if not colnames:
with open(filename, 'r') as logfile:
......
......@@ -131,7 +131,7 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs):
Downloads ADAPT magnetograms from ftp://gong2.nso.edu/adapt/maps/gong/
to a local directory. It will download all maps with the regex file
pattern: adapt4[0,1]3*yyymmddhh
pattern: adapt4[0,1]3*yyyymmddhh
Args:
time (datetime.datetime): Time in which you want the magnetogram.
......@@ -186,9 +186,8 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs):
try:
ftp.cwd(str(time.year))
except ftplib.all_errors:
raise NotADirectoryError('Cannot go to the specific year directory')
finally:
ftp.quit()
raise NotADirectoryError('Cannot go to the specific year directory')
# ADAPT maps only contains the hours for even numbers
if time.hour % 2 != 0:
......@@ -201,7 +200,7 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs):
+ str(time.month).zfill(2) \
+ str(time.day).zfill(2) \
+ str(time.hour//2*2).zfill(2) + '*'
# adapt4[0,1]3*yyymmddhh
# adapt4[0,1]3*yyyymmddhh
filenames = ftp.nlst(file_pattern)
......@@ -219,9 +218,8 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs):
try:
ftp.retrbinary('RETR ' + filename, fhandle.write)
except ftplib.all_errors:
raise FileNotFoundError('Cannot download ', filename)
finally:
ftp.quit()
raise FileNotFoundError('Cannot download ', filename)
# unzip the file
if '.gz' in filename:
......
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