-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
I've been playing with this library for a little bit now and it seems like the majority of models I am trying to run require an athlete to be defined for the df.
I've been able to do this, but can't figure out how to calculate the CP for that athlete.
Is calculating the CP for an athlete based off previous workout data something this library supports, or is it required that you define the CP for the athlete when assigning to a df.
The code shows cp as an optional argument, but leaving it blank causes a runtime error:
session, engine = db_connect()
# May need to filter on max power grouped by interval
df = pd.read_sql(
sql=session.query(stravaBestSamples.interval.label('time'),
stravaBestSamples.heartrate,
stravaBestSamples.cadence,
stravaBestSamples.velocity_smooth.label('speed'),
func.max(stravaBestSamples.best_power).label('power')).
group_by(stravaBestSamples.interval).
filter(or_(stravaBestSamples.interval == 180,
stravaBestSamples.interval == 420,
stravaBestSamples.interval == 720),
stravaBestSamples.type == 'Ride',
# stravaBestSamples.timestamp_local >= '2020-02-01'
).statement, con=engine)
engine.dispose()
session.close()
wdf = WorkoutDataFrame(df)
wdf.athlete = Athlete(name='Ethan') # , cp=175, w_prime=20000)
wdf.compute_w_prime_balance()
print(wdf.athlete.cp)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2.1\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2.1\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Ethan/PycharmProjects/fitness/index.py", line 254, in <module>
test()
File "C:\Users\Ethan\PycharmProjects\fitness\pages\pandasTesting.py", line 37, in test
wdf.compute_w_prime_balance()
File "C:\Users\Ethan\PycharmProjects\fitness\venv\lib\site-packages\sweat\io\models\dataframes.py", line 35, in compute_w_prime_balance
self.athlete.w_prime, algorithm, *args, **kwargs)
File "C:\Users\Ethan\PycharmProjects\fitness\venv\lib\site-packages\sweat\pdm\w_prime_balance.py", line 112, in w_prime_balance
return method(power, cp, w_prime, *args, **kwargs)
File "C:\Users\Ethan\PycharmProjects\fitness\venv\lib\site-packages\sweat\pdm\w_prime_balance.py", line 46, in w_prime_balance_waterworth
tau = get_tau_method(power, cp, tau_dynamic, tau_value)
File "C:\Users\Ethan\PycharmProjects\fitness\venv\lib\site-packages\sweat\pdm\w_prime_balance.py", line 25, in get_tau_method
static_tau = tau_w_prime_balance(power, cp)
File "C:\Users\Ethan\PycharmProjects\fitness\venv\lib\site-packages\sweat\pdm\w_prime_balance.py", line 14, in tau_w_prime_balance
delta_cp = cp - avg_power_below_cp
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels