Exemple #1
0
def read_data(path, dtype=np.float64, bin_factor=None, **kargs):
    """
    Read SOHO / STEREO data files and output a Data instance

    Input :

      path : path of the data set

      dtype : cast of the data array
      
      kargs : arguments of the data filtering
    """
    if not os.path.isdir(path):
        raise ValueError('Directory does not exist')
    # read files
    fnames = os.listdir(path)
    files = [pyfits.fitsopen(os.path.join(path, fname))[0] for fname in fnames]
    files = filter_files(files, **kargs)
    fits_arrays = list()
    for f in files:
        fits_array = fa.hdu2fitsarray(f)
        if bin_factor is not None:
            fits_array = fits_array.bin(bin_factor)
            fits_array.header['RSUN'] /= bin_factor
        update_header(fits_array)
        fits_arrays.append(fits_array)
    data = fa.infoarrays2infoarray(fits_arrays)
    data = data.astype(dtype)
    return data
Exemple #2
0
def circular_trajectory_data(**kargs):
    """
    Generate a circular trajectory of n images at a given radius

    Inputs
    ------
    radius : float
        radius of the trajectory
    dtype : data-type, optional (default np.float64)
        data type of the output array
    n_images : int (default 1)
        number of images
    min_lon : float (default 0.)
        first longitude value in radians
    max_lon : float (default 2 * np.pi)
        last longitude value in radians
    kargs :
        other keyword arguments are treated as keywords of
        the image header.

    Outputs
    -------

    data : InfoArray
        An empty InfoArray filled with appropriate metadata. The last axis
        is image index. The header elements are 1d arrays of length
        n_images.

    Exemple
    -------
    >>> data = circular_trajectory_data(**default_image_dict)
    >>> data.shape
    (1, 1, 1)
    """
    radius = kargs.pop('radius', 1.)
    dtype = kargs.pop('dtype', np.float64)
    n_images = kargs.pop('n_images', 1)
    min_lon = kargs.pop('min_lon', 0.)
    max_lon = kargs.pop('max_lon', 2 * np.pi)
    longitudes = np.linspace(min_lon, max_lon, n_images)
    images = []
    for i, lon in enumerate(longitudes):
        header = kargs.copy()
        shape = header['NAXIS1'], header['NAXIS2']
        images.append(Image(shape, header=dict(header), dtype=dtype))
        images[-1].update('LON', lon)
        images[-1].update('D', radius)
    data = fa.infoarrays2infoarray(images)
    # set values to zeros
    data[:] = 0.
    # compute rotation matrices
    siddon.full_rotation_matrix(data)
    return data
Exemple #3
0
def circular_trajectory_data(**kargs):
    """
    Generate a circular trajectory of n images at a given radius

    Inputs
    ------
    radius : float
        radius of the trajectory
    dtype : data-type, optional (default np.float64)
        data type of the output array
    n_images : int (default 1)
        number of images
    min_lon : float (default 0.)
        first longitude value in radians
    max_lon : float (default 2 * np.pi)
        last longitude value in radians
    kargs :
        other keyword arguments are treated as keywords of
        the image header.

    Outputs
    -------

    data : InfoArray
        An empty InfoArray filled with appropriate metadata. The last axis
        is image index. The header elements are 1d arrays of length
        n_images.

    Exemple
    -------
    >>> data = circular_trajectory_data(**default_image_dict)
    >>> data.shape
    (1, 1, 1)
    """
    radius = kargs.pop('radius', 1.)
    dtype = kargs.pop('dtype', np.float64)
    n_images = kargs.pop('n_images', 1)
    min_lon = kargs.pop('min_lon', 0.)
    max_lon = kargs.pop('max_lon', 2 * np.pi)
    longitudes = np.linspace(min_lon, max_lon, n_images)
    images = []
    for i, lon in enumerate(longitudes):
        header = kargs.copy()
        shape = header['NAXIS1'], header['NAXIS2']
        images.append(Image(shape, header=dict(header), dtype=dtype))
        images[-1].update('LON', lon)
        images[-1].update('D', radius)
    data = fa.infoarrays2infoarray(images)
    # set values to zeros
    data[:] = 0.
    # compute rotation matrices
    siddon.full_rotation_matrix(data)
    return data