Example #1
0
        params = deepcopy(original_params)
        params.rp = self.depth**0.5
        params.t0 = self.t0
        return self.amp * transit_model(t, params)


run_name = 'trappist1_bright'
output_dir = '/gscratch/stf/bmmorris/libra/'


from mpi4py import MPI

#with ObservationArchive(run_name, 'a', outputs_dir=output_dir) as obs:
for planet in list('h'):
    original_params = trappist1(planet)
    with ObservationArchive(run_name, 'a',
                        comm=MPI.COMM_WORLD, driver='mpio') as obs:

        for obs_planet in getattr(obs, planet):
            print(planet, obs_planet.path)
            mask = mask_simultaneous_transits(obs_planet.times, planet)
            obs_time = obs_planet.times[mask]
            obs_flux = np.sum(obs_planet.spectra[mask], axis=1)
            obs_err = np.sqrt(obs_flux)

            params = trappist1(planet)

            # plt.plot(obs_time, obs_flux, '.')

            mid_transit_answer = obs_planet.attrs['t0']
            # plt.show()
Example #2
0
trappist_transits = {k: v for k, v in observable_transits.items() if k.startswith("TRAPPIST")}

wl = nirspec_pixel_wavelengths()
mag = magnitudes['TRAPPIST-1']['J']

n_groups = 6
frame_time = 0.22616 * u.s
exptime = n_groups * frame_time

dataset_kwargs = dict(compression='gzip')

import sys

planet = sys.argv[1]

with ObservationArchive(run_name+'_'+planet, 'w') as obs:
    if 'wavelengths' not in obs.archive:
        obs.archive.create_dataset('wavelengths', data=wl)

    if planet in obs.archive:
        print('deleting old copy')
        del obs.archive[planet]
    group = obs.archive.create_group(planet)

    u1, u2 = trappist1(planet).u
    duration = transit_duration(trappist1(planet))

    spectrum_photo = IRTFTemplate(sptype_phot)
    spectrum_spots = IRTFTemplate(sptype_spot)#spectrum_photo.scale_temperature(delta_teff)

    for midtransit in trappist_transits["{0} {1}".format(name, planet)]:
Example #3
0
# original_params = kepler296(planet)
# #dilution_factor = 1 / (1 + 0.215)**2
# dilution_factor = 1.215

# run_name = 'k62'
# params = kepler62
# original_params = kepler62(planet)

#run_name = 'trappist1_bright2'
run_name = 'trappist1_ngroups6_photonnoise'
params = trappist1
original_params = trappist1(planet)

dilution_factor = 1

with ObservationArchive(run_name + "_" + planet, 'r') as obs:
    for obs_planet in getattr(obs, planet)[:5]:
        #         try:
        mask = mask_simultaneous_transits_trappist(obs_planet.times, planet)

        mid_transit_answer = obs_planet.attrs['t0']

        obs_time = obs_planet.times[mask] - mid_transit_answer
        obs_flux = np.sum(obs_planet.spectra[mask], axis=1)
        obs_err = np.sqrt(obs_flux)

        obs_err /= np.median(obs_flux)
        obs_flux /= np.median(obs_flux)

        #params = params(planet)
Example #4
0
from libra import (trappist1, transit_model, ObservationArchive,
                   trappist_out_of_transit, nirspec_pixel_wavelengths,
                   transit_duration)

t0 = trappist1('b').t0
original_params = trappist1('b')
duration = transit_duration(original_params)
times = np.arange(t0 - 1.5 * duration, t0 + 1.5 * duration, 1 / 60 / 60 / 24)

import sys
j = int(sys.argv[1])

outputs_dir = '/astro/store/scratch/tmp/bmmorris/libra/'

with ObservationArchive('trappist1_bright2_b', 'r',
                        outputs_dir=outputs_dir) as obs:
    # with ObservationArchive('trappist1_bright2_b', 'r') as obs:
    sim = obs.b[j]
    times = sim.times[:]
    spectra = sim.spectra[:]
    plt.plot(sim.times, np.sum(sim.spectra, axis=1))

oot = trappist_out_of_transit(times)

fluxes = np.sum(spectra, axis=1)
oot_median = np.median(fluxes[oot])
errors = np.sqrt(fluxes) / oot_median
fluxes /= oot_median
fluxes -= 1

plt.errorbar(times, fluxes, errors, color='k', fmt='.', ecolor='silver')
Example #5
0
        params = deepcopy(original_params)
        params.rp = self.depth**0.5
        params.t0 = self.t0
        return self.amp * transit_model(t, params)


run_name = 'trappist1_halftransit'
output_dir = '/gscratch/stf/bmmorris/libra/'

#with ObservationArchive(run_name, 'a', outputs_dir=output_dir) as obs:
original_params = trappist1(planet)

#with ObservationArchive(run_name, 'a', outputs_dir=output_dir) as obs:

for obs_planet in getattr(obs, planet):
    with ObservationArchive(run_name, 'r') as obs:

        print(planet, obs_planet.path)
        mask = mask_simultaneous_transits_trappist(obs_planet.times, planet)
        obs_time = obs_planet.times[mask]
        obs_flux = np.sum(obs_planet.spectra[mask], axis=1)
        obs_err = np.sqrt(obs_flux)

        params = trappist1(planet)

        mid_transit_answer = obs_planet.attrs['t0']

        initp_dict = dict(amp=np.median(obs_flux),
                          depth=original_params.rp**2,
                          t0=original_params.t0)
Example #6
0
    parameter_names = ['amp', 'depth', 't0']

    def get_value(self, t):
        params = deepcopy(original_params)
        params.rp = self.depth**0.5
        params.t0 = self.t0
        return self.amp * transit_model(t, params)


run_name = 'trappist1_bright'
output_dir = '/gscratch/stf/bmmorris/libra/'

#with ObservationArchive(run_name, 'a', outputs_dir=output_dir) as obs:
original_params = trappist1(planet)

with ObservationArchive(run_name, 'a', outputs_dir=output_dir) as obs:

    for obs_planet in getattr(obs, planet):
        print(planet, obs_planet.path)
        mask = mask_simultaneous_transits(obs_planet.times, planet)
        obs_time = obs_planet.times[mask]
        obs_flux = np.sum(obs_planet.spectra[mask], axis=1)
        obs_err = np.sqrt(obs_flux)

        params = trappist1(planet)

        # plt.plot(obs_time, obs_flux, '.')

        mid_transit_answer = obs_planet.attrs['t0']
        # plt.show()
Example #7
0
# Condor log information
"""

cfg_2 = """
Log        = {log_path}
Output     = {output_path}
Error = {error_path}
Arguments  = {arg}
Queue
"""

output_dir = '/astro/store/scratch/tmp/bmmorris/libra/outputs'

from libra import ObservationArchive

with ObservationArchive('trappist1_bright2_b', 'r') as obs:
    n_transits = len(obs.b)

cfg = cfg_1

python_path = "/astro/users/bmmorris/premap/miniconda3/bin/python"

for i in range(n_transits):
    cfg += cfg_2.format(log_path=os.path.join(output_dir,
                                              'log_{0:03d}.txt'.format(i)),
                        output_path=os.path.join(output_dir,
                                                 'out_{0:03d}.txt'.format(i)),
                        error_path=os.path.join(output_dir,
                                                'err_{0:03d}.txt'.format(i)),
                        arg=i)