Example #1
0
    def _r_and_a(row, passthrough, accumulate_result, find_pins=True, fiber=None, exposure=None):
        grid = (skyexp_wlen_out if not use_loglam else skyexp_loglam_out) \
                    if use_skyexp_fid else (10**bdspec.fiducial_loglam if not use_loglam \
                    else bdspec.fiducial_loglam)
        resampled_data = resample(row, ('wavelength' if not use_loglam else 'loglam'), grid, passthrough)
        pins = None
        if find_pins:
            pins = _find_grid_pins(resampled_data, fiber, exposure)

        return accumulate(accumulate_result, resampled_data, data_out=accumulate_result,
                    join=('wavelength' if not use_loglam else 'loglam'),
                    add=('flux'), weight='ivar'), \
                pins
def build_observation_list(observations, start_wlen, end_wlen, delta_wlen):
    ''' This function takes a list of observations and redshifts them and
    resamples them to be on the same grid. '''
    wlen_range = np.arange(start_wlen, end_wlen, delta_wlen)
    qsos = list()
    for info, qso in observations.items():
        rest_frame = redshift(z_in=qso.z, z_out=0, data_in=qso.data,
                              rules=[dict(name='wavelength', exponent=1),
                                     dict(name='flux', exponent=-1),
                                     dict(name='dflux', exponent=-1)])
        resampled = resample(rest_frame, x_in='wavelength',
                             x_out=wlen_range, y=('flux', 'dflux'))
        qsos.append(resampled)

    return qsos
Example #3
0
    def _r_and_a(row,
                 passthrough,
                 accumulate_result,
                 find_pins=True,
                 fiber=None,
                 exposure=None):
        grid = (skyexp_wlen_out if not use_loglam else skyexp_loglam_out) \
                    if use_skyexp_fid else (10**bdspec.fiducial_loglam if not use_loglam \
                    else bdspec.fiducial_loglam)
        resampled_data = resample(
            row, ('wavelength' if not use_loglam else 'loglam'), grid,
            passthrough)
        pins = None
        if find_pins:
            pins = _find_grid_pins(resampled_data, fiber, exposure)

        return accumulate(accumulate_result, resampled_data, data_out=accumulate_result,
                    join=('wavelength' if not use_loglam else 'loglam'),
                    add=('flux'), weight='ivar'), \
                pins
fiducial_grid = np.arange(1000.0, 3000.0)
rest_frame, resampled, spec_qso = None, None, None
for row in qso_table:
    filename = finder.get_spec_path(plate=row["PLATE"], mjd=row["MJD"], fiber=row["FIBER"], lite=True)
    spectrum = bossdata.spec.SpecFile(mirror.get(filename))
    data = spectrum.get_valid_data(use_ivar=True, fiducial_grid=True)
    rest_frame = speclite.redshift(
        z_in=row["Z_VI"],
        z_out=0,
        data_in=data,
        data_out=rest_frame,
        rules=[dict(name="wavelength", exponent=+1), dict(name="flux", exponent=-1), dict(name="ivar", exponent=+2)],
    )
    resampled = speclite.resample(
        rest_frame, x_in="wavelength", x_out=fiducial_grid, y=("flux", "ivar"), data_out=resampled
    )
    spec_qso = speclite.accumulate(spec_qso, resampled, data_out=spec_qso, join="wavelength", add="flux", weight="ivar")


plot_stack(spec_qso, truncate_percentile=99.5)

filename = finder.get_plate_spec_path(plate=6641, mjd=56383)
plate = bossdata.plate.PlateFile(mirror.get(filename))
plate_data = plate.get_valid_data(qso_table["FIBER"], use_ivar=True, fiducial_grid=True)
zorder = np.argsort(qso_table["Z_VI"])

z_in = qso_table["Z_VI"][:, np.newaxis]
plate_data = speclite.redshift(
    z_in=z_in,
    z_out=0,