Coder Social home page Coder Social logo

climtas's Introduction

climtas

CircleCI Codecov Read the Docs (latest) Conda

Functions for working with large (> 10 GB) datasets using Xarray and Dask, especially for working in the time domain

Topics

Climtas' blocked resample and groupby operations use array reshaping, rather than Xarray's default slicing methods. This results in a much simpler and efficient Dask graph, at the cost of some restrictions to the data (the data must be regularly spaced and start/end on a resampling boundary)

Example notebook: ERA-5 90th percentile climatology

Walltime of Climtas climatology vs xarray

>>> import numpy; import pandas; import xarray
>>> time = pandas.date_range("20010101", "20030101", closed="left")
>>> data = numpy.random.rand(len(time))
>>> da = xarray.DataArray(data, coords=[("time", time)])
>>> da = da.chunk({"time": 365})

>>> from climtas import blocked_groupby
>>> blocked_groupby(da, time='dayofyear').mean()
<xarray.DataArray 'stack-...' (dayofyear: 366)>
dask.array<mean_agg-aggregate, shape=(366,), dtype=float64, chunksize=(365,), chunktype=numpy.ndarray>
Coordinates:
  * dayofyear  (dayofyear) int64 1 2 3 4 5 6 7 8 ... 360 361 362 363 364 365 366

Climtas includes a number of parallelised building blocks for heatwave detection

>>> from climtas.event import find_events, map_events
>>> temp = xarray.DataArray([28,31,34,32,30,35,39], dims=['time'])
>>> events = find_events(temp > 30)
>>> sums = map_events(temp, events, lambda x: {'sum': x.sum().item()})
>>> events.join(sums)
   time  event_duration  sum
0     1               3   97
1     5               2   74

Climtas' throttled saver reduces memory usage, by limiting the number of Dask output chunks that get processed at one time

Examples

See the examples in the notebooks directory for mores ideas on how to use these functions to analyse large datasets

climtas's People

Contributors

scottwales 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.