Пример #1
0
    def _fetch_data(dat_path):
        try:
            finder = bossdata.path.Finder()
            mirror = bossdata.remote.Manager()
        except ValueError as e:
            print(e)

        raw_data = []
        with open(dat_path, 'r') as f:
            f.readline()
            for line in f:
                line_split = line.split()

                plate = np.int(line_split[0])
                mjd = np.int(line_split[1])
                fiber = np.int(line_split[2])
                z = np.float(line_split[3])

                remote_path = finder.get_spec_path(plate=plate, mjd=mjd, fiber=fiber, lite=True)
                local_path = mirror.get(remote_path)
                try:
                    spec = bossdata.spec.SpecFile(local_path)
                    data = spec.get_valid_data()
                    wlen, flux, dflux = data['wavelength'][:], data['flux'][:], data['dflux'][:]
                except RuntimeError as e:
                    print e
                    print plate,mjd,fiber

                qso = {'plate':plate, 'mjd':mjd, 'fiber':fiber, \
                        'wlen':wlen, 'flux':flux, 'dflux':dflux, 'z':z}
                raw_data.append(qso)
            return raw_data
def get_spec_data(plate, mjd, fiber):
    """Thi is a docstring."""
    remote_path = finder.get_spec_path(plate=plate, mjd=mjd, fiber=fiber, lite=True)
    local_path = mirror.get(remote_path)
    try:
        spec = bossdata.spec.SpecFile(local_path)
        data = spec.get_valid_data()
        wlen, flux, dflux = data["wavelength"][:], data["flux"][:], data["dflux"][:]
    except RuntimeError as e:
        print e
        print plate, mjd, fiber

    offset = wlen_offset(wlen.view(type=np.ndarray)[0])
    wlen_off = create_offset_array(offset, wlen)
    flux_off = create_offset_array(offset, flux)
    dflux_off = create_offset_array(offset, dflux)

    return wlen_off, flux_off, dflux_off, offset