Пример #1
0
def two_order_image():
    # generate 2 flat traces.
    traces = np.zeros((60, 20))
    traces[[10, 11, 12], :] = 1
    # the second trace that does not span the image entirely
    traces[[50, 51, 52], :] = 2
    traces[[50, 51, 52], 0] = 0
    traces[[50, 51, 52], -1] = 0
    # generate test data with zero noise
    data = np.ones_like(traces, dtype=float)
    data[~np.isclose(traces, 0)] = 100.
    uncertainty = 1. * data
    wavelengths = (traces > 0).astype(float) * 5
    image = NRESObservationFrame([
        CCDData(data=data,
                uncertainty=uncertainty,
                meta={'OBJECTS': 'tung&tung&none'})
    ], 'foo.fits')
    image.wavelengths = wavelengths
    image.traces = traces
    image.fibers = {'fiber': np.arange(2), 'order': np.arange(2)}
    image.blaze = {
        'id': np.arange(2),
        'blaze': [np.arange(20), np.arange(20)],
        'blaze_error': [np.arange(20), np.arange(20)]
    }
    return image
Пример #2
0
 def apply_master_calibration(self, image: NRESObservationFrame,
                              master_calibration_image):
     # TODO should not load a master arc calibration if it is older than ~a week.
     image.wavelengths = master_calibration_image.wavelengths
     image.fibers = master_calibration_image.fibers
     image.meta[
         'L1IDARC'] = master_calibration_image.filename, 'ID of ARC/DOUBLE frame'
     return image
Пример #3
0
def five_hundred_square_image(maxflux,
                              number_traces,
                              trace_width,
                              read_noise=10,
                              seed=None):
    traces = np.zeros((500, 500))
    data = np.ones_like(traces, dtype=float)
    profile = np.zeros_like(traces, dtype=float)
    ix = np.arange(trace_width)
    for i in range(1, number_traces + 1):
        traces[40 * i:40 * i + trace_width, :] = i
        for j in range(0, trace_width):
            data[40 * i + j, :] += maxflux * np.exp(
                (-1.) * (ix[j] - trace_width / 2.)**2 / (trace_width / 6.)**2)
        for j in range(0, trace_width):
            profile[40 * i + j, :] = data[40 * i + j, :] / np.sum(
                data[40 * i:40 * i + trace_width, 0])
    np.random.seed(seed=seed)
    data += np.random.poisson(data)
    data += np.random.normal(0.0, read_noise, size=data.shape)
    uncertainty = np.sqrt(data + read_noise**2)
    wavelengths = np.ones_like(
        traces
    ) * 5  # dummy wavelengths image that has values distinct from flux and traces.
    image = NRESObservationFrame([
        CCDData(data=data,
                uncertainty=uncertainty,
                meta={'OBJECTS': 'tung&tung&none'})
    ], 'foo.fits')
    image.traces = traces
    image.profile = profile
    image.wavelengths = wavelengths
    image.blaze = {
        'id': np.arange(number_traces) + 1,
        'blaze': [np.ones(traces.shape[1]) for i in range(number_traces)],
        'blaze_error':
        [np.ones(traces.shape[1]) for i in range(number_traces)]
    }
    image.fibers = {
        'fiber': np.arange(number_traces) + 1,
        'order': np.arange(number_traces) + 1
    }
    return image