How to use satpy - 10 common examples

To help you get started, we’ve selected a few satpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pytroll / satpy / satpy / imageo / formats / libtiff.py View on Github external
TIFF_LONG = 4
    TIFF_RATIONAL = 5
    TIFF_SBYTE = 6
    TIFF_UNDEFINED = 7
    TIFF_SSHORT = 8
    TIFF_SLONG = 9
    TIFF_SRATIONAL = 10
    TIFF_FLOAT = 11
    TIFF_DOUBLE = 12
    TIFF_IFD = 13

ttype2ctype = {
    TIFFDataType.TIFF_NOTYPE : None,
    TIFFDataType.TIFF_BYTE : ctypes.c_ubyte,
    TIFFDataType.TIFF_ASCII : ctypes.c_char_p,
    TIFFDataType.TIFF_SHORT : ctypes.c_uint16,
    TIFFDataType.TIFF_LONG : ctypes.c_uint32,
    TIFFDataType.TIFF_RATIONAL : ctypes.c_double, # Should be unsigned
    TIFFDataType.TIFF_SBYTE : ctypes.c_byte,
    TIFFDataType.TIFF_UNDEFINED : ctypes.c_char,
    TIFFDataType.TIFF_SSHORT : ctypes.c_int16,
    TIFFDataType.TIFF_SLONG : ctypes.c_int32,
    TIFFDataType.TIFF_SRATIONAL : ctypes.c_double,
    TIFFDataType.TIFF_FLOAT : ctypes.c_float,
    TIFFDataType.TIFF_DOUBLE : ctypes.c_double,
    TIFFDataType.TIFF_IFD : ctypes.c_uint32
    }

class TIFFFieldInfo(ctypes.Structure):
    """
    typedef struct {
        ttag_t  field_tag;      /* field's tag */
github pytroll / satpy / satpy / imageo / formats / libtiff.py View on Github external
TIFF_DOUBLE = 12
    TIFF_IFD = 13

ttype2ctype = {
    TIFFDataType.TIFF_NOTYPE : None,
    TIFFDataType.TIFF_BYTE : ctypes.c_ubyte,
    TIFFDataType.TIFF_ASCII : ctypes.c_char_p,
    TIFFDataType.TIFF_SHORT : ctypes.c_uint16,
    TIFFDataType.TIFF_LONG : ctypes.c_uint32,
    TIFFDataType.TIFF_RATIONAL : ctypes.c_double, # Should be unsigned
    TIFFDataType.TIFF_SBYTE : ctypes.c_byte,
    TIFFDataType.TIFF_UNDEFINED : ctypes.c_char,
    TIFFDataType.TIFF_SSHORT : ctypes.c_int16,
    TIFFDataType.TIFF_SLONG : ctypes.c_int32,
    TIFFDataType.TIFF_SRATIONAL : ctypes.c_double,
    TIFFDataType.TIFF_FLOAT : ctypes.c_float,
    TIFFDataType.TIFF_DOUBLE : ctypes.c_double,
    TIFFDataType.TIFF_IFD : ctypes.c_uint32
    }

class TIFFFieldInfo(ctypes.Structure):
    """
    typedef struct {
        ttag_t  field_tag;      /* field's tag */
        short   field_readcount;    /* read count/TIFF_VARIABLE/TIFF_SPP */
        short   field_writecount;   /* write count/TIFF_VARIABLE */
        TIFFDataType field_type;    /* type of associated data */
        unsigned short field_bit;   /* bit in fieldsset bit vector */
        unsigned char field_oktochange; /* if true, can change while writing */
        unsigned char field_passcount;  /* if true, pass dir count on set */
        char    *field_name;        /* ASCII name */
        } TIFFFieldInfo;
github pytroll / satpy / satpy / imageo / formats / libtiff.py View on Github external
TIFF_UNDEFINED = 7
    TIFF_SSHORT = 8
    TIFF_SLONG = 9
    TIFF_SRATIONAL = 10
    TIFF_FLOAT = 11
    TIFF_DOUBLE = 12
    TIFF_IFD = 13

