{ "cells": [ { "cell_type": "markdown", "id": "bd8b250a", "metadata": {}, "source": [ "# Intro\n", "Let's make station data easier!" ] }, { "cell_type": "markdown", "id": "ec8b8e2d", "metadata": {}, "source": [ "## Install and structure" ] }, { "cell_type": "markdown", "id": "3edd86b1", "metadata": {}, "source": [ "This is a walkthrough of the installation, importing, and general structure of metloom" ] }, { "cell_type": "markdown", "id": "38b6fe0c", "metadata": {}, "source": [ "## But first, why?\n", "\n", "What datasources have you used for accessing station data before?\n", "\n", "What is difficult about accessing data from multiple sources?" ] }, { "cell_type": "markdown", "id": "3e6d6019", "metadata": {}, "source": [ "## The goal\n", "The goal of metloom is consistent, simple sampling of meteorology and snow related point measurments from a variety of datasources" ] }, { "cell_type": "markdown", "id": "c7642440", "metadata": {}, "source": [ "## Install\n", "metloom is available on pypi and can be installed by running" ] }, { "cell_type": "code", "execution_count": null, "id": "7d0e39f1", "metadata": {}, "outputs": [], "source": [ "!pip install metloom\n", "\n", "try:\n", " import matplotlib\n", "except Exception as e:\n", " !pip install matplotlib" ] }, { "cell_type": "markdown", "id": "63adbe7c", "metadata": {}, "source": [ "## Importing\n", "The core components of metloom are the pointdata and the variables. \n", "\n", "Each point data class is tailored to a specific datasource and extends the base class found\n", "[here](https://github.com/M3Works/metloom/blob/main/metloom/pointdata/base.py#L64).\n", "Each variable class is made up of the variables known for a specific datasource and extends the base variable\n", "class found [here](https://github.com/M3Works/metloom/blob/main/metloom/variables.py#L16).\n", "\n", "Note: the variables are not an exhaustive list for each source. The class is extensible so we can add new variables as needed. We will cover how to do that later in the tutorial." ] }, { "cell_type": "code", "execution_count": null, "id": "9ca9c560", "metadata": {}, "outputs": [], "source": [ "# import the pointdata classes\n", "from metloom.pointdata import (\n", " PointData, CDECPointData, SnotelPointData, MesowestPointData, USGSPointData\n", ")\n", "# import the variable classes\n", "from metloom.variables import (\n", " SensorDescription, CdecStationVariables, SnotelVariables, MesowestVariables, USGSVariables\n", ")" ] }, { "cell_type": "markdown", "id": "a83f6115", "metadata": {}, "source": [ "Let's explore the base classes and see what methods are available to us.\n", "\n", "## Variables\n", "\n", "Each variable class is made up of `SensorDescription`s. The sensor descriptions specify the \n", "variable code used by the datasource, the name of the variable, and a description of the variable.\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "31490ffc", "metadata": {}, "outputs": [], "source": [ "sensor = CdecStationVariables.SWE\n", "print(\n", " f\"THe SWE sensor has code {sensor.code}, \"\n", " f\"name {sensor.name}, and description {sensor.description}\"\n", ")\n" ] }, { "cell_type": "markdown", "id": "1b18f3e0", "metadata": {}, "source": [ "The goal with sensor descriptions is that sensors representing the same property should have the same name. This allows us to access the same variable seamlessly across multiple networks." ] }, { "cell_type": "code", "execution_count": null, "id": "a620e511", "metadata": {}, "outputs": [], "source": [ "# The sensors represent SWE in inches, so the name is the same\n", "print(CdecStationVariables.SWE.name)\n", "print(SnotelVariables.SWE.name)\n", "\n", "# The sensors represent accumulated precip in inches, so the name is the same\n", "print(CdecStationVariables.PRECIPITATIONACCUM.name)\n", "print(SnotelVariables.PRECIPITATIONACCUM.name)" ] }, { "cell_type": "markdown", "id": "d0358a36", "metadata": {}, "source": [ "## Point data" ] }, { "cell_type": "markdown", "id": "ae27888f", "metadata": { "tags": [] }, "source": [ "The pointdata class has a number of attributes and methods available to us\n", "\n", "### Attributes\n", " * ALLOWED_VARIABLES\n", " * tzinfo\n", " * metdata\n", " \n", "### Methods\n", " * get_daily_data\n", " * get_hourly_data\n", " * get_snow_course_data\n", " \n", "### Class method\n", " * points_from_geometry" ] }, { "cell_type": "code", "execution_count": null, "id": "6fd6bccf", "metadata": {}, "outputs": [], "source": [ "# Let's explore the attributes for Red Mountain Pass SNOTEL 713:CO:SNTL\n", "\n", "# a station requires a code and a name (the name can be anything)\n", "point = SnotelPointData(\"713:CO:SNTL\", \"Red Mountain Pass\")\n", "\n", "print(f\"Name: {point.name}\")\n", "print(f\"ID: {point.id}\")\n", "print(f\"Allowed Variables: {point.ALLOWED_VARIABLES}\")\n", "print(f\"location: {point.metadata}\")\n", "print(f\"tzinfo: {point.tzinfo}\")" ] }, { "cell_type": "markdown", "id": "836aa3a7", "metadata": {}, "source": [ "## Knowledge check\n", "How would you find the latitude and longitude for the `Banner Summit` SNOTEL with code `312:ID:SNTL`?" ] }, { "cell_type": "code", "execution_count": null, "id": "9ed33099", "metadata": {}, "outputs": [], "source": [ "# Your work here\n" ] }, { "cell_type": "markdown", "id": "f4d6868a", "metadata": {}, "source": [ "### Note\n", "**This is an opensource, free project, so we love your participation!**\n", "\n", "Suggest new datasources, report bugs, and even contribute code\n", "\n", "https://github.com/M3Works/metloom/issues\n" ] }, { "cell_type": "markdown", "id": "7085593a", "metadata": {}, "source": [ "In the next section we will work on actually pulling data!\n" ] }, { "cell_type": "code", "execution_count": null, "id": "10fdcace", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.18" } }, "nbformat": 4, "nbformat_minor": 5 }