Example #1
0
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)

# Import dev version of friedrich:
import sys
sys.path.insert(0, '../')
from friedrich.analysis import MCMCResults
from friedrich.lightcurve import hat11_params_morris
from glob import glob
import matplotlib.pyplot as plt
import numpy as np

archive_paths = sorted(glob('/local/tmp/friedrich/hat11/chains???.hdf5'))

#archive_paths = ['/local/tmp/friedrich/hat11/chains043.hdf5']

n_significant_spots = []
indices = []
for archive_path in archive_paths:
    m = MCMCResults(archive_path, hat11_params_morris())
    delta_bics = m.get_spots_delta_chi2(plots=False)
    indices.append(m.index)
    n_significant_spots.append(np.count_nonzero(delta_bics > 10))
    #plt.savefig('spots/{0}.png'.format(m.index))
    #plt.close()
indices = [int(i[6:]) for i in indices]
np.savetxt('nspots.txt', np.vstack([indices, n_significant_spots]).T)
plt.show()
Example #2
0
plots = True

if os.path.exists('/Users/bmmorris/data/hat11/'):
    # on laptop:
    light_curve_paths = glob('/Users/bmmorris/data/hat11/*slc.fits')
    output_dir = os.path.abspath('/Users/bmmorris/data')
elif os.path.exists('/usr/lusers/bmmorris/data/hat11/'):
    # on Hyak
    light_curve_paths = glob('/usr/lusers/bmmorris/data/hat11/*slc.fits')
    output_dir = os.path.abspath('/gscratch/stf/bmmorris/friedrich/')

else:
    raise ValueError('No input files found.')

depth = 0.00343
hat11_params = hat11_params_morris()

# Construct light curve object from the raw data
whole_lc = LightCurve.from_raw_fits(light_curve_paths, name='HAT11')
transits = LightCurve(**whole_lc.mask_out_of_transit(hat11_params)
                      ).get_transit_light_curves(hat11_params)

transit_numbers = [62]

for transit_number in transit_numbers:
    lc = transits[transit_number]
    lc.remove_linear_baseline(hat11_params)

    # Subtract out a transit model
    transit_model = generate_lc_depth(lc.times_jd, depth, hat11_params)
    residuals = lc.fluxes - transit_model
Example #3
0
import os
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import fmin

########################################################
# Import dev version of friedrich:
import sys
sys.path.insert(0, "/astro/users/bmmorris/git/friedrich/")
from friedrich.stsp import STSP, friedrich_results_to_stsp_inputs
from friedrich.lightcurve import hat11_params_morris
########################################################

friedrich_results_to_stsp_inputs('/local/tmp/friedrich/hat11', hat11_params_morris())

        traces.append(trace)
    return traces


def render_with_plotly(fig, path, width=1000, height=1000):
    counter = 0
    while not os.path.exists(path) and counter < 10:
        try:
            py.image.save_as(fig, path, width=width, height=height)
        except KeyError:
            print('Plotly API request fail {0}'.format(counter))
            counter += 1
            sleep(5)


transit_params = hat11_params_morris()
transit_params.t0 += 0.25 * transit_params.per
min_chi2 = np.argmin(m.chi2)
r = m.radius[min_chi2, :]
t = m.theta[min_chi2, :]
p = m.phi[min_chi2, :]

spot_traces = spot_polar_to_latlon(r, t, p, transit_params, m.light_curve)

chord_lat, chord_lon = times_to_occulted_lat_lon(m.light_curve.times,
                                                 transit_params)
occulted_times = np.logical_not(np.isnan(chord_lat))
chord_lat = np.degrees(chord_lat[occulted_times])
chord_lon = np.degrees(chord_lon[occulted_times])
chord_trace = Scattergeo(lat=chord_lat,
                         lon=chord_lon,
Example #5
0
from __future__ import (absolute_import, division, print_function,
                                unicode_literals)
import sys
sys.path.insert(0, '../')

from friedrich.stsp import friedrich_results_to_stsp_inputs
from friedrich.lightcurve import hat11_params_morris

results_dir = '/local/tmp/friedrich/hat11'
transit_params = hat11_params_morris()

friedrich_results_to_stsp_inputs(results_dir, transit_params)
Example #6
0
                                   observer_view_to_stellar_view,
                                   cartesian_to_spherical,
                                   times_to_occulted_lat_lon)
window_ind = 20171030
plotly_star = True
mpl_lightcurve = True

#window_ind = int(sys.argv[-1])

#m = MCMCResults.from_stsp('/local/tmp/osg/tmp/hat11-osg/', 33)
#m.to_hdf5('/local/tmp/osg/tmp/hat11-osg/')
#m = MCMCResults.from_hdf5('/local/tmp/osg/tmp/hat11-osg/', 33, hat11_params_morris())
m = MCMCResults.from_stsp_local(
    '/Users/bmmorris/git/friedrich/hat11/arctic/first_half_mcmc.txt',
    '/Users/bmmorris/git/friedrich/hat11/arctic/first_half.dat',
    transit_params=hat11_params_morris())  #'/local/tmp/osg/tmp', window_ind)


def spot_polar_to_latlon(radius,
                         theta,
                         phi,
                         transit_params,
                         light_curve,
                         n_points=20):
    """
    Return lat/lon that traces spot, in degrees.

    Conversion formula discovered here:
    http://williams.best.vwh.net/avform.htm#LL
    """
    lat1 = np.radians(90 - np.degrees(theta))