Giter VIP home page Giter VIP logo

Comments (2)

FabianHofmann avatar FabianHofmann commented on June 5, 2024

Here is the code, for reproducibility:

import atlite
import matplotlib.pyplot as plt
import geopandas as gpd
from pathlib import Path
import xarray as xr


pypsa_eur_dir = Path('/home/fabian/vres/py/pypsa-eur/')

chunked = atlite.Cutout('pypsa-eur.nc', chunks={'time':100})
non_chunked = atlite.Cutout('pypsa-eur.nc', chunks=None)

layout = xr.ones_like(chunked.data.height)
kwargs = dict(layout=layout, hour_shift=3)
heat_demand = xr.Dataset(dict(chunked = chunked.heat_demand(**kwargs),
                              non_chunked = non_chunked.heat_demand(**kwargs)))

fig, (ax1, ax2) = plt.subplots(2,1, sharex=True)
heat_demand.to_array(name='Total Heat Demand Europe').plot.line(x='time', ax=ax1)
(chunked.data.temperature.mean(['x', 'y']).resample(time='1D').mean() - 273)\
        .rename('T [°C]').plot.line(ax=ax2)
fig.tight_layout()
fig.savefig('heat_demand_chunked.png')

from atlite.

coroa avatar coroa commented on June 5, 2024

Just a small note to clarify: Atlite v0.0.2 or v0.2 before merging the dask compatibility PR by Fabian had the problem that when they were averaging over days with a active time-shift of f.ex. 2hrs, they would in each window see a day with only 22hrs at the beginning and additional day of 2hrs at the end, over which the averages were computed. This introduced non-unique indices at the boundary as described in #6. One would have had to postprocess these manually by averaging the duplicate entries with the correct weights, ie. use (2*left + 22*right) / 24 at each boundary.

The dask chunks on the other hand know their neighbours and they seem to be combined correctly automatically, so that no postprocessing is necessary, anymore!

from atlite.

Related Issues (20)

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.