sample_slope - bruno-beloff/scs_analysis GitHub Wiki
docs > software repositories > scs_analysis > commands > filtering and aggregating data
DESCRIPTION
The sample_slope utility it used to find the slope for a given field in a sequence of JSON documents. Slope is defined as delta value / delta time (in seconds).
The output document replaced the input field with field.cur (the current value) and field.slope. For the initial input document, the corresponding output document's field.slope value is null. A --tally flag specifies the number of rolling samples in the regression.
The --max-interval flag is intended to prevent slope analyses covering long periods such as device downtime.
If the --exclude-incomplete flag is set, then any data prior to the required number of tallies is not output. Where a chain of slope analyses are being performed, the flag should only be used on the last (highest tally) pass.
SYNOPSIS
sample_slope.py -n NAME [-i ISO] [-t TALLY] [-m [DD-]HH:MM[:SS]] [-x] [-p PRECISION] [-v] PATH
Options | |
---|---|
--version | show program's version number and exit |
-h, --help | show this help message and exit |
-n NAME, --name=NAME | slope field name (i.e. '1min') |
-i ISO, --iso-path=ISO | path for ISO 8601 datetime field (default 'rec') |
-t TALLY, --tally=TALLY | compute for rolling TALLY number of data points (default 2) |
-m MAX_INTERVAL, --max-interval=MAX_INTERVAL | restart regression on long intervals |
-x, --exclude-incomplete | exclude incomplete tallies |
-p PRECISION, --prec=PRECISION | precision (default 6 decimal places) |
-v, --verbose | report narrative to stderr |
EXAMPLES
csv_reader.py -v climate-15min.csv | sample_slope.py -v -n 15min -t2 val.hmd | sample_slope.py -v -n 30min -t3 -x val.hmd | csv_writer.py -v climate-15min-slp15-slp30.csv
DOCUMENT EXAMPLE - INPUT
{"rec": "2022-09-13T13:30:00Z", "val": {"hmd": 72.5, "tmp": 22.2, "bar": {"pA": 100.964}}, "ver": 1.0, "tag": "scs-opc-125"}
DOCUMENT EXAMPLE - INPUT
{"rec": "2022-09-13T13:30:00Z", "val": {"hmd": {"cur": 72.5, "slp15min": -0.000111, "slp30min": 0.0005}, "tmp": 22.2, "bar": {"pA": 100.964}}, "ver": 1.0, "tag": "scs-opc-125"}