alturaPredictiveMaintenanceExt

Altura functions for predictive maintenance
alturaPredictiveMaintenanceExtAxon funcs

Registered StackHub users may elect to receive email notifications whenever a new package version is released or a comment is posted on the forum.

There are 0 watchers.

v0.1

prma_demoGen
prma_demoGen(dictToAll: {}, opts: {})
prma_filter_applyModelsOnAHis
prma_filter_applyModelsOnAHis(modelPaths, hisAirFlow, filterRec, spanTrain, opts: {})

Invalid annotation [] [fandoc:5] - "- filterRec: dict with the following keys {id, filterRecurringInfo: {path: uri}}"

Invalid annotation [] [fandoc:10] - " - boundOnFan: Number[]. Default value: [0, posInf()]}"

Invalid annotation [] [fandoc:11] - ""

Apply a regression models on a history. Return a hisGrid of regression and save the same hisGrid to file.

Inputs

  • modelsPath: dict with the following key: power_vs_dp_and_flow, dp_vs_flow
  • hisAirFlow: hisGrid with only columns ["ts", "v0"] or a hisGrid with multiple columns, one column must be "airFlow"
  • filterRec: dict with the following keys {id, filterRecurringInfo: {path: uri}}
  • spanTrain: null or Span. Used to save model name.
  • opts: {
    • debugMode: Bool. Default value: false
    • boundOnDp: Number[]. Default value: [0, posInf()]}
    • boundOnFan: Number[]. Default value: [0, posInf()]}

See also prma_trainModelOnATimeSpan

Outputs

  • hisPredict: hisGrid. If debugMode is true, show all the columns. If debugMode is false, have only ts and modelFan

Side effect: write the results to Zinc file. The path of the Zinc file is specified in filterRec->filterRecurringInfo.

Example

do
  /*Setup*/
  recs: prma_demoGen({tt_2021June23_07h20});
  recsB: readAll(tt_2021June23_07h20);
  diff(recsB.find(filterToFunc(campus)), {dis: "Test prma_applyModelsOnAHis"}).commit;
  projSync();
  prefilterRec: read(tt_2021June23_07h20 and navName == "prefilter information");
  trainPreFilterDict: prma_filter_trainModelOnATimeSpan(prefilterRec, 2021-05-10..2021-05-24, {});

  finalfilteRec: read(tt_2021June23_07h20 and navName == "final filter information");
  trainFinalFilterDict: prma_filter_trainModelOnATimeSpan(finalfilteRec, 2021-05-10..2021-05-24, {});
  projSync();
  /*- - -*/
  /*Run the function on the representative supply air flow*/
  hisTs: hisSlidingWindows(2021-06, 1min, 1h).keepCols(["ts"]);
  hisSupFlow: read(tt_2021June23_07h20 and navName == "supply air flow (calc)")
                .hisRead(2021-05)
                .hisClip
                .hisFindAll(v=> v.isNumber and v!= nan())
                .util_hisWeeklyProfile(avg,
                hisTs);
  resOut: prma_filter_applyModelsOnAHis(trainPreFilterDict, hisSupFlow, prefilterRec, null, {debugMode: true});


end

/*Clean up*/
readAll(tt_2021June23_07h20).util_helper_clearHisRemoveRecs

Author

  • Gia Nguyen

©Altura Associates 2021

prma_filter_applyRegrModels
prma_filter_applyRegrModels(filterRec, hisA, opts: {})

Invalid annotation [] [fandoc:13] - " - boundOnFan: Number[]. Default value: [0, posInf()]}"

Invalid annotation [] [fandoc:14] - ""

Apply regression models to determine supply fan power.

Steps:

  • Use model dp_vs_flow on history data of airFlowSquare to determine pressure drop across filter when filter is new
  • Calculate the product (dp_new_filter * air flow)
  • Calculate power use by applying model power_vs_dp_and_flow

Inputs

  • filterRec: Dict. The filter record have all the information needed. This function use the content of filterChangeInfo.
  • hisA: hisGrid with the following columns: airFlow, airFlowSquare
  • opts: {
    • debugMode: Bool. Default value: false,
    • boundOnDp: Number[]. Default value: [0, posInf()]}
    • boundOnFan: Number[]. Default value: [0, posInf()]}

