Coder Social home page Coder Social logo

jeancarloszambrano / cloudside Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geosyntec/cloudside

0.0 0.0 0.0 6.25 MB

๐ŸŒง Simple weather data visualization and downloads

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

cloudside's Introduction

cloudside: download, assess, and visualize weather data

https://travis-ci.org/Geosyntec/cloudside.svg?branch=master https://codecov.io/gh/Geosyntec/cloudside/branch/master/graph/badge.svg?token=02qkR2vPrK

The problem this is solving

cloudside is a library suited to parsing weather data in the METAR format. METAR is kind of a mess and not very human-readable. Hopefully this makes things a bit easier. What appears to be an official spec on the format can be found here.

Basically I wanted a library that could do something like this:

import cloudside
data = cloudside.asos.get_data('KPDX', '2012-12-01', '2015-05-01', '[email protected]')
fig, rose_data = cloudside.viz.rose(data, magcol="wind_speed", dircol="wind_direction")

KPDX Rose Plot

And so cloudside does that. After installation, you can also directly use it from the command line

$ cloudside get-asos KPDX 2018-01-01 2018-09-30 [email protected]

You can also fetch data from Portland's Hydra Network of rain gauges:

import cloudside
data = cloudside.hydra.get_data('Beaumont')

or from the command line

$ cloudside get-hydra Beaumont

Bigger Example

import pandas
import cloudside

def summarizer(g):
    return pandas.Series({
        'start': g['datetime'].min(),
        'end': g['datetime'].max(),
        'duration_hours': (g['datetime'].max() - g['datetime'].min()).total_seconds() / 3600,
        precip_col: g[precip_col].sum()
    })


def storm_totaller(df):
    return (
        df.query('storm > 0')
          .reset_index()
          .groupby(by=['storm'])
          .apply(summarizer)
          .assign(antecedent_hours=lambda df: (df['start'] - df['end'].shift()).dt.total_seconds() / 3600)
          .assign(ends_on_weekday=lambda df: df['end'].dt.weekday < 5)
    )

data = cloudside.asos.get_data('KPDX', '2012-12-01', '2015-05-01', '[email protected]')
storms = cloudside.storms.parse_record(data, intereventHours=6, outputfreqMinutes=5, precipcol='precip_inches')
storm_stats = storm_totaller(storms)
with pandas.ExcelWriter('output.xlsx') as xl:
    data.to_excel(xl, sheet_name='Weather Data')
    storm_stats.to_excel(xl, sheet_name='Storm Stats')

Basic History

Tom Pollard originally wrote python-metar to parse weather hourly reports as they were posted to the web. Building on top of his original work, cloudside tries to provide an easy way to download and visualize data from ASOS.

You can download cloudside from the repoository from Github.

Dependencies

  • Python 3.6 or greater
  • recent versions of pandas, matplotlib
  • python-metar to actually parse the metar codes
  • Jupyter for running notebook-based examples (optional)
  • pytest for testing (optional)
  • sphinx to build the documentation (optional)

If you're using environments managed through conda (recommended), this will get you started:

conda create --name=cloudside python=3.6 notebook pytest pandas matplotlib requests coverage

Followed by:

conda activate cloudside
conda install metar --channel=conda-forge

Installation

  • Activate your conda environment;
  • Install via pip and git; and
conda activate cloudside
pip install git+https://github.com/Geosyntec/cloudside.git

Testing

Tests are run via pytest. Run them all with:

source activate cloudside # (omit "source" on Windows)
python -c "import cloudside; cloudside.test()"

Documentation

We have HTML docs built with sphinx.

Development status

This is sort of a weekend hack, but I keep adding stuff to it. So, uh, caveat emptor, I guess.

cloudside's People

Contributors

phobson avatar austinorr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.