{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Infrared Sensor Data Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import numpy as np\n", "import xarray as xr\n", "import warnings\n", "from osirisl1services.readlevel1 import open_level1_ir\n", "from osirisl1services.services import Level1Services\n", "import matplotlib.pyplot as plt\n", "from matplotlib.colors import LogNorm\n", "from scipy.interpolate import interp1d\n", "\n", "FIG_SIZE = (15, 6)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load the IR data for orbit 6432, scan 12" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "channel = 1\n", "ir = open_level1_ir(orbit=6432, channel=channel)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The data and added variables are returned as xarray Datasets" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(ir)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The corresponding pointing, position, tangent point, and sza info can be accessed through the 'l1' xarray accessor" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(ir.l1.look_ecef)\n", "print(ir.l1.position_ecef)\n", "print(ir.l1.altitude)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot the data vs pixel" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "warnings.filterwarnings('ignore')\n", "\n", "ir.data.plot(x='mjd', y='pixel', norm=LogNorm(), vmin=1e8, vmax=1e15, figsize=FIG_SIZE)\n", "plt.ylim(127, 20) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot the data vs altitude" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "alts = np.arange(10000., 90000., 250.)\n", "ir_altitude = []\n", "for (data, alt) in zip(ir.data, ir.l1.altitude):\n", " f = interp1d(alt, data, bounds_error=False)\n", " ir_altitude.append(f(alts))\n", "ir_altitude = xr.DataArray(ir_altitude, coords=[ir.mjd, alts], dims=['mjd', 'altitude'])\n", "ir_altitude.plot(x='mjd', y='altitude', norm=LogNorm(), vmin=1e10, vmax=1e12, figsize=FIG_SIZE)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot just night-time data vs altitude (be patient, calculating the sza's takes a minute)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ir_night = ir.where(ir.l1.sza > 90.)\n", "ir_night_altitudes = ir.l1.altitude.where(ir.l1.sza > 90.)\n", "\n", "alts = np.arange(50000., 90000., 250.)\n", "ir_altitude = []\n", "for (data, alt) in zip(ir_night.data, ir_night_altitudes):\n", " f = interp1d(alt, data, bounds_error=False)\n", " ir_altitude.append(f(alts))\n", "ir_altitude = xr.DataArray(ir_altitude, coords=[ir.mjd, alts], dims=['mjd', 'altitude'])\n", "ir_altitude.plot(x='mjd', y='altitude', norm=LogNorm(), vmin=1e10, vmax=1e12, figsize=FIG_SIZE)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.1" } }, "nbformat": 4, "nbformat_minor": 1 }