Outputs

  • hisB: hisGrid of applying regression models of opts->usModels

Side effect

Example

do
  filterRec: read(tt_2021June04_07h46 and filterChangeInfo and navName == "prefilter information");
  hisA: prma_filter_getHis(filterRec,[2021-03-15..today()])[0];
  /*Assuming the model in filterRec is trained*/
  prma_filter_applyRegrModels(filterRec, hisA)

end

Author

  • Gia Nguyen

©Altura Associates 2021

prma_filter_calculateCostReplacement
prma_filter_calculateCostReplacement(filterChangeInfo, hisTs, opts: {})

Invalid annotation [] [fandoc:10] - ""

Calculate cost of replacement of filters

Inputs

  • filterChangeInfo: Dict[] or Grid with column dateChange and costReplacementRef
  • hisTs: a hisGrid with column ts
  • opts: {
    • debugMode: Bool. Def value: false,
    • colTime: "dateChange"
    • colRef: "costReplacementRef"
    • keyOnRefRec: Str[]. DefVal: ["partCost", "laborCost", "otherCost"]}

Outputs

  • hisB: The cost of replacement on the nth day

Example

do
  costReplacement: [{id: refGen(), prmaReplacementCost,
                  partCost: 82$,laborCost: 1090$, otherCost: 50$},
                  {id: refGen(), prmaReplacementCost,
                  partCost: 100$, laborCost: 1500$, otherCost: 50$},
                  ].toGrid.map(r=> r.merge({tt_2021June30_11h27}));
  costReplacement.stream.map(r=> diff(null, r, {add})).commit;

  filterChangeInfo: util_toGridFromList(
    [[2021-01-01, `io/`, costReplacement[0]->id, @elec],
    [2021-02-01, `io/`, costReplacement[1]->id, @elec],
    ],
    ["dateChange", "filePath", "costReplacementRef", "costElecRef"]);
  hisTs: hisSlidingWindows(2021-01-01..2021-02-05, 1min, 1day)
          .keepCols(["ts"])

  prma_filter_calculateCostReplacement(filterChangeInfo, hisTs)

end

/*To remove*/
readAll(tt_2021June30_11h27).edit_commit("remove")

Author

  • Gia Nguyen

©Altura Associates 2021

prma_filter_calculateOperatingCost
prma_filter_calculateOperatingCost(filterChangeInfo, hisA, opts: {})

Invalid annotation [] [fandoc:15] - ""

Calculate the operation cost by

  • looking up unit cost of electricity
  • mulitiplying the unit cost of electricy to energy usage

If the unit cost of electricity hase the field unit and is consistent with value on his, simplify the output. For example, given {utilityCost: 0.1$, unit: "kWh"} and v0: 1kWh, the output will be 0.1$. The exapmle of inconsistent unit is when v0: 1m, the output will be 0.1$_m/kWh

Inputs

  • filterChangeInfo: Dict[] or Grid with column dateChange and costElecRef
  • hisA: a hisGrid with column ts and a second column of v0
  • opts: {
    • debugMode: Bool. Def value: false,
    • colTime: "dateChange",
    • colRef: "costElecRef",
    • keyOnRefRec: Str[]. DefVal: ["utilityCost"]}

Outputs

  • hisGrid

Example

do
  elecCost: [{id: refGen(), utilityCost: 0.1$, unit: "kWh", description: "2021 Blended rate"},
            {id: refGen(), utilityCost: 0.2$, unit: "kWh", description: "2021 Double blended rate"}
            ].map(r=> r.merge({tt_2021July09_08h16}))
            .edit_commit("new", false, true);

  filterChangeInfo: util_toGridFromList([[2021-03-01, elecCost[0]->id],
                    [2021-04-01, elecCost[1]->id]],
                    ["dateChange", "costElecRef"]).toRecList;
  hisA: hisSlidingWindows(2021-03-01..2021-05-01, 1min, 15day)
          .hisMap(v=> 1kW);
  projSync();
  res: prma_filter_calculateOperatingCost(filterChangeInfo, hisA);
  readAll(tt_2021July09_08h16).edit_commit("remove");
  res;
end

Author

  • Gia Nguyen

©Altura Associates 2021

prma_filter_getHis
prma_filter_getHis(filterRec, datesA, opts: {})

