simulit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- simulit/__init__.py +35 -0
- simulit/simulit.py +702 -0
- simulit-0.1.0.dist-info/METADATA +184 -0
- simulit-0.1.0.dist-info/RECORD +6 -0
- simulit-0.1.0.dist-info/WHEEL +4 -0
- simulit-0.1.0.dist-info/licenses/LICENSE +202 -0
simulit/__init__.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from .simulit import (
|
|
2
|
+
__version__,
|
|
3
|
+
Detector,
|
|
4
|
+
Drift,
|
|
5
|
+
Observation,
|
|
6
|
+
GaussianSource,
|
|
7
|
+
ExponentialGalaxy,
|
|
8
|
+
UniformDisk,
|
|
9
|
+
generate_sources,
|
|
10
|
+
generate_galaxies,
|
|
11
|
+
simulate_events,
|
|
12
|
+
create_truth_catalogue,
|
|
13
|
+
save_truth_catalogue,
|
|
14
|
+
save_events_to_fits,
|
|
15
|
+
make_image_from_events,
|
|
16
|
+
add_simulated_events_to_existing_list,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"__version__",
|
|
21
|
+
"Detector",
|
|
22
|
+
"Drift",
|
|
23
|
+
"Observation",
|
|
24
|
+
"GaussianSource",
|
|
25
|
+
"ExponentialGalaxy",
|
|
26
|
+
"UniformDisk",
|
|
27
|
+
"generate_sources",
|
|
28
|
+
"generate_galaxies",
|
|
29
|
+
"simulate_events",
|
|
30
|
+
"create_truth_catalogue",
|
|
31
|
+
"save_truth_catalogue",
|
|
32
|
+
"save_events_to_fits",
|
|
33
|
+
"make_image_from_events",
|
|
34
|
+
"add_simulated_events_to_existing_list",
|
|
35
|
+
]
|
simulit/simulit.py
ADDED
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from astropy.io import fits
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
from typing import ClassVar, TypeAlias
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0"
|
|
12
|
+
FWHM_TO_SIGMA = 1.0 / (2.0 * np.sqrt(2.0 * np.log(2.0)))
|
|
13
|
+
UVIT_FINAL_IMAGE_SIZE = 4800
|
|
14
|
+
UVIT_FRAME_RATE = 28.719265
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True)
|
|
18
|
+
class Detector:
|
|
19
|
+
"""
|
|
20
|
+
Detector configuration used for event simulations.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
detector_size : int, optional
|
|
25
|
+
Size of the detector in pixels.
|
|
26
|
+
The default corresponds to the UVIT final image size.
|
|
27
|
+
|
|
28
|
+
frame_rate : float, optional
|
|
29
|
+
Detector frame rate in frames per second.
|
|
30
|
+
The default corresponds to the UVIT detector (full window mode).
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
detector_size: int = UVIT_FINAL_IMAGE_SIZE
|
|
34
|
+
frame_rate: float = UVIT_FRAME_RATE
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass(frozen=True)
|
|
38
|
+
class Drift:
|
|
39
|
+
"""
|
|
40
|
+
Pointing drift model.
|
|
41
|
+
|
|
42
|
+
A drift model specifies the detector X and Y offsets to be applied
|
|
43
|
+
to each detector frame during the simulation.
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
x_offset, y_offset : ndarray
|
|
48
|
+
One-dimensional arrays containing the detector X and Y offsets,
|
|
49
|
+
in detector pixels, for each frame.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
x_offset: np.ndarray
|
|
53
|
+
y_offset: np.ndarray
|
|
54
|
+
|
|
55
|
+
def __post_init__(self):
|
|
56
|
+
if len(self.x_offset) != len(self.y_offset):
|
|
57
|
+
raise ValueError("x_offset and y_offset must have the same length.")
|
|
58
|
+
if self.x_offset.ndim != 1 or self.y_offset.ndim != 1:
|
|
59
|
+
raise ValueError("Drift offsets must be one-dimensional arrays.")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class Observation:
|
|
64
|
+
"""
|
|
65
|
+
Observation configuration.
|
|
66
|
+
|
|
67
|
+
An Observation combines the exposure time, detector configuration,
|
|
68
|
+
and an optional pointing drift model. Event lists can be simulated
|
|
69
|
+
from one or more source models using :meth:`simulate_events`.
|
|
70
|
+
|
|
71
|
+
Parameters
|
|
72
|
+
----------
|
|
73
|
+
exposure : float
|
|
74
|
+
Exposure time in seconds.
|
|
75
|
+
|
|
76
|
+
detector : Detector, optional
|
|
77
|
+
Detector configuration. If not specified, the default UVIT
|
|
78
|
+
configuration is used.
|
|
79
|
+
|
|
80
|
+
drift : Drift, optional
|
|
81
|
+
Pointing drift model applied during the simulation.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
exposure: float
|
|
85
|
+
detector: Detector = field(default_factory=Detector)
|
|
86
|
+
drift: Drift | None = None
|
|
87
|
+
|
|
88
|
+
def simulate_events(self, sources, rng=None):
|
|
89
|
+
return simulate_events(
|
|
90
|
+
exposure=self.exposure,
|
|
91
|
+
sources=sources,
|
|
92
|
+
detector=self.detector,
|
|
93
|
+
rng=rng,
|
|
94
|
+
drift=self.drift,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@dataclass(frozen=True)
|
|
99
|
+
class GaussianSource:
|
|
100
|
+
"""
|
|
101
|
+
Gaussian point source.
|
|
102
|
+
|
|
103
|
+
Photons are sampled from a circular Gaussian distribution centred
|
|
104
|
+
at the specified detector position.
|
|
105
|
+
|
|
106
|
+
Parameters
|
|
107
|
+
----------
|
|
108
|
+
rate : float
|
|
109
|
+
Source count rate in counts per second.
|
|
110
|
+
|
|
111
|
+
x, y : float
|
|
112
|
+
Detector coordinates of the source centre in detector pixels.
|
|
113
|
+
|
|
114
|
+
fwhm : float
|
|
115
|
+
Full width at half maximum of the Gaussian profile in detector
|
|
116
|
+
pixels.
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
profile: ClassVar[str] = "gaussian"
|
|
120
|
+
|
|
121
|
+
rate: float
|
|
122
|
+
x: float
|
|
123
|
+
y: float
|
|
124
|
+
fwhm: float
|
|
125
|
+
|
|
126
|
+
def sample_positions(self, rng, n):
|
|
127
|
+
return _sample_gaussian(
|
|
128
|
+
rng,
|
|
129
|
+
self.x,
|
|
130
|
+
self.y,
|
|
131
|
+
n,
|
|
132
|
+
self.fwhm,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@dataclass(frozen=True)
|
|
137
|
+
class ExponentialGalaxy:
|
|
138
|
+
"""
|
|
139
|
+
Elliptical exponential galaxy.
|
|
140
|
+
|
|
141
|
+
Photons are sampled from a two-dimensional exponential surface
|
|
142
|
+
brightness profile with elliptical isophotes.
|
|
143
|
+
|
|
144
|
+
Parameters
|
|
145
|
+
----------
|
|
146
|
+
rate : float
|
|
147
|
+
Source count rate in counts per second.
|
|
148
|
+
|
|
149
|
+
x, y : float
|
|
150
|
+
Detector coordinates of the galaxy centre in detector pixels.
|
|
151
|
+
|
|
152
|
+
r0 : float
|
|
153
|
+
Exponential scale length in detector pixels.
|
|
154
|
+
|
|
155
|
+
q : float
|
|
156
|
+
Axis ratio (minor axis / major axis).
|
|
157
|
+
|
|
158
|
+
pa : float
|
|
159
|
+
Position angle in radians, measured counter-clockwise.
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
profile: ClassVar[str] = "elliptical_exp_disk"
|
|
163
|
+
|
|
164
|
+
rate: float
|
|
165
|
+
x: float
|
|
166
|
+
y: float
|
|
167
|
+
r0: float
|
|
168
|
+
q: float
|
|
169
|
+
pa: float
|
|
170
|
+
|
|
171
|
+
def sample_positions(self, rng, n):
|
|
172
|
+
return _sample_elliptical_exp_disk(
|
|
173
|
+
rng,
|
|
174
|
+
n,
|
|
175
|
+
self.x,
|
|
176
|
+
self.y,
|
|
177
|
+
self.r0,
|
|
178
|
+
self.q,
|
|
179
|
+
self.pa,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@dataclass(frozen=True)
|
|
184
|
+
class UniformDisk:
|
|
185
|
+
"""
|
|
186
|
+
Uniform circular source.
|
|
187
|
+
|
|
188
|
+
Photons are sampled uniformly within a circular disk.
|
|
189
|
+
|
|
190
|
+
Parameters
|
|
191
|
+
----------
|
|
192
|
+
rate : float
|
|
193
|
+
Source count rate in counts per second.
|
|
194
|
+
|
|
195
|
+
x, y : float
|
|
196
|
+
Detector coordinates of the disk centre in detector pixels.
|
|
197
|
+
|
|
198
|
+
radius : float
|
|
199
|
+
Disk radius in detector pixels.
|
|
200
|
+
"""
|
|
201
|
+
|
|
202
|
+
profile: ClassVar[str] = "uniform_disk"
|
|
203
|
+
|
|
204
|
+
rate: float
|
|
205
|
+
x: float
|
|
206
|
+
y: float
|
|
207
|
+
radius: float
|
|
208
|
+
|
|
209
|
+
def sample_positions(self, rng, n):
|
|
210
|
+
return _sample_uniform_disk(
|
|
211
|
+
rng,
|
|
212
|
+
n,
|
|
213
|
+
self.x,
|
|
214
|
+
self.y,
|
|
215
|
+
self.radius,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
Source: TypeAlias = GaussianSource | ExponentialGalaxy | UniformDisk
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def generate_sources(n_sources, rate, fwhm, x0, y0, radius, rng):
|
|
223
|
+
"""
|
|
224
|
+
Generate a random distribution of Gaussian point sources.
|
|
225
|
+
|
|
226
|
+
Source positions are sampled uniformly within a circular region.
|
|
227
|
+
|
|
228
|
+
Parameters
|
|
229
|
+
----------
|
|
230
|
+
n_sources : int
|
|
231
|
+
Number of sources to generate.
|
|
232
|
+
|
|
233
|
+
rate : float
|
|
234
|
+
Count rate assigned to every source.
|
|
235
|
+
|
|
236
|
+
fwhm : float
|
|
237
|
+
Gaussian FWHM in detector pixels.
|
|
238
|
+
|
|
239
|
+
x0, y0 : float
|
|
240
|
+
Centre of the generation region.
|
|
241
|
+
|
|
242
|
+
radius : float
|
|
243
|
+
Radius of the generation region in detector pixels.
|
|
244
|
+
|
|
245
|
+
rng : numpy.random.Generator
|
|
246
|
+
Random number generator.
|
|
247
|
+
|
|
248
|
+
Returns
|
|
249
|
+
-------
|
|
250
|
+
list of GaussianSource
|
|
251
|
+
Generated Gaussian source models.
|
|
252
|
+
"""
|
|
253
|
+
sources = []
|
|
254
|
+
|
|
255
|
+
x_positions, y_positions = _sample_uniform_disk(rng, n_sources, x0, y0, radius)
|
|
256
|
+
|
|
257
|
+
for x, y in zip(x_positions, y_positions):
|
|
258
|
+
sources.append(
|
|
259
|
+
GaussianSource(
|
|
260
|
+
rate=rate,
|
|
261
|
+
x=x,
|
|
262
|
+
y=y,
|
|
263
|
+
fwhm=fwhm,
|
|
264
|
+
)
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
return sources
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def generate_galaxies(
|
|
271
|
+
n_sources,
|
|
272
|
+
rate,
|
|
273
|
+
r0,
|
|
274
|
+
x0,
|
|
275
|
+
y0,
|
|
276
|
+
radius,
|
|
277
|
+
rng,
|
|
278
|
+
axis_ratio_low=0.4,
|
|
279
|
+
axis_ratio_high=1.0,
|
|
280
|
+
orientation_low=0 * np.pi,
|
|
281
|
+
orientation_high=2 * np.pi,
|
|
282
|
+
):
|
|
283
|
+
"""
|
|
284
|
+
Generate a random distribution of elliptical exponential galaxies.
|
|
285
|
+
|
|
286
|
+
Galaxy centres are sampled uniformly within a circular region. Each
|
|
287
|
+
galaxy is assigned a random axis ratio and position angle drawn from
|
|
288
|
+
the specified ranges.
|
|
289
|
+
|
|
290
|
+
Parameters
|
|
291
|
+
----------
|
|
292
|
+
n_sources : int
|
|
293
|
+
Number of galaxies to generate.
|
|
294
|
+
|
|
295
|
+
rate : float
|
|
296
|
+
Count rate assigned to every galaxy.
|
|
297
|
+
|
|
298
|
+
r0 : float
|
|
299
|
+
Exponential scale length in detector pixels.
|
|
300
|
+
|
|
301
|
+
x0, y0 : float
|
|
302
|
+
Centre of the generation region.
|
|
303
|
+
|
|
304
|
+
radius : float
|
|
305
|
+
Radius of the generation region in detector pixels.
|
|
306
|
+
|
|
307
|
+
rng : numpy.random.Generator
|
|
308
|
+
Random number generator.
|
|
309
|
+
|
|
310
|
+
axis_ratio_low, axis_ratio_high : float, optional
|
|
311
|
+
Lower and upper limits for the galaxy axis ratio.
|
|
312
|
+
|
|
313
|
+
orientation_low, orientation_high : float, optional
|
|
314
|
+
Lower and upper limits for the position angle in radians.
|
|
315
|
+
|
|
316
|
+
Returns
|
|
317
|
+
-------
|
|
318
|
+
list of ExponentialGalaxy
|
|
319
|
+
Generated galaxy models.
|
|
320
|
+
"""
|
|
321
|
+
|
|
322
|
+
galaxies = []
|
|
323
|
+
|
|
324
|
+
x_positions, y_positions = _sample_uniform_disk(rng, n_sources, x0, y0, radius)
|
|
325
|
+
|
|
326
|
+
for x, y in zip(x_positions, y_positions):
|
|
327
|
+
|
|
328
|
+
q = rng.uniform(axis_ratio_low, axis_ratio_high) # axis ratio
|
|
329
|
+
pa = rng.uniform(orientation_low, orientation_high) # random orientation
|
|
330
|
+
|
|
331
|
+
galaxies.append(
|
|
332
|
+
ExponentialGalaxy(
|
|
333
|
+
rate=rate,
|
|
334
|
+
x=x,
|
|
335
|
+
y=y,
|
|
336
|
+
r0=r0,
|
|
337
|
+
q=q,
|
|
338
|
+
pa=pa,
|
|
339
|
+
)
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
return galaxies
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def simulate_events(
|
|
346
|
+
exposure: float,
|
|
347
|
+
sources: list[Source],
|
|
348
|
+
detector: Detector,
|
|
349
|
+
rng=None,
|
|
350
|
+
drift: Drift | None = None,
|
|
351
|
+
):
|
|
352
|
+
"""
|
|
353
|
+
Simulate a UVIT-like photon event list from a set of astrophysical
|
|
354
|
+
sources.
|
|
355
|
+
|
|
356
|
+
This function generates a list of photon events (time, detector X,
|
|
357
|
+
detector Y) for a given exposure. Each source contributes photons
|
|
358
|
+
according to a Poisson process with mean rate ``rate × exposure``.
|
|
359
|
+
Photon arrival times are assigned to detector frames and converted
|
|
360
|
+
to seconds using the detector frame rate.
|
|
361
|
+
|
|
362
|
+
Source spatial distributions are determined by the specified source
|
|
363
|
+
models. The resulting events are clipped to the detector boundaries
|
|
364
|
+
and sorted by time.
|
|
365
|
+
|
|
366
|
+
Parameters
|
|
367
|
+
----------
|
|
368
|
+
exposure : float
|
|
369
|
+
Exposure time in seconds.
|
|
370
|
+
|
|
371
|
+
sources : list of Source
|
|
372
|
+
Source models to simulate.
|
|
373
|
+
|
|
374
|
+
detector : Detector, optional
|
|
375
|
+
Detector configuration. If not specified, the default UVIT
|
|
376
|
+
detector configuration is used.
|
|
377
|
+
|
|
378
|
+
rng : numpy.random.Generator, optional
|
|
379
|
+
Random number generator. If not provided, a new generator is
|
|
380
|
+
created.
|
|
381
|
+
|
|
382
|
+
drift : Drift, optional
|
|
383
|
+
Pointing drift model applied during the simulation.
|
|
384
|
+
|
|
385
|
+
Returns
|
|
386
|
+
-------
|
|
387
|
+
times, x, y : ndarray
|
|
388
|
+
Arrays containing the photon arrival times and detector
|
|
389
|
+
coordinates.
|
|
390
|
+
|
|
391
|
+
Raises
|
|
392
|
+
------
|
|
393
|
+
ValueError
|
|
394
|
+
If no photon events are generated.
|
|
395
|
+
"""
|
|
396
|
+
|
|
397
|
+
if rng is None:
|
|
398
|
+
rng = np.random.default_rng()
|
|
399
|
+
|
|
400
|
+
if detector is None:
|
|
401
|
+
detector = Detector()
|
|
402
|
+
|
|
403
|
+
detector_size = detector.detector_size
|
|
404
|
+
frame_rate = detector.frame_rate
|
|
405
|
+
|
|
406
|
+
all_times = []
|
|
407
|
+
all_x = []
|
|
408
|
+
all_y = []
|
|
409
|
+
|
|
410
|
+
n_frames = int(exposure * frame_rate)
|
|
411
|
+
|
|
412
|
+
for src in sources:
|
|
413
|
+
|
|
414
|
+
n = rng.poisson(src.rate * exposure)
|
|
415
|
+
if n == 0:
|
|
416
|
+
continue
|
|
417
|
+
|
|
418
|
+
frame_indices = rng.integers(0, n_frames, size=n)
|
|
419
|
+
times = frame_indices / frame_rate
|
|
420
|
+
|
|
421
|
+
x, y = src.sample_positions(rng, n)
|
|
422
|
+
|
|
423
|
+
all_times.append(times)
|
|
424
|
+
all_x.append(x)
|
|
425
|
+
all_y.append(y)
|
|
426
|
+
|
|
427
|
+
if not all_times:
|
|
428
|
+
raise ValueError("No events generated.")
|
|
429
|
+
|
|
430
|
+
times = np.concatenate(all_times)
|
|
431
|
+
x = np.concatenate(all_x)
|
|
432
|
+
y = np.concatenate(all_y)
|
|
433
|
+
|
|
434
|
+
if drift is not None:
|
|
435
|
+
|
|
436
|
+
frame_index = np.clip(
|
|
437
|
+
(times * frame_rate).astype(int),
|
|
438
|
+
0,
|
|
439
|
+
len(drift.x_offset) - 1,
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
x += drift.x_offset[frame_index]
|
|
443
|
+
y += drift.y_offset[frame_index]
|
|
444
|
+
|
|
445
|
+
# Keep only detector-valid events
|
|
446
|
+
mask = (x >= 0) & (x < detector_size) & (y >= 0) & (y < detector_size)
|
|
447
|
+
|
|
448
|
+
times = times[mask]
|
|
449
|
+
x = x[mask]
|
|
450
|
+
y = y[mask]
|
|
451
|
+
|
|
452
|
+
# Sort by time
|
|
453
|
+
order = np.argsort(times)
|
|
454
|
+
times = times[order]
|
|
455
|
+
x = x[order]
|
|
456
|
+
y = y[order]
|
|
457
|
+
|
|
458
|
+
return times, x, y
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
def create_truth_catalogue(sources: list[Source]):
|
|
462
|
+
"""
|
|
463
|
+
Create a truth catalogue from a list of simulated sources.
|
|
464
|
+
|
|
465
|
+
The returned structured array contains the intrinsic properties of
|
|
466
|
+
every simulated source and can be written to a FITS table using
|
|
467
|
+
:func:`save_truth_catalogue`.
|
|
468
|
+
|
|
469
|
+
Parameters
|
|
470
|
+
----------
|
|
471
|
+
sources : list of Source
|
|
472
|
+
Source models.
|
|
473
|
+
|
|
474
|
+
Returns
|
|
475
|
+
-------
|
|
476
|
+
numpy.ndarray
|
|
477
|
+
Structured NumPy array containing the source catalogue.
|
|
478
|
+
"""
|
|
479
|
+
rows = []
|
|
480
|
+
|
|
481
|
+
for i, src in enumerate(sources):
|
|
482
|
+
|
|
483
|
+
rows.append(
|
|
484
|
+
(
|
|
485
|
+
i,
|
|
486
|
+
src.profile,
|
|
487
|
+
src.rate,
|
|
488
|
+
src.x,
|
|
489
|
+
src.y,
|
|
490
|
+
getattr(src, "fwhm", np.nan),
|
|
491
|
+
getattr(src, "r0", np.nan),
|
|
492
|
+
getattr(src, "q", np.nan),
|
|
493
|
+
getattr(src, "pa", np.nan),
|
|
494
|
+
getattr(src, "radius", np.nan),
|
|
495
|
+
)
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
dtype = [
|
|
499
|
+
("ID", "i4"),
|
|
500
|
+
("PROFILE", "U20"),
|
|
501
|
+
("RATE", "f8"),
|
|
502
|
+
("X", "f8"),
|
|
503
|
+
("Y", "f8"),
|
|
504
|
+
("FWHM", "f8"),
|
|
505
|
+
("R0", "f8"),
|
|
506
|
+
("Q", "f8"),
|
|
507
|
+
("PA", "f8"),
|
|
508
|
+
("RADIUS", "f8"),
|
|
509
|
+
]
|
|
510
|
+
|
|
511
|
+
return np.array(rows, dtype=dtype)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
def save_truth_catalogue(truth, filename="truth_catalogue.fits"):
|
|
515
|
+
"""
|
|
516
|
+
Save a truth catalogue to a FITS binary table.
|
|
517
|
+
|
|
518
|
+
Parameters
|
|
519
|
+
----------
|
|
520
|
+
truth : numpy.ndarray
|
|
521
|
+
Structured array returned by :func:`create_truth_catalogue`.
|
|
522
|
+
|
|
523
|
+
filename : str, optional
|
|
524
|
+
Name of the output FITS file.
|
|
525
|
+
"""
|
|
526
|
+
cols = []
|
|
527
|
+
for name in truth.dtype.names:
|
|
528
|
+
cols.append(
|
|
529
|
+
fits.Column(
|
|
530
|
+
name=name,
|
|
531
|
+
format=(
|
|
532
|
+
"D"
|
|
533
|
+
if truth.dtype[name].kind == "f"
|
|
534
|
+
else "20A" if truth.dtype[name].kind == "U" else "J"
|
|
535
|
+
),
|
|
536
|
+
array=truth[name],
|
|
537
|
+
)
|
|
538
|
+
)
|
|
539
|
+
|
|
540
|
+
hdu = fits.BinTableHDU.from_columns(cols, name="TRUTH")
|
|
541
|
+
hdu.writeto(filename, overwrite=True)
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
def save_events_to_fits(times, x, y, filename="simulated_events.fits"):
|
|
545
|
+
"""
|
|
546
|
+
Save a simulated event list to a FITS binary table.
|
|
547
|
+
|
|
548
|
+
The output table contains the photon arrival time and detector
|
|
549
|
+
coordinates for every simulated event.
|
|
550
|
+
|
|
551
|
+
Parameters
|
|
552
|
+
----------
|
|
553
|
+
times, x, y : ndarray
|
|
554
|
+
Photon arrival times and detector coordinates.
|
|
555
|
+
|
|
556
|
+
filename : str, optional
|
|
557
|
+
Name of the output FITS file.
|
|
558
|
+
"""
|
|
559
|
+
cols = [
|
|
560
|
+
fits.Column(name="TIME", format="D", array=times),
|
|
561
|
+
fits.Column(name="X_DET", format="D", array=x),
|
|
562
|
+
fits.Column(name="Y_DET", format="D", array=y),
|
|
563
|
+
]
|
|
564
|
+
|
|
565
|
+
hdu = fits.BinTableHDU.from_columns(cols)
|
|
566
|
+
hdu.writeto(filename, overwrite=True)
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
def make_image_from_events(
|
|
570
|
+
x, y, exposure, detector_size, filename="simulated_image.fits"
|
|
571
|
+
):
|
|
572
|
+
"""
|
|
573
|
+
Create a detector image from simulated events.
|
|
574
|
+
|
|
575
|
+
Events are binned into detector pixels and converted to a count-rate
|
|
576
|
+
image.
|
|
577
|
+
|
|
578
|
+
Parameters
|
|
579
|
+
----------
|
|
580
|
+
x, y : ndarray
|
|
581
|
+
Detector coordinates of the simulated events.
|
|
582
|
+
|
|
583
|
+
exposure : float
|
|
584
|
+
Exposure time in seconds.
|
|
585
|
+
|
|
586
|
+
detector_size : int
|
|
587
|
+
Size of the detector image in pixels.
|
|
588
|
+
|
|
589
|
+
filename : str, optional
|
|
590
|
+
Name of the output FITS image.
|
|
591
|
+
"""
|
|
592
|
+
ndarray, _, _ = np.histogram2d(
|
|
593
|
+
x, y, bins=detector_size, range=[[0, detector_size], [0, detector_size]]
|
|
594
|
+
)
|
|
595
|
+
count_rate_image = ndarray.T / exposure
|
|
596
|
+
fits.writeto(filename, count_rate_image, overwrite=True)
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
def add_simulated_events_to_existing_list(
|
|
600
|
+
sim_time, sim_fx, sim_fy, frame_rate, existing_list, output_file
|
|
601
|
+
):
|
|
602
|
+
"""
|
|
603
|
+
Append simulated events to an existing UVIT Level-2 events list.
|
|
604
|
+
|
|
605
|
+
The simulated events are converted to the UVIT Level-2 events table
|
|
606
|
+
format, merged with the existing events, sorted by time, and written
|
|
607
|
+
to a new FITS file. This is useful for testing source detection,
|
|
608
|
+
photometry, and variability analysis software on realistic UVIT
|
|
609
|
+
datasets.
|
|
610
|
+
|
|
611
|
+
Parameters
|
|
612
|
+
----------
|
|
613
|
+
sim_time : ndarray
|
|
614
|
+
Simulated photon arrival times in seconds.
|
|
615
|
+
|
|
616
|
+
sim_fx, sim_fy : ndarray
|
|
617
|
+
Detector coordinates of the simulated photons.
|
|
618
|
+
|
|
619
|
+
frame_rate : float
|
|
620
|
+
Detector frame rate in frames per second.
|
|
621
|
+
|
|
622
|
+
existing_list : str
|
|
623
|
+
Path to the input UVIT Level-2 events list.
|
|
624
|
+
|
|
625
|
+
output_file : str
|
|
626
|
+
Path to the output FITS file.
|
|
627
|
+
"""
|
|
628
|
+
with fits.open(existing_list) as hdul:
|
|
629
|
+
events = hdul["EVENTS"].data
|
|
630
|
+
|
|
631
|
+
n_sim = len(sim_time)
|
|
632
|
+
new = np.zeros(n_sim, dtype=events.dtype)
|
|
633
|
+
t0 = events["Time"].min()
|
|
634
|
+
|
|
635
|
+
new["Time"] = t0 + sim_time
|
|
636
|
+
new["Fx"] = sim_fx
|
|
637
|
+
new["Fy"] = sim_fy
|
|
638
|
+
new["PacketSequence"] = 0
|
|
639
|
+
new["FrameCount"] = events["FrameCount"].min() + (sim_time * frame_rate).astype(
|
|
640
|
+
int
|
|
641
|
+
)
|
|
642
|
+
new["Max-Min"] = 0
|
|
643
|
+
new["Min"] = 0
|
|
644
|
+
new["BAD FLAG"] = 1
|
|
645
|
+
new["MULT PHOTON"] = 1
|
|
646
|
+
new["EFFECTIVE_NUM_PHOTONS"] = frame_rate
|
|
647
|
+
new["UVIT_MASTER_TIME"] = t0 + sim_time
|
|
648
|
+
new["Sky_RA"] = np.nan
|
|
649
|
+
new["Sky_DEC"] = np.nan
|
|
650
|
+
new["MJD_L2"] = (
|
|
651
|
+
events["MJD_L2"].min() + sim_time
|
|
652
|
+
) # MJD_L2 is in seconds, legacy design choice.
|
|
653
|
+
new["Fx_astronomical"] = sim_fx
|
|
654
|
+
new["Fy_astronomical"] = sim_fy
|
|
655
|
+
new["Fx_original"] = np.nan
|
|
656
|
+
new["Fy_original"] = np.nan
|
|
657
|
+
|
|
658
|
+
combined = np.concatenate([events, new])
|
|
659
|
+
order = np.argsort(combined["Time"])
|
|
660
|
+
combined = combined[order]
|
|
661
|
+
hdul["EVENTS"].data = combined
|
|
662
|
+
hdul.writeto(output_file, overwrite=True)
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
def _sample_gaussian(rng, x0, y0, n, fwhm):
|
|
666
|
+
sigma = fwhm * FWHM_TO_SIGMA
|
|
667
|
+
x = rng.normal(x0, sigma, n)
|
|
668
|
+
y = rng.normal(y0, sigma, n)
|
|
669
|
+
return x, y
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
def _sample_elliptical_exp_disk(rng, n, x0, y0, r0, q, pa):
|
|
673
|
+
# Radial distribution: Gamma(k=2, theta=r0)
|
|
674
|
+
r = rng.gamma(shape=2.0, scale=r0, size=n)
|
|
675
|
+
|
|
676
|
+
theta = rng.uniform(0, 2 * np.pi, n)
|
|
677
|
+
|
|
678
|
+
# Elliptical coordinates before rotation
|
|
679
|
+
x_ell = r * np.cos(theta)
|
|
680
|
+
y_ell = r * np.sin(theta) * q
|
|
681
|
+
|
|
682
|
+
# Rotate by PA
|
|
683
|
+
cos_pa = np.cos(pa)
|
|
684
|
+
sin_pa = np.sin(pa)
|
|
685
|
+
|
|
686
|
+
x_rot = x_ell * cos_pa - y_ell * sin_pa
|
|
687
|
+
y_rot = x_ell * sin_pa + y_ell * cos_pa
|
|
688
|
+
|
|
689
|
+
x = x0 + x_rot
|
|
690
|
+
y = y0 + y_rot
|
|
691
|
+
|
|
692
|
+
return x, y
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
def _sample_uniform_disk(rng, n, x0, y0, radius):
|
|
696
|
+
r = radius * np.sqrt(rng.uniform(0, 1, n))
|
|
697
|
+
theta = rng.uniform(0, 2 * np.pi, n)
|
|
698
|
+
|
|
699
|
+
x = x0 + r * np.cos(theta)
|
|
700
|
+
y = y0 + r * np.sin(theta)
|
|
701
|
+
|
|
702
|
+
return x, y
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: simulit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Simulate UVIT-like photon event lists from astrophysical source models
|
|
5
|
+
Project-URL: Homepage, https://github.com/prajwel/simulit
|
|
6
|
+
Project-URL: Issues, https://github.com/prajwel/simulit/issues
|
|
7
|
+
Author-email: Prajwel Joseph <prajwel.pj@gmail.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: AstroSat,UVIT,astronomy,detector,event list,photon,simulation
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Requires-Dist: astropy
|
|
17
|
+
Requires-Dist: numpy
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# Simulit
|
|
21
|
+
|
|
22
|
+
Simulit is a Python package for simulating UVIT-like photon event lists from astrophysical source models.
|
|
23
|
+
|
|
24
|
+
It is designed for developing, testing, and validating software for source detection, photometry, variability analysis, PSF improvement, and other UVIT data analysis applications.
|
|
25
|
+
|
|
26
|
+
Current source models include:
|
|
27
|
+
|
|
28
|
+
- Gaussian point sources
|
|
29
|
+
- Elliptical exponential galaxies
|
|
30
|
+
- Uniform circular sources
|
|
31
|
+
|
|
32
|
+
Simulit can also:
|
|
33
|
+
|
|
34
|
+
- Generate detector images from simulated event lists
|
|
35
|
+
- Create truth catalogues for validation and benchmarking
|
|
36
|
+
- Inject simulated events into existing UVIT Level-2 event lists
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install simulit
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
import numpy as np
|
|
48
|
+
import simulit as sm
|
|
49
|
+
|
|
50
|
+
rng = np.random.default_rng(42)
|
|
51
|
+
|
|
52
|
+
observation = sm.Observation(
|
|
53
|
+
exposure=2000,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
centre = observation.detector.detector_size / 2
|
|
57
|
+
|
|
58
|
+
sources = sm.generate_sources(
|
|
59
|
+
n_sources=100,
|
|
60
|
+
rate=0.1,
|
|
61
|
+
fwhm=1.2,
|
|
62
|
+
x0=centre,
|
|
63
|
+
y0=centre,
|
|
64
|
+
radius=2048,
|
|
65
|
+
rng=rng,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
times, x, y = observation.simulate_events(
|
|
69
|
+
sources,
|
|
70
|
+
rng=rng,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
truth = sm.create_truth_catalogue(sources)
|
|
74
|
+
|
|
75
|
+
sm.save_events_to_fits(times, x, y)
|
|
76
|
+
sm.save_truth_catalogue(truth)
|
|
77
|
+
|
|
78
|
+
sm.make_image_from_events(
|
|
79
|
+
x,
|
|
80
|
+
y,
|
|
81
|
+
exposure=observation.exposure,
|
|
82
|
+
detector_size=observation.detector.detector_size,
|
|
83
|
+
)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Source models
|
|
87
|
+
|
|
88
|
+
### GaussianSource
|
|
89
|
+
|
|
90
|
+
A Gaussian point source.
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
sm.GaussianSource(
|
|
94
|
+
rate=1.0,
|
|
95
|
+
x=2400,
|
|
96
|
+
y=2400,
|
|
97
|
+
fwhm=1.2,
|
|
98
|
+
)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### ExponentialGalaxy
|
|
102
|
+
|
|
103
|
+
An elliptical exponential galaxy with an exponential surface brightness profile.
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
sm.ExponentialGalaxy(
|
|
107
|
+
rate=0.5,
|
|
108
|
+
x=2400,
|
|
109
|
+
y=2400,
|
|
110
|
+
r0=3.0,
|
|
111
|
+
q=0.7,
|
|
112
|
+
pa=np.pi / 4,
|
|
113
|
+
)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### UniformDisk
|
|
117
|
+
|
|
118
|
+
A uniformly illuminated circular source.
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
sm.UniformDisk(
|
|
122
|
+
rate=5.0,
|
|
123
|
+
x=2400,
|
|
124
|
+
y=2400,
|
|
125
|
+
radius=200,
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Observation
|
|
130
|
+
|
|
131
|
+
An `Observation` combines
|
|
132
|
+
|
|
133
|
+
- exposure time
|
|
134
|
+
- detector configuration
|
|
135
|
+
- optional pointing drift
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
observation = sm.Observation(
|
|
139
|
+
exposure=2000,
|
|
140
|
+
)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
A pointing drift model can also be supplied.
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
drift = sm.Drift(
|
|
147
|
+
x_offset=x_shift,
|
|
148
|
+
y_offset=y_shift,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
observation = sm.Observation(
|
|
152
|
+
exposure=2000,
|
|
153
|
+
drift=drift,
|
|
154
|
+
)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Output products
|
|
158
|
+
|
|
159
|
+
Simulit can generate
|
|
160
|
+
|
|
161
|
+
- simulated photon event lists
|
|
162
|
+
- detector images
|
|
163
|
+
- truth catalogues
|
|
164
|
+
|
|
165
|
+
It can also append simulated events to an existing UVIT Level-2 event list, enabling realistic testing of UVIT analysis software.
|
|
166
|
+
|
|
167
|
+
## Examples
|
|
168
|
+
|
|
169
|
+
The `examples/` directory contains complete working examples.
|
|
170
|
+
|
|
171
|
+
- `mixed_sources.py` — mixed populations of point sources, galaxies, and diffuse background
|
|
172
|
+
- `synthetic_drift.py` — simulate observations with synthetic UVIT-inspired pointing drift
|
|
173
|
+
|
|
174
|
+
## Planned features
|
|
175
|
+
|
|
176
|
+
Future development is expected to include:
|
|
177
|
+
|
|
178
|
+
- additional source models
|
|
179
|
+
- realistic background models
|
|
180
|
+
- cosmic ray simulations
|
|
181
|
+
- detector artefacts
|
|
182
|
+
- UVIT slitless spectroscopy
|
|
183
|
+
- filter-dependent simulations
|
|
184
|
+
- additional validation datasets
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
simulit/__init__.py,sha256=lcHIc4CkaRHtj_atip4RrtBo3rNPCUWBKMoyFzkbeZI,740
|
|
2
|
+
simulit/simulit.py,sha256=Wwg94flZO9vO1wVBlM28O_2pLAGYh7udBZa1Akbw79o,17231
|
|
3
|
+
simulit-0.1.0.dist-info/METADATA,sha256=xZJ7w46Nj79-G7OUrVjrXLovnm0D_dbKJVJq_1jeYPU,3739
|
|
4
|
+
simulit-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
5
|
+
simulit-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
6
|
+
simulit-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|