diff --git a/.DS_Store b/.DS_Store index bf75453..e92c8e9 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.ipynb_checkpoints/test-checkpoint.ipynb b/.ipynb_checkpoints/test-checkpoint.ipynb new file mode 100644 index 0000000..73587cc --- /dev/null +++ b/.ipynb_checkpoints/test-checkpoint.ipynb @@ -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 +} diff --git a/LICENSE.txt b/LICENSE.txt index ce91ee0..46dc3d0 100755 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ 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 of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 89a2fae..4c9f664 100755 --- a/README.md +++ b/README.md @@ -123,6 +123,10 @@ pip install pyatmos --upgrade # to upgrade a pre-existing installation ``` ## 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** - Added atmospheric models **JB2008** - 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) - [ATMOSPHERE API](https://amentum.com.au/atmosphere) - [COSPAR International Reference Atmosphere - 2012](https://spacewx.com/wp-content/uploads/2021/03/chapters_1_3.pdf) - diff --git a/pyatmos/.DS_Store b/pyatmos/.DS_Store index 13a7ac9..d752f51 100644 Binary files a/pyatmos/.DS_Store and b/pyatmos/.DS_Store differ diff --git a/pyatmos/__pycache__/__init__.cpython-39.pyc b/pyatmos/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..f9e0a01 Binary files /dev/null and b/pyatmos/__pycache__/__init__.cpython-39.pyc differ diff --git a/pyatmos/__pycache__/class_atmos.cpython-39.pyc b/pyatmos/__pycache__/class_atmos.cpython-39.pyc new file mode 100644 index 0000000..0482e42 Binary files /dev/null and b/pyatmos/__pycache__/class_atmos.cpython-39.pyc differ diff --git a/pyatmos/jb2008/__pycache__/JB2008_subfunc.cpython-39.pyc b/pyatmos/jb2008/__pycache__/JB2008_subfunc.cpython-39.pyc new file mode 100644 index 0000000..ee5f840 Binary files /dev/null and b/pyatmos/jb2008/__pycache__/JB2008_subfunc.cpython-39.pyc differ diff --git a/pyatmos/jb2008/__pycache__/__init__.cpython-39.pyc b/pyatmos/jb2008/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..aad8cd0 Binary files /dev/null and b/pyatmos/jb2008/__pycache__/__init__.cpython-39.pyc differ diff --git a/pyatmos/jb2008/__pycache__/jb2008.cpython-39.pyc b/pyatmos/jb2008/__pycache__/jb2008.cpython-39.pyc new file mode 100644 index 0000000..fb6dbd3 Binary files /dev/null and b/pyatmos/jb2008/__pycache__/jb2008.cpython-39.pyc differ diff --git a/pyatmos/jb2008/__pycache__/spaceweather.cpython-39.pyc b/pyatmos/jb2008/__pycache__/spaceweather.cpython-39.pyc new file mode 100644 index 0000000..c4de74e Binary files /dev/null and b/pyatmos/jb2008/__pycache__/spaceweather.cpython-39.pyc differ diff --git a/pyatmos/jb2008/spaceweather.py b/pyatmos/jb2008/spaceweather.py index c2dc49c..0988ba4 100644 --- a/pyatmos/jb2008/spaceweather.py +++ b/pyatmos/jb2008/spaceweather.py @@ -3,7 +3,7 @@ from datetime import datetime,timedelta from os import path,makedirs,remove from pathlib import Path -from ..utils.try_download import tqdm_request +from ..utils.try_download import wget_download from ..utils import Const 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(swfile1): - desc1 = "Downloading the space weather data '{:s}' from Space Environment Technologies(SET)".format('SOLFSMY.TXT') - desc2 = "Downloading the space weather data '{:s}' from Space Environment Technologies(SET)".format('DTCFILE.TXT') - tqdm_request(url1,direc,'SOLFSMY.TXT',desc1) - tqdm_request(url2,direc,'DTCFILE.TXT',desc2) + desc1 = "Downloading the Space Weather file '{:s}' from Space Environment Technologies(SET)".format('SOLFSMY.TXT') + desc2 = "Downloading the Space Weather file '{:s}' from Space Environment Technologies(SET)".format('DTCFILE.TXT') + wget_download(url1,swfile1,desc1) + wget_download(url2,swfile2,desc2) else: modified_time = datetime.fromtimestamp(path.getmtime(swfile1)) if datetime.now() > modified_time + timedelta(days=1): remove(swfile1) remove(swfile2) - 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') - tqdm_request(url1,direc,'SOLFSMY.TXT',desc1) - tqdm_request(url2,direc,'DTCFILE.TXT',desc2) + 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') + wget_download(url1,swfile1,desc1) + wget_download(url2,swfile2,desc2) 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] def read_sw_jb2008(swfile): diff --git a/pyatmos/msise/__pycache__/__init__.cpython-39.pyc b/pyatmos/msise/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..5a5a48d Binary files /dev/null and b/pyatmos/msise/__pycache__/__init__.cpython-39.pyc differ diff --git a/pyatmos/msise/__pycache__/nrlmsise00.cpython-39.pyc b/pyatmos/msise/__pycache__/nrlmsise00.cpython-39.pyc new file mode 100644 index 0000000..24cf122 Binary files /dev/null and b/pyatmos/msise/__pycache__/nrlmsise00.cpython-39.pyc differ diff --git a/pyatmos/msise/__pycache__/nrlmsise00_subfunc.cpython-39.pyc b/pyatmos/msise/__pycache__/nrlmsise00_subfunc.cpython-39.pyc new file mode 100644 index 0000000..7a92e6f Binary files /dev/null and b/pyatmos/msise/__pycache__/nrlmsise00_subfunc.cpython-39.pyc differ diff --git a/pyatmos/msise/__pycache__/spaceweather.cpython-39.pyc b/pyatmos/msise/__pycache__/spaceweather.cpython-39.pyc new file mode 100644 index 0000000..288163f Binary files /dev/null and b/pyatmos/msise/__pycache__/spaceweather.cpython-39.pyc differ diff --git a/pyatmos/msise/nrlmsise00.py b/pyatmos/msise/nrlmsise00.py index 00665ff..55697c0 100644 --- a/pyatmos/msise/nrlmsise00.py +++ b/pyatmos/msise/nrlmsise00.py @@ -51,9 +51,8 @@ def nrlmsise00(t,location,SW_OBS_PRE,aphmode=True): alt = h t = Time(t) - lon_wrap = wraplon(lon) + t_ymd = t.isot.split('T')[0] t_yday = t.yday.split(':') - t_ymd = t.iso.split()[0].split('-') 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])) lst = hour + wraplon(lon)/15 @@ -62,6 +61,7 @@ def nrlmsise00(t,location,SW_OBS_PRE,aphmode=True): else: 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,\ 'f107A':f107A,'f107':f107,'ap':ap,'ap_a':aph} diff --git a/pyatmos/msise/spaceweather.py b/pyatmos/msise/spaceweather.py index ac9d20e..034dcf2 100644 --- a/pyatmos/msise/spaceweather.py +++ b/pyatmos/msise/spaceweather.py @@ -1,9 +1,10 @@ import numpy as np from datetime import datetime,timedelta +import pandas as pd from os import path,makedirs,remove from pathlib import Path -from ..utils.try_download import tqdm_request +from ..utils.try_download import wget_download def download_sw_nrlmsise00(direc=None): ''' @@ -27,29 +28,29 @@ def download_sw_nrlmsise00(direc=None): home = str(Path.home()) direc = home + '/src/sw-data/' - swfile = direc + 'SW-All.txt' - url = 'https://www.celestrak.com/SpaceData/SW-All.txt' + swfile = direc + 'SW-All.csv' + url = 'https://www.celestrak.com/SpaceData/SW-All.csv' if not path.exists(direc): makedirs(direc) if not path.exists(swfile): - desc = "Downloading the space weather data '{:s}' from CELESTRAK".format('SW-All.txt') - tqdm_request(url,direc,'SW-All.txt',desc) + desc = "Downloading the Space Weather file '{:s}' from CELESTRAK".format('SW-All.csv') + wget_download(url,swfile,desc) else: 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) - desc = "Updating the space weather data '{:s}' from CELESTRAK".format('SW-All.txt') - tqdm_request(url,direc,'SW-All.txt',desc) + desc = "Updating the Space Weather file '{:s}' from CELESTRAK".format('SW-All.csv') + wget_download(url,swfile,desc) 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 - + def read_sw_nrlmsise00(swfile): ''' Parse and read the space weather data Usage: - sw_obs_pre = read_sw(swfile) + sw_obs_pre = read_sw_nrlmsise00(swfile) Inputs: 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 Examples: - >>> swfile = 'sw-data/SW-All.txt' + >>> swfile = 'sw-data/SW-All.csv' >>> sw_obs_pre = read_sw(swfile) >>> print(sw_obs_pre) [['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' '01' ... '269.3' '266.6' '230.9']] ''' - sw_data = open(swfile,'r').readlines() - SW_OBS,SW_PRE = [],[] - flag1 = flag2 = 0 - for line in sw_data: - if line.startswith('BEGIN OBSERVED'): - flag1 = 1 - 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'): - 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='>> f107A,f107,ap,aph = get_sw(SW_OBS_PRE,t_ymd,hour) ''' - ymds = SW_OBS_PRE[:,0] - j_, = np.where(''.join(t_ymd) == ymds) + ymds = sw_df['DATE'] + j_, = np.where(sw_df['DATE'] == t_ymd) 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]) - aph_tmp_b0 = SW_OBS_PRE[j,12: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_df.iloc[j]['AP1':'AP8'] i = int(np.floor_divide(hour,3)) ap_c = aph_tmp_b0[i] - aph_tmp_b1 = SW_OBS_PRE[j+1,12:20] - aph_tmp_b2 = SW_OBS_PRE[j+2,12:20] - aph_tmp_b3 = SW_OBS_PRE[j+3,12:20] - aph_tmp = np.hstack((aph_tmp_b3,aph_tmp_b2,aph_tmp_b1,aph_tmp_b0))[::-1].astype(np.float) + aph_tmp_b1 = sw_df.iloc[j+1]['AP1':'AP8'] + aph_tmp_b2 = sw_df.iloc[j+2]['AP1':'AP8'] + 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] apc_index = 7-i aph_c369 = aph_tmp[apc_index:apc_index+4] 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 = np.hstack((ap,aph_c369,aph_1233,aph_3657)) - return f107A,f107,ap,aph + return f107A,f107,ap,aph \ No newline at end of file diff --git a/pyatmos/standardatmos/__pycache__/__init__.cpython-39.pyc b/pyatmos/standardatmos/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..c6f1f0c Binary files /dev/null and b/pyatmos/standardatmos/__pycache__/__init__.cpython-39.pyc differ diff --git a/pyatmos/standardatmos/__pycache__/coesa76.cpython-39.pyc b/pyatmos/standardatmos/__pycache__/coesa76.cpython-39.pyc new file mode 100644 index 0000000..630b5e5 Binary files /dev/null and b/pyatmos/standardatmos/__pycache__/coesa76.cpython-39.pyc differ diff --git a/pyatmos/standardatmos/__pycache__/expo.cpython-39.pyc b/pyatmos/standardatmos/__pycache__/expo.cpython-39.pyc new file mode 100644 index 0000000..43a04ee Binary files /dev/null and b/pyatmos/standardatmos/__pycache__/expo.cpython-39.pyc differ diff --git a/pyatmos/standardatmos/__pycache__/ussa76.cpython-39.pyc b/pyatmos/standardatmos/__pycache__/ussa76.cpython-39.pyc new file mode 100644 index 0000000..486f597 Binary files /dev/null and b/pyatmos/standardatmos/__pycache__/ussa76.cpython-39.pyc differ diff --git a/pyatmos/utils/__pycache__/Const.cpython-39.pyc b/pyatmos/utils/__pycache__/Const.cpython-39.pyc new file mode 100644 index 0000000..c5abe3d Binary files /dev/null and b/pyatmos/utils/__pycache__/Const.cpython-39.pyc differ diff --git a/pyatmos/utils/__pycache__/__init__.cpython-39.pyc b/pyatmos/utils/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..b2c45f6 Binary files /dev/null and b/pyatmos/utils/__pycache__/__init__.cpython-39.pyc differ diff --git a/pyatmos/utils/__pycache__/try_download.cpython-39.pyc b/pyatmos/utils/__pycache__/try_download.cpython-39.pyc new file mode 100644 index 0000000..8b0b7d3 Binary files /dev/null and b/pyatmos/utils/__pycache__/try_download.cpython-39.pyc differ diff --git a/pyatmos/utils/__pycache__/utils.cpython-39.pyc b/pyatmos/utils/__pycache__/utils.cpython-39.pyc new file mode 100644 index 0000000..b9f2272 Binary files /dev/null and b/pyatmos/utils/__pycache__/utils.cpython-39.pyc differ diff --git a/pyatmos/utils/try_download.py b/pyatmos/utils/try_download.py index fd1bba1..7e3e51e 100644 --- a/pyatmos/utils/try_download.py +++ b/pyatmos/utils/try_download.py @@ -1,33 +1,21 @@ -import requests -from tqdm import tqdm -from colorama import Fore -from time import sleep -from os import remove +import wget -def tqdm_request(url,dir_to,file,desc): - ''' - Try to download files from a remote server by request with a colored progress bar. - ''' - block_size = 1024*10 - bar_format = "{l_bar}%s{bar}%s{r_bar}" % (Fore.BLUE, Fore.RESET) - for idownload in range(5): - try: - local_file = open(dir_to + file, 'ab') - pos = local_file.tell() - res = requests.get(url,stream=True,timeout=100,headers={'Accept-Encoding': None,'Range': f'bytes={pos}-'}) - 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): - pbar.update(len(chunk)) - local_file.write(chunk) - pbar.close() - res.close() - break - except: - sleep(2) - if idownload == 4: - remove(dir_to + file) - print('No response, skip this file.') - finally: - local_file.close() +def wget_download(url,dir_file,desc=None): + """ + Download files by wget command + + Inputs: + url -> [str] + dir_file -> [str] output filename or directory + Parameters: + desc -> [str] description of the downloading + Outpits: + wget_out -> [str] path and filename where URL is downloaded to + + """ + if desc: print(desc) + wget_out = wget.download(url,dir_file) + print() + + return wget_out diff --git a/setup.py b/setup.py index f28820e..513e4b7 100755 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup,find_packages setup( 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', author = 'Chunxiao Li', author_email = 'lcx366@126.com', @@ -27,9 +27,9 @@ setup( 'scipy', 'numpy', 'numba', + 'pandas', 'astropy', 'pyshtools', - 'tqdm', - 'colorama' + 'wget' ] ) diff --git a/test.ipynb b/test.ipynb index f87c727..73587cc 100644 --- a/test.ipynb +++ b/test.ipynb @@ -39,18 +39,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1.22500000e+00 7.76098911e-02 3.97200000e-03 3.20600000e-04\n", - " 1.90500000e-05]\n" - ] - } - ], + "outputs": [], "source": [ ">>> from pyatmos import expo\n", ">>> expo_geom = expo([0,20,40,60,80]) # geometric altitudes by default\n", @@ -67,21 +58,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "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" - ] - } - ], + "outputs": [], "source": [ ">>> from pyatmos import coesa76\n", ">>> coesa76_geom = coesa76([0,20,40,60,80]) # geometric altitudes by default\n", @@ -107,14 +86,14 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "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", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -168,17 +147,9 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The space weather data in /Users/lichunxiao/src/sw-data/ is already the latest.\n" - ] - } - ], + "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", @@ -189,18 +160,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1.2991711750265394e-14\n", - "754.2803276187265\n" - ] - } - ], + "outputs": [], "source": [ ">>> from pyatmos import jb2008\n", ">>> # Set a specific time and location\n", @@ -264,9 +226,9 @@ ], "metadata": { "kernelspec": { - "display_name": "py3.9", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "py3.9" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -278,7 +240,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.1" + "version": "3.9.16" } }, "nbformat": 4,