change the space weather file from 'SW-ALL.txt' to 'SW-ALL.csv'

This commit is contained in:
Chunxiao Li 2023-02-16 15:26:34 +08:00
parent e079601ea4
commit 1cfd030342
29 changed files with 331 additions and 152 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -0,0 +1,248 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Welcome to ATMOS\n",
"\n",
"This package is an archive of scientific routines that estimates the vertical structure of atmosphere with various *atmospheric density models*, such as **Exponential**(-0.611\\~1000 km), **COESA76**(-0.611\\~1000 km), **NRLMSISE-00**(0\\~2000 km), and **JB2008**(90\\~2500 km). "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to install\n",
"\n",
"On Linux, macOS and Windows architectures, the binary wheels can be installed using pip by executing one of the following commands:\n",
"\n",
"```python\n",
"pip install pyatmos\n",
"pip install pyatmos --upgrade # to upgrade a pre-existing installation\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to use"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Exponential"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> from pyatmos import expo\n",
">>> expo_geom = expo([0,20,40,60,80]) # geometric altitudes by default\n",
">>> print(expo_geom.rho) # [kg/m^3]\n",
">>> # expo_geop = expo([0,20,40,60,80],'geopotential') # geopotential altitudes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### COESA 1976"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> from pyatmos import coesa76\n",
">>> coesa76_geom = coesa76([0,20,40,60,80]) # geometric altitudes by default\n",
">>> print(coesa76_geom.rho) # [kg/m^3]\n",
">>> print(coesa76_geom.T) # [K]\n",
">>> print(coesa76_geom.P) # [Pa]\n",
">>> # coesa76_geop = coesa76([0,20,40,60,80],'geopotential') # geopotential altitudes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### NRLMSISE-00"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Before using NRLMSISE-00, the space weather data needs to be prepared in advance.*"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The Space Weather file 'SW-All.csv' in /Users/lichunxiao/src/sw-data/ is already the latest.\n"
]
}
],
"source": [
">>> from pyatmos import download_sw_nrlmsise00,read_sw_nrlmsise00\n",
">>> # Download or update the space weather file from www.celestrak.com\n",
">>> swfile = download_sw_nrlmsise00() \n",
">>> # Read the space weather data\n",
">>> swdata = read_sw_nrlmsise00(swfile) "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.714115212984513e-14\n",
"765.8976564552341\n",
"{'He': 645851224907.2849, 'O': 456706971423.5056, 'N2': 531545420.00015724, 'O2': 2681352.1654067687, 'Ar': 406.9308900607773, 'H': 157249711103.90558, 'N': 6759664327.87355, 'ANM O': 10526544596.059282}\n"
]
}
],
"source": [
">>> from pyatmos import nrlmsise00\n",
">>> # Set a specific time and location\n",
">>> t = '2014-07-22 22:18:45' # time(UTC) \n",
">>> lat,lon,alt = 25,102,600 # latitude, longitude in [degree], and altitude in [km]\n",
">>> nrl00 = nrlmsise00(t,(lat,lon,alt),swdata)\n",
">>> print(nrl00.rho) # [kg/m^3]\n",
">>> print(nrl00.T) # [K]\n",
">>> print(nrl00.nd) # composition in [1/m^3]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### JB2008"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Before using JB2008, the space weather data needs to be prepared in advance.*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> from pyatmos import download_sw_jb2008,read_sw_jb2008\n",
">>> # Download or update the space weather file from https://sol.spacenvironment.net\n",
">>> swfile = download_sw_jb2008() \n",
">>> # Read the space weather data\n",
">>> swdata = read_sw_jb2008(swfile) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
">>> from pyatmos import jb2008\n",
">>> # Set a specific time and location\n",
">>> t = '2014-07-22 22:18:45' # time(UTC) \n",
">>> lat,lon,alt = 25,102,600 # latitude, longitude in [degree], and altitude in [km]\n",
">>> jb08 = jb2008(t,(lat,lon,alt),swdata)\n",
">>> print(jb08.rho) # [kg/m^3]\n",
">>> print(jb08.T) # [K]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Change log\n",
"\n",
"- **1.2.3 — Jun 7, 2021**\n",
" - Added atmospheric models **JB2008**\n",
" - Changed the output of the result to an instance\n",
" - Improved the code structure for NRLMSISE-00, and the running speed is nearly threefold\n",
"- **1.2.1 — Jan 22, 2021**\n",
" - Added **Exponential Atmosphere** up to 1000 km\n",
" - Added **Committee on Extension to the Standard Atmosphere(COESA)** up to 1000 km\n",
" - Completed part of the help documentation for NRLMSISE-00\n",
" - Improved the code structure to make it easier to read\n",
"- **1.1.2 — Jul 26, 2020**\n",
" - Added colored-progress bar for downloading data\n",
"- **1.1.0 — Mar 29, 2020**\n",
" - Added the International Standard Atmosphere(ISA) Model up to 86kms \n",
"\n",
"## Next release\n",
"\n",
"- Complete the help documentation for NRLMSISE-00\n",
"- Add other atmospheric models, such as the **Earth Global Reference Atmospheric Model(Earth-GRAM) 2016**, and the **Jacchia-Bowman 2008 Empirical Thermospheric Density Model(JB2008)**\n",
"\n",
"## Reference\n",
"\n",
"- U.S. Standard Atmosphere, 1976, U.S. Government Printing Office, Washington, D.C. \n",
"- [Public Domain Aeronautical Software](http://www.pdas.com/atmos.html) \n",
"- https://gist.github.com/buzzerrookie/5b6438c603eabf13d07e\n",
"- https://ww2.mathworks.cn/help/aerotbx/ug/atmosisa.html\n",
"- [Original Fortran and C code](https://ccmc.gsfc.nasa.gov/pub/modelweb/atmospheric/msis/)\n",
"- [MSISE-00 in Python and Matlab](https://github.com/space-physics/msise00)\n",
"- [NRLMSISE-00 Atmosphere Model - Matlab](https://ww2.mathworks.cn/matlabcentral/fileexchange/56253-nrlmsise-00-atmosphere-model?requestedDomain=zh)\n",
"- [NRLMSISE-00 Atmosphere Model - Aerospace Blockset](https://www.mathworks.com/help/aeroblks/nrlmsise00atmospheremodel.html?requestedDomain=)\n",
"- [NRLMSISE-00 Atmosphere Model - CCMC](https://ccmc.gsfc.nasa.gov/modelweb/models/nrlmsise00.php)\n",
"- [NRLMSISE-00 empirical model of the atmosphere: Statistical comparisons and scientific issues](http://onlinelibrary.wiley.com/doi/10.1029/2002JA009430/pdf)\n",
"- [ATMOSPHERIC MODELS](http://www.braeunig.us/space/atmmodel.htm)\n",
"- [poliastro-Atmosphere module](https://docs.poliastro.space/en/latest/autoapi/poliastro/earth/atmosphere/index.html?highlight=poliastro.earth.atmosphere)\n",
"- [ATMOSPHERE API](https://amentum.com.au/atmosphere)\n",
"- [COSPAR International Reference Atmosphere - 2012](https://spacewx.com/wp-content/uploads/2021/03/chapters_1_3.pdf)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2019-2021 Chunxiao Li Copyright (c) 2019-2023 Chunxiao Li
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -123,6 +123,10 @@ pip install pyatmos --upgrade # to upgrade a pre-existing installation
``` ```
## Change log ## Change log
- **1.2.4 — Feb 16, 2023**
- Changed functions `read_sw_nrlmsise00` and `get_sw` due to the space weather file changed from 'SW-ALL.txt' to 'SW-ALL.csv'
- Deleted the colored-progress bar for downloading space weather file, and use `wget` instead.
- **1.2.3 — Jun 7, 2021** - **1.2.3 — Jun 7, 2021**
- Added atmospheric models **JB2008** - Added atmospheric models **JB2008**
- Changed the output of the result to an instance - Changed the output of the result to an instance
@ -158,4 +162,3 @@ pip install pyatmos --upgrade # to upgrade a pre-existing installation
- [poliastro-Atmosphere module](https://docs.poliastro.space/en/latest/autoapi/poliastro/earth/atmosphere/index.html?highlight=poliastro.earth.atmosphere) - [poliastro-Atmosphere module](https://docs.poliastro.space/en/latest/autoapi/poliastro/earth/atmosphere/index.html?highlight=poliastro.earth.atmosphere)
- [ATMOSPHERE API](https://amentum.com.au/atmosphere) - [ATMOSPHERE API](https://amentum.com.au/atmosphere)
- [COSPAR International Reference Atmosphere - 2012](https://spacewx.com/wp-content/uploads/2021/03/chapters_1_3.pdf) - [COSPAR International Reference Atmosphere - 2012](https://spacewx.com/wp-content/uploads/2021/03/chapters_1_3.pdf)

BIN
pyatmos/.DS_Store vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -3,7 +3,7 @@ from datetime import datetime,timedelta
from os import path,makedirs,remove from os import path,makedirs,remove
from pathlib import Path from pathlib import Path
from ..utils.try_download import tqdm_request from ..utils.try_download import wget_download
from ..utils import Const from ..utils import Const
def download_sw_jb2008(direc=None): def download_sw_jb2008(direc=None):
@ -37,21 +37,21 @@ def download_sw_jb2008(direc=None):
if not path.exists(direc): makedirs(direc) if not path.exists(direc): makedirs(direc)
if not path.exists(swfile1): if not path.exists(swfile1):
desc1 = "Downloading the space weather data '{:s}' from Space Environment Technologies(SET)".format('SOLFSMY.TXT') desc1 = "Downloading the Space Weather file '{:s}' from Space Environment Technologies(SET)".format('SOLFSMY.TXT')
desc2 = "Downloading the space weather data '{:s}' from Space Environment Technologies(SET)".format('DTCFILE.TXT') desc2 = "Downloading the Space Weather file '{:s}' from Space Environment Technologies(SET)".format('DTCFILE.TXT')
tqdm_request(url1,direc,'SOLFSMY.TXT',desc1) wget_download(url1,swfile1,desc1)
tqdm_request(url2,direc,'DTCFILE.TXT',desc2) wget_download(url2,swfile2,desc2)
else: else:
modified_time = datetime.fromtimestamp(path.getmtime(swfile1)) modified_time = datetime.fromtimestamp(path.getmtime(swfile1))
if datetime.now() > modified_time + timedelta(days=1): if datetime.now() > modified_time + timedelta(days=1):
remove(swfile1) remove(swfile1)
remove(swfile2) remove(swfile2)
desc1 = "Updating the space weather data '{:s}' from Space Environment Technologies(SET)".format('SOLFSMY.TXT') desc1 = "Updating the Space weather data '{:s}' from Space Environment Technologies(SET)".format('SOLFSMY.TXT')
desc2 = "Updating the space weather data '{:s}' from Space Environment Technologies(SET)".format('DTCFILE.TXT') desc2 = "Updating the Space weather data '{:s}' from Space Environment Technologies(SET)".format('DTCFILE.TXT')
tqdm_request(url1,direc,'SOLFSMY.TXT',desc1) wget_download(url1,swfile1,desc1)
tqdm_request(url2,direc,'DTCFILE.TXT',desc2) wget_download(url2,swfile2,desc2)
else: else:
print("The space weather data '{0:s}' and '{1:s}' in {2:s} is already the latest.".format('SOLFSMY.TXT','DTCFILE.TXT',direc)) print("The Space Weather files '{:s}' and '{:s}' in {:s} are already the latest.".format('SOLFSMY.TXT','DTCFILE.TXT',direc))
return [swfile1,swfile2] return [swfile1,swfile2]
def read_sw_jb2008(swfile): def read_sw_jb2008(swfile):

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -51,9 +51,8 @@ def nrlmsise00(t,location,SW_OBS_PRE,aphmode=True):
alt = h alt = h
t = Time(t) t = Time(t)
lon_wrap = wraplon(lon) t_ymd = t.isot.split('T')[0]
t_yday = t.yday.split(':') t_yday = t.yday.split(':')
t_ymd = t.iso.split()[0].split('-')
year,doy = int(t_yday[0]),int(t_yday[1]) year,doy = int(t_yday[0]),int(t_yday[1])
hour,sec = hms_conver(int(t_yday[2]),int(t_yday[3]),float(t_yday[4])) hour,sec = hms_conver(int(t_yday[2]),int(t_yday[3]),float(t_yday[4]))
lst = hour + wraplon(lon)/15 lst = hour + wraplon(lon)/15
@ -62,6 +61,7 @@ def nrlmsise00(t,location,SW_OBS_PRE,aphmode=True):
else: else:
f107A,f107,ap,aph = 150,150,4,np.full(7,4) f107A,f107,ap,aph = 150,150,4,np.full(7,4)
lon_wrap = wraplon(lon)
inputp = {'doy':doy,'year':year,'sec':sec,'alt':alt,'g_lat':lat,'g_lon':lon_wrap,'lst':lst,\ inputp = {'doy':doy,'year':year,'sec':sec,'alt':alt,'g_lat':lat,'g_lon':lon_wrap,'lst':lst,\
'f107A':f107A,'f107':f107,'ap':ap,'ap_a':aph} 'f107A':f107A,'f107':f107,'ap':ap,'ap_a':aph}

View File

@ -1,9 +1,10 @@
import numpy as np import numpy as np
from datetime import datetime,timedelta from datetime import datetime,timedelta
import pandas as pd
from os import path,makedirs,remove from os import path,makedirs,remove
from pathlib import Path from pathlib import Path
from ..utils.try_download import tqdm_request from ..utils.try_download import wget_download
def download_sw_nrlmsise00(direc=None): def download_sw_nrlmsise00(direc=None):
''' '''
@ -27,21 +28,21 @@ def download_sw_nrlmsise00(direc=None):
home = str(Path.home()) home = str(Path.home())
direc = home + '/src/sw-data/' direc = home + '/src/sw-data/'
swfile = direc + 'SW-All.txt' swfile = direc + 'SW-All.csv'
url = 'https://www.celestrak.com/SpaceData/SW-All.txt' url = 'https://www.celestrak.com/SpaceData/SW-All.csv'
if not path.exists(direc): makedirs(direc) if not path.exists(direc): makedirs(direc)
if not path.exists(swfile): if not path.exists(swfile):
desc = "Downloading the space weather data '{:s}' from CELESTRAK".format('SW-All.txt') desc = "Downloading the Space Weather file '{:s}' from CELESTRAK".format('SW-All.csv')
tqdm_request(url,direc,'SW-All.txt',desc) wget_download(url,swfile,desc)
else: else:
modified_time = datetime.fromtimestamp(path.getmtime(swfile)) modified_time = datetime.fromtimestamp(path.getmtime(swfile))
if datetime.now() > modified_time + timedelta(days=1): if datetime.now() > modified_time + timedelta(days=7):
remove(swfile) remove(swfile)
desc = "Updating the space weather data '{:s}' from CELESTRAK".format('SW-All.txt') desc = "Updating the Space Weather file '{:s}' from CELESTRAK".format('SW-All.csv')
tqdm_request(url,direc,'SW-All.txt',desc) wget_download(url,swfile,desc)
else: else:
print("The space weather data '{0:s}' in {1:s} is already the latest.".format('SW-All.txt',direc)) print("The Space Weather file '{:s}' in {:s} is already the latest.".format('SW-All.csv',direc))
return swfile return swfile
def read_sw_nrlmsise00(swfile): def read_sw_nrlmsise00(swfile):
@ -49,7 +50,7 @@ def read_sw_nrlmsise00(swfile):
Parse and read the space weather data Parse and read the space weather data
Usage: Usage:
sw_obs_pre = read_sw(swfile) sw_obs_pre = read_sw_nrlmsise00(swfile)
Inputs: Inputs:
swfile -> [str] Path of the space weather data swfile -> [str] Path of the space weather data
@ -58,7 +59,7 @@ def read_sw_nrlmsise00(swfile):
sw_obs_pre -> [2d str array] Content of the space weather data sw_obs_pre -> [2d str array] Content of the space weather data
Examples: Examples:
>>> swfile = 'sw-data/SW-All.txt' >>> swfile = 'sw-data/SW-All.csv'
>>> sw_obs_pre = read_sw(swfile) >>> sw_obs_pre = read_sw(swfile)
>>> print(sw_obs_pre) >>> print(sw_obs_pre)
[['2020' '01' '07' ... '72.4' '68.0' '71.0'] [['2020' '01' '07' ... '72.4' '68.0' '71.0']
@ -68,37 +69,14 @@ def read_sw_nrlmsise00(swfile):
['1957' '10' '02' ... '253.3' '267.4' '231.7'] ['1957' '10' '02' ... '253.3' '267.4' '231.7']
['1957' '10' '01' ... '269.3' '266.6' '230.9']] ['1957' '10' '01' ... '269.3' '266.6' '230.9']]
''' '''
sw_data = open(swfile,'r').readlines() sw_df = pd.read_csv(swfile)
SW_OBS,SW_PRE = [],[] sw_df.dropna(subset=['C9'],inplace=True)
flag1 = flag2 = 0 # Sort from newest date to past
for line in sw_data: sw_df.sort_values(by=['DATE'],ascending=False,inplace=True)
if line.startswith('BEGIN OBSERVED'): sw_df.reset_index(drop=True,inplace=True)
flag1 = 1 return sw_df
continue
if line.startswith('END OBSERVED'): flag1 = 0
if flag1 == 1:
sw_p = line.split()
if len(sw_p) == 30:
del sw_p[24]
elif len(sw_p) == 31:
sw_p = np.delete(sw_p,[23,25])
else:
sw_p = np.delete(sw_p,[23,24,25,27])
SW_OBS.append(sw_p)
if line.startswith('BEGIN DAILY_PREDICTED'): def get_sw(sw_df,t_ymd,hour):
flag2 = 1
continue
if line.startswith('END DAILY_PREDICTED'): break
if flag2 == 1: SW_PRE.append(line.split())
SW_OBS_PRE = np.vstack((np.array(SW_OBS),np.array(SW_PRE)))
# inverse sort
SW_OBS_PRE = np.flip(SW_OBS_PRE,0).astype(dtype='<U8')
ymds = np.apply_along_axis(''.join, 1, SW_OBS_PRE[:,:3])
SW_OBS_PRE = np.insert(SW_OBS_PRE[:,3:],0,ymds,axis=1)
return SW_OBS_PRE
def get_sw(SW_OBS_PRE,t_ymd,hour):
''' '''
Extract the necessary parameters describing the solar activity and geomagnetic activity from the space weather data. Extract the necessary parameters describing the solar activity and geomagnetic activity from the space weather data.
@ -120,17 +98,17 @@ def get_sw(SW_OBS_PRE,t_ymd,hour):
>>> f107A,f107,ap,aph = get_sw(SW_OBS_PRE,t_ymd,hour) >>> f107A,f107,ap,aph = get_sw(SW_OBS_PRE,t_ymd,hour)
''' '''
ymds = SW_OBS_PRE[:,0] ymds = sw_df['DATE']
j_, = np.where(''.join(t_ymd) == ymds) j_, = np.where(sw_df['DATE'] == t_ymd)
j = j_[0] j = j_[0]
f107A,f107,ap = float(SW_OBS_PRE[j,25]),float(SW_OBS_PRE[j+1,24]),int(SW_OBS_PRE[j,20]) f107A,f107,ap = sw_df.iloc[j]['F10.7_OBS_CENTER81'],sw_df.iloc[j+1]['F10.7_OBS'],sw_df.iloc[j]['AP_AVG']
aph_tmp_b0 = SW_OBS_PRE[j,12:20] aph_tmp_b0 = sw_df.iloc[j]['AP1':'AP8']
i = int(np.floor_divide(hour,3)) i = int(np.floor_divide(hour,3))
ap_c = aph_tmp_b0[i] ap_c = aph_tmp_b0[i]
aph_tmp_b1 = SW_OBS_PRE[j+1,12:20] aph_tmp_b1 = sw_df.iloc[j+1]['AP1':'AP8']
aph_tmp_b2 = SW_OBS_PRE[j+2,12:20] aph_tmp_b2 = sw_df.iloc[j+2]['AP1':'AP8']
aph_tmp_b3 = SW_OBS_PRE[j+3,12:20] aph_tmp_b3 = sw_df.iloc[j+3]['AP1':'AP8']
aph_tmp = np.hstack((aph_tmp_b3,aph_tmp_b2,aph_tmp_b1,aph_tmp_b0))[::-1].astype(np.float) aph_tmp = np.hstack((aph_tmp_b3,aph_tmp_b2,aph_tmp_b1,aph_tmp_b0))[::-1]
apc_index = 7-i apc_index = 7-i
aph_c369 = aph_tmp[apc_index:apc_index+4] aph_c369 = aph_tmp[apc_index:apc_index+4]
aph_1233 = np.average(aph_tmp[apc_index+4:apc_index+12]) aph_1233 = np.average(aph_tmp[apc_index+4:apc_index+12])

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,33 +1,21 @@
import requests import wget
from tqdm import tqdm
from colorama import Fore
from time import sleep
from os import remove
def tqdm_request(url,dir_to,file,desc): def wget_download(url,dir_file,desc=None):
''' """
Try to download files from a remote server by request with a colored progress bar. Download files by wget command
'''
block_size = 1024*10 Inputs:
bar_format = "{l_bar}%s{bar}%s{r_bar}" % (Fore.BLUE, Fore.RESET) url -> [str]
for idownload in range(5): dir_file -> [str] output filename or directory
try: Parameters:
local_file = open(dir_to + file, 'ab') desc -> [str] description of the downloading
pos = local_file.tell() Outpits:
res = requests.get(url,stream=True,timeout=100,headers={'Accept-Encoding': None,'Range': f'bytes={pos}-'}) wget_out -> [str] path and filename where URL is downloaded to
total_size = int(res.headers.get('content-length'))
pbar = tqdm(desc = desc,total=total_size,unit='B',unit_scale=True,bar_format = bar_format,position=0,initial=pos) """
for chunk in res.iter_content(block_size): if desc: print(desc)
pbar.update(len(chunk)) wget_out = wget.download(url,dir_file)
local_file.write(chunk) print()
pbar.close()
res.close() return wget_out
break
except:
sleep(2)
if idownload == 4:
remove(dir_to + file)
print('No response, skip this file.')
finally:
local_file.close()

View File

@ -2,7 +2,7 @@ from setuptools import setup,find_packages
setup( setup(
name = 'pyatmos', name = 'pyatmos',
version = '1.2.3', version = '1.2.4',
description = 'A package to estimate the vertical structure of atmosphere with various atmospheric density models', description = 'A package to estimate the vertical structure of atmosphere with various atmospheric density models',
author = 'Chunxiao Li', author = 'Chunxiao Li',
author_email = 'lcx366@126.com', author_email = 'lcx366@126.com',
@ -27,9 +27,9 @@ setup(
'scipy', 'scipy',
'numpy', 'numpy',
'numba', 'numba',
'pandas',
'astropy', 'astropy',
'pyshtools', 'pyshtools',
'tqdm', 'wget'
'colorama'
] ]
) )

View File

@ -39,18 +39,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1.22500000e+00 7.76098911e-02 3.97200000e-03 3.20600000e-04\n",
" 1.90500000e-05]\n"
]
}
],
"source": [ "source": [
">>> from pyatmos import expo\n", ">>> from pyatmos import expo\n",
">>> expo_geom = expo([0,20,40,60,80]) # geometric altitudes by default\n", ">>> expo_geom = expo([0,20,40,60,80]) # geometric altitudes by default\n",
@ -67,21 +58,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1.22499916e+00 8.89079563e-02 3.99535051e-03 3.09628985e-04\n",
" 1.84514759e-05]\n",
"[288.15 216.65 250.35120115 247.01740767 198.63418825]\n",
"[1.01325000e+05 5.52919008e+03 2.87122194e+02 2.19548951e+01\n",
" 1.05207648e+00]\n"
]
}
],
"source": [ "source": [
">>> from pyatmos import coesa76\n", ">>> from pyatmos import coesa76\n",
">>> coesa76_geom = coesa76([0,20,40,60,80]) # geometric altitudes by default\n", ">>> coesa76_geom = coesa76([0,20,40,60,80]) # geometric altitudes by default\n",
@ -107,14 +86,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 1,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"The space weather data in /Users/lichunxiao/src/sw-data/ is already the latest.\n" "The Space Weather file 'SW-All.csv' in /Users/lichunxiao/src/sw-data/ is already the latest.\n"
] ]
} }
], ],
@ -128,7 +107,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -168,17 +147,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"The space weather data in /Users/lichunxiao/src/sw-data/ is already the latest.\n"
]
}
],
"source": [ "source": [
">>> from pyatmos import download_sw_jb2008,read_sw_jb2008\n", ">>> from pyatmos import download_sw_jb2008,read_sw_jb2008\n",
">>> # Download or update the space weather file from https://sol.spacenvironment.net\n", ">>> # Download or update the space weather file from https://sol.spacenvironment.net\n",
@ -189,18 +160,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.2991711750265394e-14\n",
"754.2803276187265\n"
]
}
],
"source": [ "source": [
">>> from pyatmos import jb2008\n", ">>> from pyatmos import jb2008\n",
">>> # Set a specific time and location\n", ">>> # Set a specific time and location\n",
@ -264,9 +226,9 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "py3.9", "display_name": "Python 3 (ipykernel)",
"language": "python", "language": "python",
"name": "py3.9" "name": "python3"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": {
@ -278,7 +240,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.9.1" "version": "3.9.16"
} }
}, },
"nbformat": 4, "nbformat": 4,