├── .gitignore ├── Index.ipynb ├── LICENSE ├── README.md ├── Supplement A - MWR retrieval.ipynb ├── Supplement B - DSD retrieval.ipynb ├── data ├── huntsville_parameters.nc └── radiosonde_climatology_nsa_2002-2020.nc ├── environment.yml ├── environment_linux.yml ├── environment_macosx.yml └── lib ├── nonScatMWRadTran.py ├── prepare_radiosondes.ipynb └── supporting_routines.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | parts/ 18 | sdist/ 19 | var/ 20 | wheels/ 21 | *.egg-info/ 22 | .installed.cfg 23 | *.egg 24 | MANIFEST 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *.cover 45 | .hypothesis/ 46 | .pytest_cache/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | db.sqlite3 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # Environments 83 | .env 84 | .venv 85 | env/ 86 | venv/ 87 | ENV/ 88 | env.bak/ 89 | venv.bak/ 90 | 91 | # Spyder project settings 92 | .spyderproject 93 | .spyproject 94 | 95 | # Rope project settings 96 | .ropeproject 97 | 98 | # mkdocs documentation 99 | /site 100 | 101 | # mypy 102 | .mypy_cache/ 103 | 104 | # Mac OS specific 105 | .DS_Store 106 | 107 | # large netcdf file 108 | data/radiosonde_climatology_nsa.nc 109 | 110 | #images 111 | *.pdf 112 | *.png -------------------------------------------------------------------------------- /Index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Retrievals and Their Uncertainties: What Every Atmospheric Scientist and Meteorologist Should Know\n", 8 | "# Supplements" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "Maximilian Maahn, David D. Turner, Ulrich Löhnert, Derek J. Posselt, Kerstin Ebell, Gerald G. Mace, and Jennifer M. Comstock\n", 16 | "\n", 17 | "Corresponding author: Maximilian Maahn (maximilian.maahn@uni-leipzig.de)" 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "The supplement consists of two Jupyter Notebooks:\n", 25 | "\n", 26 | "* [Supplement A: Microwave Radiometer Temperature and Humidity Retrieval ](Supplement%20A%20-%20MWR%20retrieval.ipynb)\n", 27 | "* [Supplement B: Cloud Radar Drop Size Distribution Retrieval ](Supplement%20B%20-%20DSD%20retrieval.ipynb)\n", 28 | "\n", 29 | "The script required to extract the radiosonde data is available here\n", 30 | "* [Prepare Radiosondes](lib/prepare_radiosondes.ipynb)\n", 31 | "\n", 32 | "\n", 33 | "We strongly recommend to experiment with the examples to get deeper insight into the retrievals. \n", 34 | "\n", 35 | "**Note that changes are not saved automatically but a modified Notebook can be downloaded via File > Download as > Notebook**" 36 | ] 37 | }, 38 | { 39 | "cell_type": "markdown", 40 | "metadata": {}, 41 | "source": [ 42 | "## What is a Jupyter Notebook?\n", 43 | "\n", 44 | "Jupyter Notebooks are documents that contain live code, equations, visualizations and narrative text. Usually they are executed in a browser. Click on the following cells and press *shift+enter* to execute them." 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": 4, 50 | "metadata": {}, 51 | "outputs": [ 52 | { 53 | "name": "stdout", 54 | "output_type": "stream", 55 | "text": [ 56 | "Hello World!\n" 57 | ] 58 | } 59 | ], 60 | "source": [ 61 | "print('Hello World!')" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 6, 67 | "metadata": {}, 68 | "outputs": [ 69 | { 70 | "data": { 71 | "text/plain": [ 72 | "43" 73 | ] 74 | }, 75 | "execution_count": 6, 76 | "metadata": {}, 77 | "output_type": "execute_result" 78 | } 79 | ], 80 | "source": [ 81 | "10 + 33" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 5, 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "data": { 91 | "text/plain": [ 92 | "[]" 93 | ] 94 | }, 95 | "execution_count": 5, 96 | "metadata": {}, 97 | "output_type": "execute_result" 98 | }, 99 | { 100 | "data": { 101 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3WlwHHd63/HfM4PBfd/AzPAmQRIkzoZWK2q1pLSSKFISTwy8ie2Ka1Nbip2UXXES56g4lfKrlCuJy3HZysa7tXHZWWNAkJRIUdeK1HK1OojGRRK875nBDRD3OZh/XvQMRUE4GsDM9DHPp4q1lNDC/HcEPuru6f42CSHAGGPMXCxaL4Axxlj48XBnjDET4uHOGGMmxMOdMcZMiIc7Y4yZEA93xhgzIR7ujDFmQjzcGWPMhHi4M8aYCcVp9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WpZW7xcR2aAM0H8QQpxcYBNN3q/l1qX1z5cQYgjApwD2z/uSpj9fi61Lo/drD4A3iegBlFO3LxLR38/bJqLvl56HexOArUS0kYjiAfwWlIdxP02Lh3Mvuy4iKiQiCv7+GSjv80CE16WGLh9mrsX7FXy9nwK4LoT4H4tsFvX3S826NHq/8ogoM/j7JAA/AHBj3mZavF/LrkuL90sI8R+EEA4hxAYoM+K8EOK3520W0fdr2WeoakUI4SeifwngQyhXqPxMCNFBRG8Fv67Jw7lVrus4gH9BRH4AkwB+SwQ/Ho8k0unDzFWsS4v3aw+A3wFwJXi+FgD+I4B1T61Li/dLzbq0eL+KAPxfIrJCGY5uIcRZrf88qlyXJn8eFxLN94vvUGWMMRPS82kZxhhjq8TDnTHGTIiHO2OMmRAPd8YYMyEe7owxZkI83BljzIR4uDPGmAnxcGeMMRP6/znRomHzDVTWAAAAAElFTkSuQmCC\n", 102 | "text/plain": [ 103 | "
" 104 | ] 105 | }, 106 | "metadata": { 107 | "needs_background": "light" 108 | }, 109 | "output_type": "display_data" 110 | } 111 | ], 112 | "source": [ 113 | "import matplotlib.pyplot as plt\n", 114 | "%matplotlib inline\n", 115 | "plt.plot([1,2,1,2,1])" 116 | ] 117 | }, 118 | { 119 | "cell_type": "markdown", 120 | "metadata": {}, 121 | "source": [ 122 | "If you have never used Jupyter notebooks before, we recommend to check out the official tutorial: https://mybinder.org/v2/gh/ipython/ipython-in-depth/master?filepath=binder/Index.ipynb\n", 123 | "\n", 124 | "\n" 125 | ] 126 | } 127 | ], 128 | "metadata": { 129 | "language_info": { 130 | "codemirror_mode": { 131 | "name": "ipython", 132 | "version": 3 133 | }, 134 | "file_extension": ".py", 135 | "mimetype": "text/x-python", 136 | "name": "python", 137 | "nbconvert_exporter": "python", 138 | "pygments_lexer": "ipython3", 139 | "version": "3.7.6" 140 | }, 141 | "toc": { 142 | "base_numbering": 1, 143 | "nav_menu": {}, 144 | "number_sections": true, 145 | "sideBar": true, 146 | "skip_h1_title": false, 147 | "title_cell": "Table of Contents", 148 | "title_sidebar": "Contents", 149 | "toc_cell": false, 150 | "toc_position": {}, 151 | "toc_section_display": true, 152 | "toc_window_display": false 153 | } 154 | }, 155 | "nbformat": 4, 156 | "nbformat_minor": 2 157 | } 158 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/maahn/pyOptimalEstimation_examples/master?filepath=Index.ipynb) 2 | 3 | # Optimal Estimation Retrievals and Their Uncertainties: What Every Atmospheric Scientist Should Know 4 | # Supplemental material 5 | 6 | Maahn, M., D. D. Turner, U. Löhnert, D. J. Posselt, K. Ebell, G. G. Mace, and J. M. Comstock, 2020: Optimal Estimation Retrievals and Their Uncertainties: What Every Atmospheric Scientist Should Know. Bull. Amer. Meteor. Soc., doi:https://doi.org/10.1175/BAMS-D-19-0027.1 7 | 8 | This repository contains examples illustrating the use of the [pyOptimalEstimation library](https://github.com/maahn/pyOptimalEstimation). Two Juptyter Notebooks are provided: 9 | 10 | * [Supplement A: Microwave Radiometer Temperature and Humidity Retrieval ](Supplement%20A%20-%20MWR%20retrieval.ipynb) 11 | * [Supplement B: Cloud Radar Drop Size Distribution Retrieval ](Supplement%20B%20-%20DSD%20retrieval.ipynb) 12 | 13 | If you are new to Jupyter Notebooks, pelase check out the [official tutorial](https://mybinder.org/v2/gh/ipython/ipython-in-depth/master?filepath=binder/Index.ipynb). 14 | 15 | 16 | ## How to try the examples online 17 | [You can try the examples online in your browser without any local installation on binder by following this link](https://mybinder.org/v2/gh/maahn/pyOptimalEstimation_examples/master?filepath=Index.ipynb). Note that it takes a minute or two to launch the server, that sometimes you have to try it twice, and that the server shuts down when you do not use it for a couple of minutes. Changes are not saved but a modified Notebook can be downloaded via File > Download as > Notebook 18 | 19 | ## How to try the examples locally 20 | Unless you have pyOptimalEstimation already installed, it is recommended to 21 | 22 | 1. Install [Anaconda](https://www.anaconda.com/distribution/#download-section). Version 3.6 or higher is recommended. 23 | 2. Download or clone this repository, e.g. with the green `Code` button. 24 | 3. Open a terminal and navigate to the folder of this repository 25 | 4. Install the [conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) `pyoe_examples` (so it won't mess with your default Python installation) with 26 | 1. on Linux: `conda env create -f environment_linux.yml` 27 | 2. on Mac OS X: `conda env create -f environment_macosx.yml` 28 | 5. Activate the environemnt with `conda activate pyoe_examples` 29 | 6. In the terminal, start the Jupyter server with `jupyter notebook` 30 | 7. Your browser should open automatically and you can open one of the provided ipynb files. 31 | 8. Make sure to change the kernel to `pyoe_examples` with Kernel > Set_Kernel 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /data/huntsville_parameters.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maahn/pyOptimalEstimation_examples/497b1891d6fe0c804e4233ac39bfd668c7211912/data/huntsville_parameters.nc -------------------------------------------------------------------------------- /data/radiosonde_climatology_nsa_2002-2020.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maahn/pyOptimalEstimation_examples/497b1891d6fe0c804e4233ac39bfd668c7211912/data/radiosonde_climatology_nsa_2002-2020.nc -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | #Mybinder is picky, so it get's it's own environment file 2 | channels: 3 | - conda-forge 4 | - default 5 | dependencies: 6 | - python=3.10 7 | - numpy=1.26.4 8 | - nb_conda=2.2.1 9 | - matplotlib=3.9.2 10 | - scipy=1.11.4 11 | - pandas=2.2.3 12 | - xarray=2024.10.0 13 | - uncertainties=3.2.2 14 | - seaborn=0.13.2 15 | - pip=24.3.1 16 | - cython=3.0.11 17 | - dask=2024.11.2 18 | - netcdf4=1.7.2 19 | - numba=0.60.0 20 | - setuptools=59.8.0 21 | - pip: 22 | # - pyOptimalEstimation 23 | # - git+git://github.com/maahn/pamtra2.git@7d4cb2feb42342b5bdf088b08fbf9ccacfce08aa 24 | - git+https://github.com/maahn/pamtra2.git@python_only 25 | - pyOptimalEstimation 26 | -------------------------------------------------------------------------------- /environment_linux.yml: -------------------------------------------------------------------------------- 1 | name: pyoe_examples 2 | channels: 3 | - conda-forge 4 | # - default 5 | dependencies: 6 | - python=3.10 7 | - numpy=1.26.4 8 | - nb_conda=2.2.1 9 | - matplotlib=3.9.2 10 | - scipy=1.11.4 11 | - pandas=2.2.3 12 | - xarray=2024.10.0 13 | - uncertainties=3.2.2 14 | - seaborn=0.13.2 15 | - pip=24.3.1 16 | - cython=3.0.11 17 | - dask=2024.11.2 18 | - netcdf4=1.7.2 19 | - numba=0.60.0 20 | - setuptools=59.8.0 21 | - libgcc 22 | - libgfortran 23 | - fftw 24 | - lapack 25 | - pip: 26 | # - pyOptimalEstimation 27 | # - git+git://github.com/maahn/pamtra2.git@7d4cb2feb42342b5bdf088b08fbf9ccacfce08aa 28 | - git+https://github.com/maahn/pamtra2.git 29 | - git+https://github.com/maahn/pyOptimalEstimation.git 30 | -------------------------------------------------------------------------------- /environment_macosx.yml: -------------------------------------------------------------------------------- 1 | name: pyoe_examples 2 | channels: 3 | - conda-forge 4 | # - default 5 | dependencies: 6 | - python=3.10 7 | - numpy=1.26.4 8 | - nb_conda=2.2.1 9 | - matplotlib=3.9.2 10 | - scipy=1.11.4 11 | - pandas=2.2.3 12 | - xarray=2024.10.0 13 | - uncertainties=3.2.2 14 | - seaborn=0.13.2 15 | - pip=24.3.1 16 | - cython=3.0.11 17 | - dask=2024.11.2 18 | - netcdf4=1.7.2 19 | - numba=0.60.0 20 | - setuptools=59.8.0 21 | - libgcc 22 | - libgfortran 23 | - fftw 24 | - lapack 25 | - pip: 26 | # - pyOptimalEstimation 27 | # - git+git://github.com/maahn/pamtra2.git@7d4cb2feb42342b5bdf088b08fbf9ccacfce08aa 28 | - git+https://github.com/maahn/pamtra2.git 29 | - git+https://github.com/maahn/pyOptimalEstimation.git 30 | -------------------------------------------------------------------------------- /lib/nonScatMWRadTran.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | import numpy as np 3 | import numba 4 | 5 | 6 | ''' 7 | Simple microwave radiative transfer code. 8 | Translated from IDL to Python 3 by M. Maahn 9 | ''' 10 | 11 | 12 | def STP_IM10( 13 | # [m] states grid of T_final [K], p_final [Pa], q_final [kgm^-3] 14 | z_final, 15 | T_final, 16 | p_final, 17 | q_final, 18 | theta, # zenith angle of observation in deg. 19 | f, # frequency vector in GHz 20 | # re-calculate opt. depth for every angle =0: no! (=1: yes is default), 21 | # tau_calc=True, 22 | # can save some time when calc. Jacobians 23 | ): 24 | ''' 25 | non-scattering microwave radiative transfer using Rosenkranz 1998 gas 26 | absorption 27 | 28 | Author: Ulrich Loehnert (loehnert@meteo.uni-koeln.de) 29 | 30 | ''' 31 | 32 | z_final = np.asarray(z_final) 33 | T_final = np.asarray(T_final) 34 | p_final = np.asarray(p_final) 35 | q_final = np.asarray(q_final) 36 | f = np.asarray(f) 37 | 38 | theta = np.deg2rad(theta) 39 | mu = np.cos(theta) + 0.025 * np.exp(-11. * np.cos(theta)) 40 | 41 | # ****radiative transfer 42 | 43 | # ULI: Where is tau, tau_wv, tau_o2 coming from if tau_calc=False? are 44 | # these global variables? 45 | # if tau_calc: 46 | tau, tau_wv, tau_o2 = TAU_CALC_IM10(z_final, T_final, p_final, q_final, 47 | f) 48 | 49 | TB = TB_CALC_PL_IM10(T_final, tau, mu, f) 50 | 51 | return ( 52 | TB, # [K] brightness temperature array of f grid 53 | tau, # total optical depth 54 | tau_wv, # WV optical depth 55 | tau_o2, 56 | ) 57 | 58 | 59 | @numba.jit(cache=True, nopython=True) 60 | def TAU_CALC_IM10( 61 | z, # height [m] 62 | T, # Temp. [K] 63 | p, # press. [Pa] 64 | rhow, # abs. hum. [kg m^-3] 65 | f, # freq. [GHz] 66 | ): 67 | ''' 68 | $Id: tau_calc_r98.pro,v 1.1 2009/11/11 14:38:52 loehnert Exp $ 69 | Abstract: 70 | subroutine to determine optical thichkness tau 71 | at height k (index counting from bottom of zgrid) 72 | on the basis of Rosenkranz 1998 water vapor and absorption model 73 | Rayleigh calculations 74 | 75 | Author: Ulrich Loehnert 76 | Changes: 77 | 2009-10-09: 78 | ''' 79 | 80 | kmax = len(z) 81 | n_f = len(f) 82 | 83 | abs_all = np.zeros((kmax-1, n_f)) 84 | abs_wv = np.zeros((kmax-1, n_f)) 85 | abs_o2 = np.zeros((kmax-1, n_f)) 86 | 87 | tau = np.zeros((kmax-1, n_f)) 88 | tau_wv = np.zeros((kmax-1, n_f)) 89 | tau_o2 = np.zeros((kmax-1, n_f)) 90 | 91 | for ii in range(kmax-1): 92 | # FOR ii = 0, kmax-2 DO BEGIN 93 | # alles SI!! 94 | deltaz = z[kmax-1-ii]-z[kmax-1-ii-1] 95 | T_mean = (T[kmax-1-ii] + T[kmax-1-ii-1])/2. 96 | deltap = p[kmax-1-ii]-p[kmax-1-ii-1] 97 | 98 | if deltap >= 0: 99 | p[kmax-1-ii] = p[kmax-1-ii] - 0.1 100 | if deltap >= 1: 101 | print( 102 | 'Warning: p profile adjusted by %f5.2 to assure monotonic' 103 | 'decrease!', deltap) 104 | 105 | xp = -np.log(p[kmax-1-ii]/p[kmax-1-ii-1])/deltaz 106 | p_mean = -p[kmax-1-ii-1]/xp*(np.exp(-xp*deltaz)-1.0)/deltaz 107 | rhow_mean = (rhow[kmax-1-ii] + rhow[kmax-1-ii-1])/2. 108 | 109 | # ****gas absorption 110 | # water vapor 111 | AWV = ABWVR98_IM10(rhow_mean*1000., T_mean, p_mean/100, f) 112 | AWV = AWV/1000. 113 | 114 | # oxygen 115 | AO2 = ABO2R98_IM10(T_mean, p_mean/100., rhow_mean*1000., f) 116 | AO2 = AO2/1000. 117 | 118 | # nitrogen (nur bei Rosenkranz O2) 119 | AN2 = ABSN2_IM10(T_mean, p_mean/100, f) 120 | AN2 = AN2/1000. 121 | 122 | absg = AWV + AO2 + AN2 123 | 124 | abs_all[kmax-2-ii, :] = absg 125 | abs_wv[kmax-2-ii, :] = AWV 126 | abs_o2[kmax-2-ii, :] = AO2 127 | 128 | tau_x = np.zeros(n_f) 129 | tau_x1 = np.zeros(n_f) 130 | tau_x2 = np.zeros(n_f) 131 | 132 | for jj in range(ii+1): 133 | 134 | deltaz = z[kmax-1-jj]-z[kmax-2-jj] 135 | tau_x = (abs_all[kmax-2-jj, :])*deltaz + tau_x 136 | tau_x1 = (abs_wv[kmax-2-jj, :])*deltaz + tau_x1 137 | tau_x2 = (abs_o2[kmax-2-jj, :])*deltaz + tau_x2 138 | 139 | tau[kmax-2-ii, :] = tau_x 140 | tau_wv[kmax-2-ii, :] = tau_x1 141 | tau_o2[kmax-2-ii, :] = tau_x2 142 | 143 | return ( 144 | tau, # total opt. depth 145 | tau_wv, # WV opt. depth 146 | tau_o2 # O2 opt. depth 147 | ) 148 | 149 | 150 | @numba.jit(cache=True, nopython=True) 151 | def ABWVR98_IM10( 152 | RHO, # abs. humidity in gm-3 153 | T, # temp. in K 154 | P, # pressure in hPa 155 | F, # freqeuncy in GHz 156 | ): 157 | ''' 158 | OUPUT: 159 | ALPHA absorption coefficient in nepers(??)/km 160 | KEYWORDS: 161 | Abstract: 162 | PURPOSE- COMPUTE ABSORPTION COEF IN ATMOSPHERE DUE TO WATER VAPOR 163 | 164 | CALLING SEQUENCE PARAMETERS-SPECIFICATIONS 165 | 166 | NAME UNITS I/O DESCRIPTON VALID RANGE 167 | T KELVIN I TEMPERATURE 168 | P MILLIBAR I PRESSURE .1 TO 1000 169 | RHO G/M**3 I WATER VAPOR DENSITY 170 | F GHZ I FREQUENCY 0 TO 800 171 | ALPHA NEPERS/KM O ABSORPTION COEFFICIENT 172 | 173 | REFERENCES- 174 | P.W. ROSENKRANZ, RADIO SCIENCE V.33, PP.919-928 (1998) V.34, P.1025 175 | (1999). 176 | 177 | LINE INTENSITIES SELECTION THRESHOLD= 178 | HALF OF CONTINUUM ABSORPTION AT 1000 MB. 179 | WIDTHS MEASURED AT 22, 183, 380 GHZ, OTHERS CALCULATED. 180 | A.BAUER ET AL.ASA WORKSHOP (SEPT. 1989) (380GHz). 181 | # 182 | Dependencies: 183 | - 184 | Changes: 185 | DATE- OCT.6, 1988 P.W.ROSENKRANZ - EQS AS PUBL. IN 1993. 186 | OCT.4, 1995 PWR- USE CLOUGH'S DEFINITION OF LOCAL LINE 187 | CONTRIBUTION, HITRAN INTENSITIES, ADD 7 LINES. 188 | OCT. 24, 95 PWR -ADD 1 LINE. 189 | JULY 7, 97 PWR -SEPARATE COEFF. FOR SELF-BROADENING, 190 | REVISED CONTINUUM. 191 | DEC. 11, 98 PWR - ADDED COMMENTS 192 | MAY 30, 2008 Bernhard Pospichal, 193 | according to Liljegren et al.,2005, IEEE Transactions on 194 | Geoscience and Remote Sensing, Vol. 43, No. 5: 195 | 22.235 GHz air-broadened width parameter changed from .00281 to 196 | .002656. 197 | Self-broadened width parameter changed from .01349 to .0127488 198 | 11 NOV, 2009 Ulrich Loehnert 199 | 1.) Added multipliers for corrected self (bs_mult) and foreign 200 | (bf_mult) continuum contribution according to Turner et al. 201 | 2009 (IEEE TGARS) 202 | 2.) added keywords linew_22 and cont_corr in order to be able to 203 | choose between original R98 and modified Liljegren 2005 204 | linewidth (default), respectively bewteen original and Turner et 205 | al. modified contiuum (default) 206 | changed program ... 207 | - 208 | ''' 209 | linew_22 = 'lil05' 210 | cont_corr = 'tur09' 211 | 212 | # ****number of frequencies 213 | n_f = len(F) 214 | 215 | # ****LOCAL VARIABLES: 216 | NLINES = 15 217 | DF = np.zeros((2, n_f)) 218 | 219 | # ****LINE FREQUENCIES: 220 | FL = [ 221 | 22.2351, 183.3101, 321.2256, 325.1529, 380.1974, 439.1508, 443.0183, 222 | 448.0011, 470.8890, 474.6891, 488.4911, 556.9360, 620.7008, 752.0332, 223 | 916.1712 224 | ] 225 | 226 | # ****LINE INTENSITIES AT 300K: 227 | S1 = [ 228 | .1310E-13, .2273E-11, .8036E-13, .2694E-11, .2438E-10, .2179E-11, 229 | .4624E-12, .2562E-10, .8369E-12, .3263E-11, .6659E-12, .1531E-08, 230 | .1707E-10, .1011E-08, .4227E-10 231 | ] 232 | 233 | # ****T COEFF. OF INTENSITIES: 234 | B2 = [ 235 | 2.144, .668, 6.179, 1.541, 1.048, 3.595, 5.048, 1.405, 3.597, 2.379, 236 | 2.852, .159, 2.391, .396, 1.441 237 | ] 238 | 239 | # ****AIR-BROADENED WIDTH PARAMETERS AT 300K: 240 | # W3 = [ 241 | # .00281, .00281, .0023, .00278, .00287, .0021, .00186, .00263, .00215, 242 | # .00236, .0026, .00321, .00244, .00306, .00267 243 | # ] 244 | 245 | # ****T-EXPONENT OF AIR-BROADENING: 246 | X = [ 247 | .69, .64, .67, .68, .54, .63, .60, .66, .66, .65, .69, .69, .71, .68, 248 | .70 249 | ] 250 | 251 | # ****SELF-BROADENED WIDTH PARAMETERS AT 300K 252 | # WS = [ 253 | # .01349, .01491, .0108, .0135, .01541, .0090, .00788, .01275, .00983, 254 | # .01095, .01313, .01320, .01140, .01253, .01275 255 | # ] 256 | 257 | # if linew_22 == 'lil05': 258 | # ****AIR-BROADENED WIDTH PARAMETERS AT 300K: 259 | W3 = [ 260 | .002656, .00281, .0023, .00278, .00287, .0021, .00186, .00263, 261 | .00215, .00236, .0026, .00321, .00244, .00306, .00267 262 | ] 263 | 264 | # ****SELF-BROADENED WIDTH PARAMETERS AT 300K 265 | WS = [ 266 | .0127488, .01491, .0108, .0135, .01541, .0090, .00788, .01275, 267 | .00983, .01095, .01313, .01320, .01140, .01253, .01275 268 | ] 269 | 270 | 271 | # ****T-EXPONENT OF SELF-BROADENING: 272 | XS = [ 273 | .61, .85, .54, .74, .89, .52, .50, .67, .65, .64, .72, 1.0, .68, .84, 274 | .78 275 | ] 276 | 277 | if RHO <= 0: 278 | ALPHA = np.zeros(n_f) 279 | else: 280 | PVAP = RHO * T / 217. 281 | PDA = P - PVAP 282 | DEN = 3.335E16 * RHO 283 | TI = 300. / T 284 | TI2 = TI**2.5 285 | 286 | # ****CONTINUUM TERMS 287 | bf_org = 5.43E-10 288 | bs_org = 1.8E-8 289 | 290 | # bf_mult = 1.0 291 | # bs_mult = 1.0 292 | 293 | # if cont_corr == 'tur09': 294 | bf_mult = 1.105 295 | bs_mult = 0.79 296 | 297 | bf = bf_org * bf_mult 298 | bs = bs_org * bs_mult 299 | 300 | CON = (bf * PDA * TI**3 + bs * PVAP * TI**7.5) * PVAP * F * F 301 | 302 | # ****ADD RESONANCES 303 | SUM = np.zeros(n_f) 304 | 305 | for I in range(NLINES): 306 | 307 | WIDTH = W3[I] * PDA * TI**X[I] + WS[I] * PVAP * TI**XS[I] 308 | WSQ = WIDTH * WIDTH 309 | S = S1[I] * TI2 * np.exp(B2[I] * (1. - TI)) 310 | DF[0, :] = F - FL[I] 311 | DF[1, :] = F + FL[I] 312 | 313 | # USE CLOUGH'S DEFINITION OF LOCAL LINE CONTRIBUTION 314 | BASE = WIDTH / (562500. + WSQ) 315 | 316 | # DO FOR POSITIVE AND NEGATIVE RESONANCES 317 | RES = np.zeros(n_f) 318 | 319 | for i_n_f in range(n_f): 320 | for J in range(2): 321 | if (np.abs(DF[J, i_n_f]) < 750.): 322 | RES[i_n_f] = RES[i_n_f] + WIDTH / ( 323 | DF[J, i_n_f]**2 + WSQ) - BASE 324 | 325 | SUM = SUM + S * RES * (F / FL[I])**2 326 | 327 | ALPHA = .3183E-4 * DEN * SUM + CON 328 | 329 | return ALPHA 330 | 331 | 332 | @numba.jit(cache=True, nopython=True) 333 | def ABO2R98_IM10(TEMP, PRES, VAPDEN, FREQ): 334 | ''' 335 | # 336 | PURPOSE: RETURNS ABSORPTION COEFFICIENT DUE TO OXYGEN IN AIR, 337 | IN NEPERS/KM 338 | # 339 | 5/1/95 P. Rosenkranz 340 | 11/5/97 P. Rosenkranz - 1- line modification. 341 | 12/16/98 pwr - updated submm freq's and intensities from HITRAN96 342 | # 343 | ARGUMENTS: 344 | TEMP, PRES, VAPDEN, FREQ 345 | NAME UNITS DESCRIPTION VALID RANGE 346 | # 347 | TEMP KELVIN TEMPERATURE UNCERTAIN, but believed to be 348 | valid for atmosphere 349 | PRES MILLIBARS PRESSURE 3 TO 1000 350 | VAPDEN G/M^3 WATER VAPOR DENSITY (ENTERS LINEWIDTH CALCULATION 351 | DUE TO GREATER BROADENING EFFICIENCY OF H2O) 352 | FREQ GHZ FREQUENCY 0 TO 900 353 | # 354 | REFERENCES FOR EQUATIONS AND COEFFICIENTS: 355 | P.W. Rosenkranz, CHAP. 2 and appendix, in ATMOSPHERIC REMOTE SENSING 356 | BY MICROWAVE RADIOMETRY (M.A. Janssen, ed., 1993). 357 | H.J. Liebe et al, JQSRT V.48, PP.629-643 (1992). 358 | M.J. Schwartz, Ph.D. thesis, M.I.T. (1997). 359 | SUBMILLIMETER LINE INTENSITIES FROM HITRAN96. 360 | This version differs from Liebe's MPM92 in two significant respects: 361 | 1. It uses the modification of the 1- line width temperature dependence 362 | recommended by Schwartz: (1/T). 363 | 2. It uses the same temperature dependence (X) for submillimeter 364 | line widths as in the 60 GHz band: (1/T)^0.8 365 | 366 | LINES ARE ARRANGED 1-,1+,3-,3+,ETC. IN SPIN-ROTATION SPECTRUM 367 | ''' 368 | F = [ 369 | 118.7503, 56.2648, 62.4863, 58.4466, 60.3061, 59.5910, 59.1642, 370 | 60.4348, 58.3239, 61.1506, 57.6125, 61.8002, 56.9682, 62.4112, 56.3634, 371 | 62.9980, 55.7838, 63.5685, 55.2214, 64.1278, 54.6712, 64.6789, 54.1300, 372 | 65.2241, 53.5957, 65.7648, 53.0669, 66.3021, 52.5424, 66.8368, 52.0214, 373 | 67.3696, 51.5034, 67.9009, 368.4984, 424.7632, 487.2494, 715.3931, 374 | 773.8397, 834.1458 375 | ] 376 | 377 | S300 = [ 378 | .2936E-14, .8079E-15, .2480E-14, .2228E-14, .3351E-14, .3292E-14, 379 | .3721E-14, .3891E-14, .3640E-14, .4005E-14, .3227E-14, .3715E-14, 380 | .2627E-14, .3156E-14, .1982E-14, .2477E-14, .1391E-14, .1808E-14, 381 | .9124E-15, .1230E-14, .5603E-15, .7842E-15, .3228E-15, .4689E-15, 382 | .1748E-15, .2632E-15, .8898E-16, .1389E-15, .4264E-16, .6899E-16, 383 | .1924E-16, .3229E-16, .8191E-17, .1423E-16, .6494E-15, .7083E-14, 384 | .3025E-14, .1835E-14, .1158E-13, .3993E-14 385 | ] 386 | 387 | BE = [ 388 | .009, .015, .083, .084, .212, .212, .391, .391, .626, .626, .915, .915, 389 | 1.260, 1.260, 1.660, 1.665, 2.119, 2.115, 2.624, 2.625, 3.194, 3.194, 390 | 3.814, 3.814, 4.484, 4.484, 5.224, 5.224, 6.004, 6.004, 6.844, 6.844, 391 | 7.744, 7.744, .048, .044, .049, .145, .141, .145 392 | ] 393 | # WIDTHS IN MHZ/MB 394 | 395 | WB300 = .56 396 | X = .8 397 | W300 = [ 398 | 1.63, 1.646, 1.468, 1.449, 1.382, 1.360, 1.319, 1.297, 1.266, 1.248, 399 | 1.221, 1.207, 1.181, 1.171, 1.144, 1.139, 1.110, 1.108, 1.079, 1.078, 400 | 1.05, 1.05, 1.02, 1.02, 1.00, 1.00, .97, .97, .94, .94, .92, .92, .89, 401 | .89, 1.92, 1.92, 1.92, 1.81, 1.81, 1.81 402 | ] 403 | 404 | Y300 = [ 405 | -0.0233, 0.2408, -0.3486, 0.5227, -0.5430, 0.5877, -0.3970, 0.3237, 406 | -0.1348, 0.0311, 0.0725, -0.1663, 0.2832, -0.3629, 0.3970, -0.4599, 407 | 0.4695, -0.5199, 0.5187, -0.5597, 0.5903, -0.6246, 0.6656, -0.6942, 408 | 0.7086, -0.7325, 0.7348, -0.7546, 0.7702, -0.7864, 0.8083, -0.8210, 409 | 0.8439, -0.8529, 0., 0., 0., 0., 0., 0. 410 | ] 411 | 412 | V = [ 413 | 0.0079, -0.0978, 0.0844, -0.1273, 0.0699, -0.0776, 0.2309, -0.2825, 414 | 0.0436, -0.0584, 0.6056, -0.6619, 0.6451, -0.6759, 0.6547, -0.6675, 415 | 0.6135, -0.6139, 0.2952, -0.2895, 0.2654, -0.2590, 0.3750, -0.3680, 416 | 0.5085, -0.5002, 0.6206, -0.6091, 0.6526, -0.6393, 0.6640, -0.6475, 417 | 0.6729, -0.6545, 0., 0., 0., 0., 0., 0. 418 | ] 419 | 420 | TH = 300. / TEMP 421 | TH1 = TH - 1. 422 | B = TH**X 423 | PRESWV = VAPDEN * TEMP / 217. 424 | PRESDA = PRES - PRESWV 425 | DEN = .001 * (PRESDA * B + 1.1 * PRESWV * TH) 426 | DENS = .001 * (PRESDA + 1.1 * PRESWV) * TH 427 | DFNR = WB300 * DEN 428 | SUM = 1.6E-17 * FREQ * FREQ * DFNR / (TH * (FREQ * FREQ + DFNR * DFNR)) 429 | 430 | for K in range(40): 431 | if K == 0: 432 | DF = W300[0] * DENS 433 | else: 434 | DF = W300[K] * DEN 435 | Y = .001 * PRES * B * (Y300[K] + V[K] * TH1) 436 | STR = S300[K] * np.exp(-BE[K] * TH1) 437 | SF1 = (DF + (FREQ - F[K]) * Y) / ((FREQ - F[K])**2 + DF * DF) 438 | SF2 = (DF - (FREQ + F[K]) * Y) / ((FREQ + F[K])**2 + DF * DF) 439 | SUM = SUM + STR * (SF1 + SF2) * (FREQ / F[K])**2 440 | 441 | O2ABS = .5034E12 * SUM * PRESDA * TH**3 / 3.14159 442 | 443 | return O2ABS 444 | 445 | 446 | @numba.jit(cache=True, nopython=True) 447 | def ABSN2_IM10(T, P, F): 448 | ''' 449 | ****ABSN2 = ABSORPTION COEFFICIENT DUE TO NITROGEN IN AIR (NEPER/KM) 450 | T = TEMPERATURE (K) 451 | P = PRESSURE (MB) 452 | F = FREQUENCY (GHZ) 453 | ''' 454 | TH = 300. / T 455 | ALPHA = 6.4E-14 * P * P * F * F * TH**3.55 456 | 457 | return ALPHA 458 | 459 | 460 | @numba.jit(cache=True, nopython=True) 461 | # https://github.com/numba/numba/issues/2518 462 | def TB_CALC_PL_IM10(T, tau, mu_s, freq): 463 | ''' 464 | calculate brightness temperatures without scattering 465 | according to Simmer (94) pp. 87 - 91 (alpha = 1, no scattering) 466 | Planck/thermodynamic conform (28.05.03) # UL 467 | ''' 468 | h = 6.6262e-34 # Planck constant 469 | kB = 1.3806e-23 # Boltzmann constant 470 | c_li = 2.997925*1e8 # Lichtgeschw. 471 | 472 | kmax = len(T) 473 | n_f = len(freq) 474 | 475 | # tau = np.float64(tau) 476 | 477 | # T = np.float64(T) 478 | mu = np.zeros(n_f) + mu_s 479 | freq_si = freq*1e9 480 | lamda_si = c_li/freq_si 481 | 482 | IN = np.zeros(n_f, dtype=np.float64) + 2.73 483 | IN = (2.*h*freq_si/(lamda_si**2.))*1./(np.exp(h*freq_si/(kB*IN))-1.) 484 | 485 | tau_top = np.zeros(n_f, dtype=np.float64) 486 | tau_bot = tau[kmax-2] 487 | for i in range(kmax-1): 488 | 489 | valid = 1 490 | if i > 0: 491 | tau_top = tau[kmax-2-i+1] 492 | tau_bot = tau[kmax-2-i] 493 | 494 | for ii in range(n_f): 495 | if tau_bot[ii] == tau_top[ii]: 496 | valid = 0 497 | if tau_bot[ii] < tau_top[ii]: 498 | valid = -1 499 | if valid == 0: 500 | print('warning, zero absorption coefficient') 501 | if valid == -1: 502 | print('warning, negative absorption coefficient') 503 | 504 | if valid == 1: 505 | delta_tau = tau_bot-tau_top 506 | A = np.ones(n_f, dtype=np.float64) - np.exp(-1*delta_tau/mu) 507 | B = delta_tau - mu + mu*np.exp(-1*delta_tau/mu) 508 | 509 | T_pl2 = (2.*h*freq_si/(lamda_si**2.))*1. / \ 510 | (np.exp(h*freq_si/(kB*T[kmax-2-i]))-1) 511 | T_pl1 = (2.*h*freq_si/(lamda_si**2.))*1. / \ 512 | (np.exp(h*freq_si/(kB*T[kmax-1-i]))-1) 513 | diff = (T_pl2 - T_pl1)/delta_tau 514 | IN = IN*np.exp(-1*delta_tau/mu) + T_pl1*A + diff*B 515 | 516 | TB = (h*freq_si/kB)*1./np.log((2*h*freq_si/(IN*lamda_si**2.))+1.) 517 | 518 | return TB 519 | 520 | 521 | def doTests(): 522 | ''' 523 | results of these tests are compared with Uli's IDL routines. 524 | ''' 525 | 526 | assert np.isclose(ABWVR98_IM10( 527 | 10, 250, 700, np.array([35])), np.array([0.0252045])) 528 | assert np.isclose(ABSN2_IM10(250, 700, 53), 0.00016827562671213744) 529 | assert np.isclose(ABO2R98_IM10(250, 700, 10, 53), 0.159599435186749) 530 | 531 | tau, tau_wv, tau_o2 = TAU_CALC_IM10( 532 | np.array([10., 1000., 10000.]), # height [m] 533 | np.array([300., 270., 250.]), # Temp. [K] 534 | np.array([100000., 75000., 20000.]), # press. [Pa] 535 | np.array([10e-3, 5e-3, 1e-3]), # abs. hum. [kg m^-3] 536 | np.array([35.]), # freq. [GHz] 537 | 538 | ) 539 | assert np.all(np.isclose(tau, np.array([[0.06479182], 540 | [0.04500077]]))) 541 | assert np.all(np.isclose(tau_wv, np.array([[0.04458111], 542 | [0.03022091]]))) 543 | assert np.all(np.isclose(tau_o2, np.array([[0.01993734], 544 | [0.01457681]]))) 545 | 546 | tau, tau_wv, tau_o2 = TAU_CALC_IM10( 547 | np.array([10., 1000., 10000.]), # height [m] 548 | np.array([300., 270., 250.]), # Temp. [K] 549 | np.array([100000., 75000., 20000.]), # press. [Pa] 550 | np.array([10e-3, 5e-3, 1e-3]), # abs. hum. [kg m^-3] 551 | np.array([53.]), # freq. [GHz] 552 | ) 553 | assert np.all(np.isclose(tau, np.array([[0.84145784], 554 | [0.62035005]]))) 555 | assert np.all(np.isclose(tau_wv, np.array([[0.08091379], 556 | [0.05529443]]))) 557 | assert np.all(np.isclose(tau_o2, np.array([[0.75991718], 558 | [0.56459001]]))) 559 | 560 | TB, tau, tau_wv, tau_o2 = STP_IM10( 561 | # [m] states grid of T_final [K], p_final [Pa], q_final [kgm^-3] 562 | np.array([10., 1000., 10000.]), 563 | np.array([300., 270., 250.]), 564 | np.array([100000., 75000., 20000.]), 565 | np.array([10e-3, 5e-3, 1e-3]), 566 | 10., # zenith angle of observation in deg. 567 | np.array([35., 53.]), # frequency vector in GHz 568 | ) 569 | assert np.all(np.isclose(TB, np.array([19.68133037, 156.13616292]))) 570 | assert np.all(np.isclose(tau, np.array([[0.06479182, 0.84145784], 571 | [0.04500077, 0.62035005]]))) 572 | assert np.all(np.isclose(tau_wv, np.array([[0.04458111, 0.08091379], 573 | [0.03022091, 0.05529443]]))) 574 | assert np.all(np.isclose(tau_o2, np.array([[0.01993734, 0.75991718], 575 | [0.01457681, 0.56459001]]))) 576 | 577 | heights = [ 578 | 0.0000000e+00, 4.2440624e+01, 8.5076721e+01, 1.2790133e+02, 579 | 1.7091106e+02, 2.1410199e+02, 2.5747302e+02, 3.0102405e+02, 580 | 3.4475641e+02, 3.8867044e+02, 4.3276773e+02, 4.7704846e+02, 581 | 5.2151447e+02, 5.6616852e+02, 6.1101276e+02, 6.5604932e+02, 582 | 7.0128076e+02, 7.4670978e+02, 7.9233929e+02, 8.3817181e+02, 583 | 8.8420935e+02, 1.0704741e+03, 1.2602533e+03, 1.4537362e+03, 584 | 1.6511360e+03, 1.8526676e+03, 2.0585374e+03, 2.2689570e+03, 585 | 2.4841409e+03, 2.7043225e+03, 2.9297371e+03, 3.1606392e+03, 586 | 3.3973149e+03, 3.6400652e+03, 3.8892119e+03, 4.1450962e+03, 587 | 4.8168247e+03, 5.5401792e+03, 6.3240845e+03, 7.1800732e+03, 588 | 8.1243667e+03, 9.1821113e+03, 1.0395719e+04, 1.1844845e+04, 589 | 1.2703082e+04, 1.3693662e+04, 1.4865961e+04, 1.6300934e+04, 590 | 1.8150615e+04, 2.0760561e+04, 2.4076291e+04, 2.5271123e+04, 591 | 2.6741920e+04, 2.8651969e+04, 3.1373289e+04, 3.3807105e+04, 592 | 3.6156855e+04, 3.7751129e+04, 3.9850242e+04, 4.2892234e+04 593 | ] 594 | temperature = [ 595 | 293.06253, 295.9907, 297.61807, 298.29483, 298.47858, 298.34824, 596 | 298.0353, 297.71616, 297.38647, 297.0542, 296.6928, 296.3217, 597 | 295.95053, 295.5693, 295.18384, 294.79764, 294.40634, 294.00082, 598 | 293.5864, 293.172, 292.75635, 291.04688, 289.47742, 288.29865, 599 | 287.69485, 286.70486, 285.5756, 284.28503, 282.8634, 281.38602, 600 | 279.77945, 278.14996, 276.42813, 274.7154, 273.0224, 601 | 271.39532, 267.7346, 263.31265, 258.08643, 251.79128, 602 | 244.4248, 235.92027, 226.98349, 224.13881, 224.78397, 603 | 225.24701, 225.24701, 225.24701, 225.3689, 226.56195, 229.273, 604 | 230.22314, 231.79558, 233.58482, 236.5767, 242.67717, 248.45955, 605 | 253.52713, 258.5947, 266.24683 606 | ] 607 | pressure = [ 608 | 100000., 99500., 99000., 98500., 98000., 97500., 97000., 609 | 96500., 96000., 95500., 95000., 94500., 94000., 93500., 610 | 93000., 92500., 92000., 91500., 91000., 90500., 90000., 611 | 88000., 86000., 84000., 82000., 80000., 78000., 76000., 612 | 74000., 72000., 70000., 68000., 66000., 64000., 62000., 613 | 60000., 55000., 50000., 45000., 40000., 35000., 30000., 614 | 25000., 20000., 17500., 15000., 12500., 10000., 7500., 615 | 5000., 3000., 2500., 2000., 1500., 1000., 700., 616 | 500., 400., 300., 200. 617 | ] 618 | humidity = [ 619 | 1.18251285e-02, 1.14939269e-02, 1.11975744e-02, 1.09878751e-02, 620 | 1.08402278e-02, 1.07536148e-02, 1.07092401e-02, 1.06639238e-02, 621 | 1.06170261e-02, 1.05705503e-02, 1.05287395e-02, 1.04884841e-02, 622 | 1.04482342e-02, 1.04073379e-02, 1.03661669e-02, 1.03249513e-02, 623 | 1.02846604e-02, 1.02469595e-02, 1.02108689e-02, 1.01747783e-02, 624 | 1.01378299e-02, 9.95743275e-03, 9.41002835e-03, 8.42119381e-03, 625 | 6.94509782e-03, 5.98434173e-03, 5.21718571e-03, 4.67937114e-03, 626 | 4.31687059e-03, 4.02891682e-03, 3.81084811e-03, 3.57917766e-03, 627 | 3.26925074e-03, 2.88613979e-03, 2.34445557e-03, 1.81542535e-03, 628 | 7.76122033e-04, 6.57636556e-04, 2.95107893e-04, 1.55331218e-04, 629 | 9.08064612e-05, 6.24438544e-05, 4.23682905e-05, 2.08727743e-05, 630 | 1.37270645e-05, 9.99999975e-06, 9.99999975e-06, 9.99999975e-06, 631 | 9.99999975e-06, 9.99999975e-06, 9.99999975e-06, 9.99999975e-06, 632 | 9.99999975e-06, 9.99999975e-06, 9.99999975e-06, 9.99999975e-06, 633 | 9.99999975e-06, 9.99999975e-06, 9.99999975e-06, 9.99999975e-06 634 | ] 635 | zenithAngle = 0 636 | frequencies = [51.26, 52.28, 53.86, 54.94, 56.66, 57.3, 58.] 637 | TB, tau, tau_wv, tau_o2 = STP_IM10( 638 | heights, temperature, pressure, humidity, zenithAngle, frequencies) 639 | TBref = np.array([ 640 | 112.38722248, 155.71521178, 259.08914502, 289.34402775, 641 | 295.16305358, 295.67990855, 295.98309774 642 | ]) 643 | assert np.all(np.isclose(TB, TBref)) 644 | -------------------------------------------------------------------------------- /lib/prepare_radiosondes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Prepare radiosondes\n", 9 | "\n", 10 | "This script is for documentation only. Running it requires downloading radiosonde observations (nsainterpolatedsondeC1) from https://www.arm.gov/data\n", 11 | "\n", 12 | "Because this is only a toy retrieval, we made a couple of important simplifications:\n", 13 | "* Instead of using the radiosondes directly, the ARM interpolated radiosonde product is used for convenience at standard observations times. \n", 14 | "* The filtering of outliers is very crude\n", 15 | "* Only every 5th available height level is used. \n", 16 | "\n", 17 | "When designing an operational retrieval, these shortcomings should be addressed." 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 1, 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [ 26 | "import xarray as xr\n", 27 | "import pandas as pn\n", 28 | "import numpy as np\n", 29 | "import matplotlib.pyplot as plt\n", 30 | "import scipy.stats as stats\n", 31 | "import pamtra2\n", 32 | "import supporting_routines\n", 33 | "%matplotlib inline" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "Open data\n", 41 | "\n" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 2, 47 | "metadata": {}, 48 | "outputs": [ 49 | { 50 | "name": "stderr", 51 | "output_type": "stream", 52 | "text": [ 53 | "/home/mmaahn/miniconda3/envs/py36/lib/python3.6/site-packages/ipykernel_launcher.py:1: FutureWarning: In xarray version 0.15 the default behaviour of `open_mfdataset`\n", 54 | "will change. To retain the existing behavior, pass\n", 55 | "combine='nested'. To use future default behavior, pass\n", 56 | "combine='by_coords'. See\n", 57 | "http://xarray.pydata.org/en/stable/combining.html#combining-multi\n", 58 | "\n", 59 | " \"\"\"Entry point for launching an IPython kernel.\n", 60 | "/home/mmaahn/miniconda3/envs/py36/lib/python3.6/site-packages/xarray/backends/api.py:933: FutureWarning: The datasets supplied have global dimension coordinates. You may want\n", 61 | "to use the new `combine_by_coords` function (or the\n", 62 | "`combine='by_coords'` option to `open_mfdataset`) to order the datasets\n", 63 | "before concatenation. Alternatively, to continue concatenating based\n", 64 | "on the order the datasets are supplied in future, please use the new\n", 65 | "`combine_nested` function (or the `combine='nested'` option to\n", 66 | "open_mfdataset).\n", 67 | " from_openmfds=True,\n" 68 | ] 69 | } 70 | ], 71 | "source": [ 72 | "interpolatedsonde = xr.open_mfdataset('/psd3data/oliktok/RawData/ARM/nsa/sonde/nsainterpolatedsondeC1/nsainterpolatedsondeC1.c1.*.nc')\n", 73 | "\n" 74 | ] 75 | }, 76 | { 77 | "cell_type": "markdown", 78 | "metadata": {}, 79 | "source": [ 80 | "Select data every 6 hours" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": 3, 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [ 89 | "interpolatedsondeRS = interpolatedsonde.resample(time='6H').nearest(\n", 90 | " tolerance='1H')" 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "metadata": {}, 96 | "source": [ 97 | "Apply quality flags" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": 4, 103 | "metadata": {}, 104 | "outputs": [], 105 | "source": [ 106 | "variables = [\n", 107 | " 'temp',\n", 108 | " 'rh',\n", 109 | " 'bar_pres',\n", 110 | " 'dp',\n", 111 | "]\n", 112 | "\n", 113 | "for var in variables:\n", 114 | " interpolatedsondeRS[var] = interpolatedsondeRS[var].where(\n", 115 | " interpolatedsondeRS['qc_%s' % var] == 0)\n", 116 | "interpolatedsondeRS = interpolatedsondeRS[variables]" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 5, 122 | "metadata": {}, 123 | "outputs": [], 124 | "source": [ 125 | "for k in list(interpolatedsondeRS.attrs.keys()):\n", 126 | " del interpolatedsondeRS.attrs[k]" 127 | ] 128 | }, 129 | { 130 | "cell_type": "markdown", 131 | "metadata": {}, 132 | "source": [ 133 | "remove invalid data" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": 6, 139 | "metadata": {}, 140 | "outputs": [], 141 | "source": [ 142 | "interpolatedsondeRS = interpolatedsondeRS.dropna('time', how='all')\n", 143 | "interpolatedsondeRS = interpolatedsondeRS.dropna('height', how='all')" 144 | ] 145 | }, 146 | { 147 | "cell_type": "markdown", 148 | "metadata": {}, 149 | "source": [ 150 | "estimate and plot potential temperature" 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": 7, 156 | "metadata": {}, 157 | "outputs": [], 158 | "source": [ 159 | "tpot = pamtra2.libs.meteo_si.temperature.T_pot(\n", 160 | " interpolatedsondeRS['temp']+ 273.15, interpolatedsondeRS['bar_pres'] * 1000)\n" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": 8, 166 | "metadata": {}, 167 | "outputs": [ 168 | { 169 | "data": { 170 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEICAYAAACktLTqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAP9klEQVR4nO3df6zdd13H8eeL4VCZdEoLYn/Qwi2TgibozQBJFANi57jrgqgtoEybNQNGkEiwAzQag45oEAgDLbIMZW40E8cKJQPRZcF0ug5BVsqkGZsrG3RA1jH5Mbu9/eOchuPdufeee8+5Pfd+7vORNL3fz/d8v9/PZ1lf/fT9/Z7vJ1WFJKktjxp3ByRJo2e4S1KDDHdJapDhLkkNMtwlqUGGuyQ1yHBXE5IcSvL8cfdDWioMdy0LSe5I8sJpbRck+TRAVT2jqm6Y4xwbk1SSRy9iV6UlwXCXRsS/NLSUGO5qQu/MPsnZSQ4muT/J15K8vfuxG7u/35fkgSTPTfKoJG9JcmeSY0n+NsmqnvP+VnffN5L8wbTr/FGSa5J8MMn9wAXdax9Icl+Se5K8O8npPeerJK9O8qUk30ryJ0me2j3m/iR7ez8vLZThrha9E3hnVT0OeCqwt9v+893fz6yqM6rqAHBB99cvAk8BzgDeDZBkC/Ae4OXAk4BVwNpp19oGXAOcCVwJPAS8HlgNPB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R//hadwFtLZ6wf6H7sA8D54+nh6CVZB5wL/E1Pc3PjNdznKcl5wFeq6nPTds20pmxrfgf4ePfnlsfc8tj6SrIReBbwb8ATq+oe6PwFADxhfD0buXfQmZw93NPW3HiHWUO1WUn+CfjxPrveDLwJeFG/w/q0LZvnTGcbc1V9pPuZN9P5Z/yVJw/r8/llM+Y5tDy2R0hyBvAPwO9W1f1Jv+Evf0leDByrqluSPH/c/VlMhnsfVfXCfu1JfgrYBHyu+z//OuAzSc5mBGvKjtNMYz4pySuBFwMvqO9/OWJZj3kOLY/t/0nyA3SC/cqq+nC3+WtJnlRV9yR5EnBsfD0cqecB5yX5FeAHgccl+SANjteyzDxU1eer6glVtbGqNtIJgJ+pqq/SWT92e5LHJNkEbAb+fYzdHZkkW4HfB86rqm/37Gp2zIxgjeDlIJ1ZyvuBw1X19p5d1wGv7P78SuAjp7pvi6GqLqmqdd0/v9uBf66qV9DgeJ25j0hVHUqyF/gCndLFa6rqoTF3a1TeDTwG+GT3Xyw3VdVFLY+5qk4kOblG8GnA5fNdI3iZeB7wm8Dnk3y22/Ym4FJgb5KddJ4K+7Ux9e9UaW68vn5AkhpkWUaSGmS4S1KDDHdJapDhLkkNMtwlqUGGuyQ1yHCXpAb9H7DOC4yPWtYaAAAAAElFTkSuQmCC", 171 | "text/plain": [ 172 | "
" 173 | ] 174 | }, 175 | "metadata": { 176 | "needs_background": "light" 177 | }, 178 | "output_type": "display_data" 179 | } 180 | ], 181 | "source": [ 182 | "lts = tpot - tpot[:, 0]\n", 183 | "level_925 = np.nanargmin(np.abs(interpolatedsondeRS.bar_pres.mean('time').values - 92.5))\n", 184 | "lts[:, level_925].plot.hist(bins=np.linspace(-50, 50))\n", 185 | "plt.yscale('log')" 186 | ] 187 | }, 188 | { 189 | "cell_type": "markdown", 190 | "metadata": {}, 191 | "source": [ 192 | "remove outliers and plot again\n", 193 | "\n" 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": 9, 199 | "metadata": {}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qfVWtpxMAP1FVX6Wzf+zWJE9LsgHYCPzbGLs7Mkk2A78LnF1V3+x5qdkxM4I9gpeDdGYpHwHurKr39Ly0Gzi3+/O5wLXHu2+Loaouqao13f9/twL/VFWvp8HxOnMfkaran2QX8EU6pYs3VdXjY+7WqLwfeBpwffdfLLdW1YUtj7mqjiQ5ukfwCmDnfPcIXiZeAfw68IUkn+u2vQO4FNiV5Hw6T4X98pj6d7w0N16XH5CkBlmWkaQGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ0y3CWpQf8HNsECgJ6tX2wAAAAASUVORK5CYII=", 204 | "text/plain": [ 205 | "
" 206 | ] 207 | }, 208 | "metadata": { 209 | "needs_background": "light" 210 | }, 211 | "output_type": "display_data" 212 | } 213 | ], 214 | "source": [ 215 | "II = np.where(~((interpolatedsondeRS['temp'].diff('height') > 11).any('height')))[0]\n", 216 | "\n", 217 | "lts.isel(time=II)[:, level_925].plot.hist(bins=np.linspace(-50, 50).tolist())\n", 218 | "plt.yscale('log')" 219 | ] 220 | }, 221 | { 222 | "cell_type": "markdown", 223 | "metadata": {}, 224 | "source": [ 225 | "limit to every 5th height" 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 10, 231 | "metadata": {}, 232 | "outputs": [], 233 | "source": [ 234 | "hh = slice(0, 300, 5)\n", 235 | "interpolatedsondeRS_5 = interpolatedsondeRS.isel(height=hh, time=II)" 236 | ] 237 | }, 238 | { 239 | "cell_type": "code", 240 | "execution_count": 11, 241 | "metadata": {}, 242 | "outputs": [ 243 | { 244 | "data": { 245 | "text/html": [ 246 | "
<xarray.Dataset>\n",
247 |        "Dimensions:   (height: 60, time: 24095)\n",
248 |        "Coordinates:\n",
249 |        "  * time      (time) datetime64[ns] 2002-04-29 ... 2020-02-04T18:00:00\n",
250 |        "  * height    (height) float32 0.008 0.107999995 ... 20.008007 22.508007\n",
251 |        "Data variables:\n",
252 |        "    temp      (time, height) float32 -11.4468975 -10.507055 ... -45.524162\n",
253 |        "    rh        (time, height) float32 74.25851 77.52467 ... 0.5102128 0.5082667\n",
254 |        "    bar_pres  (time, height) float32 101.90272 100.83725 ... 5.1028395 3.5113027\n",
255 |        "    dp        (time, height) float32 -14.990514 -13.192951 ... -84.815704
" 256 | ], 257 | "text/plain": [ 258 | "\n", 259 | "Dimensions: (height: 60, time: 24095)\n", 260 | "Coordinates:\n", 261 | " * time (time) datetime64[ns] 2002-04-29 ... 2020-02-04T18:00:00\n", 262 | " * height (height) float32 0.008 0.107999995 ... 20.008007 22.508007\n", 263 | "Data variables:\n", 264 | " temp (time, height) float32 -11.4468975 -10.507055 ... -45.524162\n", 265 | " rh (time, height) float32 74.25851 77.52467 ... 0.5102128 0.5082667\n", 266 | " bar_pres (time, height) float32 101.90272 100.83725 ... 5.1028395 3.5113027\n", 267 | " dp (time, height) float32 -14.990514 -13.192951 ... -84.815704" 268 | ] 269 | }, 270 | "execution_count": 12, 271 | "metadata": {}, 272 | "output_type": "execute_result" 273 | } 274 | ], 275 | "source": [ 276 | "interpolatedsondeRS_5.load()" 277 | ] 278 | }, 279 | { 280 | "cell_type": "markdown", 281 | "metadata": {}, 282 | "source": [ 283 | "Convert to SI units" 284 | ] 285 | }, 286 | { 287 | "cell_type": "code", 288 | "execution_count": 13, 289 | "metadata": {}, 290 | "outputs": [], 291 | "source": [ 292 | "interpolatedsondeRS_5['height'] = interpolatedsondeRS_5.height * 1000\n", 293 | "interpolatedsondeRS_5['temp'] = interpolatedsondeRS_5.temp + 273.15\n", 294 | "interpolatedsondeRS_5['bar_pres'] = interpolatedsondeRS_5.bar_pres * 1000\n", 295 | "interpolatedsondeRS_5['rh'] = interpolatedsondeRS_5.rh / 100\n", 296 | "interpolatedsondeRS_5['q'] = pamtra2.libs.meteo_si.humidity.rh2q(interpolatedsondeRS_5.rh, interpolatedsondeRS_5.temp,\n", 297 | " interpolatedsondeRS_5.bar_pres) * 1000" 298 | ] 299 | }, 300 | { 301 | "cell_type": "code", 302 | "execution_count": 14, 303 | "metadata": {}, 304 | "outputs": [], 305 | "source": [ 306 | "interpolatedsondeRS_5 = interpolatedsondeRS_5[['temp','q','bar_pres']]" 307 | ] 308 | }, 309 | { 310 | "cell_type": "markdown", 311 | "metadata": {}, 312 | "source": [ 313 | "Store data using best possible compression" 314 | ] 315 | }, 316 | { 317 | "cell_type": "code", 318 | "execution_count": 15, 319 | "metadata": { 320 | "scrolled": true 321 | }, 322 | "outputs": [], 323 | "source": [ 324 | "for var in interpolatedsondeRS_5.variables:\n", 325 | " interpolatedsondeRS_5[var].encoding = {}\n", 326 | " interpolatedsondeRS_5[var].encoding['zlib']=True \n", 327 | " interpolatedsondeRS_5[var].encoding['complevel'] = 9 \n", 328 | " interpolatedsondeRS_5[var].encoding['_FillValue'] = -9999 \n", 329 | "\n", 330 | "\n", 331 | "interpolatedsondeRS_5['temp'].encoding['dtype'] = 'uint16' \n", 332 | "interpolatedsondeRS_5['temp'].encoding['scale_factor'] = 0.01 \n", 333 | "interpolatedsondeRS_5['bar_pres'].encoding['dtype'] = 'uint16' \n", 334 | "interpolatedsondeRS_5['bar_pres'].encoding['scale_factor'] = 10 \n", 335 | "interpolatedsondeRS_5['time'].encoding['dtype']='uint32' \n", 336 | "\n", 337 | "interpolatedsondeRS_5.to_netcdf('../data/radiosonde_climatology_nsa_2002-2020.nc')" 338 | ] 339 | } 340 | ], 341 | "metadata": { 342 | "language_info": { 343 | "codemirror_mode": { 344 | "name": "ipython", 345 | "version": 3 346 | }, 347 | "file_extension": ".py", 348 | "mimetype": "text/x-python", 349 | "name": "python", 350 | "nbconvert_exporter": "python", 351 | "pygments_lexer": "ipython3", 352 | "version": "3.6.7" 353 | }, 354 | "notify_time": "5", 355 | "toc": { 356 | "base_numbering": 1, 357 | "nav_menu": {}, 358 | "number_sections": true, 359 | "sideBar": true, 360 | "skip_h1_title": false, 361 | "title_cell": "Table of Contents", 362 | "title_sidebar": "Contents", 363 | "toc_cell": false, 364 | "toc_position": { 365 | "height": "calc(100% - 180px)", 366 | "left": "10px", 367 | "top": "150px", 368 | "width": "255.390625px" 369 | }, 370 | "toc_section_display": true, 371 | "toc_window_display": true 372 | }, 373 | "varInspector": { 374 | "cols": { 375 | "lenName": 16, 376 | "lenType": 16, 377 | "lenVar": 40 378 | }, 379 | "kernels_config": { 380 | "python": { 381 | "delete_cmd_postfix": "", 382 | "delete_cmd_prefix": "del ", 383 | "library": "var_list.py", 384 | "varRefreshCmd": "print(var_dic_list())" 385 | }, 386 | "r": { 387 | "delete_cmd_postfix": ") ", 388 | "delete_cmd_prefix": "rm(", 389 | "library": "var_list.r", 390 | "varRefreshCmd": "cat(var_dic_list()) " 391 | } 392 | }, 393 | "types_to_exclude": [ 394 | "module", 395 | "function", 396 | "builtin_function_or_method", 397 | "instance", 398 | "_Feature" 399 | ], 400 | "window_display": false 401 | } 402 | }, 403 | "nbformat": 4, 404 | "nbformat_minor": 2 405 | } 406 | -------------------------------------------------------------------------------- /lib/supporting_routines.py: -------------------------------------------------------------------------------- 1 | from copy import deepcopy 2 | 3 | import pandas as pn 4 | import numpy as np 5 | import xarray as xr 6 | import matplotlib 7 | import matplotlib.pyplot as plt 8 | import scipy.special 9 | import numpy.linalg as LA 10 | 11 | 12 | import pamtra2 13 | 14 | niceKeys = { 15 | 'Nw_log10': 'log$_{10}$N$_w$', 16 | 'Dm_log10': 'log$_{10}$D$_m$', 17 | 'Sm_log10': 'log$_{10}\sigma_m$', 18 | 'Nw': 'N$_w$', 19 | 'Dm': 'D$_m$', 20 | 'Sm': '$\sigma_m$', 21 | 'Smprime': "$\sigma_m\!'$", 22 | 'Sm_prime': "$\sigma_m\!'$", 23 | 'Smprime_log10': "log$_{10}\sigma_m\!'$", 24 | 'PCS0': 'PCS 0', 25 | 'PCS1': 'PCS 1', 26 | 'PCS2': 'PCS 2', 27 | } 28 | niceKeysSimple = { 29 | 'Nw': 'N$_w$', 30 | 'Dm': 'D$_m$', 31 | 'Sm': "$\sigma_m$ or $\sigma_m\!'$", 32 | 'Smprime': "$\sigma_m\!'$", 33 | 'PCS0': 'PCS 0', 34 | 'PCS1': 'PCS 1', 35 | 'PCS2': 'PCS 2', 36 | } 37 | niceRuns = { 38 | 'Sm': 'log$_{10}$', 39 | 'SmLin': "linear", 40 | 'Smprime': "linear with $\sigma_m\!'$", 41 | 'SmprimeLog10': "log$_{10}$ with $\sigma_m\!'$", 42 | 'PCS': 'PCS', 43 | } 44 | niceRetrievals = { 45 | 'Z': "$Z_e$ retrieval", 46 | 'ZW': "$Z_e$, $V_d$ retrieval", 47 | 'Zdual': "dual $Z_e$ retrieval", 48 | 'ZWdual': "dual $Z_e$, $V_d$ retrieval", 49 | 50 | } 51 | 52 | 53 | def plotCorrelation(cov, fig, sp, tickLabels=None, isCov=True, cmap='viridis_r'): 54 | 55 | std = pn.Series(np.sqrt(np.diag(cov)), index=cov.index) 56 | 57 | if isCov: 58 | cor = deepcopy(cov) 59 | cor[:] = 0 60 | for xx in cov.index: 61 | for yy in cov.index: 62 | cor[xx][yy] = cov[xx][yy] / (std[xx] * std[yy]) 63 | else: 64 | cor = cov 65 | 66 | sp.set_aspect('equal') 67 | 68 | ind_array = np.arange(cor.shape[0]) 69 | 70 | x, y = np.meshgrid(ind_array, ind_array) 71 | for i, (x_val, y_val) in enumerate(zip(x.flatten(), y.flatten())): 72 | if x_val < y_val: 73 | c = "%.g" % cov.iloc[x_val, y_val] 74 | sp.text( 75 | x_val + 0.5, 76 | y_val + 0.5, 77 | c, 78 | va='center', 79 | ha='center', 80 | fontsize=9) 81 | 82 | if x_val > y_val: 83 | c = "%.g" % cor.iloc[x_val, y_val] 84 | sp.text( 85 | x_val + 0.5, 86 | y_val + 0.5, 87 | c, 88 | va='center', 89 | ha='center', 90 | color='w', 91 | fontsize=9) 92 | cor.iloc[x_val, y_val] = -1 93 | 94 | if x_val == y_val: 95 | c = "%.g" % cov.iloc[x_val, y_val] 96 | sp.text( 97 | x_val + 0.5, 98 | y_val + 0.5, 99 | c, 100 | va='center', 101 | ha='center', 102 | color='k', 103 | fontsize=9) 104 | cor.iloc[x_val, y_val] = -1 105 | 106 | if tickLabels != None: 107 | labels = [] 108 | for ii in range(cor.shape[0]): 109 | labels.append(tickLabels[cor.index[ii]].split(' [')[0]) 110 | else: 111 | labels = cov.index 112 | cor_values = np.ma.masked_equal(cor.values, -1) 113 | pc = sp.pcolormesh(cor_values, vmin=-1, vmax=1, cmap=cmap) 114 | sp.tick_params(axis=u'both', which=u'both', length=0) 115 | sp.set_xticks(np.arange(len(labels)) + 0.5) 116 | sp.set_xticklabels(labels, rotation=90) 117 | sp.set_yticks(np.arange(len(labels)) + 0.5) 118 | sp.set_yticklabels(labels) 119 | sp.set_xlim(0, len(std)) 120 | sp.set_ylim(0, len(std)) 121 | return pc 122 | 123 | 124 | def normalizedDSD(D, Nw, Dm, mu): 125 | 126 | fmu = (6*(4 + mu)**(mu + 4)) / (4**4 * scipy.special.gamma(mu + 4)) 127 | N = Nw * fmu * ((D/Dm)**mu) * np.exp(-(mu+4) * (D/Dm)) 128 | return N 129 | 130 | 131 | def normalizedDSD_sigma_prime(D, Nw, Dm, sigma_prime): 132 | 133 | bm = 1.36 134 | mu = Dm**(2-2*bm)/sigma_prime**2 - 4 # eq. 25 w14 135 | # print(mu) 136 | return normalizedDSD(D, Nw, Dm, mu) 137 | 138 | 139 | def normalizedDSD_sigma(D, Nw, Dm, sigma): 140 | 141 | mu = (Dm/sigma)**2 - 4 # eq 18 w14 142 | # print(mu) 143 | return normalizedDSD(D, Nw, Dm, mu) 144 | 145 | 146 | def normalizedDSD4Pamtra(sizeCenter, sizeBoundsWidth, Nw, Dm, mu): 147 | sizeCenter = sizeCenter*1000. 148 | 149 | fmu = (6*(4 + mu)**(mu + 4)) / (4**4 * scipy.special.gamma(mu + 4)) 150 | N = Nw * fmu * ((sizeCenter/Dm)**mu) * np.exp(-(mu+4) * (sizeCenter/Dm)) 151 | 152 | N = N*1000 153 | 154 | return N * sizeBoundsWidth 155 | 156 | 157 | def preparePamtra(frequencies=[35.9e9], additionalDims={}, radar='simple'): 158 | pam2 = pamtra2.pamtra2( 159 | nLayer=1, 160 | hydrometeors=['rain'], 161 | frequencies=frequencies, 162 | additionalDims=additionalDims, 163 | ) 164 | 165 | pam2.profile['height'][:] = 100 166 | pam2.profile['heightBinDepth'] = xr.ones_like(pam2.profile['height']) * 10 167 | pam2.profile['temperature'][:] = 283 168 | pam2.profile['pressure'][:] = 100000 169 | pam2.profile['relativeHumidity'][:] = 50 170 | pam2.profile['eddyDissipationRate'][:] = 1e-4 171 | pam2.profile['horizontalWind'][:] = 10 172 | 173 | pam2.addMissingVariables() 174 | 175 | pam2.addHydrometeor( 176 | pamtra2.hydrometeors.rain( 177 | name='rain', 178 | Dmin=1e-5, 179 | Dmax=1e-2, 180 | scattering=pamtra2.hydrometeors.scattering.Mie, 181 | numberConcentration=xr.DataArray([0.] * 50, dims=['sizeBin']), 182 | useFuncArgDefaults=False, 183 | )) 184 | 185 | if radar == 'simple': 186 | pam2.addInstrument(pamtra2.instruments.radar.simpleRadar( 187 | name='radar'), solve=False) 188 | elif radar == 'spectral': 189 | pam2.addInstrument(pamtra2.instruments.radar.dopplerRadarPamtra( 190 | name='radar', 191 | radarMaxV=7.885*2, 192 | radarMinV=-7.885*2, 193 | radarNFFT=256*2, 194 | momentsNPeaks=1, 195 | seed=10, 196 | radarNAve=15, 197 | ), solve=False) 198 | return pam2 199 | 200 | 201 | def forwardPamtra(X, 202 | pam2=None, 203 | y_vars=None, 204 | solver_training=None, 205 | origStd_training=None, 206 | origMean_training=None, 207 | returnDSD=False, 208 | ): 209 | 210 | if 'PCS1' in X.keys(): 211 | X = X[['PCS0', 'PCS1', 'PCS2']] 212 | back2state1 = X.values.dot(LA.inv(solver_training.eofs().T)) 213 | back2state = back2state1 * origStd_training 214 | back2state = back2state + origMean_training 215 | X = back2state.to_series() 216 | 217 | try: 218 | Nw = 10**X['Nw_log10'] 219 | except KeyError: 220 | Nw = X['Nw'] 221 | try: 222 | Dm = 10**X['Dm_log10'] 223 | except KeyError: 224 | Dm = X['Dm'] 225 | 226 | if 'Smprime' in X.keys(): 227 | sigma_prime = X['Smprime'] 228 | elif 'Smprime_log10' in X.keys(): 229 | sigma_prime = 10**X['Smprime_log10'] 230 | elif 'Sm_log10' in X.keys(): 231 | sigma = 10**X['Sm_log10'] 232 | sigma_prime = sigma / (Dm**1.36) 233 | elif 'Sm' in X.keys(): 234 | sigma = X['Sm'] 235 | sigma_prime = sigma / (Dm**1.36) 236 | else: 237 | raise KeyError 238 | 239 | bm = 1.36 240 | mu = Dm**(2 - 2 * bm) / sigma_prime**2 - 4 # eq. 25 w14 241 | 242 | pam2.hydrometeors.rain.profile.numberConcentration[:] = normalizedDSD4Pamtra( 243 | pam2.hydrometeors.rain.profile.sizeCenter.values, 244 | pam2.hydrometeors.rain.profile.sizeBoundsWidth.values, Nw, Dm, mu) 245 | 246 | pam2.instruments.radar.solve() 247 | 248 | res = pam2.instruments.radar.results[[ 249 | 'radarReflectivity', 'meanDopplerVel' 250 | ]].load() 251 | 252 | out = pn.Series(dtype=np.float64) 253 | for freq in pam2.profile.frequency.values: 254 | out['Ze_%g' % (freq / 1e9)] = res['radarReflectivity'].sel( 255 | frequency=freq).values.squeeze() 256 | out['MDV_%g' % 257 | (freq / 1e9 258 | )] = res['meanDopplerVel'].sel(frequency=freq).values.squeeze() 259 | try: 260 | out = out.astype(np.float64) 261 | except ValueError: 262 | pass 263 | 264 | if returnDSD: # for debugging only 265 | return out[y_vars], (Nw, Dm, sigma_prime) 266 | else: 267 | return out[y_vars] 268 | 269 | 270 | def splitTQ(x): 271 | t_index = [i for i in x.index if i.endswith('t')] 272 | q_index = [i for i in x.index if i.endswith('q')] 273 | h_index = [float(i.split('_')[0]) for i in x.index if i.endswith('q')] 274 | 275 | assert len(t_index) == len(q_index) 276 | assert len(t_index) == len(h_index) 277 | assert len(t_index)*2 == len(x) 278 | 279 | xt = x[t_index] 280 | xt.index = h_index 281 | 282 | xq = x[q_index] 283 | xq.index = h_index 284 | 285 | xt.index.name = 'height' 286 | xq.index.name = 'height' 287 | 288 | return xt, xq 289 | 290 | 291 | def plotMwrResults(oe1, title=None, oe2=None, title2=None, oe3=None, title3=None, h=None, hlabel='Height [m]', xlimT=(None, None), xlimH=(None, None)): 292 | 293 | if oe2 is None: 294 | gridspec = dict(wspace=0.0) 295 | fig, (axA, axB) = plt.subplots(ncols=2, sharey=True, 296 | gridspec_kw=gridspec, figsize=[5.0, 4.0]) 297 | vals = [oe1], [axA], [axB], [title] 298 | elif oe3 is None: 299 | 300 | gridspec = dict(wspace=0.0, width_ratios=[1, 1, 0.25, 1, 1]) 301 | fig, (axA, axB, ax0, axC, axD) = plt.subplots( 302 | ncols=5, sharey=True, figsize=[10.0, 4.0], gridspec_kw=gridspec) 303 | vals = [oe1, oe2], [axA, axC], [axB, axD], [title, title2] 304 | ax0.set_visible(False) 305 | else: 306 | 307 | gridspec = dict(wspace=0.0, width_ratios=[1, 1, 0.1, 1, 1, 0.1, 1, 1]) 308 | fig, (axA, axB, ax0, axC, axD, ax1, axE, axF) = plt.subplots( 309 | ncols=8, sharey=True, figsize=[12.0, 4.0], gridspec_kw=gridspec) 310 | vals = [oe1, oe2, oe3], [axA, axC, axE], [ 311 | axB, axD, axF], [title, title2, title3] 312 | ax0.set_visible(False) 313 | ax1.set_visible(False) 314 | 315 | for oe, ax1, ax2, tit in zip(*vals): 316 | 317 | t_op, q_op = splitTQ(oe.x_op) 318 | t_op_err, q_op_err = splitTQ(oe.x_op_err) 319 | t_a, q_a = splitTQ(oe.x_a) 320 | t_a_err, q_a_err = splitTQ(oe.x_a_err) 321 | t_truth, q_truth = splitTQ(oe.x_truth) 322 | 323 | nProf = len(t_op) 324 | 325 | if h is None: 326 | hvar = t_op.index 327 | else: 328 | hvar = h 329 | 330 | ax1.plot(t_op, hvar, color='C0', label='Optimal') 331 | ax1.fill_betweenx(hvar, t_op+t_op_err, t_op-t_op_err, 332 | color='C0', alpha=0.2) 333 | 334 | ax1.plot(t_a, hvar, color='C1', label='Prior') 335 | ax1.fill_betweenx(hvar, t_a+t_a_err, t_a-t_a_err, 336 | color='C1', alpha=0.2) 337 | ax1.plot(t_truth, hvar, color='C2', label='Truth') 338 | 339 | ax2.plot(q_op, hvar, color='C0') 340 | ax2.fill_betweenx(hvar, q_op+q_op_err, q_op-q_op_err, 341 | color='C0', alpha=0.2) 342 | 343 | ax2.plot(q_a, hvar, color='C1') 344 | ax2.fill_betweenx(hvar, q_a+q_a_err, q_a-q_a_err, 345 | color='C1', alpha=0.2) 346 | ax2.plot(q_truth, hvar, color='C2') 347 | 348 | ax1.set_xlabel('Temperature [K]') 349 | ax2.set_xlabel('Specific humidity\n[log$_{10}$(g/kg)]') 350 | 351 | ax1.set_xlim(xlimT) 352 | ax2.set_xlim(xlimH) 353 | 354 | ax1.set_title(tit, loc='left') 355 | 356 | if h is not None: 357 | axA.invert_yaxis() 358 | 359 | axA.set_ylabel(hlabel) 360 | 361 | axA.legend(loc='upper right') 362 | 363 | return fig 364 | 365 | 366 | def q2a(q, p, T): 367 | ''' 368 | specific to absolute humidty 369 | ''' 370 | Rair = 287.04 # J/kg/K 371 | Rvapor = 461.5 # J/kg/K 372 | rho = p / (Rair * T * (1 + (Rvapor / Rair - 1) * q)) # density kg/m3 373 | return q*rho 374 | 375 | 376 | def print_mwr_rms(oe): 377 | T_optimal, Q_optimal = splitTQ(oe.x_op) 378 | T_truth, Q_truth = splitTQ(oe.x_truth) 379 | 380 | print('RMS X Temperature: %g [K]' % 381 | np.sqrt(np.mean((T_optimal - T_truth)**2))) 382 | print('RMS X Humidity: %g [log$_{10}$(g/kg)]' % 383 | np.sqrt(np.mean((10**Q_optimal - 10**Q_truth)**2))) 384 | print('RMS Y %g [K]' % np.sqrt(np.mean((oe.y_obs - oe.y_op)**2))) 385 | 386 | 387 | def plot_uncertainty_dof(oe1, oe2, label2, pressure, oe3=None, label3=None): 388 | 389 | fig, (axA, axB) = plt.subplots(ncols=2, sharey=True, figsize=(6, 4)) 390 | 391 | T, Q = splitTQ(oe1.x_op_err / oe1.x_a_err) 392 | T_2, Q_2 = splitTQ(oe2.x_op_err / oe2.x_a_err) 393 | 394 | axA.plot(T*100, pressure, color='C2', label='Temperature') 395 | axA.plot( 396 | T_2*100, 397 | pressure, 398 | color='C2', 399 | ls='-.', 400 | label='' 401 | ) 402 | 403 | axA.plot( 404 | Q*100, 405 | pressure, 406 | color='C3', 407 | label='Specific humidity') 408 | axA.plot( 409 | Q_2*100, 410 | pressure, 411 | color='C3', 412 | ls='-.', 413 | label='' 414 | ) 415 | 416 | if oe3 is not None: 417 | T_3, Q_3 = splitTQ(oe3.x_op_err / oe3.x_a_err) 418 | axA.plot( 419 | T_3 * 100, 420 | pressure, 421 | color='C2', 422 | ls=':', 423 | label='' 424 | ) 425 | axA.plot( 426 | Q_3 * 100, 427 | pressure, 428 | color='C3', 429 | ls=':', 430 | label='' 431 | ) 432 | 433 | T, Q = [(x) for x in splitTQ(oe1.dgf_x)] 434 | T_2, Q_2 = [(x) for x in splitTQ(oe2.dgf_x)] 435 | 436 | axB.plot(T, pressure, color='C2', label='Temperature') 437 | axB.plot( 438 | T_2, 439 | pressure, 440 | color='C2', 441 | ls='-.', 442 | label=label2) 443 | 444 | axB.plot( 445 | Q, 446 | pressure, 447 | color='C3', 448 | label='Specific humidity') 449 | axB.plot( 450 | Q_2, 451 | pressure, 452 | color='C3', 453 | ls='-.', 454 | label=label2) 455 | if oe3 is not None: 456 | T_3, Q_3 = [(x) for x in splitTQ(oe3.dgf_x)] 457 | axB.plot( 458 | T_3, 459 | pressure, 460 | color='C2', 461 | ls=':', 462 | label=label3) 463 | 464 | axB.plot( 465 | Q_3, 466 | pressure, 467 | color='C3', 468 | ls=':', 469 | label=label3) 470 | 471 | axA.legend(frameon=False, loc='upper left') 472 | # axB.legend(frameon=False) 473 | 474 | lines = [matplotlib.lines.Line2D( 475 | [0], [0], color='gray', linestyle=ls) for ls in ['-', '-.', ':']] 476 | labels = ['reference', label2, label3] 477 | if oe3 is None: 478 | lines.pop() 479 | labels.pop() 480 | 481 | axB.legend(lines, labels, frameon=False, loc='upper right') 482 | 483 | axB.set_xlabel('Degrees of freedom [-]') 484 | axA.set_xlabel('Optimal to prior uncertainty [%]') 485 | 486 | axA.set_ylabel('Pressure [hPa]') 487 | axA.invert_yaxis() 488 | axA.set_xlim(-5, 110) 489 | 490 | axA.text(0.99, 0.99, 491 | 'a)', 492 | horizontalalignment='right', 493 | verticalalignment='top', 494 | transform=axA.transAxes 495 | ) 496 | axB.text(0.99, 0.99, 497 | 'b)', 498 | horizontalalignment='right', 499 | verticalalignment='top', 500 | transform=axB.transAxes 501 | ) 502 | fig.subplots_adjust(wspace=0.05) 503 | 504 | return fig 505 | --------------------------------------------------------------------------------