<jupyter_start><jupyter_text>Create WP with n shutters per cycle<jupyter_code>photonic = Photonic(config='Cfg3')

freq = 45e6
shutter_per_cycle = 7
total_shutters = shutter_per_cycle + 8

shutters = photonic.generate_tof_shutters(op=photonic.op, freq=freq, 
                                  shutter_per_cycle=shutter_per_cycle, 
                                  total_shutters=total_shutters)                                                                           
shutters['dt'].shape, shutters['sh0'].shape, 
data = [None] * total_shutters # Generate blank list with length equal number of shutters
for i in range(total_shutters):
    data[i] = go.Scatter(x=shutters['dt'], y=shutters['sh'+str(i)],
                          mode='lines+markers',  # Select 'lines', 'markers' or 'lines+markers'
                          name='sh'+str(i))

layout = dict(title='WP - separated',
              xaxis=dict(title='time delay [sec]',type='linear'),  # Select 'log' or 'linear'
              yaxis=dict(title='Signal',type='linear'),  # Select 'log' or 'linear'
              template='plotly_dark')

iplot(dict(data=data, layout=layout))
data = [None] * shutter_per_cycle # Generate blank list with length equal number of shutters
for i in range(shutter_per_cycle):
    data[i] = go.Scatter(x=shutters['dt'], y=shutters['sh_comb'+str(i)],
                          mode='lines+markers',  # Select 'lines', 'markers' or 'lines+markers'
                          name='sh'+str(i))

layout = dict(title='WP - combined',
              xaxis=dict(title='time delay [sec]',type='linear'),  # Select 'log' or 'linear'
              yaxis=dict(title='Signal',type='linear'),  # Select 'log' or 'linear'
              template='plotly_dark')

iplot(dict(data=data, layout=layout))<jupyter_output><empty_output><jupyter_text>Calc phase of the phase modulation<jupyter_code>phase = photonic.get_modulation_phase(shutters, shutter_per_cycle, initial_phase = -3.0)   

diff_phase = np.diff(phase) * 3.
diff_phase[np.abs(diff_phase) > 1.5] = np.nan
data = 2 * [None]
data[0] = go.Scatter(x=shutters['dt'], y=phase,
                          mode='lines+markers',  # Select 'lines', 'markers' or 'lines+markers'
                          name='phase')

data[1] = go.Scatter(x=shutters['dt'][:-1], y=diff_phase,
                          mode='lines+markers',  # Select 'lines', 'markers' or 'lines+markers'
                          name='phase derivative')

layout = dict(title='WP - phase',
              xaxis=dict(title='time delay [sec]', type='linear'),  # Select 'log' or 'linear'
              yaxis=dict(title='Signal', type='linear'),  # Select 'log' or 'linear'
              template='plotly_dark')

iplot(dict(data=data, layout=layout))<jupyter_output><empty_output><jupyter_text>Calc distance<jupyter_code>shutters['dist'] = -c * shutters['dt'] / 2 + 10
data = 2 * [None]
data[0] = go.Scatter(x=shutters['dist'] , y=phase,
                          mode='lines+markers',  # Select 'lines', 'markers' or 'lines+markers'
                          name='phase')

data[1] = go.Scatter(x=shutters['dist'][:-1], y=diff_phase,
                          mode='lines+markers',  # Select 'lines', 'markers' or 'lines+markers'
                          name='phase derivative')

layout = dict(title='WP - phase',
              xaxis=dict(title='dist [m]', type='linear'),  # Select 'log' or 'linear'
              yaxis=dict(title='Signal', type='linear'),  # Select 'log' or 'linear'
              template='plotly_dark')

iplot(dict(data=data, layout=layout))
c
data = [None] * shutter_per_cycle # Generate blank list with length equal number of shutters
for i in range(shutter_per_cycle):
    data[i] = go.Scatter(x=shutters['dist'], y=shutters['sh_comb'+str(i)],
                          mode='lines+markers',  # Select 'lines', 'markers' or 'lines+markers'
                          name='sh'+str(i))

layout = dict(title='WP - combined',
              xaxis=dict(title='distance [m]',type='linear'),  # Select 'log' or 'linear'
              yaxis=dict(title='Signal',type='linear'),  # Select 'log' or 'linear'
              template='plotly_dark')

