コード例 #1
0
# In[ ]:

w_aces, f_aces = load_phoenix_aces(
    "data/lte05200-1.50-0.0.PHOENIX-ACES-AGSS-COND-2011-HiRes.fits")
aces_spec_15 = Spectrum(xaxis=vac2air(w_aces * 10) / 10, flux=f_aces)

(aces_spec_15 - aces_spec).plot(label="Teff=5200")
plt.title("Difference between 1.5 and 4.5 logg for phoenix aces")
plt.show()

# In[ ]:

# Full Spectrum
plt.figure(figsize=(15, 10))
dusty_spec.plot(label="BT-DUSTY")
settl_spec.plot(label="BT-SETTL")
cond_spec.plot(label="BT-COND")
aces_spec.plot(linestyle="--", label="PHOENIX ACES")
next_spec.plot(linestyle=":", label="NEXTGEN")
#plt.plot(w_dusty_fits, f_dusty_fits/max(f_dusty_fits), label="Dusty fits")

plt.title("HD30501 host - 5200K")
plt.xlabel("Wavelength(nm)")
plt.ylabel("Flux")
plt.legend()
plt.show()

# In[ ]:

# COMPARISON TO PHOENIX ACES
コード例 #2
0
def main(star,
         obsnum,
         teff_1,
         logg_1,
         feh_1,
         teff_2,
         logg_2,
         feh_2,
         gamma,
         rv,
         plot_name=None):
    fig, axis = plt.subplots(2, 2, figsize=(15, 8), squeeze=False)

    for chip, ax in zip(range(1, 5), axis.flatten()):
        # Get observation data
        obs_name, params, output_prefix = iam_helper_function(
            star, obsnum, chip)

        # Load observed spectrum
        obs_spec = load_spectrum(obs_name)

        # Mask out bad portion of observed spectra
        obs_spec = spectrum_masking(obs_spec, star, obsnum, chip)

        # Barycentric correct spectrum
        _obs_spec = barycorr_crires_spectrum(obs_spec, extra_offset=None)

        # Determine Spectrum Errors
        # error_off = False
        # errors = spectrum_error(star, obsnum, chip, error_off=error_off)

        # Create model with given parameters
        host = load_starfish_spectrum([teff_1, logg_1, feh_1],
                                      limits=[2110, 2165],
                                      area_scale=True,
                                      hdr=True)
        if teff_2 is None:
            assert (logg_2 is None) and (feh_2 is None) and (
                rv == 0), "All must be None for bhm case."
            companion = Spectrum(xaxis=host.xaxis,
                                 flux=np.zeros_like(host.flux))
        else:
            companion = load_starfish_spectrum([teff_2, logg_2, feh_2],
                                               limits=[2110, 2165],
                                               area_scale=True,
                                               hdr=True)

        joint_model = inherent_alpha_model(host.xaxis,
                                           host.flux,
                                           companion.flux,
                                           gammas=gamma,
                                           rvs=rv)

        model_spec = Spectrum(xaxis=host.xaxis,
                              flux=joint_model(host.xaxis).squeeze())
        model_spec = model_spec.remove_nans()
        model_spec = model_spec.normalize("exponential")

        # plot
        obs_spec.plot(axis=ax, label="{}-{}".format(star, obsnum))
        model_spec.plot(axis=ax, linestyle="--", label="Chi-squared model")
        ax.set_xlim([obs_spec.xmin() - 0.5, obs_spec.xmax() + 0.5])

        ax.set_title("{} obs {} chip {}".format(star, obsnum, chip))
        ax.legend()
    plt.tight_layout()

    if plot_name is None:
        fig.show()
    else:
        if not (plot_name.endswith(".png") or plot_name.endswith(".pdf")):
            raise ValueError("plot_name does not end with .pdf or .png")
        fig.savefig(plot_name)

    return 0
コード例 #3
0
#print(next_spec.xaxis, next_spec.flux)
next_spec = next_spec.normalize("exponential")
dusty_spec.wav_select(*limits)
dusty_spec = dusty_spec.normalize("exponential")
settl_spec.wav_select(*limits)
settl_spec = settl_spec.normalize("exponential")
cond_spec.wav_select(*limits)
cond_spec = cond_spec.normalize("exponential")
aces_spec.wav_select(*limits)
aces_spec = aces_spec.normalize("exponential")
dusty_fits_spec.wav_select(*limits)
dusty_fits_spec = dusty_fits_spec.normalize("exponential")

# In[ ]:

next_spec.plot(label="nextgen")
dusty_spec.plot(label="dusty_spec")
cond_spec.plot(label="cond")
aces_spec.plot(label="aces")
dusty_fits_spec.plot(label="dusty_fits")
settl_spec.plot(label="settl")
plt.legend()
plt.show()

# In[ ]:

next_spec.plot(label="nextgen")
plt.legend()
plt.show()
dusty_spec.plot(label="dusty_spec")
plt.legend()
コード例 #4
0
# Manually load Phoenix spectra
#phoenix_path = simulators...
phoenix_path = "/home/jneal/Phd/data/PHOENIX-ALL/PHOENIX/"

phoenix_1 = "Z-0.0/lte06000-4.50-0.0.PHOENIX-ACES-AGSS-COND-2011-HiRes.fits"
phoenix_2 = "Z-0.0/lte05800-4.50-0.0.PHOENIX-ACES-AGSS-COND-2011-HiRes.fits"

wav = fits.getdata(phoenix_path + "WAVE_PHOENIX-ACES-AGSS-COND-2011.fits")
phoenix1 = fits.getdata(phoenix_path + phoenix_1)
phoenix2 = fits.getdata(phoenix_path + phoenix_2)

spec1 = Spectrum(xaxis=wav/10, flux=phoenix1)
spec2 = Spectrum(xaxis=wav/10, flux=phoenix2)
spec1.wav_select(2000,2200)
spec2.wav_select(2000,2200)
spec1.plot(label="1")
spec2.plot(label="2")

plt.legend()
plt.show()



# In[4]:


from Convolution.IP_multi_Convolution import convolve_spectrum

# Convolve to 50000
conv1 = convolve_spectrum(spec1, [2100, 2150], 50000, numProcs=4)
conv2 = convolve_spectrum(spec2, [2100, 2150], 50000, numProcs=4)