Exemplo n.º 1
0
def read_image(mda, filename=None, mask=True, calibrate=1):
    mda = copy.copy(mda)
    mda.calibrate = _Calibrator(mda)
    mda.calibration_unit = 'counts'
    mda.is_calibrated = False
    del mda.calibrated
    mda.product_name = (mda.time_start.strftime("%Y%m%d_%H%M%S") + '_' +
                        mda.satellite_name + '_' + mda.product_type + '_' +
                        mda.polarisation)
    logger.info('Product name: %s' % mda.product_name)

    if not filename:
        filename = mda.image_filename

    params, data = read_geotiff(filename)
    area_def = tiff2areadef(params['projection'], params['geotransform'],
                            data.shape)

    mda.proj4_params = area_def.proj4_string.replace('+', '')
    mda.area_extent = area_def.area_extent
    mda.tiff_params = params

    if calibrate:
        data, mda.calibration_unit = mda.calibrate(data, calibrate)
        mda.is_calibrated = True
        logger.info('calibrated: %s %s [%.2f -> %.2f -> %.2f] %s' %
                    (str(data.shape), data.dtype, data.min(), data.mean(),
                     data.max(), mda.calibration_unit))

    if mask:
        mask = (data == mda.no_data_value)
        data = np.ma.array(data, mask=mask, copy=False)

    return mda, data
Exemplo n.º 2
0
    def load_channel(self, filename):
        """Load one sentinel channel file"""
        from geotiepoints.basic_interpolator import BasicSatelliteInterpolator

        params, data = read_geotiff(filename)
        tie_lons = params['tiepoints']['lons']
        tie_lats = params['tiepoints']['lats']
        tie_cols = params['tiepoints']['cols']
        tie_rows = params['tiepoints']['rows']

        interpolator = BasicSatelliteInterpolator(tie_cols, tie_rows, tie_lats,
                                                  tie_lons)
        lats, lons = interpolator.interpolate()

        return lons, lats, data
Exemplo n.º 3
0
    def load_channel(self, filename):
        """Load one sentinel channel file"""
        from geotiepoints.basic_interpolator import BasicSatelliteInterpolator

        params, data = read_geotiff(filename)
        tie_lons = params['tiepoints']['lons']
        tie_lats = params['tiepoints']['lats']
        tie_cols = params['tiepoints']['cols']
        tie_rows = params['tiepoints']['rows']

        interpolator = BasicSatelliteInterpolator(tie_cols, 
                                                  tie_rows, 
                                                  tie_lats, 
                                                  tie_lons)
        lats, lons = interpolator.interpolate()
        
        return lons, lats, data
Exemplo n.º 4
0
Arquivo: TSX.py Projeto: pytroll/mipp
def read_image(mda, filename=None, mask=True, calibrate=1):
    mda = copy.copy(mda)
    mda.calibrate = _Calibrator(mda)
    mda.calibration_unit = 'counts'
    mda.is_calibrated = False
    del mda.calibrated
    mda.product_name = (mda.time_start.strftime("%Y%m%d_%H%M%S") + '_' + 
                        mda.satellite_name + '_' + mda.sensor_type + '_' + 
                        mda.beam_mode + '_' + mda.polarisation)
    logger.info('Product name: %s'% mda.product_name)
    
    if not filename:
        filename = mda.image_filename

    params, data = read_geotiff(filename)
    area_def = tiff2areadef(params['projection'],
                            params['geotransform'],
                            data.shape)

    mda.proj4_params = area_def.proj4_string.replace('+', '')
    mda.area_extent = area_def.area_extent
    mda.tiff_params = params

    mda.no_data_value = no_data_value

    if calibrate:
        data, mda.calibration_unit = mda.calibrate(data, calibrate)
        mda.is_calibrated = True
        logger.info('calibrated: %s %s [%.2f -> %.2f -> %.2f] %s'%
                    (str(data.shape), data.dtype, data.min(),
                     data.mean(), data.max(), mda.calibration_unit))

    if mask:
        mask = (data == no_data_value)
        data = np.ma.array(data, mask=mask, copy=False)

    return mda, data
Exemplo n.º 5
0
                  b=6356759.0,
                  h=35785831.0,
                  rf=295.49)
x_ll, y_ll = prj(3, 47)
x_ur, y_ur = prj(19, 55)
ger_extent = (x_ll, y_ll, x_ur, y_ur)
germ_areadef = utils.load_area(
    os.path.join(os.getenv("PPP_CONFIG_DIR"), "areas.yaml"), 'germ')
germ_extent = germ_areadef.area_extent_ll
x_ll, y_ll = prj(*germ_extent[0:2])
x_ur, y_ur = prj(*germ_extent[2:])
ger_extent = (x_ll, y_ll, x_ur, y_ur)

# Import geoftiff with DEM information
tiff = "/media/nas/satablage/Thomas/Grassdata/srtm_germany_dsm.tif"
params, dem = gtiff.read_geotiff(tiff)
tiffarea = gtiff.tiff2areadef(params['projection'], params['geotransform'],
                              dem.shape)

elevation = image.ImageContainerQuick(dem, tiffarea)

# Directory for cloud physical properties
cpp_dir = '/media/nas/satablage/Thomas/Nebel/CMSAF_microphysics'

# Define time series for analysis
#start = "201408270700"
#end = "201408270715"
start = "201311120830"
end = "201311120845"
#start = "201407110800"
#end = "201407110815"