iplot(dict(data=data, layout=layout))<jupyter_output><empty_output><jupyter_text>Adding photonic signal - IR<jupyter_code>cw_signal = photonic.photoelectron2(dist_vec=shutters['dist'])
for i in range(shutter_per_cycle):
    shutters['ir'+str(i)] = cw_signal * shutters['sh_comb'+str(i)]
data = [None] * (shutter_per_cycle + 1) # Generate blank list with length equal number of shutters
sum_ir = np.zeros(shutters['dist'].shape)
for i in range(shutter_per_cycle):
    sum_ir = sum_ir + shutters['ir'+str(i)]
    data[i] = go.Scatter(x=shutters['dist'], y=shutters['ir'+str(i)],
                          mode='lines+markers',  # Select 'lines', 'markers' or 'lines+markers'
                          name='sh'+str(i))
data[shutter_per_cycle] = go.Scatter(x=shutters['dist'], y=sum_ir,
                          mode='lines+markers',  # Select 'lines', 'markers' or 'lines+markers'
                          name='sum_ir')

layout = dict(title='WP - IR',
              xaxis=dict(title='distance [m]',type='linear', range=[0.4, 7]),  # Select 'log' or 'linear'
              yaxis=dict(title='Signal [photoelectron]',type='log', range=[np.log10(1), np.log10(10000)]),  # Select 'log' or 'linear'
              template='plotly_dark')

iplot(dict(data=data, layout=layout))<jupyter_output><empty_output><jupyter_text>Add photon shot noise<jupyter_code>samples = 20
phase_per_dist = 2 * np.pi / (c/(2. * freq))
# Add Monte Carlo photon shot noise to signal
for i in range(shutter_per_cycle):
    shutters['shotN'+str(i)] = np.random.randn(samples, shutters['ir0'].shape[0]) * \
                                    np.matlib.repmat(np.sqrt(shutters['ir'+str(i)]), samples, 1) + \
                                    np.matlib.repmat(shutters['ir'+str(i)], samples, 1) 

noise_phase = photonic.get_modulation_phase(shutters, shutter_per_cycle, initial_phase = -3.0, key='shotN') 
phase_error = noise_phase - np.matlib.repmat(phase, samples, 1)
depth_error = phase_error / phase_per_dist   
depth_error.shape
data = (samples + 1) * [None]
for i in range(samples):
    data[i] = go.Scatter(x=shutters['dist'], y=depth_error[i,:],
                              mode='markers',  # Select 'lines', 'markers' or 'lines+markers'
                              name='depth error [m]')

data[samples] = go.Scatter(x=shutters['dist'], y=np.std(depth_error, axis=0),
                              mode='lines',  # Select 'lines', 'markers' or 'lines+markers'
                              name='depth stdev [m]')

layout = dict(title='WP - Depth Error',
              xaxis=dict(title='depth [m]', type='linear', range=[0.3,7.]),  # Select 'log' or 'linear'
              yaxis=dict(title='depth error [m] ', type='linear', range=[-0.07,0.07]),  # Select 'log' or 'linear'
              template='plotly_dark')

iplot(dict(data=data, layout=layout))<jupyter_output><empty_output><jupyter_text>Power consumption<jupyter_code>power = photonic.power_consumption()
P_opt = power['optical'] * 1000 # [mW]
P_light = power['light'] * 1000 # [mW]
P_sensor = power['sensor'] * 1000 # [mW]
P_heat = power['heat_light'] * 1000 + P_sensor
P_total = P_light + P_sensor  
print(f'Light Power Consumption is {P_light:2.1f} mW\nSensor Power Consumption is {P_sensor:2.1f} mW')
print(f'Total Power Consumption is {P_total:2.1f} mW')
print(f'Total Heat Dissipation is {P_heat:2.1f} mW')<jupyter_output>Light Power Consumption is 230.4 mW
Sensor Power Consumption is 165.9 mW
Total Power Consumption is 396.3 mW
Total Heat Dissipation is 304.1 mW
{'fraction_non_alphanumeric': 0.15476035000652996, 'fraction_numerical': 0.013059945148230378, 'mean_word_length': 3.0326487625065823, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '191188', 'license': 'MIT', 'n_tokens_mistral': 2644, 'n_tokens_neox': 2521, 'n_words': 505, 'path': 'examples/tof_working_point_photonic.ipynb', 'repo_name': 'davidxcohen/imaging', 'size': '7657'}