### pypho v1

#### pypho_functions

pypho_functions is a collection of usefull functions to make your coding live easier.

dbm2w( power_dbm )

Converts a power value from dBm to W: $P|_{W} = 10^{\frac{P|_{dBm}}{10}}$ W

Parameter Type Description
power_dbm float Power value in dBm ($P|_{dBm}$).

Output Type Description
Power value in W float $P|_{W}$

w2dbm( power_w )

Converts a power value from W to dBm: $P|_{dBm} = 10\cdot \lg{\left(\frac{P|_{W}}{1mW}\right)}$ dBm.

Parameter Type Description
power_dbm float Power value in W ($P|_{W}$).

Output Type Description
Power value in dBm float $P|_{dBm}$

getpower_W( E )

Calculates the mean power in W of an optical Signal $E$: $P|_{dBm} = \frac{1}{T} \int _{ \tau=0 }^{ T } \left( \left\lvert E_x(\tau) \right\rvert^{ 2 } +\left\lvert E_y(\tau) \right\rvert^{ 2 }\right) d\tau$.

Parameter Type Description
E numpy.ndarray 2 dimensional array with complex values, which represents the sample points over time of the X- and Y-polarisation.
For example E[0]['E'].

Output Type Description
Power value in W float $P|_{W}$

getpower_dBm( E )

Same as getpower_w( E ), but output is in dBm.

Dec_x, Esx_I_ax, Esx_Q_ax, Dec_y, Esy_I_ax, Esy_Q_ax = ...
get_decision_matrix( gp, E, [constpts_x, constpts_y], [bits_x, bits_y], LO, filter, sigsampler)

Calculates a decision matrix needed for the BER calculation.

Parameter Type Description
gp numpy.ndarray Global parameters as defined in pypho_setup.
E list List which defines the optical data and noise signal. Read here about data signal and noise representation.
[constpts_x, constpts_y] numpy.ndarray Defines the constellation points.
Definition of constpoints can be found here pypho_arbmod.
[bits_x, bits_y] numpy.ndarray Definition of bits_* can be found here pypho_arbmod.
LO list Local oscillator of the coherent receiver. cw-laser defined by pypho_cwlaser.
filter list Optical filter of the coherent receiver. Defined by pypho_optfi.
sigsampler list Signal sampler defined by pypho_sample.

Output Type Description
Dec_x, Dec_y numpy.ndarray Array with the identification numbers of each constelleation point as defined in [constpts_x, constpts_y] (pypho_arbmod).
Esx_I_ax, Esx_Q_ax, Esy_I_ax, Esy_Q_ax numpy.ndarray Arrays representing the axis of the I- and Q- part of the received signal of the X- and Y-polarisation.

You can find an example for the BER calculation including the calculation of the decision matrix here.

BER = ...
calc_BER( gp, E, [constpts_x, constpts_y], OSNR, Dec_x, Dec_y, Esx_I_ax, Esx_Q_ax, Esy_I_ax, Esy_Q_ax, M, LO, filter, sigsampler)

Calculates a decision matrix needed for the BER calculation.

Parameter Type Description
gp numpy.ndarray Global parameters as defined in pypho_setup.
E list List which defines the optical data and noise signal. Read here about data signal and noise representation.
[constpts_x, constpts_y] numpy.ndarray Defines the constellation points.
Definition of constpoints can be found here pypho_arbmod.
OSNR float OSNR in dB
Dec_x, Dec_y numpy.ndarray Array with the identification numbers of each constellation point as defined in [constpts_x, constpts_y] (pypho_arbmod).
Esx_I_ax, Esx_Q_ax, Esy_I_ax, Esy_Q_ax numpy.ndarray Arrays representing the axis of the I- and Q- part of the received signal of the X- and Y-polarisation.
M inetger Defines the number of repitions. This parameters defines the lowest BER, which can be theoretical achieved.
LO list Local oscillator of the coherent receiver. cw-laser defined by pypho_cwlaser.
filter list Optical filter of the coherent receiver. Defined by pypho_optfi.
sigsampler list Signal sampler defined by pypho_sample.

Output Type Description
BER numpy.ndarray Array with two float numbers representing the BER of the X- and Y-polaristion: $\lg{\left(BER_x\right)}$ and $\lg{\left(BER_y\right)}$
You can find an example for the BER calculation including the calculation of the decision matrix here.