-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathring.py
More file actions
122 lines (100 loc) · 4.23 KB
/
Copy pathring.py
File metadata and controls
122 lines (100 loc) · 4.23 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"""
Create a ring of objects representing theoretical populations of objects in the distant solar system.
When run as a script, uses CFEPS survey characterization, runs until 28 sources have been detected in this ring and plots the result.
"""
from ossssim.models import Parametric
from ossssim import OSSSSim, DetectFile, ModelFile, definitions, plotter
from astropy import units
class Ring(Parametric):
"""
Class used to create and store the objects generated and passed by the GiMeObj module into the main Driver.py
module that executes the survey simulator code.
"""
def __init__(self, ring_centre, ring_width, **kwargs):
"""Build a ring distribution of given with at a given distance. Ring is edge-on and circular.
Args:
ring_center (units.Quantity): The location of the ring, given as unit quantity
ring_width (units.Quantity): Width of the ring.
"""
super().__init__(**kwargs)
self.ring_center = ring_centre
self.ring_width = ring_width
@property
def a(self):
"""
Semi-major axis distribution for a narrow ring
"""
return self.distributions.normal(self.ring_center.to('au').value,
self.ring_width.to('au').value) * units.au
@property
def e(self):
"""
Eccentricity axis distribution for a narrow ring
"""
return self.distributions.constant(0.0)
@property
def inc(self):
"""
Inclination distribution for a narrow ring
"""
return self.distributions.constant(0.0) * units.rad
def run(model_filename,
detect_filename,
characterization_directory, seed, ntrack):
"""
Using the ParametricModel defined here run the survey simulator and save detected sources to detect_filename
Args:
model_filename (str): Name of file to store the model targets.
detect_filename (str): Name of file to store detected targets.
characterization_directory (str): Relative or absolute path to directory on disk where the characterization files are organized
seed (int): random number seed, specifying allows reproducibility
ntrack (int): < 0 continue for ntrack iterations;
> 0 continue until n_tracked tracked detections;
= 0 continue until input exhausted
"""
ssim = OSSSSim(characterization_directory=characterization_directory)
# the default Resonant class arguments setup for a Plutino model....
model = Ring(45*units.au, 1*units.au, seed=seed, component='Ring')
model_file = DetectFile(model_filename)
model_file.epoch = model.epoch
model_file.longitude_neptune =model.longitude_neptune
model_file.colors = definitions.COLORS.values()
model_file.write_header(seed)
detect_file = DetectFile(detect_filename)
detect_file.epoch = model.epoch
detect_file.longitude_neptune = model.longitude_neptune
detect_file.colors = definitions.COLORS.values()
detect_file.write_header(seed)
n_iter = n_track = n_hits = 0
for row in model:
n_iter += 1
result = ssim.simulate(row, seed=model.seed)
model_file.write_row(result)
if result['flag'] > 0:
n_hits += 1
detect_file.write_row(result)
if result['flag'] > 2:
n_track += 1
if (0 < ntrack < n_track) or (0 < -ntrack < n_iter):
break
detect_file.write_footer(n_iter=n_iter, n_hits=n_hits, n_track=n_track)
model_file.write_footer(n_iter=n_iter,
n_hits=n_hits,
n_track=n_track)
def face_down_plot(model_file: str, detect_file: str) -> None:
"""_
Plot the detected objects in a face-down plot
Args:
detect_file: name of file with the detected sources
"""
plot = plotter.RosePlot(definitions.Neptune['Longitude'])
plot.add_model(ModelFile(model_file), mc='k', ms=0.05, alpha=0.1)
plot.add_model(ModelFile(detect_file), ms=5, mc='g')
# plot.add_scale_rings()
plot.show()
if __name__ == '__main__':
run('RingModel.dat', 'RingDetect.dat',
'../tests/data/CFEPS',
123456789,
28)
face_down_plot('RingModel.dat', 'RingDetect.dat')