Python - plotting surface around 3D plot cloud - python

I run computational fluid dynamic simulation and I want to refine my mesh in the areas for which a quantity is superior to a threshold. I manage to extract the point locations so I obtain a list of points describing the areas that correspond to my criteria for refining.
To refine my mesh, I need to provide to the software the external boundaries of the surface (or curve if we are in 2D) that is described by the point cloud.
More particularly, I need to remove all the points that are in the center of the area to get the coordinates of those which are on the boundary. Then I would like to surround the points with a curve.
I found similar post on the forum but the question was to interpolate the point cloud, so not exactly what I want: Fit Curve-Spline to 3D Point Cloud
May you help me to do that ?
Here is a 2D example of point cloud for which I would like to only keep the boundary points and plot the surrounding curve:
0.20215,0.29703,0
0.22857,0.29703,0
0.25526,0.29703,0
0.28221,0.29703,0
0.30943,0.29703,0
0.33692,0.29703,0
0.36469,0.29703,0
0.39273,0.29703,0
0.42106,0.29703,0
0.44966,0.29703,0
0.47856,0.29703,0
0.50774,0.29703,0
0.53722,0.29703,0
0.56699,0.29703,0
0.59706,0.29703,0
0.62742,0.29703,0
0.6581,0.29703,0
0.68907,0.29703,0
0.72036,0.29703,0
0.75196,0.29703,0
0.78388,0.29703,0
0.81612,0.29703,0
0.84868,0.29703,0
0.88156,0.29703,0
0.91478,0.29703,0
0.94832,0.29703,0
0.9822,0.29703,0
1.0164,0.29703,0
1.051,0.29703,0
1.0859,0.29703,0
1.1211,0.29703,0
1.1568,0.29703,0
1.1927,0.29703,0
1.229,0.29703,0
1.2657,0.29703,0
1.3028,0.29703,0
1.3402,0.29703,0
1.378,0.29703,0
1.4162,0.29703,0
1.4548,0.29703,0
1.4937,0.29703,0
1.533,0.29703,0
1.5728,0.29703,0
1.6129,0.29703,0
1.6534,0.29703,0
1.6944,0.29703,0
1.7357,0.29703,0
1.7774,0.29703,0
1.8196,0.29703,0
1.8622,0.29703,0
1.9052,0.29703,0
1.9487,0.29703,0
1.9926,0.29703,0
2.0369,0.29703,0
2.0817,0.29703,0
2.1269,0.29703,0
2.1725,0.29703,0
2.2187,0.29703,0
2.2652,0.29703,0
2.3123,0.29703,0
2.3598,0.29703,0
2.4078,0.29703,0
2.4563,0.29703,0
2.5053,0.29703,0
2.5547,0.29703,0
2.6046,0.29703,0
2.6551,0.29703,0
2.706,0.29703,0
2.7575,0.29703,0
2.8095,0.29703,0
2.862,0.29703,0
2.915,0.29703,0
2.9685,0.29703,0
3.0226,0.29703,0
3.0772,0.29703,0
3.1324,0.29703,0
3.1881,0.29703,0
3.2444,0.29703,0
3.3013,0.29703,0
3.3587,0.29703,0
3.4166,0.29703,0
3.4752,0.29703,0
3.5344,0.29703,0
3.5941,0.29703,0
3.6544,0.29703,0
3.7154,0.29703,0
3.7769,0.29703,0
3.8391,0.29703,0
3.9019,0.29703,0
3.9653,0.29703,0
4.0294,0.29703,0
4.094,0.29703,0
4.1594,0.29703,0
4.2254,0.29703,0
4.292,0.29703,0
4.3593,0.29703,0
4.4273,0.29703,0
4.496,0.29703,0
4.5654,0.29703,0
4.6354,0.29703,0
4.7062,0.29703,0
4.7776,0.29703,0
4.8498,0.29703,0
4.9227,0.29703,0
0.28221,0.28425,0
0.30943,0.28425,0
0.33692,0.28425,0
0.36469,0.28425,0
0.39273,0.28425,0
0.42106,0.28425,0
0.44966,0.28425,0
0.47856,0.28425,0
0.50774,0.28425,0
0.53722,0.28425,0
0.56699,0.28425,0
0.59706,0.28425,0
0.62742,0.28425,0
0.6581,0.28425,0
0.68907,0.28425,0
0.72036,0.28425,0
0.75196,0.28425,0
0.78388,0.28425,0
0.81612,0.28425,0
0.84868,0.28425,0
0.88156,0.28425,0
0.91478,0.28425,0
0.94832,0.28425,0
0.9822,0.28425,0
1.0164,0.28425,0
1.051,0.28425,0
1.0859,0.28425,0
1.1211,0.28425,0
1.1568,0.28425,0
1.1927,0.28425,0
1.229,0.28425,0
1.2657,0.28425,0
1.3028,0.28425,0
1.3402,0.28425,0
1.378,0.28425,0
1.4162,0.28425,0
1.4548,0.28425,0
1.4937,0.28425,0
1.533,0.28425,0
1.5728,0.28425,0
1.6129,0.28425,0
1.6534,0.28425,0
1.6944,0.28425,0
1.7357,0.28425,0
1.7774,0.28425,0
1.8196,0.28425,0
1.8622,0.28425,0
1.9052,0.28425,0
1.9487,0.28425,0
1.9926,0.28425,0
2.0369,0.28425,0
2.0817,0.28425,0
2.1269,0.28425,0
2.1725,0.28425,0
2.2187,0.28425,0
2.2652,0.28425,0
2.3123,0.28425,0
2.3598,0.28425,0
2.4078,0.28425,0
2.4563,0.28425,0
2.5053,0.28425,0
2.5547,0.28425,0
2.6046,0.28425,0
2.6551,0.28425,0
2.706,0.28425,0
2.7575,0.28425,0
2.8095,0.28425,0
2.862,0.28425,0
2.915,0.28425,0
2.9685,0.28425,0
3.0226,0.28425,0
3.0772,0.28425,0
3.1324,0.28425,0
3.1881,0.28425,0
3.2444,0.28425,0
3.3013,0.28425,0
3.3587,0.28425,0
3.4166,0.28425,0
3.4752,0.28425,0
3.5344,0.28425,0
3.5941,0.28425,0
3.6544,0.28425,0
3.7154,0.28425,0
3.7769,0.28425,0
3.8391,0.28425,0
3.9019,0.28425,0
3.9653,0.28425,0
4.0294,0.28425,0
4.094,0.28425,0
4.1594,0.28425,0
4.2254,0.28425,0
4.292,0.28425,0
4.3593,0.28425,0
4.4273,0.28425,0
4.496,0.28425,0
4.5654,0.28425,0
0.39273,0.27117,0
0.42106,0.27117,0
0.44966,0.27117,0
0.47856,0.27117,0
0.50774,0.27117,0
0.53722,0.27117,0
0.56699,0.27117,0
0.59706,0.27117,0
0.62742,0.27117,0
0.6581,0.27117,0
0.68907,0.27117,0
0.72036,0.27117,0
0.75196,0.27117,0
0.78388,0.27117,0
0.81612,0.27117,0
0.84868,0.27117,0
0.88156,0.27117,0
0.91478,0.27117,0
0.94832,0.27117,0
0.9822,0.27117,0
1.0164,0.27117,0
1.051,0.27117,0
1.0859,0.27117,0
1.1211,0.27117,0
1.1568,0.27117,0
1.1927,0.27117,0
1.229,0.27117,0
1.2657,0.27117,0
1.3028,0.27117,0
1.3402,0.27117,0
1.378,0.27117,0
1.4162,0.27117,0
1.4548,0.27117,0
1.4937,0.27117,0
1.533,0.27117,0
1.5728,0.27117,0
1.6129,0.27117,0
1.6534,0.27117,0
1.6944,0.27117,0
1.7357,0.27117,0
1.7774,0.27117,0
1.8196,0.27117,0
1.8622,0.27117,0
1.9052,0.27117,0
1.9487,0.27117,0
1.9926,0.27117,0
2.0369,0.27117,0
2.0817,0.27117,0
2.1269,0.27117,0
2.1725,0.27117,0
2.2187,0.27117,0
2.2652,0.27117,0
2.3123,0.27117,0
2.3598,0.27117,0
2.4078,0.27117,0
2.4563,0.27117,0
2.5053,0.27117,0
2.5547,0.27117,0
2.6046,0.27117,0
2.6551,0.27117,0
2.706,0.27117,0
2.7575,0.27117,0
2.8095,0.27117,0
2.862,0.27117,0
2.915,0.27117,0
2.9685,0.27117,0
3.0226,0.27117,0
3.0772,0.27117,0
3.1324,0.27117,0
3.1881,0.27117,0
3.2444,0.27117,0
3.3013,0.27117,0
3.3587,0.27117,0
3.4166,0.27117,0
3.4752,0.27117,0
3.5344,0.27117,0
3.5941,0.27117,0
3.6544,0.27117,0
3.7154,0.27117,0
3.7769,0.27117,0
3.8391,0.27117,0
3.9019,0.27117,0
3.9653,0.27117,0
4.0294,0.27117,0
4.094,0.27117,0
4.1594,0.27117,0
0.47856,0.25781,0
0.50774,0.25781,0
0.53722,0.25781,0
0.56699,0.25781,0
0.59706,0.25781,0
0.62742,0.25781,0
0.6581,0.25781,0
0.68907,0.25781,0
0.72036,0.25781,0
0.75196,0.25781,0
0.78388,0.25781,0
0.81612,0.25781,0
0.84868,0.25781,0
0.88156,0.25781,0
0.91478,0.25781,0
0.94832,0.25781,0
0.9822,0.25781,0
1.0164,0.25781,0
1.051,0.25781,0
1.0859,0.25781,0
1.1211,0.25781,0
1.1568,0.25781,0
1.1927,0.25781,0
1.229,0.25781,0
1.2657,0.25781,0
1.3028,0.25781,0
1.3402,0.25781,0
1.378,0.25781,0
1.4162,0.25781,0
1.4548,0.25781,0
1.4937,0.25781,0
1.533,0.25781,0
1.5728,0.25781,0
1.6129,0.25781,0
1.6534,0.25781,0
1.6944,0.25781,0
1.7357,0.25781,0
1.7774,0.25781,0
1.8196,0.25781,0
1.8622,0.25781,0
1.9052,0.25781,0
1.9487,0.25781,0
1.9926,0.25781,0
2.0369,0.25781,0
2.0817,0.25781,0
2.1269,0.25781,0
2.1725,0.25781,0
2.2187,0.25781,0
2.2652,0.25781,0
2.3123,0.25781,0
2.3598,0.25781,0
2.4078,0.25781,0
2.4563,0.25781,0
2.5053,0.25781,0
2.5547,0.25781,0
2.6046,0.25781,0
2.6551,0.25781,0
2.706,0.25781,0
2.7575,0.25781,0
2.8095,0.25781,0
2.862,0.25781,0
2.915,0.25781,0
2.9685,0.25781,0
3.0226,0.25781,0
3.0772,0.25781,0
3.1324,0.25781,0
3.1881,0.25781,0
3.2444,0.25781,0
3.3013,0.25781,0
3.3587,0.25781,0
3.4166,0.25781,0
3.4752,0.25781,0
3.5344,0.25781,0
3.5941,0.25781,0
3.6544,0.25781,0
3.7154,0.25781,0
3.7769,0.25781,0
3.8391,0.25781,0
0.53722,0.24422,0
0.56699,0.24422,0
0.59706,0.24422,0
0.62742,0.24422,0
0.6581,0.24422,0
0.68907,0.24422,0
0.72036,0.24422,0
0.75196,0.24422,0
0.78388,0.24422,0
0.81612,0.24422,0
0.84868,0.24422,0
0.88156,0.24422,0
0.91478,0.24422,0
0.94832,0.24422,0
0.9822,0.24422,0
1.0164,0.24422,0
1.051,0.24422,0
1.0859,0.24422,0
1.1211,0.24422,0
1.1568,0.24422,0
1.1927,0.24422,0
1.229,0.24422,0
1.2657,0.24422,0
1.3028,0.24422,0
1.3402,0.24422,0
1.378,0.24422,0
1.4162,0.24422,0
1.4548,0.24422,0
1.4937,0.24422,0
1.533,0.24422,0
1.5728,0.24422,0
1.6129,0.24422,0
1.6534,0.24422,0
1.6944,0.24422,0
1.7357,0.24422,0
1.7774,0.24422,0
1.8196,0.24422,0
1.8622,0.24422,0
1.9052,0.24422,0
1.9487,0.24422,0
1.9926,0.24422,0
2.0369,0.24422,0
2.0817,0.24422,0
2.1269,0.24422,0
2.1725,0.24422,0
2.2187,0.24422,0
2.2652,0.24422,0
2.3123,0.24422,0
2.3598,0.24422,0
2.4078,0.24422,0
2.4563,0.24422,0
2.5053,0.24422,0
2.5547,0.24422,0
2.6046,0.24422,0
2.6551,0.24422,0
2.706,0.24422,0
2.7575,0.24422,0
2.8095,0.24422,0
2.862,0.24422,0
2.915,0.24422,0
2.9685,0.24422,0
3.0226,0.24422,0
3.0772,0.24422,0
3.1324,0.24422,0
3.1881,0.24422,0
3.2444,0.24422,0
3.3013,0.24422,0
3.3587,0.24422,0
3.4166,0.24422,0
3.4752,0.24422,0
0.62742,0.23041,0
0.6581,0.23041,0
0.68907,0.23041,0
0.72036,0.23041,0
0.75196,0.23041,0
0.78388,0.23041,0
0.81612,0.23041,0
0.84868,0.23041,0
0.88156,0.23041,0
0.91478,0.23041,0
0.94832,0.23041,0
0.9822,0.23041,0
1.0164,0.23041,0
1.051,0.23041,0
1.0859,0.23041,0
1.1211,0.23041,0
1.1568,0.23041,0
1.1927,0.23041,0
1.229,0.23041,0
1.2657,0.23041,0
1.3028,0.23041,0
1.3402,0.23041,0
1.378,0.23041,0
1.4162,0.23041,0
1.4548,0.23041,0
1.4937,0.23041,0
1.533,0.23041,0
1.5728,0.23041,0
1.6129,0.23041,0
1.6534,0.23041,0
1.6944,0.23041,0
1.7357,0.23041,0
1.7774,0.23041,0
1.8196,0.23041,0
1.8622,0.23041,0
1.9052,0.23041,0
1.9487,0.23041,0
1.9926,0.23041,0
2.0369,0.23041,0
2.0817,0.23041,0
2.1269,0.23041,0
2.1725,0.23041,0
2.2187,0.23041,0
2.2652,0.23041,0
2.3123,0.23041,0
2.3598,0.23041,0
2.4078,0.23041,0
2.4563,0.23041,0
2.5053,0.23041,0
2.5547,0.23041,0
2.6046,0.23041,0
2.6551,0.23041,0
2.706,0.23041,0
2.7575,0.23041,0
2.8095,0.23041,0
2.862,0.23041,0
2.915,0.23041,0
2.9685,0.23041,0
3.0226,0.23041,0
3.0772,0.23041,0
3.1324,0.23041,0
3.1881,0.23041,0
0.68907,0.21643,0
0.72036,0.21643,0
0.75196,0.21643,0
0.78388,0.21643,0
0.81612,0.21643,0
0.84868,0.21643,0
0.88156,0.21643,0
0.91478,0.21643,0
0.94832,0.21643,0
0.9822,0.21643,0
1.0164,0.21643,0
1.051,0.21643,0
1.0859,0.21643,0
1.1211,0.21643,0
1.1568,0.21643,0
1.1927,0.21643,0
1.229,0.21643,0
1.2657,0.21643,0
1.3028,0.21643,0
1.3402,0.21643,0
1.378,0.21643,0
1.4162,0.21643,0
1.4548,0.21643,0
1.4937,0.21643,0
1.533,0.21643,0
1.5728,0.21643,0
1.6129,0.21643,0
1.6534,0.21643,0
1.6944,0.21643,0
1.7357,0.21643,0
1.7774,0.21643,0
1.8196,0.21643,0
1.8622,0.21643,0
1.9052,0.21643,0
1.9487,0.21643,0
1.9926,0.21643,0
2.0369,0.21643,0
2.0817,0.21643,0
2.1269,0.21643,0
2.1725,0.21643,0
2.2187,0.21643,0
2.2652,0.21643,0
2.3123,0.21643,0
2.3598,0.21643,0
2.4078,0.21643,0
2.4563,0.21643,0
2.5053,0.21643,0
2.5547,0.21643,0
2.6046,0.21643,0
2.6551,0.21643,0
2.706,0.21643,0
2.7575,0.21643,0
2.8095,0.21643,0
0.78388,0.20231,0
0.81612,0.20231,0
0.84868,0.20231,0
0.88156,0.20231,0
0.91478,0.20231,0
0.94832,0.20231,0
0.9822,0.20231,0
1.0164,0.20231,0
1.051,0.20231,0
1.0859,0.20231,0
1.1211,0.20231,0
1.1568,0.20231,0
1.1927,0.20231,0
1.229,0.20231,0
1.2657,0.20231,0
1.3028,0.20231,0
1.3402,0.20231,0
1.378,0.20231,0
1.4162,0.20231,0
1.4548,0.20231,0
1.4937,0.20231,0
1.533,0.20231,0
1.5728,0.20231,0
1.6129,0.20231,0
1.6534,0.20231,0
1.6944,0.20231,0
1.7357,0.20231,0
1.7774,0.20231,0
1.8196,0.20231,0
1.8622,0.20231,0
1.9052,0.20231,0
1.9487,0.20231,0
1.9926,0.20231,0
2.0369,0.20231,0
2.0817,0.20231,0
2.1269,0.20231,0
2.1725,0.20231,0
2.2187,0.20231,0
2.2652,0.20231,0
2.3123,0.20231,0
2.3598,0.20231,0
2.4078,0.20231,0
2.4563,0.20231,0
1.051,0.1881,0
1.0859,0.1881,0
1.1211,0.1881,0
1.1568,0.1881,0
1.1927,0.1881,0
1.229,0.1881,0
1.2657,0.1881,0
1.3028,0.1881,0
1.3402,0.1881,0
1.378,0.1881,0
1.4162,0.1881,0
1.4548,0.1881,0
1.4937,0.1881,0
1.533,0.1881,0
1.5728,0.1881,0
1.6129,0.1881,0
1.6534,0.1881,0
1.6944,0.1881,0
1.7357,0.1881,0
1.7774,0.1881,0
1.8196,0.1881,0
1.8622,0.1881,0
1.9052,0.1881,0
1.9487,0.1881,0
1.9926,0.1881,0
2.0369,0.1881,0
Thanks for your help,
Sincerely