ttype2ctype = {
    TIFFDataType.TIFF_NOTYPE : None,
    TIFFDataType.TIFF_BYTE : ctypes.c_ubyte,
    TIFFDataType.TIFF_ASCII : ctypes.c_char_p,
    TIFFDataType.TIFF_SHORT : ctypes.c_uint16,
    TIFFDataType.TIFF_LONG : ctypes.c_uint32,
    TIFFDataType.TIFF_RATIONAL : ctypes.c_double, # Should be unsigned
    TIFFDataType.TIFF_SBYTE : ctypes.c_byte,
    TIFFDataType.TIFF_UNDEFINED : ctypes.c_char,
    TIFFDataType.TIFF_SSHORT : ctypes.c_int16,
    TIFFDataType.TIFF_SLONG : ctypes.c_int32,
    TIFFDataType.TIFF_SRATIONAL : ctypes.c_double,
    TIFFDataType.TIFF_FLOAT : ctypes.c_float,
    TIFFDataType.TIFF_DOUBLE : ctypes.c_double,
    TIFFDataType.TIFF_IFD : ctypes.c_uint32
    }

class TIFFFieldInfo(ctypes.Structure):
    """
    typedef struct {
        ttag_t  field_tag;      /* field's tag */
        short   field_readcount;    /* read count/TIFF_VARIABLE/TIFF_SPP */
        short   field_writecount;   /* write count/TIFF_VARIABLE */
        TIFFDataType field_type;    /* type of associated data */
github pytroll / satpy / satpy / imageo / formats / libtiff.py View on Github external
TIFF_IFD = 13

ttype2ctype = {
    TIFFDataType.TIFF_NOTYPE : None,
    TIFFDataType.TIFF_BYTE : ctypes.c_ubyte,
    TIFFDataType.TIFF_ASCII : ctypes.c_char_p,
    TIFFDataType.TIFF_SHORT : ctypes.c_uint16,
    TIFFDataType.TIFF_LONG : ctypes.c_uint32,
    TIFFDataType.TIFF_RATIONAL : ctypes.c_double, # Should be unsigned
    TIFFDataType.TIFF_SBYTE : ctypes.c_byte,
    TIFFDataType.TIFF_UNDEFINED : ctypes.c_char,
    TIFFDataType.TIFF_SSHORT : ctypes.c_int16,
    TIFFDataType.TIFF_SLONG : ctypes.c_int32,
    TIFFDataType.TIFF_SRATIONAL : ctypes.c_double,
    TIFFDataType.TIFF_FLOAT : ctypes.c_float,
    TIFFDataType.TIFF_DOUBLE : ctypes.c_double,
    TIFFDataType.TIFF_IFD : ctypes.c_uint32
    }

class TIFFFieldInfo(ctypes.Structure):
    """
    typedef struct {
        ttag_t  field_tag;      /* field's tag */
        short   field_readcount;    /* read count/TIFF_VARIABLE/TIFF_SPP */
        short   field_writecount;   /* write count/TIFF_VARIABLE */
        TIFFDataType field_type;    /* type of associated data */
        unsigned short field_bit;   /* bit in fieldsset bit vector */
        unsigned char field_oktochange; /* if true, can change while writing */
        unsigned char field_passcount;  /* if true, pass dir count on set */
        char    *field_name;        /* ASCII name */
        } TIFFFieldInfo;
    """
github pytroll / satpy / satpy / imageo / formats / libtiff.py View on Github external
TIFF_SRATIONAL = 10
    TIFF_FLOAT = 11
    TIFF_DOUBLE = 12
    TIFF_IFD = 13

ttype2ctype = {
    TIFFDataType.TIFF_NOTYPE : None,
    TIFFDataType.TIFF_BYTE : ctypes.c_ubyte,
    TIFFDataType.TIFF_ASCII : ctypes.c_char_p,
    TIFFDataType.TIFF_SHORT : ctypes.c_uint16,
    TIFFDataType.TIFF_LONG : ctypes.c_uint32,
    TIFFDataType.TIFF_RATIONAL : ctypes.c_double, # Should be unsigned
    TIFFDataType.TIFF_SBYTE : ctypes.c_byte,
    TIFFDataType.TIFF_UNDEFINED : ctypes.c_char,
    TIFFDataType.TIFF_SSHORT : ctypes.c_int16,
    TIFFDataType.TIFF_SLONG : ctypes.c_int32,
    TIFFDataType.TIFF_SRATIONAL : ctypes.c_double,
    TIFFDataType.TIFF_FLOAT : ctypes.c_float,
    TIFFDataType.TIFF_DOUBLE : ctypes.c_double,
    TIFFDataType.TIFF_IFD : ctypes.c_uint32
    }

class TIFFFieldInfo(ctypes.Structure):
    """
    typedef struct {
        ttag_t  field_tag;      /* field's tag */
        short   field_readcount;    /* read count/TIFF_VARIABLE/TIFF_SPP */
        short   field_writecount;   /* write count/TIFF_VARIABLE */
        TIFFDataType field_type;    /* type of associated data */
        unsigned short field_bit;   /* bit in fieldsset bit vector */
        unsigned char field_oktochange; /* if true, can change while writing */
        unsigned char field_passcount;  /* if true, pass dir count on set */
github pytroll / satpy / satpy / imageo / formats / libtiff.py View on Github external
TIFF_SBYTE = 6
    TIFF_UNDEFINED = 7
    TIFF_SSHORT = 8
    TIFF_SLONG = 9
    TIFF_SRATIONAL = 10
    TIFF_FLOAT = 11
    TIFF_DOUBLE = 12
    TIFF_IFD = 13

ttype2ctype = {
    TIFFDataType.TIFF_NOTYPE : None,
    TIFFDataType.TIFF_BYTE : ctypes.c_ubyte,
    TIFFDataType.TIFF_ASCII : ctypes.c_char_p,
    TIFFDataType.TIFF_SHORT : ctypes.c_uint16,
    TIFFDataType.TIFF_LONG : ctypes.c_uint32,
    TIFFDataType.TIFF_RATIONAL : ctypes.c_double, # Should be unsigned
    TIFFDataType.TIFF_SBYTE : ctypes.c_byte,
    TIFFDataType.TIFF_UNDEFINED : ctypes.c_char,
    TIFFDataType.TIFF_SSHORT : ctypes.c_int16,
    TIFFDataType.TIFF_SLONG : ctypes.c_int32,
    TIFFDataType.TIFF_SRATIONAL : ctypes.c_double,
    TIFFDataType.TIFF_FLOAT : ctypes.c_float,
    TIFFDataType.TIFF_DOUBLE : ctypes.c_double,
    TIFFDataType.TIFF_IFD : ctypes.c_uint32
    }

class TIFFFieldInfo(ctypes.Structure):
    """
    typedef struct {
        ttag_t  field_tag;      /* field's tag */
        short   field_readcount;    /* read count/TIFF_VARIABLE/TIFF_SPP */
        short   field_writecount;   /* write count/TIFF_VARIABLE */
github pytroll / fogpy / fogpy / utils / reproj_testdata.py View on Github external
lat = inputs[11]
lon = inputs[12]

msg_con_quick = image.ImageContainerQuick(ir108.squeeze(), area_def)
area_con_quick = msg_con_quick.resample(euro_areadef)
result_data_quick = area_con_quick.image_data

# Create satpy scene
testscene = Scene(platform_name="msg",
                  sensor="seviri",
                  start_time=datetime(2013, 11, 12, 8, 30),
                  end_time=datetime(2013, 11, 12, 8, 45),
                  area=area_def)
array_kwargs = {'area': area_def}

testscene['ir108'] = Dataset(ir108.squeeze(), **array_kwargs)
print(testscene['ir108'])
testscene.show('ir108', overlay={'coast_dir': '/home/mastho/data/', 'color': 'gray'})
resampscene = testscene.resample('germ')
print(resampscene.shape)
#resampscene.show('ir108', overlay={'coast_dir': '/home/mastho/data/', 'color': 'gray'})

# Define custom fog colormap
fogcol = Colormap((0., (250 / 255.0, 200 / 255.0, 40 / 255.0)),
                  (1., (1.0, 1.0, 229 / 255.0)))
maskcol = (250 / 255.0, 200 / 255.0, 40 / 255.0)
# Create image from data
github pytroll / satpy / satpy / readers / hdfeos_l1b.py View on Github external
if self.resolution != key.resolution:
            return

        datasets = datadict[self.resolution]
        for dataset in datasets:
            subdata = self.sd.select(dataset)
            band_names = subdata.attributes()["band_names"].split(",")

            # get the relative indices of the desired channel
            try:
                index = band_names.index(key.name)
            except ValueError:
                continue
            uncertainty = self.sd.select(dataset + "_Uncert_Indexes")
            array = xr.DataArray(da.from_array(subdata[index, :, :], chunks=CHUNK_SIZE),
                                 dims=['y', 'x']).astype(np.float32)
            valid_range = subdata.attributes()['valid_range']
            array = array.where(array >= np.float32(valid_range[0]))
            array = array.where(array <= np.float32(valid_range[1]))
            array = array.where(uncertainty[index, :, :] < 15)

            if dataset.endswith('Emissive'):
                projectable = calibrate_tb(array, subdata.attributes(), index, key.name)
            else:
                projectable = calibrate_refl(array, subdata.attributes(), index)
            projectable.attrs = info

            # if ((platform_name == 'Aqua' and key.name in ["6", "27", "36"]) or
            #         (platform_name == 'Terra' and key.name in ["29"])):
            #     height, width = projectable.shape
            #     row_indices = projectable.mask.sum(1) == width
github pytroll / satpy / satpy / readers / hrpt.py View on Github external
'4': 3,
                               '5': 4}
        index = avhrr_channel_index[key.name]
        mask = False
        if key.name in ['3a', '3b'] and self._is3b is None:
            ch3a = bfield(self._data["id"]["id"], 10)
            self._is3b = np.logical_not(ch3a)

        if key.name == '3a':
            mask = np.tile(self._is3b, (1, 2048))
        elif key.name == '3b':
            mask = np.tile(np.logical_not(self._is3b), (1, 2048))

        data = self._data["image_data"][:, :, index]
        if key.calibration == 'counts':
            return Dataset(data,
                           mask=mask,
                           area=self.get_lonlats(),
                           units='1')

        pg_spacecraft = ''.join(self.platform_name.split()).lower()

        jdays = (np.datetime64(self.start_time) - np.datetime64(str(
            self.year) + '-01-01T00:00:00Z')) / np.timedelta64(1, 'D')
        if index < 2 or key.name == '3a':
            data = calibrate_solar(data, index, self.year, jdays,
                                   pg_spacecraft)
            units = '%'

        if index > 2 or key.name == '3b':
            if self.times is None:
                self.times = time_seconds(self._data["timecode"], self.year)
github pytroll / satpy / satpy / composites / __init__.py View on Github external
conf = {}
        for composite_config in composite_configs:
            with open(composite_config) as conf_file:
                conf = recursive_dict_update(conf, yaml.load(conf_file, Loader=UnsafeLoader))
        try:
            sensor_name = conf['sensor_name']
        except KeyError:
            LOG.debug('No "sensor_name" tag found in %s, skipping.',
                      composite_config)
            return

        sensor_id = sensor_name.split('/')[-1]
        sensor_deps = sensor_name.split('/')[:-1]

        compositors = self.compositors.setdefault(sensor_id, DatasetDict())
        modifiers = self.modifiers.setdefault(sensor_id, {})

        for sensor_dep in reversed(sensor_deps):
            if sensor_dep not in self.compositors or sensor_dep not in self.modifiers:
                self.load_sensor_composites(sensor_dep)

        if sensor_deps:
            compositors.update(self.compositors[sensor_deps[-1]])
            modifiers.update(self.modifiers[sensor_deps[-1]])

        for composite_type in ['modifiers', 'composites']:
            if composite_type not in conf:
                continue
            for composite_name in conf[composite_type]:
                self._process_composite_config(composite_name, conf,
                                               composite_type, sensor_id, composite_config, **kwargs)