LionelDarras / PyCampbellCR1000

Communication tools for Campbell CR1000-type Datalogger http://pycampbellcr1000.readthedocs.org
GNU General Public License v3.0
43 stars 32 forks source link

PyCampbellCR1000 : Query the Campbell CR1000-type Dataloggers

PyCampbellCR1000 is a python project which aims to allow the communication with Campbell CR1000 Type Datalogger

The main features include automatic collecting of data and settings (read only) as a list of dictionnaries.

The tool can be used in your python scripts for data post-processing, or in command line mode to collect data as CSV.

We don't update anything from PyCampbellCR1000 besides time, because we are assuming that the dataloggers are already configured.

Note: PyCampbellCR1000 uses the PyLink <http://pypi.python.org/pypi/PyLink>_ lib, offers a universal communication interface with File-Like API.

Examples

We init communication by giving the datalogger URL.

::

from pycampbellcr1000 import CR1000 device = CR1000.from_url('tcp:host-ip:port')

or with Serial connection

device = CR1000.from_url('serial:/dev/ttyUSB0:38400')

To get time, use:

::

device.gettime() datetime.datetime(2012, 7, 16, 12, 27, 55)

To get data, you have to enter the table name where it is stored. If you don't know the table name, you cannot collect the list of available tables in the datalogger.

::

device.list_tables() ['Status', 'Table1', 'Public']

Choose the time period to get your data from start date to stop date.

::

import datetime start = datetime.datetime(2012, 7, 16, 11, 0, 0) stop = datetime.datetime(2012, 7, 16, 12, 0, 0) data = device.get_data('Table1', start, stop) data[0]["Datetime"] datetime.datetime(2012, 7, 16, 11, 0)

::

data[0]["CurSensor1_mVolt_Avg"] 2508.0

::

print(data.filter(('Datetime', 'CurSensor3_mAmp_Avg')).to_csv()) Datetime,CurSensor3_mAmp_Avg 2012-07-16 11:00:00,18.7 2012-07-16 11:01:00,18.48 ... 2012-07-16 11:59:00,17.25

Features

Installation

You can install, upgrade, uninstall PyCampbellCR1000 with these commands

::

$ pip install pycampbellcr1000
$ pip install --upgrade pycampbellcr1000
$ pip uninstall pycampbellcr1000

Or if you don't have pip

::

$ easy_install pycampbellcr1000

Or you can get the source code from github <https://github.com/LionelDarras/PyCampbellCR1000>_.

::

$ git clone https://github.com/LionelDarras/PyCampbellCR1000.git $ cd PyCampbellCR1000 $ python setup.py install

Documentation

See documentation here: http://pycampbellcr1000.readthedocs.org