sicor.sensors.S2MSI package
Subpackages
- sicor.sensors.S2MSI.GranuleDEM package
- sicor.sensors.S2MSI.GranuleInfo package
- sicor.sensors.S2MSI.S2Image package
- Submodules
- sicor.sensors.S2MSI.S2Image.S2Image module
S2Image
S2Image.__rd()
S2Image.__read_img()
S2Image.__read_jp2_kdu_app()
S2Image._band_name_l1c()
S2Image._band_name_l2a()
S2Image._spatial_sampling_msk()
S2Image.bad_data_mask()
S2Image.find_in_xml()
S2Image.find_in_xml_root()
S2Image.gdal_read()
S2Image.geotransform2mapinfo()
S2Image.get_granule_metadata_xml()
S2Image.get_projection()
S2Image.get_values_from_xml()
S2Image.parse_s2_granule_xml()
S2Image.parse_s2_product_xml()
S2Image.read_aux_data()
S2Image.save_rgb_image()
S2Image.transform_utm_to_wgs84()
get_tck()
s2_snr_model
- Module contents
RSImage
S2Image
S2Image.__rd()
S2Image.__read_img()
S2Image.__read_jp2_kdu_app()
S2Image._band_name_l1c()
S2Image._band_name_l2a()
S2Image._spatial_sampling_msk()
S2Image.bad_data_mask()
S2Image.find_in_xml()
S2Image.find_in_xml_root()
S2Image.gdal_read()
S2Image.geotransform2mapinfo()
S2Image.get_granule_metadata_xml()
S2Image.get_projection()
S2Image.get_values_from_xml()
S2Image.parse_s2_granule_xml()
S2Image.parse_s2_product_xml()
S2Image.read_aux_data()
S2Image.save_rgb_image()
S2Image.transform_utm_to_wgs84()
Module contents
- class sicor.sensors.S2MSI.GranuleDEM(fn, target_resolution=60, logger=None, sampling_to_shape={10.0: (10980, 10980), 20.0: (5490, 5490), 60.0: (1830, 1830)}, zoom_order=2, slice_x=slice(None, None, None), slice_y=slice(None, None, None), **kwargs)[source]
Bases:
object
get digital elevation models for S2 MSI Granules from archive
- Parameters:
fn (string) – filename of DEM archive (zip file or hdf5 file) or path to dem folder structure
- Returns:
Dict like object which returns DEM for given granules if get_dem, [],or () are called
- class sicor.sensors.S2MSI.GranuleInfo(version='lite')[source]
Bases:
dict
Dict like object with basic information’s about Sentinel2-MSI granules.
- Parameters:
version (string with granule name, see keys() method for available names) – should be either “lite” or “full”
- Returns:
dict like object, keys are S2 granule names (e.g. ‘32UVX’), data can be accessed via () and [] methods
:Example
>>> S2gi = GranuleInfo(version="full") >>> S2gi["32UPV"] {u'country': [u'Germany'], u'epsg': 32632, u'name': u'32UPV', u'pos': {u'll': {u'lat': 48.6570271781, u'lon': 10.3579107698, u'x': 599999.9999970878, u'y': 5390220.000326163}, u'lr': {u'lat': 48.6298215752, u'lon': 11.8474784519, u'x': 709800.0000132157, u'y': 5390220.000321694}, u'tl': {u'lat': 49.644436702, u'lon': 10.3851737332, u'x': 600000.0000025682, u'y': 5500020.000361709}, u'tr': {u'lat': 49.6162737214, u'lon': 11.9045727629, u'x': 709800.0000165974, u'y': 5500020.000351718}}, u'region': [u'Europe'], u'zone': 32}
- class sicor.sensors.S2MSI.S2Image(granule_path, import_bands='all', namespace_candidate=None, aux_fields=None, default_u=1.0, target_resolution=None, dtype_float=<class 'numpy.float16'>, dtype_int=<class 'numpy.int16'>, unit='reflectance', interpolation_order=1, data_mode='dense', driver='OpenJpeg2000', call_cmd=None, logger=None, slice_x=slice(None, None, None), slice_y=slice(None, None, None), default_solar_irradiance={'B01': 1913.57, 'B02': 1941.63, 'B03': 1822.61, 'B04': 1512.79, 'B05': 1425.56, 'B06': 1288.32, 'B07': 1163.19, 'B08': 1036.39, 'B09': 813.04, 'B10': 367.15, 'B11': 245.59, 'B12': 85.25, 'B8A': 955.19}, **kwarg)[source]
Bases:
RSImage
Load Sentinel-2 Level-1C or Level-2A product.
Reads Sentinel-2 MSI data into numpy array. Images for different channels are resampled to a common sampling :param granule_path: path to granule folder, folder should contain IMG_DATA folder and S2A_[..].xml file :param import_bands: list of bands to import, default: [‘B01’, ‘B02’, ‘B03’, ‘B04’, ‘B05’, ‘B06’, ‘B07’, ‘B08’,
‘B8A’, ‘B09’, ‘B10’, ‘B11’, ‘B12’,]
- Parameters:
namespace_candidate – for XML file, or None, then several default namespaces are tested
target_resolution – spatial resolution in meter, or None for data not interpolated
interpolation_order – integer for interpolation 1,2,3
data_mode – either “dense” or “sparse”
aux_fields – either None or dict of to be loaded aux fields, e.g. {“cwv”:[ss],”spr”:[ss],”ozo”:[ss]} with ss being “mean” or iterable of spatial samplings, e.g. [20.0] or [20.0,60.0]
driver – should be “OpenJpeg2000” -> glymur, “kdu_expand”->shell command, “gdal_[driver] e.g. gdal_JP2ECW gdal_JPEG2000, gdal_JP2OpenJPEG,gdal_JP2KAK
..todo:: Real nodata mask
- __rd()
- __read_img(fn)
- __read_jp2_kdu_app(call_cmd=None)
- static _band_name_l1c(fn)[source]
S2 helper function, parse band name from jp2 file name :param fn: filename :return: string with band name
- bad_data_mask(image_data)[source]
Return mask of bad data :param image_data: numpy array :return: 2D boolean array
- static find_in_xml(xml, *branch)[source]
S2 xml helper function :param xml: xml object :param branch: iterate to branches using find :return: xml object, None if nothing was found
- static find_in_xml_root(namespace, xml_root, branch, *branches, findall=None)[source]
S2 xml helper function, search from root :param namespace: :param xml_root: :param branch: first branch, is combined with namespace :param branches: repeated find’s along these parameters :param findall: if given, at final a findall :return: found xml object, None if nothing was found
- static geotransform2mapinfo(gt, prj)[source]
Builds an ENVI map info from given GDAL GeoTransform and Projection :param gt: GDAL GeoTransform, e.g. (249885.0, 30.0, 0.0, 4578615.0, 0.0, -30.0) :param prj: GDAL Projection - WKT Format :returns: ENVI map info, e.g. [ UTM , 1 , 1 , 256785.0 , 4572015.0 , 30.0 , 30.0 , 43 , North , WGS-84 ] :rtype: list
- static get_projection(file_name)[source]
:param file_name string, points to filename :return: return {“gt”:geotransform,”prj”:coordinate projections string} for filename :rtype dict
- static get_values_from_xml(leaf, dtype=<class 'float'>)[source]
S2 xml helper function :param leaf: xml object which is searched for VALUES tag which are then composed into a numpy array :param dtype: dtype of returned numpy array :return: numpy array
- static parse_s2_granule_xml(fn, namespace)[source]
parse XML file in granule folder and return metadata :param fn: full filename tile xml file :param namespace: xml namespace :return: dictionary with metadata
- static parse_s2_product_xml(fn)[source]
S2 XML helper function to parse product xml file :param fn: file name of xml file :return: metadata dictionary