diff options
author | jaseg <git@jaseg.de> | 2023-12-30 16:38:02 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-12-30 16:38:02 +0100 |
commit | 458a5fdfc598517b9fbddd02d3e1ae7cc70ceb9d (patch) | |
tree | 0ba3319ddb214bc65dd402de13939cb9ca283574 /research/colorspace/csv_to_svg_path.py | |
parent | 9ee28abd5041ebbbc8acd39ddc84ca37e7255076 (diff) | |
parent | 58d54c5debedca8c91b28026f520b226ac8682f6 (diff) | |
download | blog-458a5fdfc598517b9fbddd02d3e1ae7cc70ceb9d.tar.gz blog-458a5fdfc598517b9fbddd02d3e1ae7cc70ceb9d.tar.bz2 blog-458a5fdfc598517b9fbddd02d3e1ae7cc70ceb9d.zip |
deploy.py auto-commitdeploy
Diffstat (limited to 'research/colorspace/csv_to_svg_path.py')
-rwxr-xr-x | research/colorspace/csv_to_svg_path.py | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/research/colorspace/csv_to_svg_path.py b/research/colorspace/csv_to_svg_path.py deleted file mode 100755 index 5f638ed..0000000 --- a/research/colorspace/csv_to_svg_path.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 -import textwrap - -def svg_path_from_points(points, r): - points_joined = ' '.join(f'{x:.6f} {y:.6f}' for x, y in points) - return textwrap.dedent(f''' - <?xml version="1.0" encoding="UTF-8" standalone="no"?> - <svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - width="{r*2}mm" - height="{r*2}mm" - viewBox="0 0 {r*2} {r*2}" - id="svg2"> - <g id="layer1"> - <path id="path2991" - style="fill:none;stroke:#000000;stroke-width:0.1mm;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - d="M 0,0 L {points_joined}" /> - </g> - </svg> - ''').strip() - -if __name__ == '__main__': - import argparse - parser = argparse.ArgumentParser() - parser.add_argument('locus_csv', help='CSV file containing locus coordinates. Format: lambda, x, y, z.') - parser.add_argument('-r', '--radius', type=float, default=100, help='Radius of plot area in mm') - args = parser.parse_args() - - import csv, ast - points = [] - with open(args.locus_csv, newline='') as f: - for row in csv.reader(f): - # use literal_eval to handle entries like "1.153E-5" - λ, x, y, z = (ast.literal_eval(e.strip()) for e in row) - points.append((x*args.radius*2, y*args.radius*2)) - - print(svg_path_from_points(points, args.radius)) |