minor bug fixes
This commit is contained in:
parent
ae64508a1e
commit
a1a723020b
@ -114,6 +114,8 @@ Calculate the temperatures, densities including anomalous oxygen using the NRLMS
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Change log
|
## Change log
|
||||||
|
- **1.1.2 — Jul 26, 2020**
|
||||||
|
- Added progress bar for downloading data
|
||||||
- **1.1.0 — Mar 29, 2020**
|
- **1.1.0 — Mar 29, 2020**
|
||||||
- Added the International Standard Atmosphere(ISA) Model up to 86km
|
- Added the International Standard Atmosphere(ISA) Model up to 86km
|
||||||
|
|
||||||
|
|||||||
BIN
pyatmos/.DS_Store
vendored
BIN
pyatmos/.DS_Store
vendored
Binary file not shown.
@ -3,11 +3,9 @@ pyatmos StandardAtmosphere subpackage
|
|||||||
|
|
||||||
This subpackage defines the following functions:
|
This subpackage defines the following functions:
|
||||||
|
|
||||||
# =================== Standard Atmosphere Model================= #
|
# StandardAtmosphere.py
|
||||||
|
|
||||||
isa - Implements the International Standard Atmosphere(ISA) Model up to 86km.
|
isa - Implements the International Standard Atmosphere(ISA) Model up to 86km.
|
||||||
|
|
||||||
# ===================== utility functions ==================== #
|
|
||||||
|
|
||||||
lapse_tp - Calculate the temperature and pressure at a given geopotential altitude above base of a specific layer.
|
lapse_tp - Calculate the temperature and pressure at a given geopotential altitude above base of a specific layer.
|
||||||
'''
|
'''
|
||||||
@ -3,25 +3,15 @@ pyatmos msise subpackage
|
|||||||
|
|
||||||
This subpackage defines the following functions:
|
This subpackage defines the following functions:
|
||||||
|
|
||||||
# ==================== nrlmisise-00 model =================== #
|
# nrlmsise00.py - Implements the NRLMSISE 00 model
|
||||||
|
|
||||||
nrlmsise00 - Implements the NRLMSISE 00 model
|
# spaceweather.py
|
||||||
|
|
||||||
# =================== spaceweather functions ================= #
|
|
||||||
|
|
||||||
download_sw - Download or update the space weather file from www.celestrak.com
|
download_sw - Download or update the space weather file from www.celestrak.com
|
||||||
|
|
||||||
read_sw - Read the space weather file
|
read_sw - Read the space weather file
|
||||||
|
|
||||||
get_sw - Extract the space weather data
|
get_sw - Extract the space weather data
|
||||||
|
|
||||||
# ===================== utility functions ==================== #
|
|
||||||
|
|
||||||
wraplon - Wrap a longitude in range of [0,360] to [-180,180]
|
|
||||||
|
|
||||||
hms2s - Convert hour/minute/second to seconds
|
|
||||||
|
|
||||||
hms2h - Convert hour/minute/second to hours
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
from .spaceweather import download_sw,read_sw
|
from .spaceweather import download_sw,read_sw
|
||||||
@ -55,7 +55,7 @@ from pyshtools.legendre import PLegendreA,PlmIndex
|
|||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from .spaceweather import get_sw
|
from .spaceweather import get_sw
|
||||||
from .utils import wraplon,hms2s,hms2h
|
from ..utils.utils import wraplon,hms2s,hms2h
|
||||||
|
|
||||||
# ======================== read data block ========================== #
|
# ======================== read data block ========================== #
|
||||||
|
|
||||||
|
|||||||
@ -1,26 +1,9 @@
|
|||||||
# -------------------------------------------------------------------- #
|
|
||||||
# ------------------------ space weather --------------------------- #
|
|
||||||
# -------------------------------------------------------------------- #
|
|
||||||
|
|
||||||
'''
|
|
||||||
pyatmos spaceweather
|
|
||||||
|
|
||||||
This submodule defines the following functions:
|
|
||||||
|
|
||||||
download_sw - Download or update the space weather file from www.celestrak.com
|
|
||||||
|
|
||||||
read_sw - Read the space weather file
|
|
||||||
|
|
||||||
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 path,makedirs,remove
|
from os import path,makedirs,remove
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.request import urlretrieve
|
|
||||||
|
|
||||||
# =================== download and update sw data =================== #
|
from ..utils.try_download import tqdm_request
|
||||||
|
|
||||||
def download_sw(direc=None):
|
def download_sw(direc=None):
|
||||||
'''
|
'''
|
||||||
@ -69,8 +52,6 @@ def download_sw(direc=None):
|
|||||||
print('The space weather data in {:s} is already the latest.'.format(direc))
|
print('The space weather data in {:s} is already the latest.'.format(direc))
|
||||||
return swfile
|
return swfile
|
||||||
|
|
||||||
# =========================== read sw file ========================== #
|
|
||||||
|
|
||||||
def read_sw(swfile):
|
def read_sw(swfile):
|
||||||
'''
|
'''
|
||||||
Parse and read the space weather file
|
Parse and read the space weather file
|
||||||
@ -124,9 +105,10 @@ def read_sw(swfile):
|
|||||||
SW_OBS_PRE = np.flip(SW_OBS_PRE,0)
|
SW_OBS_PRE = np.flip(SW_OBS_PRE,0)
|
||||||
return SW_OBS_PRE
|
return SW_OBS_PRE
|
||||||
|
|
||||||
# ========================== extract sw data ========================== #
|
|
||||||
|
|
||||||
def get_sw(SW_OBS_PRE,t_ymd,hour):
|
def get_sw(SW_OBS_PRE,t_ymd,hour):
|
||||||
|
'''
|
||||||
|
Extract space weather data
|
||||||
|
'''
|
||||||
j = 0
|
j = 0
|
||||||
for ymd in SW_OBS_PRE[:,:3]:
|
for ymd in SW_OBS_PRE[:,:3]:
|
||||||
if np.array_equal(t_ymd,ymd): break
|
if np.array_equal(t_ymd,ymd): break
|
||||||
|
|||||||
16
pyatmos/utils/__init__.py
Normal file
16
pyatmos/utils/__init__.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
'''
|
||||||
|
pyatmos utils subpackage
|
||||||
|
|
||||||
|
This subpackage defines the following functions:
|
||||||
|
|
||||||
|
# try_download.py
|
||||||
|
|
||||||
|
wraplon - Wrap a longitude in range of [0,360] to [-180,180]
|
||||||
|
|
||||||
|
hms2s - Convert hour/minute/second to seconds
|
||||||
|
|
||||||
|
hms2h - Convert hour/minute/second to hours
|
||||||
|
|
||||||
|
tqdm_request - Try to download files from a remote server by request.
|
||||||
|
|
||||||
|
'''
|
||||||
@ -1,40 +1,11 @@
|
|||||||
import requests
|
import requests
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
# ------------------------------------------------------------------- #
|
|
||||||
# ----------------------------- utilities --------------------------- #
|
|
||||||
# ------------------------------------------------------------------- #
|
|
||||||
|
|
||||||
'''
|
|
||||||
pyatmos utils
|
|
||||||
|
|
||||||
This submodule defines the following functions:
|
|
||||||
|
|
||||||
wraplon - Wrap a longitude in range of [0,360] to [-180,180]
|
|
||||||
|
|
||||||
hms2s - Convert hour/minute/second to seconds
|
|
||||||
|
|
||||||
hms2h - Convert hour/minute/second to hours
|
|
||||||
'''
|
|
||||||
|
|
||||||
# ========================= convert position ======================== #
|
|
||||||
|
|
||||||
def wraplon(lon):
|
|
||||||
if lon > 180:
|
|
||||||
lonwrap = lon - 360
|
|
||||||
else:
|
|
||||||
lonwrap = lon
|
|
||||||
return lonwrap
|
|
||||||
|
|
||||||
# =========================== convert time ========================== #
|
|
||||||
|
|
||||||
def hms2s(h,m,s):
|
|
||||||
return h*3.6E3 + m*60 + s
|
|
||||||
|
|
||||||
def hms2h(h,m,s):
|
|
||||||
return h + m/60 + s/3.6E3
|
|
||||||
|
|
||||||
def tqdm_request(url,dir_to,file,desc):
|
def tqdm_request(url,dir_to,file,desc):
|
||||||
|
'''
|
||||||
|
Try to download files from a remote server by request.
|
||||||
|
'''
|
||||||
block_size = 1024
|
block_size = 1024
|
||||||
bar_format = "{l_bar}%s{bar}%s{r_bar}" % (Fore.BLUE, Fore.RESET)
|
bar_format = "{l_bar}%s{bar}%s{r_bar}" % (Fore.BLUE, Fore.RESET)
|
||||||
for idownload in range(5):
|
for idownload in range(5):
|
||||||
@ -57,4 +28,5 @@ def tqdm_request(url,dir_to,file,desc):
|
|||||||
finally:
|
finally:
|
||||||
pbar.close()
|
pbar.close()
|
||||||
local_file.close()
|
local_file.close()
|
||||||
|
res.close()
|
||||||
|
|
||||||
21
pyatmos/utils/utils.py
Normal file
21
pyatmos/utils/utils.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
def wraplon(lon):
|
||||||
|
'''
|
||||||
|
Wrap a longitude in range of [0,360] to [-180,180]
|
||||||
|
'''
|
||||||
|
if lon > 180:
|
||||||
|
lonwrap = lon - 360
|
||||||
|
else:
|
||||||
|
lonwrap = lon
|
||||||
|
return lonwrap
|
||||||
|
|
||||||
|
def hms2s(h,m,s):
|
||||||
|
'''
|
||||||
|
Convert hour/minute/second to seconds
|
||||||
|
'''
|
||||||
|
return h*3.6E3 + m*60 + s
|
||||||
|
|
||||||
|
def hms2h(h,m,s):
|
||||||
|
'''
|
||||||
|
Convert hour/minute/second to hours
|
||||||
|
'''
|
||||||
|
return h + m/60 + s/3.6E3
|
||||||
2
setup.py
2
setup.py
@ -3,7 +3,7 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='pyatmos',
|
name='pyatmos',
|
||||||
version='1.1.1',
|
version='1.1.2',
|
||||||
long_description_content_type='text/markdown',
|
long_description_content_type='text/markdown',
|
||||||
description='A package to estimate the atmosphere parameters',
|
description='A package to estimate the atmosphere parameters',
|
||||||
long_description=open('README.md', 'rb').read().decode('utf-8'),
|
long_description=open('README.md', 'rb').read().decode('utf-8'),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user