# Enter the specs of the detector
nep = 2.34e-12  # in Watts per root hz
BW = 10e6  # Bandwidth in Hz
gain = 0.75e4  # gain in V/A
responsivity = 0.5  # Amps per Watt (assume 800 nm)
pmin = nep * np.sqrt(BW)
volts_min = pmin * responsivity * gain
print("voltage generated by p_min:",volts_min)

"""
Explanation: This is for the Thorlabs PDA36A at the 20dB setting.
End of explanation
"""


scope_floor_factor = 0.010/volts_min

# the power has to be scope_floor_factor times larger in order to generate 10mV:
pmin * scope_floor_factor

"""
Explanation: Note that we need at least 10mV to even resolve a signal on the scope. So the NEP is only part of the story:
End of explanation
"""


nep = 1.21e-12
BW = 260e3
gain = 2.38e4
responsivity = 0.5
pmin = nep * np.sqrt(BW)
volts_min = pmin * responsivity * gain
print(volts_min)

scope_floor_factor = 0.010/volts_min

# resolvable power:
pmin * scope_floor_factor

"""
Explanation: This setting (20dB) leaves plenty of bandwidth but can't resolve our signal (1.3uW). It's limited to double our signal.
Now for the 30dB setting:
End of explanation
"""


nep = 0.2e-12
BW = 50e6
gain = 50000
responsivity = 25
pmin = nep * np.sqrt(BW)
volts_min = pmin * responsivity * gain
print(volts_min)
scope_floor_factor = 0.010/volts_min

# resolvable power:
pmin * scope_floor_factor

"""
Explanation: On 30dB we start to hit the bandwidth limit but can resolve down to 0.8 uW (half our signal). Even so, we'd only get 10mV out of it.
Now the APD120A:
End of explanation
"""


1.3e-6 * 50000 * 25  # watts times volts/amp times amps/watt gives volts:

"""
Explanation: This can resolve down to 8nW so our 1.3uW would be ~1000x larger.
Final question: what is the voltage generated by hitting it with a 1.3uW pulse?
End of explanation
"""


