Skip to main content

A numpy subclass to read emoncms PHPFINA feeds as numpy array

Project description

PyFina

PyFina is a subclass of numpy np.ndarray to import emoncms PHPFINA feeds as numpy arrays

The pip installer will install any missing requirements (numpy, matplotlib)

PyFina brings the power of numpy to the PHPFINA timeseries, including basic operations and more : addition, soustraction, multiplication, division, min, max, mean, sum, slicing with the bracket operator

Note : any operation on a PyFina object results to a standard numpy nd.array object. The signature of the PyFina object is lost.

It does not prevent to add two PyFina objects of the same size but sampled with different intervals

Installation

python3 -m pip install PyFina

or, for python on Windows

py -m pip install PyFina

Post installation testing

copy the content of test.py, paste it in a blank file on your local machine and save it using the same name.

py test.py

Getting Started

To retrieve metadatas for feed number 1 :

from PyFina import getMeta, PyFina
import matplotlib.pyplot as plt
# classic emoncms feed storage on linux
dir = "/var/opt/emoncms/phpfina"
meta = getMeta(1,dir)
print(meta)

To import the first 8 days of datas, with a sampling interval of 3600 s :

step = 3600
start = meta["start_time"]
window = 8*24*3600
length = meta["npoints"] * meta["interval"]
if window > length:
    window = length
nbpts = window // step
Text = PyFina(1,dir,start,step,nbpts)

To catch the signature of the created PyFina object :

# time start as a unixtimestamp expressed in seconds
print(Text.start)
# step/interval in seconds
print(Text.step)

To plot:

import datetime
import time
localstart = datetime.datetime.fromtimestamp(start)
utcstart = datetime.datetime.utcfromtimestamp(start)
title = "starting on :\nUTC {}\n{} {}".format(utcstart,time.tzname[0],localstart)
plt.subplot(111)
plt.title(title)
plt.ylabel("outdoor Temp °C")
plt.xlabel("time in hours")
plt.plot(Text)
plt.show()

With the above code, the xrange will be expressed in hour, so 192 points will be displayed

To express the xrange in seconds :

xrange = Text.timescale()
plt.subplot(111)
plt.plot(xrange,Text)
plt.show()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfina-0.0.6.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

PyFina-0.0.6-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pyfina-0.0.6.tar.gz.

File metadata

  • Download URL: pyfina-0.0.6.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pyfina-0.0.6.tar.gz
Algorithm Hash digest
SHA256 2da541ae63360bb79e1c22e434c0b9ea3011ebb5216fabe7771620e6cac3faef
MD5 e80624fc07118cd1be0e22610c2dbfaa
BLAKE2b-256 cf76d5fc30994859ea835d2fa9352c49b36856a574655e225aca5e1e9dcdb70a

See more details on using hashes here.

File details

Details for the file PyFina-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: PyFina-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for PyFina-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a3672bccf1c1f7879a3f8226f71932c00cdb3ca4b8603f814ebec8ec93d69bc8
MD5 8088185420f7e5733957449afe24f801
BLAKE2b-256 4c1d63d00ccbe80a1eb80f788b50bf49a86c426c74e0014d5d8d20d865d92e98

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page