Project 'orgzell/software/jnum' was moved to 'libzell/software/jnum'. Please update any links and bookmarks that may still have the old path.
jpsreport_#84
The snippet can be accessed without any authentication.
Authored by
Mohcine Chraibi
Velocity calculation by @jaeger1
velocity_methodD.py 1.99 KiB
VEL_IFD = []
VEL = []
RHO = []
for f in range(df['Frame'].min(),df['Frame'].max()):
meanV01 = []
meanV02 = []
density = []
for i in df[df['Frame'] == f]['PersID'].iteritems():
polygons_mA = []
polygons_op = []
polygons_ip = []
# measurement area
poly_ma = df['measurementArea'][i[0]].strip()
# original polygon
poly_op = df['polygon_iterator'][i[0]].strip()
# intersected polygon
poly_ip = df['v'][i[0]].strip()
exec("p_mA = %s"%poly_ma)
exec("p_op = %s"%poly_op)
exec("p_ip = %s"%poly_ip)
pmA = locals()['p_mA']
pop = locals()['p_op']
pip = locals()['p_ip']
polygons_mA.append(pmA)
polygons_op.append(pop)
polygons_ip.append(pip)
Poly_mA = np.array(polygons_mA[0]) / 10000
Poly_op = np.array(polygons_op[0]) / 10000
Poly_ip = np.array(polygons_ip[0]) / 10000
# individual calculation
# velocity
# jupedsim: meanV+=Velocity[temp]*area(v[0]);
vel = df['vel'][i[0]] * Polygon(polygons_ip[0]).area()
meanV01.append(vel)
meanV02.append(df['vel'][i[0]])
# density
# jupedsim: density+=area(v[0])/area(polygon_iterator);
density_ratio = Polygon(polygons_ip[0]).area() / Polygon(polygons_op[0]).area()
density.append(density_ratio)
# calculation
# velocity
mV1 = np.array(meanV01)
mV2 = np.array(meanV02)
# jpsreport: meanV/area(measureArea);
meanV1 = mV1.sum() / Polygon(polygons_mA[0]).area()
meanV2 = mV2.mean()
# jpsreport: density = density/(area(measureArea)*CMtoM*CMtoM);
rho = np.array(density)
rho_mA = rho.sum() / (Polygon(polygons_mA[0]).area() * CMtoM * CMtoM)
RHO.append(rho_mA)
VEL.append(meanV2)
VEL_IFD.append(meanV1)
print('mean velocity IFD: {0:.3f} m/s'.format(meanV1))
print('mean velocity: {0:.3f} m/s'.format(meanV2))
print('mean density: {0:.3f} P/m2'.format(rho_mA))
Please register or sign in to comment