Invalid annotation [] [fandoc:14] - ""

Return history of feature and target using inputs from (i) a dict containing reference on supply air flow, filter dp, supply fan power and (ii) filterInfoRow of date change.

Inputs

  • filterRec: dict containing filterDpPoint, airFlowPoint, fanPowerPoint. Optional calendarRef
  • trainDatesA: Dict, Dict[], date[], span[]. The input must contain the column name "trainDate"
  • opts: A dictionary with the following key
    • hisRollupFunc: r.hisMap(v=> if (v == na()) null else v) .hisRollup(avg, 1h) .hisMap(v=> if (v==null) na() else v) For future improvement, implement a function for checking data availability and interpolate.
    • colDates: "trainDates". Only apply if trainDates is dict or Dict[]
    • selectPoints: Str[], defVal: ["filterDpPoint", "airFlowPoint", "fanPowerPoint"]. The list of columns of the output depends on the selection.

Option selectPoints and corresponding columns are below.

airFlowPoint => airFlow, airFlowSquare

airFlowPoint, filterDpPoint => airFlow, airFlowSquare, filterDp, filterDpXAirFlow

airFlowPoint, filterDpPoint, fanPowerPoint => airFlow, airFlowSquare, filterDp, filterDpXAirFlow, fanPowerPoint

Outputs

  • His[]: A list of his corresponds to train date in each row of filterInfoRows. Each hisGrid contains the history of the points above and the following columns: filterDpXAirFlow, airFlowSquare

Example

prma_filter_getHis(
  {filterDpPoint: @dp,
  airFlowPoint: @af,
  fanPowerPoint: @fp},
  {trainDates: toSpan(2021-01-01..2021-01-15)})

/*Example of using a list of date option selectPoints*/
prma_filter_getHis(read(tt_2021May28_08h47 and predictiveMaintenance and filterChangeInfo),
[2021-04-01..2021-04-15, 2021-05], {selectPoints: ["airFlowPoint"]})

/*Use a list of dict*/
resListOfDict: prma_filter_getHis(read(tt_2021May28_08h47 and predictiveMaintenance and filterChangeInfo),
[{trainDates: toSpan(2021-04)},
{trainDates: toSpan(2021-05)}]
)

Author

  • Gia Nguyen

©Altura Associates 2021

prma_filter_recNew
prma_filter_recNew(dict, commitA: false)

Create a record to contain information for calculating filter predictive maintenance.

Inputs

  • dict: Dict with the input tags: filterDpPoint, airFlowPoint, fanPowerPoint, filterChangeInfo. The tag filterChangeInfo is a grid or a list of records specifying the date change of filter. In addition, user can add on tag calendarRef.
  • commitA: Boolean. Default value: true

Output

  • Records with the tags above and id and points. The tags filterChangeInfo and filterRecurringInfo are for path to store models.

Side effect

If input 'commitA' is true, commit records to database

Example

prma_filter_recNew({filterDpPoint: @dp,
    airFlowPoint: @af,
    fanPowerPoint: @fp,
    filterChangeInfo: [{dateChange: 2021-01-01}, {dateChange: 2021-05-01}].toGrid
    })

Author

  • Gia Nguyen

©Altura Associates 2021

prma_filter_recurringUpdate
prma_filter_recurringUpdate(filterRec, spanMeasuredData, spanSupFlow, spanPredict, opts: {})
prma_filter_trainModelOnATimeSpan
prma_filter_trainModelOnATimeSpan(filterRec, spanTrain, opts: {})

Train a model using the history obtained from a specified span. This function is developed to train recurring models.

See also prma_filter_trainModels.

Inputs:

  • filterRec: Dict with filterDpPoint, airFlowPoint, fanPowerPoint, and optionally calendarRef
  • spanA: span
  • opts: {saveModel: Bool. If true, save model with the root from the tag prmaRecurringInfo}

Output:

  • A dictionary of model: hisRes, dp_vs_flow, power_vs_dp_and_flow, spanTrain

Side effect

  • Save models to disk. The folder is indicated in the tag filterRecurringInfo

Example

