{ "cells": [ { "cell_type": "markdown", "id": "eca6269f-0925-467f-9dfc-2baf2f102936", "metadata": {}, "source": [ "# Particle Size Distributions" ] }, { "cell_type": "code", "execution_count": null, "id": "4ad96665-60b8-46ba-ba1d-a91b215cff9b", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import os\n", "import pyarts3 as pyarts\n", "pyarts.arts.globals.parameters.datapath.append(\"/home/simon/data/arts-xml-data\")" ] }, { "cell_type": "code", "execution_count": null, "id": "0168afb8-3507-4810-82c3-a1e404b6ded3", "metadata": {}, "outputs": [], "source": [ "ws = pyarts.Workspace()\n", "ws.surface_fieldPlanet(option=\"Earth\")\n", "ws.surface_field[pyarts.arts.SurfaceKey(\"t\")] = 295.0\n", "ws.atmospheric_fieldRead(\n", " toa=100e3, basename=\"planets/Earth/afgl/tropical/\", missing_is_zero=1\n", ")\n", "ws.atmospheric_fieldIGRF(time=\"2000-03-11 14:39:37\")" ] }, { "cell_type": "markdown", "id": "66e48730-7be6-4cfe-9ade-f287cd06068b", "metadata": {}, "source": [ "## Single-moment Modified Gamma Distribution" ] }, { "cell_type": "code", "execution_count": null, "id": "1251a55c-4fc4-4267-9963-a2d837668287", "metadata": {}, "outputs": [], "source": [ "from pyarts3.arts import MGDSingleMoment, ScatteringSpeciesProperty, ParticulateProperty, AtmPoint\n", "\n", "rain_first_moment = pyarts.arts.ScatteringSpeciesProperty(\"rain\", pyarts.arts.ParticulateProperty(\"MassDensity\"))\n", "psd = MGDSingleMoment(rain_first_moment, \"Field19\", 270, 300, False)\n", "\n", "point = AtmPoint()\n", "point[\"t\"] = 280\n", "point[rain_first_moment] = 1e-3\n", "\n", "sizes = np.logspace(-6, -3, 101)\n", "pnd = psd.evaluate(point, sizes, 1.0, 1.0)" ] }, { "cell_type": "code", "execution_count": null, "id": "a9e1aad5-8ce9-45c2-b0f5-426de3f2913c", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "plt.plot(sizes, pnd)\n", "plt.yscale(\"log\")\n", "plt.xscale(\"log\")\n", "plt.xlabel(\"Particle Size\")\n", "plt.ylabel(\"Particle Number Density\")" ] }, { "cell_type": "markdown", "id": "78fa74da-8d16-4350-bfdd-32ed7b47b4fc", "metadata": {}, "source": [ "## Binned particles size distribution" ] }, { "cell_type": "code", "execution_count": null, "id": "4a9a7083-3522-404a-81fe-4349d89ffcaa", "metadata": {}, "outputs": [], "source": [ "from pyarts3.arts import BinnedPSD, SizeParameter" ] }, { "cell_type": "code", "execution_count": null, "id": "2db75f97-5326-48c8-ad06-451839aa57cc", "metadata": {}, "outputs": [], "source": [ "bins = [1e-5, 1e-4, 1e-3]\n", "counts = [1e6, 1e3]\n", "psd = BinnedPSD(SizeParameter(\"DVeq\"), bins, counts, 273.15, 300)\n", "sizes = np.logspace(-6, -3, 101)\n", "pnd = psd.evaluate(point, sizes, 1.0, 1.0)" ] }, { "cell_type": "code", "execution_count": null, "id": "aca6633d-73a9-432b-bfc3-5150f24f168c", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "plt.plot(sizes, pnd)\n", "plt.yscale(\"log\")\n", "plt.xscale(\"log\")\n", "plt.xlabel(\"Particle Size\")\n", "plt.ylabel(\"Particle Number Density\")" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.10" } }, "nbformat": 4, "nbformat_minor": 5 }