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 27995889 authored by Zhenguang Huang's avatar Zhenguang Huang
Browse files

@qalshidi commiting for @zghuang

parent d0a83080
...@@ -18,6 +18,7 @@ import urllib ...@@ -18,6 +18,7 @@ import urllib
from dateutil import rrule from dateutil import rrule
import drms import drms
import numpy as np import numpy as np
import os
from sunpy.coordinates.sun import carrington_rotation_number from sunpy.coordinates.sun import carrington_rotation_number
from .tools import _nearest from .tools import _nearest
...@@ -480,18 +481,23 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs): ...@@ -480,18 +481,23 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs):
raise FileNotFoundError('Could not find a file that matches' raise FileNotFoundError('Could not find a file that matches'
+ 'the pattern.') + 'the pattern.')
directory = kwargs.get('download_dir', './')
if directory[-1] != '/':
directory += '/'
for filename in filenames: for filename in filenames:
# open the file locally # Only try to download if the file does not exist
directory = kwargs.get('download_dir', './') if os.path.isfile(directory+filename) == False:
if directory[-1] != '/': # open the file locally
directory += '/' with open(directory + filename, 'wb') as fhandle:
with open(directory + filename, 'wb') as fhandle: # try to download the magnetogram
# try to download the magnetogram try:
try: ftp.retrbinary('RETR ' + filename, fhandle.write)
ftp.retrbinary('RETR ' + filename, fhandle.write) except ftplib.all_errors:
except ftplib.all_errors: ftp.quit()
ftp.quit() raise FileNotFoundError('Cannot download ', filename)
raise FileNotFoundError('Cannot download ', filename) else:
print(filename + ' already exists, skipping downloading')
# unzip the file # unzip the file
if '.gz' in filename: 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