A simple module for reading various datalogger output files
Project description
About
Dataloggers for environmental science data can be configured to output text files in any number of flavours. Differences in date format, separator, and metadata can make it hard to easily open datalogger files for further processing. A script that one scientist uses to read their files can fail when trying to open files that were configured differently, even when the data are from a sensor of the same make and model. This makes it harder for scientists to share data and use a common set of tools for quality control and analysis of observational data.
LoggerRead is a library of text-file readers for permafrost-related dataloggers meant to open files effortly as pandas dataframes. Instead of trying to make a single csv-reader that can handle any format, LoggerRead treats each datalogger separately; this makes it possible to open files automatically with greater confidence that they're being read properly. LoggerRead can be used as a standalone library for interactive data analysis and exploration, or can be integrated into other programs. Currently, data from the following sensors are supported:
- GeoPrecision (GP5W)
- GeoPrecision (FG2)
- Onset HOBO (HOBOware)
Installation
To install LoggerReader, the simplest way is to use pip
:
pip install LoggerReader
If you would prefer to install the lastest version from the source code,
git clone https://github.com/nicholas512/LoggerRead
cd LoggerRead
python setup.py develop
Consider using a virtual environment, because some dependencies are installed.
Using LoggerReader
The class used to read logger data must be selected depending on what kind of instrument the data comes from. However, each reader behaves the same way. They all have the .read()
method that takes the file name as an argument. You can create a reader first and then call the .read()
method, or just run everything on one line. For Geoprecision FG for instance:
FG2().read(file)
OR
reader = FG2()
data = reader.read(file)
Some datalogger types may require other information in order to read the file correctly.
GeoPrecision
Geoprecision logger format differs between the FG2 and GP5W variants. To read a GeoPrecision file, use either the FG2 or GP5W object
FG2
FG2 is the newer software for GeoPrecision instruments:
from LoggerReader.readers import FG2
from pkg_resources import resource_filename
fg2_file = resource_filename("LoggerReader", "sample_files/FG2_399.csv")
# Read an FG2 file
FG2().read(fg2_file)
GP5W
GP5W is the older software for GeoPrecision instruments:
from LoggerReader.readers import GP5W
from pkg_resources import resource_filename
gp5w_file = resource_filename("LoggerReader", "sample_files/GP5W_260.csv")
# To read a file, you might first create a reader object
reader = GP5W()
reader.read(gp5w_file)
# Or instead, read the data in one line
data = GP5W().read(gp5w_file)
HOBO
Because of the variability of HOBOWare CSV exports, the HOBO reader relies on on a HOBOProperties configuration object. This can be configured manually (most reliable) or autodetected from a file.
The HOBOProperties configuration object
from LoggerReader.readers import HOBOProperties
from pkg_resources import resource_filename
from pathlib import Path
# Autodetect file structure
hobo_file = resource_filename("LoggerReader", "sample_files/hobo_1_AB_classic.csv")
P = HOBOProperties.autodetect(hobo_file)
print(P)
# HOBOWare 'default' format
print(HOBOProperties.defaults())
# HOBOWare 'classic' format
print(HOBOProperties.classic())
# Custom format (unspecified properties are defaults)
P = HOBOProperties(date_separator=",",
date_format="YMD",
include_line_number=True,
include_plot_details=False,
no_quotes_or_commas=False,
separate_date_time=False)
print(P)
savepath = Path(Path.home(), "custom_hobo_properties.json")
P.write(savepath) # Save to file
# Read from a saved file
Q = HOBOProperties.from_file(savepath) # Read from a file
print(Q)
Reading HOBO files with the HOBO object
from LoggerReader.readers import HOBO, HOBOProperties
from pathlib import Path
from pkg_resources import resource_filename
classic_file = resource_filename("LoggerReader", "sample_files/hobo_1_AB_classic.csv")
defaults_file = resource_filename("LoggerReader", "sample_files/hobo_1_AB_defaults.csv")
# To autodetect HOBOWare Properties:
data = HOBO().read(defaults_file)
# To manually specify a the HOBOWare configuration, initialize the HOBO reader with a HOBOProperties object
classic_file = resource_filename("LoggerReader", "sample_files/hobo_1_AB_classic.csv")
classic_properties = HOBOProperties.classic()
hobo = HOBO(classic_properties)
data = hobo.read(classic_file)
Format
Reader objects save csv data in a pandas dataframe stored as the DATA
attribute. Column titles are left unchanged with the exception of the datetime column which is renamed to TIME
. It is always the first column in the dataframe.
Where possible, any metadata that is found in the file is stored in a META
attribute.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file LoggerReader-0.1.1.tar.gz
.
File metadata
- Download URL: LoggerReader-0.1.1.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b3fd8b727b06780182acf74be4750a3b36fb8c3b3d3390ad80aff70709fb3dd |
|
MD5 | afa3d246dcfe1cac799d8f880106b641 |
|
BLAKE2b-256 | 6634b2881b42089c677c15c6ed7fd19ea8feb2d6e62d961b0883bfd6d2711f81 |
File details
Details for the file LoggerReader-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: LoggerReader-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e73be9f070ccb97ca04b458430ee0c7d1d1be3fe40fc7a0dc43045f1746e497f |
|
MD5 | 2b6075ab1ac32bb170f8e6d8819ea83c |
|
BLAKE2b-256 | 362c3357bd11f7d74fe77f9c4b6963b2386c664a1ad5d581c516e012d4850c03 |