# optical damping rates
Gamma_opt = param.opt_damp_rate()

# photon numbers at equiv
N = tools.photon_number(param.n_mech, Gamma_opt, param.Gamma)

# the calculated gamma is actually gamma/2
param.Gamma = param.Gamma * 2

# actually the detuning is given as an angular freq
param.detuning = param.detuning * 2 * np.pi

if calc_1D == True:
    # 1D calculations
    SXX_plus = tools.spectrum_output(omega, 0, param, False)
    SXX_minus = tools.spectrum_output(-omega, 0, param, False)
    SYY_plus = tools.spectrum_output(omega, 1, param, False)
    SYY_minus = tools.spectrum_output(-omega, 1, param, False)
    SZZ_plus = tools.spectrum_output(omega, 2, param, False)
    SZZ_minus = tools.spectrum_output(-omega, 2, param, False)

    plot_1D = True
    plot_3D = False
    style = '-'

# 3D calculations
if consider_3D == True:
    SXX_plus_3D = tools.spectrum_output(omega, 0, param, True)
    SXX_minus_3D = tools.spectrum_output(-omega, 0, param, True)
    SYY_plus_3D = tools.spectrum_output(omega, 1, param, True)

def photon_number(_n_j, _Gamma_opt, _Gamma_j):
    return _n_j * _Gamma_j / (abs(_Gamma_opt) + 2 * _Gamma_j)


####################
### PLOT EXAMPLE ###
####################

### omega plus

# calculate spectrum of q
param = (omega, omega_j, detuning, g, Gamma, kappa, n_opt, n_mech)
#param2 = (omega, omega_j, detuning, g, Gamma*1e-6, kappa, n_opt, n_mech)
S_x = tools.spectrum_output(0, param)
#S_y = tools.spectrum_output(1, param)
#S_z = tools.spectrum_output(2, param)

#S_x2 = tools.spectrum_output(0, param2)
#print(S_x-S_x2)

# plot
plt.plot(omega / (2 * np.pi) * 1e-3, S_x, label='x')
#plt.plot(omega/(2*np.pi)*1e-3, S_y, label = 'y')
#plt.plot(omega/(2*np.pi)*1e-3, S_z, label = 'z')
#plt.plot(omega/(2*np.pi)*1e-3, S_x2, label = 'x2')

plt.axvline(omega_j[0] / (2 * np.pi) * 1e-3, color='gray')
#plt.axvline(omega_j[1]/(2*np.pi)*1e-3, color='gray')
#plt.axvline(omega_j[2]/(2*np.pi)*1e-3, color='gray')