From 5e819425f12673d25fa38bde623a460fc1c4ef21 Mon Sep 17 00:00:00 2001 From: Chunxiao Li Date: Mon, 7 Jun 2021 12:52:48 +0800 Subject: [PATCH] add test for JB2008 --- test.ipynb | 142 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 96 insertions(+), 46 deletions(-) diff --git a/test.ipynb b/test.ipynb index 1441768..f87c727 100644 --- a/test.ipynb +++ b/test.ipynb @@ -6,8 +6,7 @@ "source": [ "# Welcome to ATMOS\n", "\n", - "This package is an archive of scientific routines that implements the estimation of atmospheric properties for various atmosphere models, such\n", - "as exponential, coesa76, and nrimsise00. The package mainly estimates density, temperature, pressure and other parameters of air at a set of specific altitudes. For atmosphere below 86 kilometers, it also calculates the speed of sound, viscosity, and thermal conductivity." + "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). " ] }, { @@ -48,18 +47,15 @@ "output_type": "stream", "text": [ "[1.22500000e+00 7.76098911e-02 3.97200000e-03 3.20600000e-04\n", - " 1.90500000e-05]\n", - "[1.22500000e+00 7.69385063e-02 3.84131212e-03 2.97747719e-04\n", - " 1.59847603e-05]\n" + " 1.90500000e-05]\n" ] } ], "source": [ ">>> from pyatmos import expo\n", - ">>> rhos_geom = expo([0,20,40,60,80]) # geometric altitudes by default\n", - ">>> print(rhos_geom) # [kg/m^3]\n", - ">>> rhos_geop = expo([0,20,40,60,80],'geopotential') # geopotential altitudes\n", - ">>> print(rhos_geop)" + ">>> 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" ] }, { @@ -80,21 +76,19 @@ "text": [ "[1.22499916e+00 8.89079563e-02 3.99535051e-03 3.09628985e-04\n", " 1.84514759e-05]\n", - "[1.22499916e+00 8.80348036e-02 3.85100688e-03 2.88320680e-04\n", - " 1.57005388e-05]\n", - "[5.60184300e-07 1.91512264e-11 5.21285933e-13 3.06944380e-14\n", - " 5.75807856e-15]\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": [ ">>> from pyatmos import coesa76\n", - ">>> rhos_geom,Ts_geom,Ps_geom = coesa76([0,20,40,60,80]) \n", - ">>> print(rhos_geom) # [kg/m^3]\n", - ">>> rhos_geop,Ts_geop,Ps_geop = coesa76([0,20,40,60,80],'geopotential')\n", - ">>> print(rhos_geop) # [kg/m^3]\n", - ">>> rhos_geom,Ts_geom,Ps_geom = coesa76([100,300,500,700,900]) \n", - ">>> print(rhos_geom) # [kg/m^3]" + ">>> 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" ] }, { @@ -125,18 +119,11 @@ } ], "source": [ - ">>> from pyatmos import download_sw,read_sw\n", + ">>> 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() \n", + ">>> swfile = download_sw_nrlmsise00() \n", ">>> # Read the space weather data\n", - ">>> swdata = read_sw(swfile) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Calculate the temperature, density at [25N, 102E, 20km] at 03:00:00 UTC on October 5, 2015 with anomalous oxygen and 3h-geomagnetic index." + ">>> swdata = read_sw_nrlmsise00(swfile) " ] }, { @@ -148,30 +135,80 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'Year': 2015, 'DOY': 278, 'SOD': 10800.0, 'Lat': 25, 'Lon': 102, 'Alt': 600, 'LST': 9.8, 'f107A': 104.4, 'f107D': 82.6, 'ApD': 18, 'Ap3H': array([18. , 22. , 22. , 22. , 7. , 15.25 , 9.375])}\n", - "6.416602651204796e-14\n", - "(853.466244160143, 853.4647165799171)\n", - "{'He': 2388916051039.6826, 'O': 1758109067905.8027, 'N2': 2866987110.5606275, 'O2': 22411077.605527952, 'Ar': 4351.013995142538, 'H': 155026672753.3203, 'N': 46719306249.863495, 'ANM O': 4920851253.780525}\n" + "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 = '2015-10-05 03:00:00' # time(UTC) \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", - ">>> params,rho,T,nd = nrlmsise00(t,(lat,lon,alt),swdata) # aphmode=True\n", - ">>> print(params)\n", - ">>> print(rho) \n", - ">>> print(T) \n", - ">>> print(nd)" + ">>> 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": [ - "**Note: The range of longitude is [0,360] by default, and the west longitude can also be expressed as a negative number.**" + "#### JB2008" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "*Before using JB2008, the space weather data needs to be prepared in advance.*" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The space weather data in /Users/lichunxiao/src/sw-data/ is already the latest.\n" + ] + } + ], + "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": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1.2991711750265394e-14\n", + "754.2803276187265\n" + ] + } + ], + "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]" ] }, { @@ -179,15 +216,20 @@ "metadata": {}, "source": [ "## Change log\n", - "- **1.2.0 — Jan 22, 2021**\n", - " - Added **Exponential Atmosphere** up to 1000km\n", - " - Added **Committee on Extension to the Standard Atmosphere(COESA)** up to 1000km\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", + " - Added the International Standard Atmosphere(ISA) Model up to 86kms \n", "\n", "## Next release\n", "\n", @@ -200,7 +242,6 @@ "- [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", - "\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", @@ -208,8 +249,17 @@ "- [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/stable/api/safe/atmosphere/atmosphere_index.html?highlight=nrlmsise#famous-atmospheric-models)" + "- [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": {