It's possible to do with ConvexHull from SciPy and this function together with convex_hull_plot_2d yield this result for the provided dataset. Below is the code to reproduce the pictures. hull.points at the end of the code contain the resulting outlining set of points that you are looking for.
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from scipy.spatial import ConvexHull, convex_hull_plot_2d
df = pd.DataFrame([{'x': 0.20215, 'y': 0.29703, 'z': 0},
{'x': 0.22857, 'y': 0.29703, 'z': 0},
{'x': 0.25526, 'y': 0.29703, 'z': 0},
{'x': 0.28221, 'y': 0.29703, 'z': 0},
{'x': 0.30943, 'y': 0.29703, 'z': 0},
{'x': 0.33692, 'y': 0.29703, 'z': 0},
{'x': 0.36469, 'y': 0.29703, 'z': 0},
{'x': 0.39273, 'y': 0.29703, 'z': 0},
{'x': 0.42106, 'y': 0.29703, 'z': 0},
{'x': 0.44966, 'y': 0.29703, 'z': 0},
{'x': 0.47856, 'y': 0.29703, 'z': 0},
{'x': 0.50774, 'y': 0.29703, 'z': 0},
{'x': 0.53722, 'y': 0.29703, 'z': 0},
{'x': 0.56699, 'y': 0.29703, 'z': 0},
{'x': 0.59706, 'y': 0.29703, 'z': 0},
{'x': 0.62742, 'y': 0.29703, 'z': 0},
{'x': 0.6581, 'y': 0.29703, 'z': 0},
{'x': 0.68907, 'y': 0.29703, 'z': 0},
{'x': 0.72036, 'y': 0.29703, 'z': 0},
{'x': 0.75196, 'y': 0.29703, 'z': 0},
{'x': 0.78388, 'y': 0.29703, 'z': 0},
{'x': 0.81612, 'y': 0.29703, 'z': 0},
{'x': 0.84868, 'y': 0.29703, 'z': 0},
{'x': 0.88156, 'y': 0.29703, 'z': 0},
{'x': 0.91478, 'y': 0.29703, 'z': 0},
{'x': 0.94832, 'y': 0.29703, 'z': 0},
{'x': 0.9822, 'y': 0.29703, 'z': 0},
{'x': 1.0164, 'y': 0.29703, 'z': 0},
{'x': 1.051, 'y': 0.29703, 'z': 0},
{'x': 1.0859, 'y': 0.29703, 'z': 0},
{'x': 1.1211, 'y': 0.29703, 'z': 0},
{'x': 1.1568, 'y': 0.29703, 'z': 0},
{'x': 1.1927, 'y': 0.29703, 'z': 0},
{'x': 1.229, 'y': 0.29703, 'z': 0},
{'x': 1.2657, 'y': 0.29703, 'z': 0},
{'x': 1.3028, 'y': 0.29703, 'z': 0},
{'x': 1.3402, 'y': 0.29703, 'z': 0},
{'x': 1.378, 'y': 0.29703, 'z': 0},
{'x': 1.4162, 'y': 0.29703, 'z': 0},
{'x': 1.4548, 'y': 0.29703, 'z': 0},
{'x': 1.4937, 'y': 0.29703, 'z': 0},
{'x': 1.533, 'y': 0.29703, 'z': 0},
{'x': 1.5728, 'y': 0.29703, 'z': 0},
{'x': 1.6129, 'y': 0.29703, 'z': 0},
{'x': 1.6534, 'y': 0.29703, 'z': 0},
{'x': 1.6944, 'y': 0.29703, 'z': 0},
{'x': 1.7357, 'y': 0.29703, 'z': 0},
{'x': 1.7774, 'y': 0.29703, 'z': 0},
{'x': 1.8196, 'y': 0.29703, 'z': 0},
{'x': 1.8622, 'y': 0.29703, 'z': 0},
{'x': 1.9052, 'y': 0.29703, 'z': 0},
{'x': 1.9487, 'y': 0.29703, 'z': 0},
{'x': 1.9926, 'y': 0.29703, 'z': 0},
{'x': 2.0369, 'y': 0.29703, 'z': 0},
{'x': 2.0817, 'y': 0.29703, 'z': 0},
{'x': 2.1269, 'y': 0.29703, 'z': 0},
{'x': 2.1725, 'y': 0.29703, 'z': 0},
{'x': 2.2187, 'y': 0.29703, 'z': 0},
{'x': 2.2652, 'y': 0.29703, 'z': 0},
{'x': 2.3123, 'y': 0.29703, 'z': 0},
{'x': 2.3598, 'y': 0.29703, 'z': 0},
{'x': 2.4078, 'y': 0.29703, 'z': 0},
{'x': 2.4563, 'y': 0.29703, 'z': 0},
{'x': 2.5053, 'y': 0.29703, 'z': 0},
{'x': 2.5547, 'y': 0.29703, 'z': 0},
{'x': 2.6046, 'y': 0.29703, 'z': 0},
{'x': 2.6551, 'y': 0.29703, 'z': 0},
{'x': 2.706, 'y': 0.29703, 'z': 0},
{'x': 2.7575, 'y': 0.29703, 'z': 0},
{'x': 2.8095, 'y': 0.29703, 'z': 0},
{'x': 2.862, 'y': 0.29703, 'z': 0},
{'x': 2.915, 'y': 0.29703, 'z': 0},
{'x': 2.9685, 'y': 0.29703, 'z': 0},
{'x': 3.0226, 'y': 0.29703, 'z': 0},
{'x': 3.0772, 'y': 0.29703, 'z': 0},
{'x': 3.1324, 'y': 0.29703, 'z': 0},
{'x': 3.1881, 'y': 0.29703, 'z': 0},
{'x': 3.2444, 'y': 0.29703, 'z': 0},
{'x': 3.3013, 'y': 0.29703, 'z': 0},
{'x': 3.3587, 'y': 0.29703, 'z': 0},
{'x': 3.4166, 'y': 0.29703, 'z': 0},
{'x': 3.4752, 'y': 0.29703, 'z': 0},
{'x': 3.5344, 'y': 0.29703, 'z': 0},
{'x': 3.5941, 'y': 0.29703, 'z': 0},
{'x': 3.6544, 'y': 0.29703, 'z': 0},
{'x': 3.7154, 'y': 0.29703, 'z': 0},
{'x': 3.7769, 'y': 0.29703, 'z': 0},
{'x': 3.8391, 'y': 0.29703, 'z': 0},
{'x': 3.9019, 'y': 0.29703, 'z': 0},
{'x': 3.9653, 'y': 0.29703, 'z': 0},
{'x': 4.0294, 'y': 0.29703, 'z': 0},
{'x': 4.094, 'y': 0.29703, 'z': 0},
{'x': 4.1594, 'y': 0.29703, 'z': 0},
{'x': 4.2254, 'y': 0.29703, 'z': 0},
{'x': 4.292, 'y': 0.29703, 'z': 0},
{'x': 4.3593, 'y': 0.29703, 'z': 0},
{'x': 4.4273, 'y': 0.29703, 'z': 0},
{'x': 4.496, 'y': 0.29703, 'z': 0},
{'x': 4.5654, 'y': 0.29703, 'z': 0},
{'x': 4.6354, 'y': 0.29703, 'z': 0},
{'x': 4.7062, 'y': 0.29703, 'z': 0},
{'x': 4.7776, 'y': 0.29703, 'z': 0},
{'x': 4.8498, 'y': 0.29703, 'z': 0},
{'x': 4.9227, 'y': 0.29703, 'z': 0},
{'x': 0.28221, 'y': 0.28425, 'z': 0},
{'x': 0.30943, 'y': 0.28425, 'z': 0},
{'x': 0.33692, 'y': 0.28425, 'z': 0},
{'x': 0.36469, 'y': 0.28425, 'z': 0},
{'x': 0.39273, 'y': 0.28425, 'z': 0},
{'x': 0.42106, 'y': 0.28425, 'z': 0},
{'x': 0.44966, 'y': 0.28425, 'z': 0},
{'x': 0.47856, 'y': 0.28425, 'z': 0},
{'x': 0.50774, 'y': 0.28425, 'z': 0},
{'x': 0.53722, 'y': 0.28425, 'z': 0},
{'x': 0.56699, 'y': 0.28425, 'z': 0},
{'x': 0.59706, 'y': 0.28425, 'z': 0},
{'x': 0.62742, 'y': 0.28425, 'z': 0},
{'x': 0.6581, 'y': 0.28425, 'z': 0},
{'x': 0.68907, 'y': 0.28425, 'z': 0},
{'x': 0.72036, 'y': 0.28425, 'z': 0},
{'x': 0.75196, 'y': 0.28425, 'z': 0},
{'x': 0.78388, 'y': 0.28425, 'z': 0},
{'x': 0.81612, 'y': 0.28425, 'z': 0},
{'x': 0.84868, 'y': 0.28425, 'z': 0},
{'x': 0.88156, 'y': 0.28425, 'z': 0},
{'x': 0.91478, 'y': 0.28425, 'z': 0},
{'x': 0.94832, 'y': 0.28425, 'z': 0},
{'x': 0.9822, 'y': 0.28425, 'z': 0},
{'x': 1.0164, 'y': 0.28425, 'z': 0},
{'x': 1.051, 'y': 0.28425, 'z': 0},
{'x': 1.0859, 'y': 0.28425, 'z': 0},
{'x': 1.1211, 'y': 0.28425, 'z': 0},
{'x': 1.1568, 'y': 0.28425, 'z': 0},
{'x': 1.1927, 'y': 0.28425, 'z': 0},
{'x': 1.229, 'y': 0.28425, 'z': 0},
{'x': 1.2657, 'y': 0.28425, 'z': 0},
{'x': 1.3028, 'y': 0.28425, 'z': 0},
{'x': 1.3402, 'y': 0.28425, 'z': 0},
{'x': 1.378, 'y': 0.28425, 'z': 0},
{'x': 1.4162, 'y': 0.28425, 'z': 0},
{'x': 1.4548, 'y': 0.28425, 'z': 0},
{'x': 1.4937, 'y': 0.28425, 'z': 0},
{'x': 1.533, 'y': 0.28425, 'z': 0},
{'x': 1.5728, 'y': 0.28425, 'z': 0},
{'x': 1.6129, 'y': 0.28425, 'z': 0},
{'x': 1.6534, 'y': 0.28425, 'z': 0},
{'x': 1.6944, 'y': 0.28425, 'z': 0},
{'x': 1.7357, 'y': 0.28425, 'z': 0},
{'x': 1.7774, 'y': 0.28425, 'z': 0},
{'x': 1.8196, 'y': 0.28425, 'z': 0},
{'x': 1.8622, 'y': 0.28425, 'z': 0},
{'x': 1.9052, 'y': 0.28425, 'z': 0},
{'x': 1.9487, 'y': 0.28425, 'z': 0},
{'x': 1.9926, 'y': 0.28425, 'z': 0},
{'x': 2.0369, 'y': 0.28425, 'z': 0},
{'x': 2.0817, 'y': 0.28425, 'z': 0},
{'x': 2.1269, 'y': 0.28425, 'z': 0},
{'x': 2.1725, 'y': 0.28425, 'z': 0},
{'x': 2.2187, 'y': 0.28425, 'z': 0},
{'x': 2.2652, 'y': 0.28425, 'z': 0},
{'x': 2.3123, 'y': 0.28425, 'z': 0},
{'x': 2.3598, 'y': 0.28425, 'z': 0},
{'x': 2.4078, 'y': 0.28425, 'z': 0},
{'x': 2.4563, 'y': 0.28425, 'z': 0},
{'x': 2.5053, 'y': 0.28425, 'z': 0},
{'x': 2.5547, 'y': 0.28425, 'z': 0},
{'x': 2.6046, 'y': 0.28425, 'z': 0},
{'x': 2.6551, 'y': 0.28425, 'z': 0},
{'x': 2.706, 'y': 0.28425, 'z': 0},
{'x': 2.7575, 'y': 0.28425, 'z': 0},
{'x': 2.8095, 'y': 0.28425, 'z': 0},
{'x': 2.862, 'y': 0.28425, 'z': 0},
{'x': 2.915, 'y': 0.28425, 'z': 0},
{'x': 2.9685, 'y': 0.28425, 'z': 0},
{'x': 3.0226, 'y': 0.28425, 'z': 0},
{'x': 3.0772, 'y': 0.28425, 'z': 0},
{'x': 3.1324, 'y': 0.28425, 'z': 0},
{'x': 3.1881, 'y': 0.28425, 'z': 0},
{'x': 3.2444, 'y': 0.28425, 'z': 0},
{'x': 3.3013, 'y': 0.28425, 'z': 0},
{'x': 3.3587, 'y': 0.28425, 'z': 0},
{'x': 3.4166, 'y': 0.28425, 'z': 0},
{'x': 3.4752, 'y': 0.28425, 'z': 0},
{'x': 3.5344, 'y': 0.28425, 'z': 0},
{'x': 3.5941, 'y': 0.28425, 'z': 0},
{'x': 3.6544, 'y': 0.28425, 'z': 0},
{'x': 3.7154, 'y': 0.28425, 'z': 0},
{'x': 3.7769, 'y': 0.28425, 'z': 0},
{'x': 3.8391, 'y': 0.28425, 'z': 0},
{'x': 3.9019, 'y': 0.28425, 'z': 0},
{'x': 3.9653, 'y': 0.28425, 'z': 0},
{'x': 4.0294, 'y': 0.28425, 'z': 0},
{'x': 4.094, 'y': 0.28425, 'z': 0},
{'x': 4.1594, 'y': 0.28425, 'z': 0},
{'x': 4.2254, 'y': 0.28425, 'z': 0},
{'x': 4.292, 'y': 0.28425, 'z': 0},
{'x': 4.3593, 'y': 0.28425, 'z': 0},
{'x': 4.4273, 'y': 0.28425, 'z': 0},
{'x': 4.496, 'y': 0.28425, 'z': 0},
{'x': 4.5654, 'y': 0.28425, 'z': 0},
{'x': 0.39273, 'y': 0.27117, 'z': 0},
{'x': 0.42106, 'y': 0.27117, 'z': 0},
{'x': 0.44966, 'y': 0.27117, 'z': 0},
{'x': 0.47856, 'y': 0.27117, 'z': 0},
{'x': 0.50774, 'y': 0.27117, 'z': 0},
{'x': 0.53722, 'y': 0.27117, 'z': 0},
{'x': 0.56699, 'y': 0.27117, 'z': 0},
{'x': 0.59706, 'y': 0.27117, 'z': 0},
{'x': 0.62742, 'y': 0.27117, 'z': 0},
{'x': 0.6581, 'y': 0.27117, 'z': 0},
{'x': 0.68907, 'y': 0.27117, 'z': 0},
{'x': 0.72036, 'y': 0.27117, 'z': 0},
{'x': 0.75196, 'y': 0.27117, 'z': 0},
{'x': 0.78388, 'y': 0.27117, 'z': 0},
{'x': 0.81612, 'y': 0.27117, 'z': 0},
{'x': 0.84868, 'y': 0.27117, 'z': 0},
{'x': 0.88156, 'y': 0.27117, 'z': 0},
{'x': 0.91478, 'y': 0.27117, 'z': 0},
{'x': 0.94832, 'y': 0.27117, 'z': 0},
{'x': 0.9822, 'y': 0.27117, 'z': 0},
{'x': 1.0164, 'y': 0.27117, 'z': 0},
{'x': 1.051, 'y': 0.27117, 'z': 0},
{'x': 1.0859, 'y': 0.27117, 'z': 0},
{'x': 1.1211, 'y': 0.27117, 'z': 0},
{'x': 1.1568, 'y': 0.27117, 'z': 0},
{'x': 1.1927, 'y': 0.27117, 'z': 0},
{'x': 1.229, 'y': 0.27117, 'z': 0},
{'x': 1.2657, 'y': 0.27117, 'z': 0},
{'x': 1.3028, 'y': 0.27117, 'z': 0},
{'x': 1.3402, 'y': 0.27117, 'z': 0},
{'x': 1.378, 'y': 0.27117, 'z': 0},
{'x': 1.4162, 'y': 0.27117, 'z': 0},
{'x': 1.4548, 'y': 0.27117, 'z': 0},
{'x': 1.4937, 'y': 0.27117, 'z': 0},
{'x': 1.533, 'y': 0.27117, 'z': 0},
{'x': 1.5728, 'y': 0.27117, 'z': 0},
{'x': 1.6129, 'y': 0.27117, 'z': 0},
{'x': 1.6534, 'y': 0.27117, 'z': 0},
{'x': 1.6944, 'y': 0.27117, 'z': 0},
{'x': 1.7357, 'y': 0.27117, 'z': 0},
{'x': 1.7774, 'y': 0.27117, 'z': 0},
{'x': 1.8196, 'y': 0.27117, 'z': 0},
{'x': 1.8622, 'y': 0.27117, 'z': 0},
{'x': 1.9052, 'y': 0.27117, 'z': 0},
{'x': 1.9487, 'y': 0.27117, 'z': 0},
{'x': 1.9926, 'y': 0.27117, 'z': 0},
{'x': 2.0369, 'y': 0.27117, 'z': 0},
{'x': 2.0817, 'y': 0.27117, 'z': 0},
{'x': 2.1269, 'y': 0.27117, 'z': 0},
{'x': 2.1725, 'y': 0.27117, 'z': 0},
{'x': 2.2187, 'y': 0.27117, 'z': 0},
{'x': 2.2652, 'y': 0.27117, 'z': 0},
{'x': 2.3123, 'y': 0.27117, 'z': 0},
{'x': 2.3598, 'y': 0.27117, 'z': 0},
{'x': 2.4078, 'y': 0.27117, 'z': 0},
{'x': 2.4563, 'y': 0.27117, 'z': 0},
{'x': 2.5053, 'y': 0.27117, 'z': 0},
{'x': 2.5547, 'y': 0.27117, 'z': 0},
{'x': 2.6046, 'y': 0.27117, 'z': 0},
{'x': 2.6551, 'y': 0.27117, 'z': 0},
{'x': 2.706, 'y': 0.27117, 'z': 0},
{'x': 2.7575, 'y': 0.27117, 'z': 0},
{'x': 2.8095, 'y': 0.27117, 'z': 0},
{'x': 2.862, 'y': 0.27117, 'z': 0},
{'x': 2.915, 'y': 0.27117, 'z': 0},
{'x': 2.9685, 'y': 0.27117, 'z': 0},
{'x': 3.0226, 'y': 0.27117, 'z': 0},
{'x': 3.0772, 'y': 0.27117, 'z': 0},
{'x': 3.1324, 'y': 0.27117, 'z': 0},
{'x': 3.1881, 'y': 0.27117, 'z': 0},
{'x': 3.2444, 'y': 0.27117, 'z': 0},
{'x': 3.3013, 'y': 0.27117, 'z': 0},
{'x': 3.3587, 'y': 0.27117, 'z': 0},
{'x': 3.4166, 'y': 0.27117, 'z': 0},
{'x': 3.4752, 'y': 0.27117, 'z': 0},
{'x': 3.5344, 'y': 0.27117, 'z': 0},
{'x': 3.5941, 'y': 0.27117, 'z': 0},
{'x': 3.6544, 'y': 0.27117, 'z': 0},
{'x': 3.7154, 'y': 0.27117, 'z': 0},
{'x': 3.7769, 'y': 0.27117, 'z': 0},
{'x': 3.8391, 'y': 0.27117, 'z': 0},
{'x': 3.9019, 'y': 0.27117, 'z': 0},
{'x': 3.9653, 'y': 0.27117, 'z': 0},
{'x': 4.0294, 'y': 0.27117, 'z': 0},
{'x': 4.094, 'y': 0.27117, 'z': 0},
{'x': 4.1594, 'y': 0.27117, 'z': 0},
{'x': 0.47856, 'y': 0.25781, 'z': 0},
{'x': 0.50774, 'y': 0.25781, 'z': 0},
{'x': 0.53722, 'y': 0.25781, 'z': 0},
{'x': 0.56699, 'y': 0.25781, 'z': 0},
{'x': 0.59706, 'y': 0.25781, 'z': 0},
{'x': 0.62742, 'y': 0.25781, 'z': 0},
{'x': 0.6581, 'y': 0.25781, 'z': 0},
{'x': 0.68907, 'y': 0.25781, 'z': 0},
{'x': 0.72036, 'y': 0.25781, 'z': 0},
{'x': 0.75196, 'y': 0.25781, 'z': 0},
{'x': 0.78388, 'y': 0.25781, 'z': 0},
{'x': 0.81612, 'y': 0.25781, 'z': 0},
{'x': 0.84868, 'y': 0.25781, 'z': 0},
{'x': 0.88156, 'y': 0.25781, 'z': 0},
{'x': 0.91478, 'y': 0.25781, 'z': 0},
{'x': 0.94832, 'y': 0.25781, 'z': 0},
{'x': 0.9822, 'y': 0.25781, 'z': 0},
{'x': 1.0164, 'y': 0.25781, 'z': 0},
{'x': 1.051, 'y': 0.25781, 'z': 0},
{'x': 1.0859, 'y': 0.25781, 'z': 0},
{'x': 1.1211, 'y': 0.25781, 'z': 0},
{'x': 1.1568, 'y': 0.25781, 'z': 0},
{'x': 1.1927, 'y': 0.25781, 'z': 0},
{'x': 1.229, 'y': 0.25781, 'z': 0},
{'x': 1.2657, 'y': 0.25781, 'z': 0},
{'x': 1.3028, 'y': 0.25781, 'z': 0},
{'x': 1.3402, 'y': 0.25781, 'z': 0},
{'x': 1.378, 'y': 0.25781, 'z': 0},
{'x': 1.4162, 'y': 0.25781, 'z': 0},
{'x': 1.4548, 'y': 0.25781, 'z': 0},
{'x': 1.4937, 'y': 0.25781, 'z': 0},
{'x': 1.533, 'y': 0.25781, 'z': 0},
{'x': 1.5728, 'y': 0.25781, 'z': 0},
{'x': 1.6129, 'y': 0.25781, 'z': 0},
{'x': 1.6534, 'y': 0.25781, 'z': 0},
{'x': 1.6944, 'y': 0.25781, 'z': 0},
{'x': 1.7357, 'y': 0.25781, 'z': 0},
{'x': 1.7774, 'y': 0.25781, 'z': 0},
{'x': 1.8196, 'y': 0.25781, 'z': 0},
{'x': 1.8622, 'y': 0.25781, 'z': 0},
{'x': 1.9052, 'y': 0.25781, 'z': 0},
{'x': 1.9487, 'y': 0.25781, 'z': 0},
{'x': 1.9926, 'y': 0.25781, 'z': 0},
{'x': 2.0369, 'y': 0.25781, 'z': 0},
{'x': 2.0817, 'y': 0.25781, 'z': 0},
{'x': 2.1269, 'y': 0.25781, 'z': 0},
{'x': 2.1725, 'y': 0.25781, 'z': 0},
{'x': 2.2187, 'y': 0.25781, 'z': 0},
{'x': 2.2652, 'y': 0.25781, 'z': 0},
{'x': 2.3123, 'y': 0.25781, 'z': 0},
{'x': 2.3598, 'y': 0.25781, 'z': 0},
{'x': 2.4078, 'y': 0.25781, 'z': 0},
{'x': 2.4563, 'y': 0.25781, 'z': 0},
{'x': 2.5053, 'y': 0.25781, 'z': 0},
{'x': 2.5547, 'y': 0.25781, 'z': 0},
{'x': 2.6046, 'y': 0.25781, 'z': 0},
{'x': 2.6551, 'y': 0.25781, 'z': 0},
{'x': 2.706, 'y': 0.25781, 'z': 0},
{'x': 2.7575, 'y': 0.25781, 'z': 0},
{'x': 2.8095, 'y': 0.25781, 'z': 0},
{'x': 2.862, 'y': 0.25781, 'z': 0},
{'x': 2.915, 'y': 0.25781, 'z': 0},
{'x': 2.9685, 'y': 0.25781, 'z': 0},
{'x': 3.0226, 'y': 0.25781, 'z': 0},
{'x': 3.0772, 'y': 0.25781, 'z': 0},
{'x': 3.1324, 'y': 0.25781, 'z': 0},
{'x': 3.1881, 'y': 0.25781, 'z': 0},
{'x': 3.2444, 'y': 0.25781, 'z': 0},
{'x': 3.3013, 'y': 0.25781, 'z': 0},
{'x': 3.3587, 'y': 0.25781, 'z': 0},
{'x': 3.4166, 'y': 0.25781, 'z': 0},
{'x': 3.4752, 'y': 0.25781, 'z': 0},
{'x': 3.5344, 'y': 0.25781, 'z': 0},
{'x': 3.5941, 'y': 0.25781, 'z': 0},
{'x': 3.6544, 'y': 0.25781, 'z': 0},
{'x': 3.7154, 'y': 0.25781, 'z': 0},
{'x': 3.7769, 'y': 0.25781, 'z': 0},
{'x': 3.8391, 'y': 0.25781, 'z': 0},
{'x': 0.53722, 'y': 0.24422, 'z': 0},
{'x': 0.56699, 'y': 0.24422, 'z': 0},
{'x': 0.59706, 'y': 0.24422, 'z': 0},
{'x': 0.62742, 'y': 0.24422, 'z': 0},
{'x': 0.6581, 'y': 0.24422, 'z': 0},
{'x': 0.68907, 'y': 0.24422, 'z': 0},
{'x': 0.72036, 'y': 0.24422, 'z': 0},
{'x': 0.75196, 'y': 0.24422, 'z': 0},
{'x': 0.78388, 'y': 0.24422, 'z': 0},
{'x': 0.81612, 'y': 0.24422, 'z': 0},
{'x': 0.84868, 'y': 0.24422, 'z': 0},
{'x': 0.88156, 'y': 0.24422, 'z': 0},
{'x': 0.91478, 'y': 0.24422, 'z': 0},
{'x': 0.94832, 'y': 0.24422, 'z': 0},
{'x': 0.9822, 'y': 0.24422, 'z': 0},
{'x': 1.0164, 'y': 0.24422, 'z': 0},
{'x': 1.051, 'y': 0.24422, 'z': 0},
{'x': 1.0859, 'y': 0.24422, 'z': 0},
{'x': 1.1211, 'y': 0.24422, 'z': 0},
{'x': 1.1568, 'y': 0.24422, 'z': 0},
{'x': 1.1927, 'y': 0.24422, 'z': 0},
{'x': 1.229, 'y': 0.24422, 'z': 0},
{'x': 1.2657, 'y': 0.24422, 'z': 0},
{'x': 1.3028, 'y': 0.24422, 'z': 0},
{'x': 1.3402, 'y': 0.24422, 'z': 0},
{'x': 1.378, 'y': 0.24422, 'z': 0},
{'x': 1.4162, 'y': 0.24422, 'z': 0},
{'x': 1.4548, 'y': 0.24422, 'z': 0},
{'x': 1.4937, 'y': 0.24422, 'z': 0},
{'x': 1.533, 'y': 0.24422, 'z': 0},
{'x': 1.5728, 'y': 0.24422, 'z': 0},
{'x': 1.6129, 'y': 0.24422, 'z': 0},
{'x': 1.6534, 'y': 0.24422, 'z': 0},
{'x': 1.6944, 'y': 0.24422, 'z': 0},
{'x': 1.7357, 'y': 0.24422, 'z': 0},
{'x': 1.7774, 'y': 0.24422, 'z': 0},
{'x': 1.8196, 'y': 0.24422, 'z': 0},
{'x': 1.8622, 'y': 0.24422, 'z': 0},
{'x': 1.9052, 'y': 0.24422, 'z': 0},
{'x': 1.9487, 'y': 0.24422, 'z': 0},
{'x': 1.9926, 'y': 0.24422, 'z': 0},
{'x': 2.0369, 'y': 0.24422, 'z': 0},
{'x': 2.0817, 'y': 0.24422, 'z': 0},
{'x': 2.1269, 'y': 0.24422, 'z': 0},
{'x': 2.1725, 'y': 0.24422, 'z': 0},
{'x': 2.2187, 'y': 0.24422, 'z': 0},
{'x': 2.2652, 'y': 0.24422, 'z': 0},
{'x': 2.3123, 'y': 0.24422, 'z': 0},
{'x': 2.3598, 'y': 0.24422, 'z': 0},
{'x': 2.4078, 'y': 0.24422, 'z': 0},
{'x': 2.4563, 'y': 0.24422, 'z': 0},
{'x': 2.5053, 'y': 0.24422, 'z': 0},
{'x': 2.5547, 'y': 0.24422, 'z': 0},
{'x': 2.6046, 'y': 0.24422, 'z': 0},
{'x': 2.6551, 'y': 0.24422, 'z': 0},
{'x': 2.706, 'y': 0.24422, 'z': 0},
{'x': 2.7575, 'y': 0.24422, 'z': 0},
{'x': 2.8095, 'y': 0.24422, 'z': 0},
{'x': 2.862, 'y': 0.24422, 'z': 0},
{'x': 2.915, 'y': 0.24422, 'z': 0},
{'x': 2.9685, 'y': 0.24422, 'z': 0},
{'x': 3.0226, 'y': 0.24422, 'z': 0},
{'x': 3.0772, 'y': 0.24422, 'z': 0},
{'x': 3.1324, 'y': 0.24422, 'z': 0},
{'x': 3.1881, 'y': 0.24422, 'z': 0},
{'x': 3.2444, 'y': 0.24422, 'z': 0},
{'x': 3.3013, 'y': 0.24422, 'z': 0},
{'x': 3.3587, 'y': 0.24422, 'z': 0},
{'x': 3.4166, 'y': 0.24422, 'z': 0},
{'x': 3.4752, 'y': 0.24422, 'z': 0},
{'x': 0.62742, 'y': 0.23041, 'z': 0},
{'x': 0.6581, 'y': 0.23041, 'z': 0},
{'x': 0.68907, 'y': 0.23041, 'z': 0},
{'x': 0.72036, 'y': 0.23041, 'z': 0},
{'x': 0.75196, 'y': 0.23041, 'z': 0},
{'x': 0.78388, 'y': 0.23041, 'z': 0},
{'x': 0.81612, 'y': 0.23041, 'z': 0},
{'x': 0.84868, 'y': 0.23041, 'z': 0},
{'x': 0.88156, 'y': 0.23041, 'z': 0},
{'x': 0.91478, 'y': 0.23041, 'z': 0},
{'x': 0.94832, 'y': 0.23041, 'z': 0},
{'x': 0.9822, 'y': 0.23041, 'z': 0},
{'x': 1.0164, 'y': 0.23041, 'z': 0},
{'x': 1.051, 'y': 0.23041, 'z': 0},
{'x': 1.0859, 'y': 0.23041, 'z': 0},
{'x': 1.1211, 'y': 0.23041, 'z': 0},
{'x': 1.1568, 'y': 0.23041, 'z': 0},
{'x': 1.1927, 'y': 0.23041, 'z': 0},
{'x': 1.229, 'y': 0.23041, 'z': 0},
{'x': 1.2657, 'y': 0.23041, 'z': 0},
{'x': 1.3028, 'y': 0.23041, 'z': 0},
{'x': 1.3402, 'y': 0.23041, 'z': 0},
{'x': 1.378, 'y': 0.23041, 'z': 0},
{'x': 1.4162, 'y': 0.23041, 'z': 0},
{'x': 1.4548, 'y': 0.23041, 'z': 0},
{'x': 1.4937, 'y': 0.23041, 'z': 0},
{'x': 1.533, 'y': 0.23041, 'z': 0},
{'x': 1.5728, 'y': 0.23041, 'z': 0},
{'x': 1.6129, 'y': 0.23041, 'z': 0},
{'x': 1.6534, 'y': 0.23041, 'z': 0},
{'x': 1.6944, 'y': 0.23041, 'z': 0},
{'x': 1.7357, 'y': 0.23041, 'z': 0},
{'x': 1.7774, 'y': 0.23041, 'z': 0},
{'x': 1.8196, 'y': 0.23041, 'z': 0},
{'x': 1.8622, 'y': 0.23041, 'z': 0},
{'x': 1.9052, 'y': 0.23041, 'z': 0},
{'x': 1.9487, 'y': 0.23041, 'z': 0},
{'x': 1.9926, 'y': 0.23041, 'z': 0},
{'x': 2.0369, 'y': 0.23041, 'z': 0},
{'x': 2.0817, 'y': 0.23041, 'z': 0},
{'x': 2.1269, 'y': 0.23041, 'z': 0},
{'x': 2.1725, 'y': 0.23041, 'z': 0},
{'x': 2.2187, 'y': 0.23041, 'z': 0},
{'x': 2.2652, 'y': 0.23041, 'z': 0},
{'x': 2.3123, 'y': 0.23041, 'z': 0},
{'x': 2.3598, 'y': 0.23041, 'z': 0},
{'x': 2.4078, 'y': 0.23041, 'z': 0},
{'x': 2.4563, 'y': 0.23041, 'z': 0},
{'x': 2.5053, 'y': 0.23041, 'z': 0},
{'x': 2.5547, 'y': 0.23041, 'z': 0},
{'x': 2.6046, 'y': 0.23041, 'z': 0},
{'x': 2.6551, 'y': 0.23041, 'z': 0},
{'x': 2.706, 'y': 0.23041, 'z': 0},
{'x': 2.7575, 'y': 0.23041, 'z': 0},
{'x': 2.8095, 'y': 0.23041, 'z': 0},
{'x': 2.862, 'y': 0.23041, 'z': 0},
{'x': 2.915, 'y': 0.23041, 'z': 0},
{'x': 2.9685, 'y': 0.23041, 'z': 0},
{'x': 3.0226, 'y': 0.23041, 'z': 0},
{'x': 3.0772, 'y': 0.23041, 'z': 0},
{'x': 3.1324, 'y': 0.23041, 'z': 0},
{'x': 3.1881, 'y': 0.23041, 'z': 0},
{'x': 0.68907, 'y': 0.21643, 'z': 0},
{'x': 0.72036, 'y': 0.21643, 'z': 0},
{'x': 0.75196, 'y': 0.21643, 'z': 0},
{'x': 0.78388, 'y': 0.21643, 'z': 0},
{'x': 0.81612, 'y': 0.21643, 'z': 0},
{'x': 0.84868, 'y': 0.21643, 'z': 0},
{'x': 0.88156, 'y': 0.21643, 'z': 0},
{'x': 0.91478, 'y': 0.21643, 'z': 0},
{'x': 0.94832, 'y': 0.21643, 'z': 0},
{'x': 0.9822, 'y': 0.21643, 'z': 0},
{'x': 1.0164, 'y': 0.21643, 'z': 0},
{'x': 1.051, 'y': 0.21643, 'z': 0},
{'x': 1.0859, 'y': 0.21643, 'z': 0},
{'x': 1.1211, 'y': 0.21643, 'z': 0},
{'x': 1.1568, 'y': 0.21643, 'z': 0},
{'x': 1.1927, 'y': 0.21643, 'z': 0},
{'x': 1.229, 'y': 0.21643, 'z': 0},
{'x': 1.2657, 'y': 0.21643, 'z': 0},
{'x': 1.3028, 'y': 0.21643, 'z': 0},
{'x': 1.3402, 'y': 0.21643, 'z': 0},
{'x': 1.378, 'y': 0.21643, 'z': 0},
{'x': 1.4162, 'y': 0.21643, 'z': 0},
{'x': 1.4548, 'y': 0.21643, 'z': 0},
{'x': 1.4937, 'y': 0.21643, 'z': 0},
{'x': 1.533, 'y': 0.21643, 'z': 0},
{'x': 1.5728, 'y': 0.21643, 'z': 0},
{'x': 1.6129, 'y': 0.21643, 'z': 0},
{'x': 1.6534, 'y': 0.21643, 'z': 0},
{'x': 1.6944, 'y': 0.21643, 'z': 0},
{'x': 1.7357, 'y': 0.21643, 'z': 0},
{'x': 1.7774, 'y': 0.21643, 'z': 0},
{'x': 1.8196, 'y': 0.21643, 'z': 0},
{'x': 1.8622, 'y': 0.21643, 'z': 0},
{'x': 1.9052, 'y': 0.21643, 'z': 0},
{'x': 1.9487, 'y': 0.21643, 'z': 0},
{'x': 1.9926, 'y': 0.21643, 'z': 0},
{'x': 2.0369, 'y': 0.21643, 'z': 0},
{'x': 2.0817, 'y': 0.21643, 'z': 0},
{'x': 2.1269, 'y': 0.21643, 'z': 0},
{'x': 2.1725, 'y': 0.21643, 'z': 0},
{'x': 2.2187, 'y': 0.21643, 'z': 0},
{'x': 2.2652, 'y': 0.21643, 'z': 0},
{'x': 2.3123, 'y': 0.21643, 'z': 0},
{'x': 2.3598, 'y': 0.21643, 'z': 0},
{'x': 2.4078, 'y': 0.21643, 'z': 0},
{'x': 2.4563, 'y': 0.21643, 'z': 0},
{'x': 2.5053, 'y': 0.21643, 'z': 0},
{'x': 2.5547, 'y': 0.21643, 'z': 0},
{'x': 2.6046, 'y': 0.21643, 'z': 0},
{'x': 2.6551, 'y': 0.21643, 'z': 0},
{'x': 2.706, 'y': 0.21643, 'z': 0},
{'x': 2.7575, 'y': 0.21643, 'z': 0},
{'x': 2.8095, 'y': 0.21643, 'z': 0},
{'x': 0.78388, 'y': 0.20231, 'z': 0},
{'x': 0.81612, 'y': 0.20231, 'z': 0},
{'x': 0.84868, 'y': 0.20231, 'z': 0},
{'x': 0.88156, 'y': 0.20231, 'z': 0},
{'x': 0.91478, 'y': 0.20231, 'z': 0},
{'x': 0.94832, 'y': 0.20231, 'z': 0},
{'x': 0.9822, 'y': 0.20231, 'z': 0},
{'x': 1.0164, 'y': 0.20231, 'z': 0},
{'x': 1.051, 'y': 0.20231, 'z': 0},
{'x': 1.0859, 'y': 0.20231, 'z': 0},
{'x': 1.1211, 'y': 0.20231, 'z': 0},
{'x': 1.1568, 'y': 0.20231, 'z': 0},
{'x': 1.1927, 'y': 0.20231, 'z': 0},
{'x': 1.229, 'y': 0.20231, 'z': 0},
{'x': 1.2657, 'y': 0.20231, 'z': 0},
{'x': 1.3028, 'y': 0.20231, 'z': 0},
{'x': 1.3402, 'y': 0.20231, 'z': 0},
{'x': 1.378, 'y': 0.20231, 'z': 0},
{'x': 1.4162, 'y': 0.20231, 'z': 0},
{'x': 1.4548, 'y': 0.20231, 'z': 0},
{'x': 1.4937, 'y': 0.20231, 'z': 0},
{'x': 1.533, 'y': 0.20231, 'z': 0},
{'x': 1.5728, 'y': 0.20231, 'z': 0},
{'x': 1.6129, 'y': 0.20231, 'z': 0},
{'x': 1.6534, 'y': 0.20231, 'z': 0},
{'x': 1.6944, 'y': 0.20231, 'z': 0},
{'x': 1.7357, 'y': 0.20231, 'z': 0},
{'x': 1.7774, 'y': 0.20231, 'z': 0},
{'x': 1.8196, 'y': 0.20231, 'z': 0},
{'x': 1.8622, 'y': 0.20231, 'z': 0},
{'x': 1.9052, 'y': 0.20231, 'z': 0},
{'x': 1.9487, 'y': 0.20231, 'z': 0},
{'x': 1.9926, 'y': 0.20231, 'z': 0},
{'x': 2.0369, 'y': 0.20231, 'z': 0},
{'x': 2.0817, 'y': 0.20231, 'z': 0},
{'x': 2.1269, 'y': 0.20231, 'z': 0},
{'x': 2.1725, 'y': 0.20231, 'z': 0},
{'x': 2.2187, 'y': 0.20231, 'z': 0},
{'x': 2.2652, 'y': 0.20231, 'z': 0},
{'x': 2.3123, 'y': 0.20231, 'z': 0},
{'x': 2.3598, 'y': 0.20231, 'z': 0},
{'x': 2.4078, 'y': 0.20231, 'z': 0},
{'x': 2.4563, 'y': 0.20231, 'z': 0},
{'x': 1.051, 'y': 0.1881, 'z': 0},
{'x': 1.0859, 'y': 0.1881, 'z': 0},
{'x': 1.1211, 'y': 0.1881, 'z': 0},
{'x': 1.1568, 'y': 0.1881, 'z': 0},
{'x': 1.1927, 'y': 0.1881, 'z': 0},
{'x': 1.229, 'y': 0.1881, 'z': 0},
{'x': 1.2657, 'y': 0.1881, 'z': 0},
{'x': 1.3028, 'y': 0.1881, 'z': 0},
{'x': 1.3402, 'y': 0.1881, 'z': 0},
{'x': 1.378, 'y': 0.1881, 'z': 0},
{'x': 1.4162, 'y': 0.1881, 'z': 0},
{'x': 1.4548, 'y': 0.1881, 'z': 0},
{'x': 1.4937, 'y': 0.1881, 'z': 0},
{'x': 1.533, 'y': 0.1881, 'z': 0},
{'x': 1.5728, 'y': 0.1881, 'z': 0},
{'x': 1.6129, 'y': 0.1881, 'z': 0},
{'x': 1.6534, 'y': 0.1881, 'z': 0},
{'x': 1.6944, 'y': 0.1881, 'z': 0},
{'x': 1.7357, 'y': 0.1881, 'z': 0},
{'x': 1.7774, 'y': 0.1881, 'z': 0},
{'x': 1.8196, 'y': 0.1881, 'z': 0},
{'x': 1.8622, 'y': 0.1881, 'z': 0},
{'x': 1.9052, 'y': 0.1881, 'z': 0},
{'x': 1.9487, 'y': 0.1881, 'z': 0},
{'x': 1.9926, 'y': 0.1881, 'z': 0},
{'x': 2.0369, 'y': 0.1881, 'z': 0}])
plt.scatter(data=df, x='x', y='y', label='original_data')
plt.legend()
plt.title('original data')
plt.show()
hull = ConvexHull(df[['x', 'y']])
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
convex_hull_plot_2d(hull, ax=ax)
fig.tight_layout()
plt.title('convex hull with points')
plt.show()
hull.points
array([[0.20215, 0.29703],
[0.22857, 0.29703],
[0.25526, 0.29703],
...,
[1.9487 , 0.1881 ],
[1.9926 , 0.1881 ],
[2.0369 , 0.1881 ]])

