Files
dougal-software/bin/preplots.py

23 lines
528 B
Python
Raw Normal View History

2020-08-08 23:59:13 +02:00
import sps
"""
Preplot importing functions.
"""
def from_file (file):
if not "type" in file or file["type"] == "sps":
records = sps.from_file(file["path"], file["format"] if "format" in file else None )
else:
return "Not an SPS file"
lines = []
line_names = set([r["line_name"] for r in records])
for line_name in line_names:
line = dict(line_name=line_name)
line_points = [r for r in records if r["line_name"] == line_name]
if line_points:
line["points"] = line_points
lines.append(line)
return lines