Commit 43975c39 authored by hazrmard's avatar hazrmard
Browse files

more unit conversions (BTU, Tons), conversion stops after first field name match

parent d4155c48
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ Python package/script for downloading trends from Building Logix Data Exchange (
## Installation

```
pip install git+https://git.isis.vanderbilt.edu/SmartBuildings/bdx@v0.2.0
pip install git+https://git.isis.vanderbilt.edu/SmartBuildings/bdx@v0.2.1
```

## Usage
@@ -63,7 +63,7 @@ dataframe = get_trend(trend_id='2422',
from bdx import apply_heuristics

dataframe, left = apply_heuristiccs(dataframe)
print('The following fields did not match and were note converted:', left)
print('The following fields did not match and were not converted:', left)

```

+3 −2
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ def get_trend(trend_id: str, username: str, password: str, start: datetime,
    end : datetime
        datetime.datetime object. If no timezone specified, converted to UTC.
    aggregation : str, optional
        Aggregation level for trend, by default 'Point'
        Aggregation level for trend. One of 'Point', 'Hourly', 'Daily, 'Weekly',
        'Monthly. By default 'Point'

    Returns
    -------
+9 −3
Original line number Diff line number Diff line
@@ -14,16 +14,21 @@ from typing import Tuple, List, Callable

import pandas as pd

from .thermo import f2k, gpm2m3s, psi2pa

from .thermo import f2k, gpm2m3s, psi2pa, btuhr2w, ton2w

# Patterns in order of preference. If a patternn is matched, later patterns
# are not considered.
# TODO: units for: SCHWP_Campus_CHW_Supply_SP Value, Chiller_*_Runtime Value
HEURISTICS = (
    ('_Temp|Temp$|_Humidity|Wet_Bulb',      f2k),
    ('Percent',                             lambda pct: 0.01 * pct),
    ('KW_Ton',                              lambda kw: kw),
    ('Kw$',                                 lambda kw: 1000 * kw),
    ('Power$',                              lambda p: p),
    ('Percent$',                            lambda pct: 0.01 * pct),
    ('Flow$',                               gpm2m3s),
    ('Press$',                              psi2pa),
    ('Load_Btuh',                           btuhr2w),
    ('Load_Tons|Load\sValue|_Capacity',     ton2w)
)


@@ -56,6 +61,7 @@ def apply_heuristics(df: pd.DataFrame,
            if re.search(pattern, column) is not None:
                matched = True
                df[column] = func(df[column])
                break
        if not matched:
            left.append(column)
    return df, left
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ from distutils.core import setup


setup(name='bdx',
      version='0.2.0',
      version='0.2.1',
      description='Download trends from Building Logix data exchange (BDX)',
      author='Ibrahim Ahmed',
      author_email='ibrahim.ahmed@vanderbilt.edu',