The convex hull is a nice approach, although it wouldn't solve the case that you are showing (the donut shape with an inner boundary).
I think that the algorithm that you need is called "Marching cubes" (or Marching squares, in 2D). It is a broadly used method, so you should be able to easily find some libraries in python that implement it.
https://en.wikipedia.org/wiki/Marching_squares
Basically, considering the 2D case, the algorithm works like this:
Discretize the space in a grid.
Count the number of points in every cell
Apply a threshold to the cells so you end up with either "empty" or "filled" cells
According to the state of every cell, and its neighbors, there are some predefined cases (16 in 2D) on how the boundary curve should look like.
Merge all the small curves
In 3D the idea is the same, but with cubes instead of squares, and with higher number of predefined cases.

The convex hull approaches mentioned by others do not work when the shape has holes (as in the case with your torus 🍩 example).
The problem you’re trying to solve is called surface reconstruction. The final mesh will not have the internal points as you wanted.
Open3D has some algorithms implemented for this and you can them on your data in Python.
Surface reconstruction
To convert your numpy point cloud to Open3D’s use
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(xyz)

Related

How can I obtain specific child objects in a json line In python

I have a JSON line and I have been trying to retrieve both "height" objects of the line but haven't been able to.
Here's my code and what I have tried:
dictonary = {'predictions': [{'x': 895.0, 'y': 1695.0, 'width': 1046.0, 'height': 1860.0, 'confidence': 0.9421133995056152, 'class': 'Potato', 'points': [{'x': 924.6015625, 'y': 2623.1372104673196}, {'x': 769.7421875, 'y': 2624.4923239162126}, {'x': 719.640625, 'y': 2614.0989617824443}, {'x': 623.9921875, 'y': 2559.17901274988}, {'x': 550.663834749923, 'y': 2481.6796875}, {'x': 496.3996585650308, 'y': 2395.140625}, {'x': 459.90986307738143, 'y': 2299.4921875}, {'x': 400.6397144303104, 'y': 2058.09375}, {'x': 378.0168381250084, 'y': 1880.4609375}, {'x': 377.99781038883225, 'y': 1702.828125}, {'x': 382.5907827376746, 'y': 1648.171875}, {'x': 399.5838603248672, 'y': 1575.296875}, {'x': 400.78761685201823, 'y': 1520.640625}, {'x': 417.8338516784328, 'y': 1470.5390625}, {'x': 418.98823283671425, 'y': 1420.4375}, {'x': 436.0082268099264, 'y': 1374.890625}, {'x': 437.167758266602, 'y': 1338.453125}, {'x': 454.28473747609706, 'y': 1292.90625}, {'x': 459.93999704686405, 'y': 1238.25}, {'x': 490.7490388888151, 'y': 1156.265625}, {'x': 491.8288016316368, 'y': 1133.4921875}, {'x': 508.8924306355354, 'y': 1106.1640625}, {'x': 527.9234807009638, 'y': 1046.953125}, {'x': 587.5365064396046, 'y': 946.7500000000001}, {'x': 701.421875, 'y': 837.3606423937706}, {'x': 769.7421875, 'y': 800.9531828008493}, {'x': 888.1640625, 'y': 782.7755220311303}, {'x': 1015.6953125, 'y': 787.2919818609915}, {'x': 1065.796875, 'y': 799.7093941263506}, {'x': 1111.34375, 'y': 800.7217819718936}, {'x': 1184.21875, 'y': 841.8955697617723}, {'x': 1253.0610901088744, 'y': 919.4218750000001}, {'x': 1271.270475224854, 'y': 951.3046875000001}, {'x': 1307.5979330272176, 'y': 1042.3984375}, {'x': 1308.4761630837356, 'y': 1074.28125}, {'x': 1325.4859189683493, 'y': 1110.71875}, {'x': 1326.6604271523647, 'y': 1156.265625}, {'x': 1343.6799094344485, 'y': 1206.3671875}, {'x': 1344.918760905306, 'y': 1302.015625}, {'x': 1361.9423092536952, 'y': 1415.8828125}, {'x': 1363.1149293109788, 'y': 1511.53125}, {'x': 1380.1437317333514, 'y': 1593.515625}, {'x': 1381.3134576724651, 'y': 1670.9453125}, {'x': 1398.360433947605, 'y': 1721.046875}, {'x': 1399.5143973675058, 'y': 1775.703125}, {'x': 1417.1507343999447, 'y': 1848.578125}, {'x': 1416.7072734730875, 'y': 2094.53125}, {'x': 1380.4241536814905, 'y': 2208.3984375}, {'x': 1289.0801683606567, 'y': 2372.3671875}, {'x': 1134.1171875, 'y': 2527.270247909732}, {'x': 1043.0234375, 'y': 2568.9770454914824}, {'x': 1029.359375, 'y': 2581.930440392619}, {'x': 924.6015625, 'y': 2623.1372104673196}], 'image_path': 'C:/Users/brind/PycharmProjects/detectingsize/Finaltesttivls.jpg', 'prediction_type': 'InstanceSegmentationModel'}, {'x': 1916.5, 'y': 1968.0, 'width': 639.0, 'height': 686.0, 'confidence': 0.8820076584815979, 'class': 'ObjComparePaper', 'points': [{'x': 2209.0234375, 'y': 2290.427330679962}, {'x': 1685.234375, 'y': 2290.414401768434}, {'x': 1630.578125, 'y': 2286.1950104231696}, {'x': 1621.4593084207368, 'y': 2276.71875}, {'x': 1607.73191020788, 'y': 2185.625}, {'x': 1603.2018627419584, 'y': 1775.703125}, {'x': 1621.4221478491934, 'y': 1711.9375}, {'x': 1671.5703125, 'y': 1643.3562532833657}, {'x': 1685.234375, 'y': 1638.2330774427853}, {'x': 2117.9296875, 'y': 1638.6612790110541}, {'x': 2177.3705950155977, 'y': 1648.171875}, {'x': 2182.9490722541473, 'y': 1748.375}, {'x': 2200.0747230334237, 'y': 1803.03125}, {'x': 2201.171766399287, 'y': 1967.0}, {'x': 2218.251697013421, 'y': 2039.875}, {'x': 2219.333945280965, 'y': 2203.84375}, {'x': 2227.350285291961, 'y': 2263.0546875}, {'x': 2218.2231592742232, 'y': 2285.828125}, {'x': 2209.0234375, 'y': 2290.427330679962}], 'image_path': 'C:/Users/brind/PycharmProjects/detectingsize/Finaltesttivls.jpg', 'prediction_type': 'InstanceSegmentationModel'}], 'image': {'width': '2915', 'height': '2768'}}
height1 = dictionary['predictions'][0]['height']
height2 = dictionary['predictions'][1]['height']
Here's the complete working code:
from roboflow import Roboflow
import json
rf = Roboflow(api_key="MY_API_KEY")
project = rf.workspace().project("myprojectname")
model = project.version(3).model
data = model.predict(filename).json()
for prediction in data["predictions"]:
height = prediction["height"]
print(height)
To test it with ur previous output, the code would be:
data = {'predictions': [{'x': 895.0, 'y': 1695.0, 'width': 1046.0, 'height': 1860.0, 'confidence': 0.9421133995056152, 'class': 'Potato', 'points': [{'x': 924.6015625, 'y': 2623.1372104673196}, {'x': 769.7421875, 'y': 2624.4923239162126}, {'x': 719.640625, 'y': 2614.0989617824443}, {'x': 623.9921875, 'y': 2559.17901274988}, {'x': 550.663834749923, 'y': 2481.6796875}, {'x': 496.3996585650308, 'y': 2395.140625}, {'x': 459.90986307738143, 'y': 2299.4921875}, {'x': 400.6397144303104, 'y': 2058.09375}, {'x': 378.0168381250084, 'y': 1880.4609375}, {'x': 377.99781038883225, 'y': 1702.828125}, {'x': 382.5907827376746, 'y': 1648.171875}, {'x': 399.5838603248672, 'y': 1575.296875}, {'x': 400.78761685201823, 'y': 1520.640625}, {'x': 417.8338516784328, 'y': 1470.5390625}, {'x': 418.98823283671425, 'y': 1420.4375}, {'x': 436.0082268099264, 'y': 1374.890625}, {'x': 437.167758266602, 'y': 1338.453125}, {'x': 454.28473747609706, 'y': 1292.90625}, {'x': 459.93999704686405, 'y': 1238.25}, {'x': 490.7490388888151, 'y': 1156.265625}, {'x': 491.8288016316368, 'y': 1133.4921875}, {'x': 508.8924306355354, 'y': 1106.1640625}, {'x': 527.9234807009638, 'y': 1046.953125}, {'x': 587.5365064396046, 'y': 946.7500000000001}, {'x': 701.421875, 'y': 837.3606423937706}, {'x': 769.7421875, 'y': 800.9531828008493}, {'x': 888.1640625, 'y': 782.7755220311303}, {'x': 1015.6953125, 'y': 787.2919818609915}, {'x': 1065.796875, 'y': 799.7093941263506}, {'x': 1111.34375, 'y': 800.7217819718936}, {'x': 1184.21875, 'y': 841.8955697617723}, {'x': 1253.0610901088744, 'y': 919.4218750000001}, {'x': 1271.270475224854, 'y': 951.3046875000001}, {'x': 1307.5979330272176, 'y': 1042.3984375}, {'x': 1308.4761630837356, 'y': 1074.28125}, {'x': 1325.4859189683493, 'y': 1110.71875}, {'x': 1326.6604271523647, 'y': 1156.265625}, {'x': 1343.6799094344485, 'y': 1206.3671875}, {'x': 1344.918760905306, 'y': 1302.015625}, {'x': 1361.9423092536952, 'y': 1415.8828125}, {'x': 1363.1149293109788, 'y': 1511.53125}, {'x': 1380.1437317333514, 'y': 1593.515625}, {'x': 1381.3134576724651, 'y': 1670.9453125}, {'x': 1398.360433947605, 'y': 1721.046875}, {'x': 1399.5143973675058, 'y': 1775.703125}, {'x': 1417.1507343999447, 'y': 1848.578125}, {'x': 1416.7072734730875, 'y': 2094.53125}, {'x': 1380.4241536814905, 'y': 2208.3984375}, {'x': 1289.0801683606567, 'y': 2372.3671875}, {'x': 1134.1171875, 'y': 2527.270247909732}, {'x': 1043.0234375, 'y': 2568.9770454914824}, {'x': 1029.359375, 'y': 2581.930440392619}, {'x': 924.6015625, 'y': 2623.1372104673196}], 'image_path': 'C:/Users/brind/PycharmProjects/detectingsize/Finaltesttivls.jpg', 'prediction_type': 'InstanceSegmentationModel'}, {'x': 1916.5, 'y': 1968.0, 'width': 639.0, 'height': 686.0, 'confidence': 0.8820076584815979, 'class': 'ObjComparePaper', 'points': [{'x': 2209.0234375, 'y': 2290.427330679962}, {'x': 1685.234375, 'y': 2290.414401768434}, {'x': 1630.578125, 'y': 2286.1950104231696}, {'x': 1621.4593084207368, 'y': 2276.71875}, {'x': 1607.73191020788, 'y': 2185.625}, {'x': 1603.2018627419584, 'y': 1775.703125}, {'x': 1621.4221478491934, 'y': 1711.9375}, {'x': 1671.5703125, 'y': 1643.3562532833657}, {'x': 1685.234375, 'y': 1638.2330774427853}, {'x': 2117.9296875, 'y': 1638.6612790110541}, {'x': 2177.3705950155977, 'y': 1648.171875}, {'x': 2182.9490722541473, 'y': 1748.375}, {'x': 2200.0747230334237, 'y': 1803.03125}, {'x': 2201.171766399287, 'y': 1967.0}, {'x': 2218.251697013421, 'y': 2039.875}, {'x': 2219.333945280965, 'y': 2203.84375}, {'x': 2227.350285291961, 'y': 2263.0546875}, {'x': 2218.2231592742232, 'y': 2285.828125}, {'x': 2209.0234375, 'y': 2290.427330679962}], 'image_path': 'C:/Users/brind/PycharmProjects/detectingsize/Finaltesttivls.jpg', 'prediction_type': 'InstanceSegmentationModel'}], 'image': {'width': '2915', 'height': '2768'}}
for prediction in data["predictions"]:
height = prediction["height"]
print(height)
Output:
1860.0
686.0
Link to execute the testing code : https://onlinegdb.com/bVQag6jqe

