From bd0b7ea82873a8dd578ad67b959c9738c7591033 Mon Sep 17 00:00:00 2001 From: Dominic Ferrando Date: Tue, 16 Sep 2025 02:39:32 -0400 Subject: [PATCH] Finish up initial weight generator logic --- calculator/calc.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/calculator/calc.ts b/calculator/calc.ts index c48de8c..01ff38f 100644 --- a/calculator/calc.ts +++ b/calculator/calc.ts @@ -213,6 +213,11 @@ export class Standards { const minWeight = referenceWeight - (weightGenerator.step * weightGenerator.spread); const maxWeight = referenceWeight + (weightGenerator.step * weightGenerator.spread); + const referenceStandard = this + .byActivity(activity) + .byMetrics({ weight: referenceWeight, gender: gender, age: age }) + .getInterpolated(); + let currWeight = minWeight; while (currWeight <= maxWeight) { const newStandard: Standard = { @@ -225,12 +230,8 @@ export class Standards { }; // apply allometric scaling to generate levels - const referenceStandard = this - .byActivity(activity) - .byMetrics({ weight: referenceWeight, gender: gender, age: age }) - .getInterpolated(); for (const lvl in referenceStandard.levels) { - const scalingExponent = .125; + const scalingExponent = .1; const coefficient = weightGenerator.ratio === "inverse" ? referenceWeight / currWeight : currWeight / referenceWeight; @@ -249,7 +250,12 @@ export class Standards { } } } + + // now that we generated metric data, remove the old data + this.activityStandards[activity].standards = this.activityStandards[activity].standards + .filter(s => s.metrics.weight !== -1); } + } Bun.write("./newStandards.json", JSON.stringify(this.activityStandards, null, 2));