Private
Public Access
1
0

dataprep -> plep

This commit is contained in:
2024-04-10 21:37:31 +02:00
parent 1a48e73a6f
commit 2a9beb7a25
5 changed files with 28 additions and 29 deletions

View File

@@ -392,7 +392,7 @@ def resample(id, r, parent, overwrite='copy'):
row.write_csv(parent.csvfilename, gzip=True)
_ = dataprep(row.df, id=parent.id, bands=True, barchart=True,
_ = dataplep(row.df, id=parent.id, bands=True, barchart=True,
otwpower=True, empower=True, inboard=parent.inboard)
isbreakthrough, ishard = checkbreakthrough(parent, r)
_ = check_marker(parent)
@@ -1397,7 +1397,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
w.team.add(t)
# put stroke data in database
_ = dataprep(row.df, id=w.id, bands=True,
_ = dataplep(row.df, id=w.id, bands=True,
barchart=True, otwpower=True, empower=True, inboard=inboard)
isbreakthrough, ishard = checkbreakthrough(w, r)

View File

@@ -1367,7 +1367,7 @@ def delete_strokedata(id, debug=False):
def update_strokedata(id, df, debug=False):
delete_strokedata(id, debug=debug)
_ = dataprep(df, id=id, bands=True, barchart=True, otwpower=True)
_ = dataplep(df, id=id, bands=True, barchart=True, otwpower=True)
# Test that all data are of a numerical time
@@ -1395,7 +1395,7 @@ def getrowdata_db(id=0, doclean=False, convertnewtons=True,
if data.empty:
rowdata, row = getrowdata(id=id)
if not rowdata.empty: # pragma: no cover
data = dataprep(rowdata.df, id=id, bands=True,
data = dataplep(rowdata.df, id=id, bands=True,
barchart=True, otwpower=True)
else:
data = pd.DataFrame() # returning empty dataframe
@@ -1425,7 +1425,7 @@ def getrowdata_pl(id=0, doclean=False, convertnewtons=True,
if data.is_empty():
rowdata, row = getrowdata(id=id)
if not rowdata.empty: # pragma: no cover
data = dataprep(rowdata.df, id=id, bands=True,
data = dataplep(rowdata.df, id=id, bands=True,
barchart=True, otwpower=True, polars=True)
else:
data = pl.DataFrame() # returning empty dataframe
@@ -1471,7 +1471,7 @@ def getsmallrowdata_pl(columns, ids=[], doclean=True, workstrokesonly=True, comp
except:
pass
if rowdata and len(rowdata.df):
_ = dataprep(rowdata.df, id=id,
_ = dataplep(rowdata.df, id=id,
bands=True, otwpower=True, barchart=True,
polars=True)
try:
@@ -1491,7 +1491,7 @@ def getsmallrowdata_pl(columns, ids=[], doclean=True, workstrokesonly=True, comp
except (OSError, IndexError, ArrowInvalid):
rowdata, row = getrowdata(id=ids[0])
if rowdata and len(rowdata.df): # pragma: no cover
data = dataprep(
data = dataplep(
rowdata.df, id=ids[0], bands=True, otwpower=True, barchart=True)
try:
df = pl.read_parquet(csvfilenames[0], columns=columns)
@@ -1502,7 +1502,7 @@ def getsmallrowdata_pl(columns, ids=[], doclean=True, workstrokesonly=True, comp
except:
rowdata, row = getrowdata(id=ids[0])
if rowdata and len(rowdata.df): # pragma: no cover
data = dataprep(
data = dataplep(
rowdata.df, id=ids[0], bands=True, otwpower=True, barchart=True)
try:
df = pl.read_parquet(csvfilenames[0], columns=columns)
@@ -1554,7 +1554,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True, comp
except (OSError, ArrowInvalid, IndexError): # pragma: no cover
rowdata, row = getrowdata(id=id)
if rowdata and len(rowdata.df):
_ = dataprep(rowdata.df, id=id,
_ = dataplep(rowdata.df, id=id,
bands=True, otwpower=True, barchart=True)
try:
df = pd.read_parquet(f, columns=columns)
@@ -1573,7 +1573,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True, comp
except (OSError, IndexError, ArrowInvalid):
rowdata, row = getrowdata(id=ids[0])
if rowdata and len(rowdata.df): # pragma: no cover
data = dataprep(
data = dataplep(
rowdata.df, id=ids[0], bands=True, otwpower=True, barchart=True)
try:
df = pd.read_parquet(csvfilenames[0], columns=columns)
@@ -1584,7 +1584,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True, comp
except:
rowdata, row = getrowdata(id=ids[0])
if rowdata and len(rowdata.df): # pragma: no cover
data = dataprep(
data = dataplep(
rowdata.df, id=ids[0], bands=True, otwpower=True, barchart=True)
try:
df = pd.read_parquet(csvfilenames[0], columns=columns)
@@ -1651,7 +1651,7 @@ def prepmultipledata(ids, verbose=False): # pragma: no cover
if verbose:
print(id)
if rowdata and len(rowdata.df):
_ = dataprep(rowdata.df, id=id, bands=True,
_ = dataplep(rowdata.df, id=id, bands=True,
barchart=True, otwpower=True)
return ids
@@ -1722,7 +1722,7 @@ def read_cols_df_sql(ids, columns, convertnewtons=True):
except OSError:
rowdata, row = getrowdata(id=ids[0])
if rowdata and len(rowdata.df):
_ = dataprep(rowdata.df,
_ = dataplep(rowdata.df,
id=ids[0], bands=True, otwpower=True, barchart=True)
pq_file = pq.ParquetDataset(filename)
columns_in_file = [c for c in columns if c in pq_file.schema.names]
@@ -1740,7 +1740,7 @@ def read_cols_df_sql(ids, columns, convertnewtons=True):
except (OSError, IndexError, ArrowInvalid):
rowdata, row = getrowdata(id=id)
if rowdata and len(rowdata.df): # pragma: no cover
_ = dataprep(rowdata.df, id=id,
_ = dataplep(rowdata.df, id=id,
bands=True, otwpower=True, barchart=True)
pq_file = pq.ParquetDataset(f)
columns_in_file = [c for c in columns if c in pq_file.schema.names]
@@ -1789,7 +1789,7 @@ def read_df_sql(id, polars=False):
except:
pass
if rowdata and len(rowdata.df):
_ = dataprep(rowdata.df, id=id,
_ = dataplep(rowdata.df, id=id,
bands=True, otwpower=True, barchart=True,
polars=True)
try:
@@ -1805,7 +1805,7 @@ def read_df_sql(id, polars=False):
except (OSError, ArrowInvalid, IndexError): # pragma: no cover
rowdata, row = getrowdata(id=id)
if rowdata and len(rowdata.df):
data = dataprep(rowdata.df, id=id, bands=True,
data = dataplep(rowdata.df, id=id, bands=True,
otwpower=True, barchart=True)
try:
df = pd.read_parquet(f)
@@ -1973,7 +1973,9 @@ def add_efficiency(id=0): # pragma: no cover
# Takes a rowingdata object's DataFrame as input
# polars
def dataplep(rowdatadf, id=0, inboard=0.88, forceunit='lbs'):
def dataplep(rowdatadf, id=0, inboard=0.88, forceunit='lbs', bands=True, barchart=True, otwpower=True,
empower=True, debug=False, polars=True
):
# rowdatadf is pd.DataFrame
if rowdatadf.empty:
return 0
@@ -2082,6 +2084,8 @@ def dataplep(rowdatadf, id=0, inboard=0.88, forceunit='lbs'):
arclength = (inboard - 0.05) * (np.radians(finish) - np.radians(catch))
if arclength.mean() > 0:
drivelength = arclength
else:
drivelength = data['drivelength']
slip = df['slip']
totalangle = finish - catch
@@ -2108,10 +2112,6 @@ def dataplep(rowdatadf, id=0, inboard=0.88, forceunit='lbs'):
peakforceangle = savgol_filter(peakforceangle, windowsize, 3)
except TypeError: # pragma: no cover
pass
try:
driveenergy = savgol_filter(driveenergy, windowsize, 3)
except TypeError: # pragma: no cover
pass
try:
drivelength = savgol_filter(drivelength, windowsize, 3)
except TypeError: # pragma: no cover
@@ -2131,7 +2131,6 @@ def dataplep(rowdatadf, id=0, inboard=0.88, forceunit='lbs'):
slip = slip,
finish = finish,
peakforceangle = peakforceangle,
driveenergy = driveenergy,
drivelength = drivelength,
totalangle = totalangle,
effectiveangle = effectiveangle,
@@ -2598,7 +2597,7 @@ def add_c2_stroke_data_db(strokedata, workoutid, starttimeunix, csvfilename,
compression='gzip')
data = dataprep(df, id=workoutid, bands=False, debug=debug)
data = dataplep(df, id=workoutid, bands=False, debug=debug)
return data
@@ -2666,7 +2665,7 @@ def create_c2_stroke_data_db(
_ = df.to_csv(csvfilename, index_label='index', compression='gzip')
data = dataprep(df, id=workoutid, bands=False, debug=debug)
data = dataplep(df, id=workoutid, bands=False, debug=debug)
return data
@@ -2705,7 +2704,7 @@ def update_empower(id, inboard, oarlength, boattype, df, f1, debug=False): # pr
if debug: # pragma: no cover
print("not updated ", id)
_ = dataprep(df, id=id, bands=True, barchart=True, otwpower=True, debug=debug)
_ = dataplep(df, id=id, bands=True, barchart=True, otwpower=True, debug=debug)
row = rrdata(df=df)
row.write_csv(f1, gzip=True)

Binary file not shown.

View File

@@ -743,7 +743,7 @@ def strokedatajson_v2(request, id):
powerperc=powerperc, powerzones=r.powerzones)
rowdata = rdata(csvfile=row.csvfilename, rower=rr).df
datadf = dataprep.dataprep(
datadf = dataprep.dataplep(
rowdata, id=row.id, bands=True, barchart=True, otwpower=True, empower=True)
_ = myqueue(queuehigh, handle_calctrimp, row.id,
@@ -910,7 +910,7 @@ def strokedatajson(request, id=0):
powerperc=powerperc, powerzones=r.powerzones)
rowdata = rdata(csvfile=row.csvfilename, rower=rr).df
datadf = dataprep.dataprep(
datadf = dataprep.dataplep(
rowdata, id=row.id, bands=True, barchart=True, otwpower=True, empower=True)
# mangling

View File

@@ -1293,7 +1293,7 @@ def remove_power_view(request, id=0):
row = rdata(csvfile=f, rower=rr)
row.df[' Power (watts)'] = 0
row.write_csv(f)
_ = dataprep.dataprep(row.df, id=workout.id)
_ = dataprep.dataplep(row.df, id=workout.id)
cpdf, delta, cpvalues = dataprep.setcp(workout)
workout.normp = 0
@@ -3599,7 +3599,7 @@ def workout_erase_column_view(request, id=0, column=''):
row.write_csv(w.csvfilename, gzip=True)
row, workout = dataprep.getrowdata(id=w.id)
_ = dataprep.dataprep(row.df, id=w.id)
_ = dataprep.dataplep(row.df, id=w.id)
if column == 'hr':
w.hrtss = 0