def loglike_h2och4(theta, y, fixed_parameters):
    # retrieve the global variables
    global pixel_bins
    global transit_data
    global err
    # only 'y' changes on the fly
    fixed = fixed_parameters
    x = pixel_bins
    yerr = err

    _, model = transit_model_H2OCH4(x, theta, fixed, p0=p0)

    sigma = yerr**2
    return -0.5 * np.sum((y - model)**2 / sigma + np.log(sigma))
# pixel_bins = pixel_wavelengths
# test the model generation function
# this produces the 'true' transit spectrum
fixed_parameters = (fine_wavelengths, water_cross_sections, ch4_cross_sections,
                    nh3_cross_sections, hcn_cross_sections, h2_cross_sections,
                    g_planet, rad_star, R)
theta = (
    rad_planet,
    T,
    log_f_h2o,
    log_fch4,
)

# generate spectrum
pixel_wavelengths, pixel_transit_depth = transit_model_H2OCH4(
    pixel_bins, theta, fixed_parameters)

# generate photon noise from a signal value
# signal = 1.22e9
# noise = (np.random.poisson(lam=signal, size=pixel_transit_depth.size) - signal)/signal
'''
generate noise instances!!!
'''
# convert error from parts per million to fractional
err = sampling_err * 1e-6

num_noise_inst = number_trials
noise_inst = []
while len(noise_inst) < num_noise_inst:
    # increase noise by 0%
    noise_inst.append(np.random.normal(scale=err * 1))
# generate spectrum
pixel_wavelengths_h2o, pixel_transit_depth_h2o = transit_model_H2O(pixel_bins,
                                                                   theta_h2o,
                                                                   fixed_h2o,
                                                                   p0=p0)

pixel_wavelengths_ch4, pixel_transit_depth_ch4 = transit_model_CH4(pixel_bins,
                                                                   theta_ch4,
                                                                   fixed_ch4,
                                                                   p0=p0)

pixel_wavelengths_null, pixel_transit_depth_null = transit_model_NULL(
    pixel_bins, theta_null, fixed_null, p0=p0)

pixel_wavelengths_mix, pixel_transit_depth_mix = transit_model_H2OCH4(
    pixel_bins, theta_h2och4, fixed_h2och4, p0=p0)

if np.array_equal(pixel_wavelengths_h2o, pixel_wavelengths_ch4):
    pixel_wavelengths = pixel_wavelengths_h2o

if plot:
    # compare the spectrums, to check
    fig, ax = plt.subplots(figsize=(8, 6))
    ax.plot(pixel_wavelengths_h2o,
            pixel_transit_depth_h2o * 1e6,
            'o',
            label='H2O')
    ax.plot(pixel_wavelengths_ch4,
            pixel_transit_depth_ch4 * 1e6,
            'o',
            label='CH4')