Example #1
0
def astropy_tabular_data(*args, **kwargs):
    """
    Build a data set from a table. We restrict ourselves to tables
    with 1D columns.

    All arguments are passed to
        astropy.table.Table.read(...).
    """

    result = Data()

    table = astropy_table_read(*args, **kwargs)

    result.meta = table.meta

    # Loop through columns and make component list
    for column_name in table.columns:
        c = table[column_name]
        u = c.unit if hasattr(c, 'unit') else c.units

        if table.masked:
            # fill array for now
            try:
                c = c.filled(fill_value=np.nan)
            except (ValueError, TypeError):  # assigning nan to integer dtype
                c = c.filled(fill_value=-1)

        nc = Component.autotyped(c, units=u)
        result.add_component(nc, column_name)

    return result
Example #2
0
def astropy_tabular_data(*args, **kwargs):
    """
    Build a data set from a table. We restrict ourselves to tables
    with 1D columns.

    All arguments are passed to
        astropy.table.Table.read(...).
    """

    result = Data()

    table = astropy_table_read(*args, **kwargs)

    result.meta = table.meta

    # Loop through columns and make component list
    for column_name in table.columns:
        c = table[column_name]
        u = c.unit if hasattr(c, 'unit') else c.units

        if table.masked:
            # fill array for now
            try:
                c = c.filled(fill_value=np.nan)
            except (ValueError, TypeError):  # assigning nan to integer dtype
                c = c.filled(fill_value=-1)

        nc = Component.autotyped(c, units=u)
        result.add_component(nc, column_name)

    return result
Example #3
0
    def load_sunpy_map(self, sunpy_map):
        sunpy_map_loaded = sunpy.map.Map(sunpy_map)
        label = 'sunpy-map-' + sunpy_map_loaded.name
        data = Data(label=label)
        data.coords = sunpy_map_loaded.wcs  # preferred way, preserves more info in some cases
        data.meta = sunpy_map_loaded.meta
        data.add_component(Component(sunpy_map_loaded.data),
                           sunpy_map_loaded.name)
        data.style = VisualAttributes(color='#FDB813',
                                      preferred_cmap=sunpy_map.cmap)

        self.datasets.append(data)
Example #4
0
    def load_sji(self, sji):
        with fits.open(sji) as hdul:
            hdul.verify("fix")
            label = hdul[0].header['TDESC1'] + hdul[0].header['OBSID']
            data = Data(label=label)
            data.coords = WCSCoordinates(hdul[0].header)
            data.meta = hdul[0].header
            preferred_cmap_name = 'IRIS ' + hdul[0].header['TDESC1'].replace(
                '_', ' ')
            data.style = VisualAttributes(preferred_cmap=preferred_cmap_name)
            data.add_component(Component(hdul[0].data), label)

            self.datasets.append(data)
Example #5
0
 def load_sequence(self, raster_data):
     for window, window_data in raster_data.items():
         for i, scan_data in enumerate(window_data):
             w_data = Data(
                 label=
                 f"{window.replace(' ', '_')}-{scan_data.meta['OBSID']}-scan-{i}"
             )
             w_data.coords = scan_data.wcs
             w_data.add_component(Component(scan_data.data),
                                  f"{window.replace(' ', '_')}-scan-{i}")
             w_data.meta = scan_data.meta
             w_data.style = VisualAttributes(color='#5A4FCF')
             self.datasets.append(w_data)
Example #6
0
def _parse_iris_raster(data, label):
    """
    Parse IRIS Level 2 raster files so that it can be loaded by glue.
    """
    w_dataset = []
    for window, window_data in data.items():
        for i, scan_data in enumerate(window_data):
            w_data = Data(label=f"{window.replace(' ', '_')}-{scan_data.meta['OBSID']}-scan-{i}")
            w_data.coords = WCSCoordinates(scan_data.wcs.to_header())
            w_data.add_component(Component(scan_data.data), f"{window.replace(' ', '_')}-{scan_data.meta['OBSID']}-scan-{i}")
            w_data.meta = scan_data.meta
            w_data.style = VisualAttributes(color='#5A4FCF')
            w_dataset.append(w_data)

    return w_dataset