/*Setup*/
do
  recs: prma_demoGen({tt_2021June22_07h26});
  recsB: readAll(tt_2021June22_07h26);
  diff(recsB.find(filterToFunc(campus)), {dis: "Test prma_trainModelOnATimeStep"}).commit;
  filterRec: recsB.find(filterToFunc(navName == "prefilter information"));
end
/*- - -*/

/*Run*/
prma_filter_trainModelOnATimeSpan(read(tt_2021June22_07h26 and navName == "prefilter information"),
    2021-05-10..2021-05-24, {})


/*To remove records*/
readAll(tt_2021June22_07h26).util_helper_clearHisRemoveRecs

Author

  • Gia Nguyen

©Altura Associates 2021

prma_filter_trainModels
prma_filter_trainModels(filterRec, filterChangeInfo, writeHis: true)

Given a table of filter records, train the following models: * power vs. flow and dp: power = a * (flow) * dp * dp vs flow: dp: b * (flow)^2

Save the models. The model saved contains the unit of powr and dp.

If model could not create on one row, it will move to the next. The filterRec usually contains the filterChangeInfo. Separate as a separate parameter so I can decide on how many rows to train models.

Inputs

  • filterRec: Dict with filterDpPoint, airFlowPoint, fanPowerPoint, and optionally calendarRef
  • filterChangeInfo: Dict[] or Grid with columns dateChange, trainDates, dp_vs_flow, and power_vs_dp_and_flow

Outputs

  • modelStatsA: list of model statistics

Side effect

  • Train regression models, save the models to files

Example

prma_filter_trainModels(read(tt_2021May31_11h32 and navName == "prefilter information"),
   read(tt_2021May31_11h32 and navName == "prefilter information")->filterChangeInfo
 )

Author

  • Gia Nguyen

©Altura Associates 2021

prma_filter_util_createModelConfig
prma_filter_util_createModelConfig(id, filterChangeInfo, opts: {})

Create path to save model, and dates to train models.

Inputs

  • id: id of the records
  • filterChangeInfo: grid or list of date change
  • opts: {path: "io/prma_filter/"+id,
    colsA: ["dp_vs_flow", "power_vs_dp_and_flow"],
    colDateChange: "dateChange",
    tLengthTrainModel: 2week}

Outputs

  • filterChangeInfoB: taken from input filterChangeInfo and path for files

Example

prma_filter_util_createModelConfig(@idA,
  [{dateChange: 2021-01-01},
  {dateChange: 2021-05-01}])

Author

  • Gia Nguyen

©Altura Associates 2021

prma_filter_util_createRecurringPaths
prma_filter_util_createRecurringPaths(filterRec, spanTrain, spanPredict: null, opts: {})

Invalid annotation [] [fandoc:9] - " }"

Create the file path based on history, name of the files, and the path specified in the tag filterRecurringInfo->path.

Inputs:

  • filterRec: record with the field id and filterRecurringInfo.
  • spanTrain
  • spanPredict
  • opts: { colModels: ["dp_vs_flow", "power_vs_dp_and_flow"], colPredict: ["predict"] }

Outputs

  • dictOfRecurring: {the base of name of other models and "train_res"}

Example

prma_filter_util_createRecurringPaths(
   {id: @p:proj:r:28be9d,
   filterRecurringInfo: {path: `io/prma_filter/28be9d/`}},
   2021-06-01..2021-06-30, 2021-07-01..2021-07-30)

>>{train_res: `io/prma_filter/28be9d/28be9d_train_res_2021-Jun-01_2021-Jun-30.model`
   dp_vs_flow:  `io/prma_filter/28be9d/28be9d_dp_vs_flow_2021-Jun-01_2021-Jun-30.model`,
   power_vs_dp_and_flow: `io/prma_filter/28be9d/28be9d_power_vs_dp_and_flow_2021-Jun-01_2021-Jun-30.model`,
   predict: `io/prma_filter/28be9d/28be9d_train_2021-Jun-01_2021-Jun-15_predict_2021-Jul-01_2021-Jul-30.zinc`}
prma_filter_validateRec
prma_filter_validateRec(rec)
prma_helper_lookup
prma_helper_lookup(ts, tableA, rec, def)
prma_util_version
prma_util_version()

Current version is v0.1 Pod Altura Predictive Maintenance

Published by Altura Associates

Products & Services by Altura Associates

Packages by Altura Associates

Free packages