-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotstar.py
More file actions
73 lines (59 loc) · 2 KB
/
plotstar.py
File metadata and controls
73 lines (59 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
"""
Plot group numbers by location
Author: Ryan Feathers jrf296
Date: 12/01/2021
"""
import argparse
import starfile
import os.path
import plotly.express as px
# def is_valid_file(parser, arg):
# if not os.path.exists(arg):
# parser.error("The file %s does not exist!" % arg)
# else:
# return open(arg, 'r') # return an open file handle
parser = argparse.ArgumentParser()
parser.add_argument('--i', type=str, required=True, help='input particle file')
parser.add_argument('--color', type=str, required=False, help ='data value to color' )
parser.add_argument('--z', nargs='?', const=1, type=int, help = ' 3D with rlnCoordinateZ')
args = parser.parse_args()
df = starfile.read(args.i)
particles = df['particles']
if args.z == 1:
###3D Plot###
if "rlnCoordinateZ" in particles.columns:
fig = px.scatter_3d(particles, x="rlnCoordinateX", y="rlnCoordinateY", \
z = "rlnCoordinateZ", color = args.color, size_max=1)
fig.update_traces(marker={'size': 2})
fig.update_layout(
scene = dict(
xaxis = dict(range = [0,5760],),
yaxis = dict(range = [0,4092],),
zaxis = dict(range = [0,3000],)),
scene_aspectmode='manual',
scene_aspectratio=dict(x=1, y=.8, z=.6))
print("Plotting z=rlnCoordinateZ")
fig.show()
elif "rlnDefocusU" in particles.columns:
fig = px.scatter_3d(particles, x="rlnCoordinateX", y="rlnCoordinateY", \
z = "rlnDefocusU", color = args.color, size_max=1)
fig.update_traces(marker={'size': 2})
fig.update_layout(
scene = dict(
xaxis = dict(range = [0,5760],),
yaxis = dict(range = [0,4092],),
zaxis = dict(range = [0,20000],)),
scene_aspectmode='manual',
scene_aspectratio=dict(x=1, y=.8, z=.6))
print("Plotting z=rlnDefocusU")
fig.show()
else:
print("No Z value found")
else:
###2D plot###
fig = px.scatter(particles, x="rlnCoordinateX", y="rlnCoordinateY", \
color = args.color)
fig.update_traces(marker={'size': 5})
print("Plotting in 2D")
fig.show()