@@ -46,7 +46,7 @@ def merge_da_multi(*da_arrays):
4646 merged_arrays .append (np .concatenate ((donor , acceptor )))
4747 a_ch = np .hstack ([np .zeros (donors [0 ].shape [0 ], dtype = bool ),
4848 np .ones (acceptors [1 ].shape [0 ], dtype = bool )])
49- index_sort = merged_arrays .argsort ()
49+ index_sort = merged_arrays [ 0 ] .argsort ()
5050 return [a [index_sort ] for a in merged_arrays ], a_ch [index_sort ]
5151
5252
@@ -112,10 +112,12 @@ def populations_diff_coeff(particles, populations):
112112
113113 D_list = []
114114 D_pop_start = 0 # start index of diffusion-based populations
115+ msg = ('The populations you defined do not align with the '
116+ 'populations in the trajectory file.' )
115117 for pop , (D , counts ) in zip (populations , D_counts ):
116118 D_list .append (D )
117- assert pop .start >= D_pop_start
118- assert pop .stop <= D_pop_start + counts
119+ assert pop .start >= D_pop_start , msg
120+ assert pop .stop <= D_pop_start + counts , msg
119121 D_pop_start += counts
120122 return D_list
121123
@@ -163,7 +165,16 @@ class TimestampSimulation:
163165
164166 def __init__ (self , S , em_rates , E_values , num_particles ,
165167 bg_rate_d , bg_rate_a , timeslice = None ):
166- assert np .sum (num_particles ) <= S .num_particles
168+ if np .sum (num_particles ) > S .num_particles :
169+ msg = (f'Wrong number of particles. \n \n With this trajectory '
170+ f'file you can specify up to { S .num_particles } particles, '
171+ f'but you requested { np .sum (num_particles )} .' )
172+ raise ValueError (msg )
173+ if np .sum (num_particles ) < S .num_particles :
174+ msg = (f'NOTE: You requested a timestamp simulation for only '
175+ f'{ np .sum (num_particles )} out of the { S .num_particles } '
176+ f'available particles.' )
177+ print (msg )
167178 if timeslice is None :
168179 timeslice = S .t_max
169180 assert timeslice <= S .t_max
@@ -340,9 +351,9 @@ def merge_da(self):
340351 """Merge donor and acceptor timestamps, computes `ts`, `a_ch`, `part`.
341352 """
342353 print (' - Merging D and A timestamps' , flush = True )
343- ts_d , ts_par_d , ts_pos_d = self .S .get_timestamps_data (
354+ ts_d , ts_par_d , ts_pos_d = self .S .get_timestamp_data (
344355 self .name_timestamps_d )
345- ts_a , ts_par_a , ts_pos_a = self .S .get_timestamps_data (
356+ ts_a , ts_par_a , ts_pos_a = self .S .get_timestamp_data (
346357 self .name_timestamps_a )
347358 da_pairs = [ts_d , ts_a , ts_par_d , ts_par_a ]
348359 self .pos = None
@@ -372,7 +383,8 @@ def _make_photon_hdf5(self, identity=None):
372383 detectors_specs = dict (spectral_ch1 = np .atleast_1d (0 ),
373384 spectral_ch2 = np .atleast_1d (1 ))))
374385 if self .pos is not None :
375- photon_data ['positions' ] = self .pos
386+ print ('positio' )
387+ photon_data ['user' ] = dict (positions = self .pos )
376388
377389 setup = dict (
378390 num_pixels = 2 ,
0 commit comments