Source code for simu.lib.mask_random
'''
Created on 6 nov. 2017
@author: user
'''
import common.num.array_square_cell as asc
import numpy as np
[docs]class MaskRandom(asc.ArraySquareCell):
def __init__(self, cel_x=1, ncel_y=1, size_cm=1):
super().__init__(cel_x, ncel_y, size_cm)
[docs] def random_mask(self, p_percent_empty):
if (p_percent_empty > 1):
print('ERROR: pEmpty < 1 ')
return None
max_val = p_percent_empty*1000
self.random_value(0,999)
idx_empty = np.where(self.ar_val < max_val)
idx_full = np.where(self.ar_val >= max_val)
self.ar_val[idx_empty] = 1 # photon no stopped
self.ar_val[idx_full] = 0 # photon stopped
self.perct_open_goal = p_percent_empty
#print("percent result:",idx_empty[0].size/self.ar_val.size)