unravel.utilities.points_compressor module#
Use utils_points_compressor
(points_compressor
) from UNRAVEL to pack or unpack point data in a CSV file or summarize the number of points per region.
- Input:
CSV file with either unpacked (x, y, z, Region_ID) or packed (x, y, z, Region_ID, count) format.
- Output:
CSV file with the desired packed or unpacked format.
Or save a summary CSV with the number of points per region.
Note
Packing: Group points with the same coordinates and Region_ID, adding a count column.
Unpacking: Expand packed points back to individual rows based on the count column.
Summary: Output a CSV summarizing the number of points per region.
Use only one of the following options: -p, -u, -s.
The summary option can be used with either packed or unpacked data.
Usage:#
utils_points_compressor -i path/<asterisk>_points.csv [-p or -u or -s] [-v]
- unravel.utilities.points_compressor.pack_points(df)[source]#
Pack points by grouping identical coordinates and summing their occurrences.
Parameters:#
- dfpandas.DataFrame
DataFrame with columns [‘x’, ‘y’, ‘z’, ‘Region_ID’]
Returns:#
- packed_dfpandas.DataFrame
DataFrame with columns [‘x’, ‘y’, ‘z’, ‘Region_ID’, ‘count’]
- unravel.utilities.points_compressor.unpack_points(df)[source]#
Unpack points by expanding them based on the count column.
Parameters:#
- dfpandas.DataFrame
DataFrame with columns [‘x’, ‘y’, ‘z’, ‘Region_ID’, ‘count’]
Returns:#
- unpacked_dfpandas.DataFrame
DataFrame with columns [‘x’, ‘y’, ‘z’, ‘Region_ID’]
- unravel.utilities.points_compressor.summarize_points(df)[source]#
Summarize points by counting the number of points per Region_ID.
Parameters:#
- dfpandas.DataFrame
DataFrame with columns [‘x’, ‘y’, ‘z’, ‘Region_ID’] or [‘x’, ‘y’, ‘z’, ‘Region_ID’, ‘count’]
Returns:#
- summary_dfpandas.DataFrame
DataFrame with columns [‘Region_ID’, ‘count’] summarizing the number of points per region.
- unravel.utilities.points_compressor.points_compressor(file_path, pack=False, unpack=False, summary=False)[source]#
Pack, unpack, or summarize points in a CSV file.
Parameters:#
- file_pathstr
Path to the input CSV file.
- packbool, optional
Pack the points by grouping them.
- unpackbool, optional
Unpack the points by expanding them based on the count column.
- summarybool, optional
Output a CSV summarizing the number of points per region.