def nodal_flux_builder_cell(coefficient):
    flux_legendre1 = Legendre(coefficient[:5])
    flux_legendre2 = Legendre(coefficient[5:])

    flux1 = flux_legendre1.linspace(64, [0, 10])
    flux2 = flux_legendre2.linspace(64, [10, 20])

    total_flux = np.concatenate((flux1[1], flux2[1]))
    flux_position = np.concatenate((flux1[0], flux2[0]))

    return total_flux, flux_position
def nodal_flux_builder_edge(coefficient, diff1, diff2):
    flux_legendre1 = Legendre(coefficient[:5])
    flux_legendre2 = Legendre(coefficient[5:])

    flux_legendre1 = flux_legendre1.deriv(1)
    flux_legendre2 = flux_legendre2.deriv(1)

    flux1 = flux_legendre1.linspace(65, [0, 10])
    flux2 = flux_legendre2.linspace(65, [10, 20])

    total_flux = np.concatenate((diff1 * flux1[1], diff2 * flux2[1]))
    flux_position = np.concatenate((flux1[0], flux2[0]))

    return total_flux, flux_position
Exemplo n.º 3
0
def wavelength_to_pix(wavelength,
                      tracepars,
                      m=1,
                      frame='dms',
                      subarray='SUBSTRIP256',
                      oversample=1):
    """Convert wavelength to pixel coordinates for order m.

    :param wavelength: wavelength values in microns.
    :param tracepars: the trace polynomial solutions returned by get_tracepars.
    :param m: the spectral order.
    :param frame: the coordinate frame of the output coordinates (nat, dms or sim).
    :param subarray: the subarray of the output coordinates (SUBARRAY256 or SUBARRAY96).
    :param oversample: the oversampling factor of the outpur coordinates.

    :type wavelength: array[float]
    :type tracepars: dict
    :type m: int
    :type frame: str
    :type subarray: str
    :type oversample: int

    :returns: specpix - the spectral pixel coordinates, spatpix - the spatial pixel coordinates,
    mask - an array that is True when the specpix values were within the valid range of the polynomial.
    :rtype: Tuple(array[float], array[float], array[bool])
    """

    # Convert wavelenght to nat pixel coordinates.
    w2spec = Legendre(tracepars[m]['spec_coef'],
                      domain=tracepars[m]['spec_domain'])
    w2spat = Legendre(tracepars[m]['spat_coef'],
                      domain=tracepars[m]['spat_domain'])

    specpix_nat = w2spec(np.log(wavelength))
    spatpix_nat = w2spat(np.log(wavelength))
    mask = bounds_check(np.log(wavelength), tracepars[m]['spec_domain'][0],
                        tracepars[m]['spec_domain'][1])

    # Convert coordinates to the requested frame.
    specpix, spatpix = pix_ref_to_frame(specpix_nat,
                                        spatpix_nat,
                                        frame=frame,
                                        subarray=subarray)

    # Oversample the coordinates.
    specpix = specpix * oversample
    spatpix = spatpix * oversample

    return specpix, spatpix, mask
Exemplo n.º 4
0
def trend(p, t):
    """
    Fit the local transit shape with the following function.

    """
    domain = [t.min(), t.max()]
    return Legendre(p, domain=domain)(t)
Exemplo n.º 5
0
    def loadCalibration(self):

        coef, domain = np.load(self.calibrationfilename)
        self.pixelstowavelengths = Legendre(coef, domain)
        self.polynomialdegree = self.pixelstowavelengths.degree()
        self.speak("loaded wavelength calibration"
                "from {0}".format(self.calibrationfilename))
Exemplo n.º 6
0
 def loadCalibration(self):
     '''Load the wavelength calibration.'''
     self.speak('trying to load calibration data')
     coef, domain = np.load(self.calibrationfilename, allow_pickle=True)
     self.pixelstowavelengths = Legendre(coef, domain)
     self.polynomialdegree = self.pixelstowavelengths.degree()
     self.speak("loaded wavelength calibration"
                "from {0}".format(self.calibrationfilename))
Exemplo n.º 7
0
def specpix_to_wavelength(specpix, tracepars, m=1, frame='dms', oversample=1):
    """Convert the spectral pixel coordinate to wavelength for order m.

    :param specpix: the pixel values.
    :param tracepars: the trace polynomial solutions returned by get_tracepars.
    :param m: the spectral order.
    :param frame: the coordinate frame of the input coordinates (nat, dms or sim).
    :param oversample: the oversampling factor of the input coordinates.

    :type specpix: array[float]
    :type tracepars: dict
    :type m: int
    :type frame: str
    :type oversample: int

    :returns: wavelength - an array containing the wavelengths corresponding to specpix,
    mask - an array that is True when the specpix values were within the valid range of the polynomial.
    :rtype: Tuple(array[float], array[bool])
    """

    # Remove any oversampling.
    specpix = specpix / oversample

    # Convert the input coordinates to nat coordinates.
    specpix_nat = specpix_frame_to_ref(specpix, frame=frame)

    # Convert the specpix coordinates to wavelength.
    spec2w = Legendre(tracepars[m]['wave_coef'],
                      domain=tracepars[m]['wave_domain'])

    with np.errstate(over='ignore'):
        wavelength = np.exp(spec2w(specpix_nat))
    mask = bounds_check(specpix_nat, tracepars[m]['wave_domain'][0],
                        tracepars[m]['wave_domain'][1])

    return wavelength, mask
Exemplo n.º 8
0
#starmaster = np.load('/h/mulan0/data/working/GJ1132b_ut160421_22/multipleapertures/aperture_587_1049/extracted'+mastern+'.npy')[()]
#oef, domain =  np.load('/h/mulan0/data/working/GJ1132b_ut160421_22/multipleapertures/aperture_587_1049/aperture_587_1049_wavelengthcalibration.npy')[()]

# this is a check to make sure you have commented in the correct star (this is obviously a hack that could be done better...)
response = raw_input(
    'Is this the correct starmaster for this dataset? [y/n] \n     ' +
    starmasterstr + '\n')
if response == 'n':
    sys.exit(
        'Please edit wavelength_recalibration.py to point to the correct starmaster'
    )
elif response == 'y':
    starmaster = np.load(starmasterstr)[()]

# reacreate the wavelength solution (way to go from pixel space to wavelength space) from mosasaurus
pxtowavemaster = Legendre(coef, domain)
# apertures form a given night (Need to have run mosasaurus in ipython or similar and then copy and paste this monster code in. This is not ideal.)
apertures = r.mask.apertures
makeplot = True
UV_poses, O2_poses, Ca1_poses, Ca2_poses, Ca3_poses, H2O_poses = [], [], [], [], [], []
x_poses = []
#shifts_1132 = []
# Fixed alignment ranges for each prominent freature
align_UV = (6870, 6900)
align_O2 = (7580, 7650)
#align_H2Osmall = (8220, 8260)
align_Ca1 = (8490, 8525)
align_Ca2 = (8535, 8580)
align_Ca3 = (8650, 8700)
align_H2O = (9300, 9700)
for n in r.obs.nScience: