Exemple #1
0
def generate_spectrum(planet):
    """
    Function to loop over to generate spectra. 
    """
    #INSERT PLANET SELECTION RULES HERE
    if planet["PlanetMass"] <= 17:  #Planet masses in Earth Masses
        #If Neptune or less, we'll just use the Exosims Flux Ratio for now at all wavelengths.
        #Later this will also use PICASO once we learn how to use it better
        planet_type = "Exosims"
        planet_spectrum = np.repeat(planet['Flux Ratio'], len(model_wvs))

    else:
        planet_type = "Gas"
        time1 = time.time()
        #Generate the spectrum and downsample to intermediate resolution
        atmospheric_parameters = spectrum.generate_picaso_inputs(planet,
                                                                 planet_type,
                                                                 clouds=True)
        planet_spectrum = spectrum.simulate_spectrum(planet, model_wvs,
                                                     intermediate_R,
                                                     atmospheric_parameters)

        time2 = time.time()
        print('Spectrum took {0:.3f} s'.format((time2 - time1)))

    return planet_type, planet_spectrum
Exemple #2
0
# sim_F_lambda = tmp[0]
# sim_F_lambda_errs = tmp[1]
# sim_F_lambda_stellar = tmp[2]
# noise_components = fits.open("noise_components.fits")[0].data
######################## Plot Cloud vs. Clear ######################

# get the best SNR Planet
avg_snrs = np.mean(snrs, axis=1)
print(avg_snrs)
argsort_snrs = np.argsort(np.abs(avg_snrs - 6))
bestsnr = argsort_snrs[0]  #np.argmax(avg_snrs)

# Generate the cloudy spectrum of this planet
planet = planet_table[rand_planets[bestsnr]]
atmospheric_parameters_clear = spectrum.generate_picaso_inputs(planet,
                                                               planet_type,
                                                               clouds=False)
planet_spectrum_clear = spectrum.simulate_spectrum(
    planet, model_wvs, intermediate_R, atmospheric_parameters_clear)

# Generate noisy spectra for cloudy and clear
clear_F_lambda, clear_F_lambda_errs, _ = observation.simulate_observation(
    tmt,
    psi_blue,
    planet_table[rand_planets[bestsnr]],
    planet_spectrum_clear,
    model_wvs,
    intermediate_R,
    inject_noise=True,
    post_processing_gain=post_processing_gain)
cloudy_F_lambda, cloudy_F_lambda_errs, _ = observation.simulate_observation(
#The number of wavelengths to generate. Divide by two for nyquist in the d_wv.
#Multiply the final number by 2 just to be safe.
n_model_wv = int((model_wv_high - model_wv_low) / (dwv_c / 2)) * 2
#Generate the model wavelenths
model_wvs = np.linspace(model_wv_low, model_wv_high,
                        n_model_wv)  #Choose some wavelengths

print("\n Starting to generate planet spectra")
for planet in planet_table[:n_planets_now]:

    #INSERT PLANET SELECTION RULES HERE
    planet_type = "Jupiter"
    planet_types.append(planet_type)

    #Generate the spectrum and downsample to intermediate resolution
    atmospheric_parameters = spectrum.generate_picaso_inputs(
        planet, planet_type)
    planet_spectrum, polarized_spectrum = spectrum.simulate_spectrum(
        planet,
        model_wvs,
        intermediate_R,
        atmospheric_parameters,
        package="picaso+pol")
    # planet_spectrum = spectrum.simulate_spectrum(planet, model_wvs, intermediate_R, atmospheric_parameters,package="picaso")
    planet_polarized_spectra.append(polarized_spectrum)
    planet_spectra.append(planet_spectrum)

print("Done generating planet spectra")
print("\n Starting to simulate observations")

post_processing_gain = 1000
sim_F_lambda, sim_F_lambda_errs, sim_F_lambda_stellar, noise_components = observation.simulate_observation_set(