6.4. datasyncΒΆ

Shift and resample excel-tables; see https://co2mpas.io/usage.html#synchronizing-time-series

Usage:

datasync template [-f] [–cycle <cycle>] <excel-file-path>... datasync [-v | -q | –logconf=<conf-file>] [–force | -f]

[–interp <method>] [–no-clone] [–prefix-cols] [-O <output>] <x-label> <y-label> <ref-table> [<sync-table> ...] [-i=<label=interp> ...]

datasync [-v | -q | –logconf=<conf-file>] (–version | -V) datasync (–interp-methods | -l) datasync –help

Options:
<x-label> Column-name of the common x-axis (e.g. ‘times’) to be
re-sampled if needed.
<y-label> Column-name of y-axis cross-correlated between all
<sync-table> and <ref-table>.
<ref-table> The reference table, in xl-ref notation (usually
given as file#sheet!); synced columns will be appended into this table. The captured table must contain <x_label> & <y_label> as column labels. If hash(#) symbol missing, assumed as file-path and the table is read from its 1st sheet .
<sync-table> Sheets to be synced in relation to <ref-table>, also in
xl-ref notation. All tables must contain <x_label> & <y_label> as column labels. Each xlref may omit file or sheet-name parts; in that case, those from the previous xlref(s) are reused. If hash(#) symbol missing, assumed as sheet-name. If none given, all non-empty sheets of <ref-table> are synced against the 1st one.
-O=<output> Output folder or file path to write the results

[default: .]:

  • Non-existent path: taken as the new file-path; fails if intermediate folders do not exist, unless –force.
  • Existent file: file-path to overwrite if –force, fails otherwise.
  • Existent folder: writes a new file <ref-file>.sync<.ext> in that folder; –force required if that file exists.
-f, --force Overwrite excel-file(s) and create any missing intermediate folders.
--prefix-cols Prefix all synced column names with their source sheet-names. By default, only clashing column-names are prefixed.
--no-clone Do not clone excel-sheets contained in <ref-table> workbook into output.
--interp=<method>
 Interpolation method used in the resampling for all signals [default: linear]: ‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’ are passed to scipy.interpolate.interp1d. ‘spline’ and ‘polynomial’ require also to specify an order (int), e.g. –interp=spline3. ‘pchip’ and ‘akima’ are wrappers around the scipy interpolation methods of similar names. ‘integral’ is respecting the signal integral.
-i=<label=interp> Interpolation method used in the resampling for a
signal with a specific label (e.g., -i alternator_currents=integral).
-l, --interp-methods
 List of all interpolation methods that can be used in the resampling.
--cycle=<cycle>
 If set (e.g., –cycle=nedc.manual), the <ref-table> is populated with the theoretical velocity profile. Options: ‘nedc.manual’, ‘nedc.automatic’, ‘wltp.class1’, ‘wltp.class2’, ‘wltp.class3a’, and ‘wltp.class3b’.

<excel-file-path> Output file.

Miscellaneous:
-h, --help Show this help message and exit.
-V, --version Print version of the program, with –verbose list release-date and installation details.
-v, --verbose Print more verbosely messages - overridden by –logconf.
-q, --quiet Print less verbosely messages (warnings) - overridden by –logconf.
--logconf=<conf-file>
 Path to a logging-configuration file, according to: See https://docs.python.org/3/library/logging.config.html#configuration-file-format Uses reads a dict-schema if file ends with ‘.yaml’ or ‘.yml’. See https://docs.python.org/3.5/library/logging.config.html#logging-config-dictschema
SUB-COMMANDS:
template Generate “empty” input-file for the datasync cmd as
<excel-file-path>.

Examples:

## Read the full contents from all `wbook.xlsx` sheets as tables and
## sync their columns using the table from the 1st sheet as reference:
datasync times velocities folder/Book.xlsx

## Sync `Sheet1` using `Sheet3` as reference:
datasync times velocities wbook.xlsx#Sheet3!  Sheet1!

## The same as above but with integers used to index excel-sheets.
## NOTE that sheet-indices are zero based!
datasync times velocities wbook.xlsx#2! 0

## Complex Xlr-ref example:
## Read the table in sheet2 of wbook-2 starting at D5 cell
## or more Down 'n Right if that was empty, till Down n Right,
## and sync this based on 1st sheet of wbook-1:
datasync times velocities wbook-1.xlsx  wbook-2.xlsx#0!D5(DR):..(DR)

## Typical usage for CO2MPAS velocity time-series from Dyno and OBD
## (the ref sheet contains the theoretical velocity profile):
datasync template --cycle wltp.class3b template.xlsx
datasync -O ./output times velocities template.xlsx#ref! dyno obd -i alternator_currents=integral -i battery_currents=integral

Functions

compute_shift
cross_correlation_using_fft
do_datasync
param str x_label:
 
integral_interpolation Re-samples data maintaining the signal integral.
main Handles some exceptions politely and returns the exit-code.
polynomial_interpolation
sheet_name
synchronize

Classes

Tables