• Stars
    star
    12
  • Rank 1,597,372 (Top 32 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created almost 10 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python package to calculate degree days (DD or in french DJU - degré jour unifié) from measured outdoor temperatures and to make it possible to quantify drift of energy consumption for heating (or cooling)

Welcome to pandas_degreedays's documentation!

Latest Version Supported Python versions Wheel format License Development Status Downloads monthly Requirements Status Documentation Status Sourcegraph Gitter Code Health Build Status

pandas_degreedays

Pandas Degree Days (pandas_degreedays) is a Python package to calculate degree days.

Usage

You must provide a Pandas Series with temperature values.

Let's call ts_temp this Serie which looks like:

datetime
2014-03-20 23:00:00    11
2014-03-20 23:30:00    11
2014-03-21 00:00:00    11
2014-03-21 00:30:00    11
2014-03-21 01:00:00    11
2014-03-21 01:30:00    11
...
2014-11-01 20:00:00    12
2014-11-01 20:30:00    12
2014-11-01 21:00:00    12
2014-11-01 21:30:00    12
2014-11-01 22:00:00    12
2014-11-01 22:30:00    12
Name: temp, Length: 10757

You can get a time serie with temperature in sample folder and read it using:

import pandas as pd
filename = 'temperature_sample.xls'
df_temp = pd.read_excel(filename)
df_temp = df_temp.set_index('datetime')
ts_temp = df_temp['temp']

You can also fetch a time serie with temperature from OpenWeatherMap.org. You need to install first openweathermap_requests.

import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
from pandas_degreedays.provider import TemperatureProvider
api_key = 'YOUR_API_KEY'
ts_temp = TemperatureProvider('OpenWeatherMap', api_key=api_key).get_from_coordinates(0.34189, 46.5798114, '20150101', '20150915')
#ts_temp = TemperatureProvider('OpenWeatherMap', api_key=api_key).get_from_place('Poitiers,FR', '20150101', '20150915')

We can see if some data are missing using:

idx = ts_temp.index
s_idx = pd.Series(idx, index=idx)
diff_idx = s_idx-s_idx.shift(1)
s_sampling_period = diff_idx.value_counts()
sampling_period = s_sampling_period.index[0] # most prevalent sampling period
not_sampling_period = (diff_idx != sampling_period) # True / False

We can interpolate linearly missing data using:

from pandas_degreedays import inter_lin_nan 
ts_temp = inter_lin_nan(ts_temp, '1H') # interpolates linearly NaN

We can calculate degree days using:

from pandas_degreedays import calculate_dd
df_degreedays = calculate_dd(ts_temp, method='pro', typ='heating', Tref=18.0, group='yearly')

method can be:

  • 'pro' (energy professionals) - this is default calculation method
  • 'meteo'

typ (calculation type) can be :

  • 'heating' - this is default calculation type
  • 'cooling'

Tref is reference temperature - default value is 18.0

group can be:

  • 'yearly' - this is default grouping option
  • 'yearly10' - same as 'yearly' but year starts in October (10)
  • 'monthly'
  • 'weekly'
  • None
  • Any lambda function that can be use and that can be applied to a datetime:

Example:

from pandas_degreedays import yearly_month
df_degreedays = calculate_dd(ts_temp, method='pro', typ='heating', Tref=18.0, group=lambda dt: yearly_month(dt, 10))

It outputs a Pandas DataFrame with degree days like:

Tmin  Tmax   Tavg  Tref         DD      DD_cum
2014-03-22 7.0 11.0 9.00 18 9.000000 9.000000
2014-03-23 3.0 12.0 7.50 18 10.500000 19.500000
2014-03-24 0.0 10.0 5.00 18 13.000000 32.500000
2014-03-25 6.0 10.0 8.00 18 10.000000 42.500000
2014-03-26 5.0 12.0 8.50 18 9.500000 52.000000
2014-03-27 2.0 8.0 5.00 18 13.000000 65.000000
... ... ... ... ... ... ...
2014-10-26 5.0 17.0 11.00 18 7.000000 653.547663
2014-10-27 9.0 22.0 15.50 18 3.336923 656.884586
2014-10-28 7.5 20.0 13.75 18 4.544400 661.428986
2014-10-29 8.0 19.0 13.50 18 4.618182 666.047168
2014-10-30 12.0 22.0 17.00 18 1.992000 668.039168
2014-10-31 11.0 24.0 17.50 18 2.143077 670.182245

[224 rows x 6 columns]

You can display plot using:

from pandas_degreedays import plot_temp
plot_temp(ts_temp, df_degreedays)

About Pandas

pandas is a Python package providing fast, flexible, and expressive data structures designed to make working with "relational" or "labeled" data both easy and intuitive. It's a very convenient library to work with time series.

Install

From Python package index

$ pip install pandas_degreedays

From source

Get latest version using Git

$ git clone https://github.com/scls19fr/pandas_degreedays.git
$ cd pandas_degreedays
$ python setup.py install

Links

More Repositories

1

pyade

Unofficial Python library to use ADE Web API for ADE Planning from Adesoft
Python
14
star
2

pandas-helper-calc

Helper methods for Pandas Series and DataFrames to calculate numerically derivative and integral
Python
9
star
3

ExtensibleScheduler.jl

An advanced and extensible Julia events scheduler. https://scls19fr.github.io/ExtensibleScheduler.jl/dev/
Julia
8
star
4

numpy-buffer

A Python NumPy implementation of ring buffer (aka circular buffer)
Python
7
star
5

python-lms-tools

Python library to manage quiz format(s) used by differents Learning management system (LMS) especially Moodle (currently only Aiken format is supported)
Python
6
star
6

openweathermap_requests

Python package to fetch data from OpenWeatherMap.org with requests and requests-cache
Python
5
star
7

pycondor

Python script to manage Condor Soaring files such as tasks (flight plans)
Python
5
star
8

GPX.jl

A Julia GPX parser (ie reader) and creator (ie writer). GPX (GPS eXchange Format) is an XML based file format for GPS tracks.
Julia
5
star
9

Pushover.jl

A simple Pushover client for Julia https://scls19fr.github.io/Pushover.jl/dev
Julia
4
star
10

Sched.jl

A Julia event scheduler inspired by Python sched. https://scls19fr.github.io/Sched.jl/dev/
Julia
4
star
11

pandas-anonymizer

Some functions to anonymize data with Python Pandas
Python
4
star
12

wnb

Weight and balance progressive web application for light aircrafts (SEP, gliders...)
TypeScript
2
star
13

morse-listen

[WIP] Decoding morse code using Python, Machine Learning...
Python
2
star
14

arduino_libraries_search

Python Pandas script to search for Arduino libraries matching some keywords and to output to Excel file
Python
2
star
15

KMLTracks.jl

A Julia library to parse KML files or strings (ie read them) with gx:Track extension
Julia
2
star
16

simulator_keypad

C++
1
star
17

CakeLocale

Project containing a translation effort for the CakePHP core
1
star
18

python-airac

Python library to deal with AIRAC cycle dates
Python
1
star
19

AIRAC.jl

Julia library to deal with AIRAC cycle dates
Julia
1
star
20

openphysic

PHP
1
star
21

polaires_excel

Fichier Excel polaire des vitesses (planeur)
1
star
22

email-verif

A Python email validator. Verify if an email address is valid and really exists.
Python
1
star
23

tkinter_matplotlib_sample

A Python Tkinter example with Matplotlib integration
Python
1
star
24

JuliaVagrant

A Vagrant environment for Julia development (Linux Ubuntu host)
1
star
25

BulkSMS.jl

A Julia package to send SMS (Short Message Service) using BulkSMS API https://scls19fr.github.io/BulkSMS.jl/dev
Julia
1
star
26

web_scraping_sia_python

Unofficial Python library to scrape SIA (Service de l'information aéronautique) website
Python
1
star
27

sia_lua

Unofficial Lua library to download VAC from SIA (Service de l'information aéronautique) website
Lua
1
star
28

Nextion.jl

An unofficial Julia library to communicate with Itead Nextion display
Julia
1
star