Update spaceweather.py

solve the issue that download fails for spaceweather file on windows platform.
This commit is contained in:
Chunxiao Li 2020-05-26 20:43:40 +08:00 committed by GitHub
parent 410daa4def
commit bb27aeada6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,8 @@ get_sw - Extract the space weather data
import numpy as np import numpy as np
from datetime import datetime,timedelta from datetime import datetime,timedelta
from os import getenv,path,makedirs,remove from os import path,makedirs,remove
from pathlib import Path
from urllib.request import urlretrieve from urllib.request import urlretrieve
# =================== download and update sw data =================== # # =================== download and update sw data =================== #
@ -48,7 +49,7 @@ def download_sw(direc=None):
''' '''
if direc is None: if direc is None:
home = getenv('HOME') home = str(Path.home())
direc = home + '/src/sw-data/' direc = home + '/src/sw-data/'
swfile = direc + 'SW-All.txt' swfile = direc + 'SW-All.txt'
@ -147,4 +148,4 @@ def get_sw(SW_OBS_PRE,t_ymd,hour):
aph_1233 = np.average(aph_tmp[apc_index+4:apc_index+12]) aph_1233 = np.average(aph_tmp[apc_index+4:apc_index+12])
aph_3657 = np.average(aph_tmp[apc_index+12:apc_index+20]) aph_3657 = np.average(aph_tmp[apc_index+12:apc_index+20])
aph = np.hstack((ap,aph_c369,aph_1233,aph_3657)) aph = np.hstack((ap,aph_c369,aph_1233,aph_3657))
return f107A,f107,ap,aph return f107A,f107,ap,aph