extract data from interactive graph

I'm trying to scrape the data from this interactive chart which is located at the bottom of the website below: https://www.vgchartz.com/tools/hw_date.php?reg=USA&ending=Yearly
I've used developer tools in chrome but cannot find the data points in the elements tab.
Would appreciate if someone can take a look and tell me if the data points are stored on the page somewhere or there is any way to do using Python
Thank you very much!
The data is included inside <script> tag on that page. To parse it, you can use js2py library. For example:
import ast
import js2py
import requests
url = "https://www.vgchartz.com/tools/hw_date.php?reg=USA&ending=Yearly"
data = re.search(
r"StockChart\(({.*?})\);", requests.get(url).text, flags=re.S
).group(1)
data = js2py.eval_js("data = " + data + ";")
data = ast.literal_eval(str(data))
print(data)
Prints:
{
"chart": {
"endOnTick": False,
"marginBottom": 90,
"marginLeft": 80,
"marginRight": 20,
"renderTo": "chart_container",
"startOnTick": False,
"zoomType": "y",
},
"legend": {"enabled": True},
"plotOptions": {"series": {"dataGrouping": {"smoothed": True}}},
"rangeSelector": {"selected": 5},
"series": [
{
"cropThreshold": 1,
"data": [
{"x": 1072933200000, "y": 1302609},
{"x": 1104555600000, "y": 2604003},
{"x": 1136091600000, "y": 5074726},
{"x": 1167627600000, "y": 8757992},
{"x": 1199163600000, "y": 10156740},
{"x": 1230786000000, "y": 10369446},
{"x": 1262322000000, "y": 8434877},
{"x": 1293858000000, "y": 4335275},
{"x": 1325394000000, "y": 2164269},
{"x": 1357016400000, "y": 600849},
],
...
The chart data is imbedded in the HTML response of a basic GET request to the link. The data points themselves can be found in a Javascript Object formatted in a script tag. To pull these points, you will need to use some sort of Javascript parser to access the Object and convert the JS object representation to a Python dictionary. Pure JSON parsing cannot easily be used here, since the Object is not initialized in valid JSON syntax. The code below uses the module pyjsparser which can be installed via pip: pip3 install pyjsparser.
import requests, pyjsparser
from bs4 import BeautifulSoup as soup
d = soup(requests.get('https://www.vgchartz.com/tools/hw_date.php?reg=USA&ending=Yearly'), 'html.parser')
ast = pyjsparser.parse(d.select_one('#chart_body > .chart_date_selector ~ script').text)
def to_json(ast):
if ast['type'] == 'ArrayExpression':
return [to_json(i) for i in ast['elements']]
if ast['type'] == 'ObjectExpression':
return {i['key']['name']:to_json(i['value']) for i in ast['properties']}
if ast['type'] == 'Literal':
return ast['value']
def get_chart_data(ast):
if isinstance(ast, dict):
if ast.get('type') == 'Property' and ast['key']['name'] == 'series' and ast['value']['type'] == 'ArrayExpression':
yield to_json(ast['value'])
return
for b in ast.values():
yield from get_chart_data(b)
elif isinstance(ast, list):
for i in ast:
yield from get_chart_data(i)
data = next(get_chart_data(ast))
Output:
[{'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'PSP', 'data': [{'x': 1072933200000.0, 'y': 0.0}, {'x': 1104555600000.0, 'y': 3527367.0}, {'x': 1136091600000.0, 'y': 2952955.0}, {'x': 1167627600000.0, 'y': 3563757.0}, {'x': 1199163600000.0, 'y': 3815680.0}, {'x': 1230786000000.0, 'y': 2452361.0}, {'x': 1262322000000.0, 'y': 1824105.0}, {'x': 1293858000000.0, 'y': 1245169.0}, {'x': 1325394000000.0, 'y': 274023.0}, {'x': 1357016400000.0, 'y': 128378.0}, {'x': 1388552400000.0, 'y': 26999.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'Wii', 'data': [{'x': 1136091600000.0, 'y': 1075329.0}, {'x': 1167627600000.0, 'y': 6444409.0}, {'x': 1199163600000.0, 'y': 9826502.0}, {'x': 1230786000000.0, 'y': 8989309.0}, {'x': 1262322000000.0, 'y': 7398500.0}, {'x': 1293858000000.0, 'y': 4878060.0}, {'x': 1325394000000.0, 'y': 2042064.0}, {'x': 1357016400000.0, 'y': 773488.0}, {'x': 1388552400000.0, 'y': 216453.0}, {'x': 1420088400000.0, 'y': 58765.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'X360', 'data': [{'x': 1104555600000.0, 'y': 563282.0}, {'x': 1136091600000.0, 'y': 3832778.0}, {'x': 1167627600000.0, 'y': 4356599.0}, {'x': 1199163600000.0, 'y': 4784134.0}, {'x': 1230786000000.0, 'y': 4691537.0}, {'x': 1262322000000.0, 'y': 6999773.0}, {'x': 1293858000000.0, 'y': 7777810.0}, {'x': 1325394000000.0, 'y': 6488715.0}, {'x': 1357016400000.0, 'y': 3164108.0}, {'x': 1388552400000.0, 'y': 855780.0}, {'x': 1420088400000.0, 'y': 165018.0}, {'x': 1451624400000.0, 'y': 67456.0}, {'x': 1483246800000.0, 'y': 5433.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'DS', 'data': [{'x': 1072933200000.0, 'y': 1302609.0}, {'x': 1104555600000.0, 'y': 2604003.0}, {'x': 1136091600000.0, 'y': 5074726.0}, {'x': 1167627600000.0, 'y': 8757992.0}, {'x': 1199163600000.0, 'y': 10156740.0}, {'x': 1230786000000.0, 'y': 10369446.0}, {'x': 1262322000000.0, 'y': 8434877.0}, {'x': 1293858000000.0, 'y': 4335275.0}, {'x': 1325394000000.0, 'y': 2164269.0}, {'x': 1357016400000.0, 'y': 600849.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'PS3', 'data': [{'x': 1136091600000.0, 'y': 667762.0}, {'x': 1167627600000.0, 'y': 2474435.0}, {'x': 1199163600000.0, 'y': 3547363.0}, {'x': 1230786000000.0, 'y': 4255949.0}, {'x': 1262322000000.0, 'y': 4737437.0}, {'x': 1293858000000.0, 'y': 4486935.0}, {'x': 1325394000000.0, 'y': 3480788.0}, {'x': 1357016400000.0, 'y': 2237467.0}, {'x': 1388552400000.0, 'y': 721523.0}, {'x': 1420088400000.0, 'y': 274884.0}, {'x': 1451624400000.0, 'y': 125072.0}, {'x': 1483246800000.0, 'y': 12482.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': '3DS', 'data': [{'x': 1293858000000.0, 'y': 4056029.0}, {'x': 1325394000000.0, 'y': 3542069.0}, {'x': 1357016400000.0, 'y': 3905067.0}, {'x': 1388552400000.0, 'y': 2518536.0}, {'x': 1420088400000.0, 'y': 2499074.0}, {'x': 1451624400000.0, 'y': 2456456.0}, {'x': 1483246800000.0, 'y': 2060575.0}, {'x': 1514782800000.0, 'y': 1534418.0}, {'x': 1546318800000.0, 'y': 615394.0}, {'x': 1577854800000.0, 'y': 249847.0}, {'x': 1609477200000.0, 'y': 2787.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'PSV', 'data': [{'x': 1293858000000.0, 'y': 0.0}, {'x': 1325394000000.0, 'y': 1227049.0}, {'x': 1357016400000.0, 'y': 509085.0}, {'x': 1388552400000.0, 'y': 324396.0}, {'x': 1420088400000.0, 'y': 247162.0}, {'x': 1451624400000.0, 'y': 108422.0}, {'x': 1483246800000.0, 'y': 20908.0}, {'x': 1514782800000.0, 'y': 3119.0}, {'x': 1546318800000.0, 'y': 0.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'WiiU', 'data': [{'x': 1325394000000.0, 'y': 899502.0}, {'x': 1357016400000.0, 'y': 1214283.0}, {'x': 1388552400000.0, 'y': 1565573.0}, {'x': 1420088400000.0, 'y': 1361771.0}, {'x': 1451624400000.0, 'y': 460025.0}, {'x': 1483246800000.0, 'y': 9553.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'PS4', 'data': [{'x': 1357016400000.0, 'y': 2072802.0}, {'x': 1388552400000.0, 'y': 4656798.0}, {'x': 1420088400000.0, 'y': 5802890.0}, {'x': 1451624400000.0, 'y': 5077809.0}, {'x': 1483246800000.0, 'y': 5404655.0}, {'x': 1514782800000.0, 'y': 5245644.0}, {'x': 1546318800000.0, 'y': 3824746.0}, {'x': 1577854800000.0, 'y': 2084519.0}, {'x': 1609477200000.0, 'y': 613650.0}, {'x': 1641013200000.0, 'y': 168996.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'XOne', 'data': [{'x': 1357016400000.0, 'y': 1928445.0}, {'x': 1388552400000.0, 'y': 4325832.0}, {'x': 1420088400000.0, 'y': 4938473.0}, {'x': 1451624400000.0, 'y': 4696984.0}, {'x': 1483246800000.0, 'y': 4307564.0}, {'x': 1514782800000.0, 'y': 4304447.0}, {'x': 1546318800000.0, 'y': 2971031.0}, {'x': 1577854800000.0, 'y': 1508975.0}, {'x': 1609477200000.0, 'y': 503439.0}, {'x': 1641013200000.0, 'y': 22086.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'NS', 'data': [{'x': 1483246800000.0, 'y': 4880477.0}, {'x': 1514782800000.0, 'y': 5613050.0}, {'x': 1546318800000.0, 'y': 6479134.0}, {'x': 1577854800000.0, 'y': 9027556.0}, {'x': 1609477200000.0, 'y': 8012707.0}, {'x': 1641013200000.0, 'y': 2163947.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'PS5', 'data': [{'x': 1577854800000.0, 'y': 1940361.0}, {'x': 1609477200000.0, 'y': 4302047.0}, {'x': 1641013200000.0, 'y': 1328693.0}]}, {'showLastLabel': True, 'cropThreshold': 1.0, 'name': 'XS', 'data': [{'x': 1577854800000.0, 'y': 1525675.0}, {'x': 1609477200000.0, 'y': 3893991.0}, {'x': 1641013200000.0, 'y': 1937560.0}]}]

python convert list of dict to list of tuple

how can I convert a list of dict to a list of tuple?
Input:
[{'x': 0.4711900100474648, 'y': 0.6294374442355883}, {'x': 0.4732473419066774, 'y': 0.629306809190704}, {'x': 0.47373722332499346, 'y': 0.6274779185623242}, {'x': 0.47363924704133026, 'y': 0.6273908285324014}, {'x': 0.4731493656230142, 'y': 0.6261715681134813}, {'x': 0.4722349203088243, 'y': 0.6252571227992915}, {'x': 0.47210428526394, 'y': 0.62521357778433}, {'x': 0.4709285698599815, 'y': 0.6253442128292143}, {'x': 0.47024273587433907, 'y': 0.62612802309852}, {'x': 0.4706019822477708, 'y': 0.6283052738465912}]
I want this:
[(0,47..., 0.62...),(...,...)]
I tried this:
tupleList = [tuple(val['x'], val['y']) for dic in listOfDict for key,val in dic.items()]
I get error TypeError: 'float' object is not subscriptable
list_of_points = [{'x': 0.4711900100474648, 'y': 0.6294374442355883}, {'x': 0.4732473419066774, 'y': 0.629306809190704}, {'x': 0.47373722332499346, 'y': 0.6274779185623242}, {'x': 0.47363924704133026, 'y': 0.6273908285324014}, {'x': 0.4731493656230142, 'y': 0.6261715681134813}, {'x': 0.4722349203088243, 'y': 0.6252571227992915}, {'x': 0.47210428526394, 'y': 0.62521357778433}, {'x': 0.4709285698599815, 'y': 0.6253442128292143}, {'x': 0.47024273587433907, 'y': 0.62612802309852}, {'x': 0.4706019822477708, 'y': 0.6283052738465912}]
points_tuples = [(p['x'], p['y']) for p in list_of_points]
If you are using python 3.7+ and inserted the keys in x,y order (like done here) you could simply use the dict.values() of each inner dict. The values() will be in key (==input) order as well:
data = [{'x': 0.4711900100474648, 'y': 0.6294374442355883},
{'x': 0.4732473419066774, 'y': 0.629306809190704},
{'x': 0.47373722332499346, 'y': 0.6274779185623242},
{'x': 0.47363924704133026, 'y': 0.6273908285324014},
{'x': 0.4731493656230142, 'y': 0.6261715681134813},
{'x': 0.4722349203088243, 'y': 0.6252571227992915},
{'x': 0.47210428526394, 'y': 0.62521357778433},
{'x': 0.4709285698599815, 'y': 0.6253442128292143},
{'x': 0.47024273587433907, 'y': 0.62612802309852},
{'x': 0.4706019822477708, 'y': 0.6283052738465912}]
tup = [tuple(d.values()) for d in data]
Output:
[(0.4711900100474648, 0.6294374442355883), (0.4732473419066774, 0.629306809190704),
(0.47373722332499346, 0.6274779185623242), (0.47363924704133026, 0.6273908285324014),
(0.4731493656230142, 0.6261715681134813), (0.4722349203088243, 0.6252571227992915),
(0.47210428526394, 0.62521357778433), (0.4709285698599815, 0.6253442128292143),
(0.47024273587433907, 0.62612802309852), (0.4706019822477708, 0.6283052738465912)]

How can I extract out the value of X, Y, Z in a list of dataset in Python?

I was given a set of dataset as show below,
How can I extracted out the value of X, Y, Z of each series in Python?
I actually later need to calculate the standard deviation of each series. (x, y, z standard deviation)
{'deviceTimestamp': 166230, 'x': 3.5538, 'y': -9.7006, 'z': 3.3077}, {'deviceTimestamp': 166250, 'x': -1.4629, 'y': -7.0692, 'z': 2.2308}, {'deviceTimestamp': 166260, 'x': -6.7571, 'y': -5.0299, 'z': -0.076923}, {'deviceTimestamp': 166280, 'x': -5.0319, 'y': -6.5896, 'z': -0.076923}, {'deviceTimestamp': 166300, 'x': -0.21122, 'y': -8.9002, 'z': 2.5}, {'deviceTimestamp': 166320, 'x': 6.3477, 'y': -9.3142, 'z': 4.5385}, {'deviceTimestamp': 166340, 'x': 10.904, 'y': -9.9498, 'z': 5.6538}, {'deviceTimestamp': 166360, 'x': 9.5501, 'y': -8.5014, 'z': 5.6923}, {'deviceTimestamp': 166380, 'x': 7.7312, 'y': -8.5973, 'z': 5.6154}, {'deviceTimestamp': 166400, 'x': 8.9783, 'y': -10.132, 'z': 4.7692}, {'deviceTimestamp': 166420, 'x': 9.8307, 'y': -11.159, 'z': 5.0385}, {'deviceTimestamp': 166440, 'x': 7.7934, 'y': -10.556, 'z': 5.8077}, {'deviceTimestamp': 166460, 'x': 5.8261, 'y': -10.259, 'z': 2.8462}, {'deviceTimestamp': 166480, 'x': 4.4837, 'y': -10.092, 'z': 1.6538}, {'deviceTimestamp': 166500, 'x': 5.5556, 'y': -11.08, 'z': 1.8462}, {'deviceTimestamp': 166520, 'x': 8.4009, 'y': -12.06, 'z': 1.0}
You can use a list comprehension to construct a list with x, y, z.
data = [
{'deviceTimestamp': 166230, 'x': 3.5538, 'y': -9.7006, 'z': 3.3077},
{'deviceTimestamp': 166250, 'x': -1.4629, 'y': -7.0692, 'z': 2.2308},
{'deviceTimestamp': 166260, 'x': -6.7571, 'y': -5.0299, 'z': -0.076923},
{'deviceTimestamp': 166280, 'x': -5.0319, 'y': -6.5896, 'z': -0.076923},
{'deviceTimestamp': 166300, 'x': -0.21122, 'y': -8.9002, 'z': 2.5},
{'deviceTimestamp': 166320, 'x': 6.3477, 'y': -9.3142, 'z': 4.5385},
{'deviceTimestamp': 166340, 'x': 10.904, 'y': -9.9498, 'z': 5.6538},
{'deviceTimestamp': 166360, 'x': 9.5501, 'y': -8.5014, 'z': 5.6923},
{'deviceTimestamp': 166380, 'x': 7.7312, 'y': -8.5973, 'z': 5.6154},
{'deviceTimestamp': 166400, 'x': 8.9783, 'y': -10.132, 'z': 4.7692},
{'deviceTimestamp': 166420, 'x': 9.8307, 'y': -11.159, 'z': 5.0385},
{'deviceTimestamp': 166440, 'x': 7.7934, 'y': -10.556, 'z': 5.8077},
{'deviceTimestamp': 166460, 'x': 5.8261, 'y': -10.259, 'z': 2.8462},
{'deviceTimestamp': 166480, 'x': 4.4837, 'y': -10.092, 'z': 1.6538},
{'deviceTimestamp': 166500, 'x': 5.5556, 'y': -11.08, 'z': 1.8462},
{'deviceTimestamp': 166520, 'x': 8.4009, 'y': -12.06, 'z': 1.0}
]
coordinates = [[d['x'], d['y'], d['z']] for d in data]
Then the coordinates list is:
[[3.5538, -9.7006, 3.3077],
[-1.4629, -7.0692, 2.2308],
[-6.7571, -5.0299, -0.076923],
[-5.0319, -6.5896, -0.076923],
[-0.21122, -8.9002, 2.5],
[6.3477, -9.3142, 4.5385],
[10.904, -9.9498, 5.6538],
[9.5501, -8.5014, 5.6923],
[7.7312, -8.5973, 5.6154],
[8.9783, -10.132, 4.7692],
[9.8307, -11.159, 5.0385],
[7.7934, -10.556, 5.8077],
[5.8261, -10.259, 2.8462],
[4.4837, -10.092, 1.6538],
[5.5556, -11.08, 1.8462],
[8.4009, -12.06, 1.0]]
To get the standard deviation, you can use numpy or write your own function.
import numpy as np
# Population standard deviation per coordinate.
np.std(coordinates, axis=1)
# array([6.19099304, 3.82337866, 2.83117498, 2.77675246, 4.86271126,
# 6.99575755, 8.85637189, 7.76173229, 7.25026715, 8.19868452,
# 8.98079242, 8.22201761, 6.98694428, 6.31068919, 7.1304471 ,
# 8.45895548])
Here is a similar function using the standard library.
import math
def stdev(values):
mean = sum(values) / len(values)
numerator = sum((x - mean) ** 2 for x in values)
denominator = len(values)
return math.sqrt(numerator / denominator)
[stdev(c) for c in coordinates]
You can of course use the keys in a comprehension as others have show. However, I like the functional style and succinctness of operator.itemgetter when there are multiple keys. You can create a list or use map (or both). For example:
from operator import itemgetter
data = [{'deviceTimestamp': 166230, 'x': 3.5538, 'y': -9.7006, 'z': 3.3077}, {'deviceTimestamp': 166250, 'x': -1.4629, 'y': -7.0692, 'z': 2.2308}, {'deviceTimestamp': 166260, 'x': -6.7571, 'y': -5.0299, 'z': -0.076923}, {'deviceTimestamp': 166280, 'x': -5.0319, 'y': -6.5896, 'z': -0.076923}, {'deviceTimestamp': 166300, 'x': -0.21122, 'y': -8.9002, 'z': 2.5}, {'deviceTimestamp': 166320, 'x': 6.3477, 'y': -9.3142, 'z': 4.5385}, {'deviceTimestamp': 166340, 'x': 10.904, 'y': -9.9498, 'z': 5.6538}, {'deviceTimestamp': 166360, 'x': 9.5501, 'y': -8.5014, 'z': 5.6923}, {'deviceTimestamp': 166380, 'x': 7.7312, 'y': -8.5973, 'z': 5.6154}, {'deviceTimestamp': 166400, 'x': 8.9783, 'y': -10.132, 'z': 4.7692}, {'deviceTimestamp': 166420, 'x': 9.8307, 'y': -11.159, 'z': 5.0385}, {'deviceTimestamp': 166440, 'x': 7.7934, 'y': -10.556, 'z': 5.8077}, {'deviceTimestamp': 166460, 'x': 5.8261, 'y': -10.259, 'z': 2.8462}, {'deviceTimestamp': 166480, 'x': 4.4837, 'y': -10.092, 'z': 1.6538}, {'deviceTimestamp': 166500, 'x': 5.5556, 'y': -11.08, 'z': 1.8462}, {'deviceTimestamp': 166520, 'x': 8.4009, 'y': -12.06, 'z': 1.0}]
# coords is an iterator
coord = map(itemgetter('x','y','z'), data)
# you can make a list if you want
list(coord)
# or loop over the values without making a list:
coord = map(itemgetter('x','y','z'), data)
for x, y, z in coord:
print(x,y,z)
Assuming you're using python 3
data = {'deviceTimestamp': 166230, 'x': 3.5538, 'y': -9.7006, 'z': 3.3077}, {'deviceTimestamp': 166250, 'x': -1.4629, 'y': -7.0692, 'z': 2.2308}, {'deviceTimestamp': 166260, 'x': -6.7571, 'y': -5.0299, 'z': -0.076923}, {'deviceTimestamp': 166280, 'x': -5.0319, 'y': -6.5896, 'z': -0.076923}, {'deviceTimestamp': 166300, 'x': -0.21122, 'y': -8.9002, 'z': 2.5}, {'deviceTimestamp': 166320, 'x': 6.3477, 'y': -9.3142, 'z': 4.5385}, {'deviceTimestamp': 166340, 'x': 10.904, 'y': -9.9498, 'z': 5.6538}, {'deviceTimestamp': 166360, 'x': 9.5501, 'y': -8.5014, 'z': 5.6923}, {'deviceTimestamp': 166380, 'x': 7.7312, 'y': -8.5973, 'z': 5.6154}, {'deviceTimestamp': 166400, 'x': 8.9783, 'y': -10.132, 'z': 4.7692}, {'deviceTimestamp': 166420, 'x': 9.8307, 'y': -11.159, 'z': 5.0385}, {'deviceTimestamp': 166440, 'x': 7.7934, 'y': -10.556, 'z': 5.8077}, {'deviceTimestamp': 166460, 'x': 5.8261, 'y': -10.259, 'z': 2.8462}, {'deviceTimestamp': 166480, 'x': 4.4837, 'y': -10.092, 'z': 1.6538}, {'deviceTimestamp': 166500, 'x': 5.5556, 'y': -11.08, 'z': 1.8462}, {'deviceTimestamp': 166520, 'x': 8.4009, 'y': -12.06, 'z': 1.0}
for item in data:
print(item[x])
print(item[y])
print(item[z])
dataset = [
{'deviceTimestamp': 166230, 'x': 3.5538, 'y': -9.7006, 'z': 3.3077},
{'deviceTimestamp': 166250, 'x': -1.4629, 'y': -7.0692, 'z': 2.2308}
{'deviceTimestamp': 166260, 'x': -6.7571, 'y': -5.0299, 'z': -0.076923},
]
for data in dataset:
print(data['x'], data['y'], data['z'])
[_['x'] for _ in dataset]
[_['y'] for _ in dataset]
[_['z'] for _ in dataset]
To calculate the stdev of each of 'x', 'y' and 'z' you can use stdev from the Python statistics package:
>>> data_set
({'deviceTimestamp': 166230, 'x': 3.5538, 'y': -9.7006, 'z': 3.3077}, {'deviceTimestamp': 166250, 'x': -1.4629, 'y': -7.0692, 'z': 2.2308}, {'deviceTimestamp': 166260, 'x': -6.7571, 'y': -5.0299, 'z': -0.076923}, {'deviceTimestamp': 166280, 'x': -5.0319, 'y': -6.5896, 'z': -0.076923}, {'deviceTimestamp': 166300, 'x': -0.21122, 'y': -8.9002, 'z': 2.5}, {'deviceTimestamp': 166320, 'x': 6.3477, 'y': -9.3142, 'z': 4.5385}, {'deviceTimestamp': 166340, 'x': 10.904, 'y': -9.9498, 'z': 5.6538}, {'deviceTimestamp': 166360, 'x': 9.5501, 'y': -8.5014, 'z': 5.6923}, {'deviceTimestamp': 166380, 'x': 7.7312, 'y': -8.5973, 'z': 5.6154}, {'deviceTimestamp': 166400, 'x': 8.9783, 'y': -10.132, 'z': 4.7692}, {'deviceTimestamp': 166420, 'x': 9.8307, 'y': -11.159, 'z': 5.0385}, {'deviceTimestamp': 166440, 'x': 7.7934, 'y': -10.556, 'z': 5.8077}, {'deviceTimestamp': 166460, 'x': 5.8261, 'y': -10.259, 'z': 2.8462}, {'deviceTimestamp': 166480, 'x': 4.4837, 'y': -10.092, 'z': 1.6538}, {'deviceTimestamp': 166500, 'x': 5.5556, 'y': -11.08, 'z': 1.8462}, {'deviceTimestamp': 166520, 'x': 8.4009, 'y': -12.06, 'z': 1.0})
from statistics import stdev
std_dev={}
for k in 'xyz':
std_dev[k]=stdev([x for d in data_set for x in [v for kt,v in d.items() if kt==k]])
>>> std_dev
{'x': 5.3742701745097445, 'y': 1.834613985511212, 'z': 2.0740453969047343}
import numpy as np
list_ = [{'deviceTimestamp': 166230, 'x': 3.5538, 'y': -9.7006, 'z': 3.3077}, {'deviceTimestamp': 166250, 'x': -1.4629, 'y': -7.0692, 'z': 2.2308}, {'deviceTimestamp': 166260, 'x': -6.7571, 'y': -5.0299, 'z': -0.076923}, {'deviceTimestamp': 166280, 'x': -5.0319, 'y': -6.5896, 'z': -0.076923}, {'deviceTimestamp': 166300, 'x': -0.21122, 'y': -8.9002, 'z': 2.5}, {'deviceTimestamp': 166320, 'x': 6.3477, 'y': -9.3142, 'z': 4.5385}, {'deviceTimestamp': 166340, 'x': 10.904, 'y': -9.9498, 'z': 5.6538}, {'deviceTimestamp': 166360, 'x': 9.5501, 'y': -8.5014, 'z': 5.6923}, {'deviceTimestamp': 166380, 'x': 7.7312, 'y': -8.5973, 'z': 5.6154}, {'deviceTimestamp': 166400, 'x': 8.9783, 'y': -10.132, 'z': 4.7692}, {'deviceTimestamp': 166420, 'x': 9.8307, 'y': -11.159, 'z': 5.0385}, {'deviceTimestamp': 166440, 'x': 7.7934, 'y': -10.556, 'z': 5.8077}, {'deviceTimestamp': 166460, 'x': 5.8261, 'y': -10.259, 'z': 2.8462}, {'deviceTimestamp': 166480, 'x': 4.4837, 'y': -10.092, 'z': 1.6538}, {'deviceTimestamp': 166500, 'x': 5.5556, 'y': -11.08, 'z': 1.8462}, {'deviceTimestamp': 166520, 'x': 8.4009, 'y': -12.06, 'z': 1.0}]
out = []
for dict_ in list_:
out.append([dict_['x'], dict_['y'], dict_['z']])
print(out)
print('standard deviation row-wise:', np.std(out, axis = 1))
output:
[[3.5538, -9.7006, 3.3077],
[-1.4629, -7.0692, 2.2308],
[-6.7571, -5.0299, -0.076923],
[-5.0319, -6.5896, -0.076923],
[-0.21122, -8.9002, 2.5],
[6.3477, -9.3142, 4.5385],
[10.904, -9.9498, 5.6538],
[9.5501, -8.5014, 5.6923],
[7.7312, -8.5973, 5.6154],
[8.9783, -10.132, 4.7692],
[9.8307, -11.159, 5.0385],
[7.7934, -10.556, 5.8077],
[5.8261, -10.259, 2.8462],
[4.4837, -10.092, 1.6538],
[5.5556, -11.08, 1.8462],
[8.4009, -12.06, 1.0]]
standard deviation row-wise:
[6.19099304 3.82337866 2.83117498 2.77675246 4.86271126 6.99575755
8.85637189 7.76173229 7.25026715 8.19868452 8.98079242 8.22201761
6.98694428 6.31068919 7.1304471 8.45895548]

Groupby and sort the values in dict in Python

I have a dictionary as follows in python and I have to group by 'label' and get the highest value of 'confidence' for each 'label'
[{'label': 'id',
'confidence': 0.11110526,
'topleft': {'x': 0, 'y': 0},
'bottomright': {'x': 187, 'y': 57}},
{'label': 'id',
'confidence': 0.10690566,
'topleft': {'x': 265, 'y': 0},
'bottomright': {'x': 525, 'y': 54}},
{'label': 'name',
'confidence': 0.15541315,
'topleft': {'x': 9, 'y': 24},
'bottomright': {'x': 116, 'y': 58}},
{'label': 'group',
'confidence': 0.12578075,
'topleft': {'x': 53, 'y': 24},
'bottomright': {'x': 153, 'y': 61}},
{'label': 'name',
'confidence': 0.12709439,
'topleft': {'x': 0, 'y': 0},
'bottomright': {'x': 247, 'y': 84}},
{'label': 'group',
'confidence': 0.116156094,
'topleft': {'x': 96, 'y': 23},
'bottomright': {'x': 191, 'y': 61}}]
How do I achieve this efficiently
You can do this with groupby
for n,g in groupby(tst,key=lambda x:x['label']):
print n,max(list(g),key=lambda x:x['confidence']).get('confidence')
Result:
id 0.11110526
name 0.15541315
group 0.12578075
name 0.12709439
group 0.116156094

Categories