s2d2.read_sentinel2

Module Contents

Functions

list_central_wavelength_msi()

create dataframe with metadata about Sentinel-2

dn2toa_s2(I)

convert the digital numbers of Sentinel-2 to top of atmosphere (TOA), see

read_band_s2(path[, band])

This function takes as input the Sentinel-2 band name and the path of the

read_stack_s2(s2_df)

read imagery data of interest into an three dimensional np.array

_get_geometric_info_from_root(root)

_get_frame_from_geometric_info(geom_info)

_get_image_size_s2_from_root(root[, resolution])

_get_ul_coord_s2_from_root(root[, resolution])

_get_geotransform_s2_from_root(root[, resolution])

_get_crs_s2_from_root(root)

_get_orbit_s2_from_root(root)

_get_spacecraft_s2_from_root(root)

read_geotransform_s2(path[, fname, resolution])

get the mapping transformation of the Sentinel-2 image

read_orbit_number_s2(path[, fname])

read the orbit number of the Sentinel-2 image from the metadata

get_local_bbox_in_s2_tile(fname_1, s2dir)

get_sun_angles_s2_from_root(root[, angle])

read_sun_angles_s2(path[, fname])

This function reads the xml-file of the Sentinel-2 scene and extracts

get_view_angles_s2_from_root(root)

read_view_angles_s2(path[, fname, det_stack, boi_df])

This function reads the xml-file of the Sentinel-2 scene and extracts

read_mean_sun_angles_s2(path[, fname])

Read the xml-file of the Sentinel-2 scene and extract the mean sun angles.

read_detector_mask(path_meta, boi, geoTransform)

create array of with detector identification

read_sensing_time_s2(path[, fname])

param path:

path where the meta-data is situated

get_xy_poly_from_gml(gml_struct, idx)

get_msk_dim_from_gml(gml_struct, geoTransform)

read_cloud_mask(path_meta, geoTransform)

param path_meta:

directory where meta data is situated, 'MSK_CLOUDS_B00.gml' is typically

read_detector_time_s2(path[, fname, s2_df])

get the detector metadata of the relative detector timing

get_flight_bearing_from_detector_mask_s2(Det)

param Det:

array with numbers of the different detectors in Sentinel-2

get_raw_imu_s2(ds_path[, fname])

get_raw_str_s2(ds_path[, fname])

get_integration_and_sampling_time_s2(ds_path[, fname, ...])

param ds_path:

location where metadata of datastrip is situated

s2d2.read_sentinel2.list_central_wavelength_msi()[source]

create dataframe with metadata about Sentinel-2

Returns:

metadata and general multispectral information about the MSI instrument that is onboard Sentinel-2, having the following collumns:

  • center_wavelength, unit=µm : central wavelength of the band

  • full_width_half_max, unit=µm : extent of the spectral sensativity

  • bandid : number for identification in the meta data

  • resolution, unit=m : spatial resolution of a pixel

  • along_pixel_size, unit=µm : physical size of the sensor

  • across_pixel_size, unit=µm : size of the photosensative sensor

  • focal_length, unit=m : lens characteristic of the telescope

  • field_of_view, unit=degrees : angle of swath of instrument

  • crossdetector_parallax, unit=degress : in along-track direction

  • name : general name of the band, if applicable

  • solar_illumination, unit=W m-2 µm-1 :

mostly following the naming convension of the STAC EO extension [stac]

Return type:

pandas.dataframe

Notes

The Multi Spectral instrument (MSI) has a Tri Mirror Anastigmat (TMA) telescope, which is opened at F/4 and has a focal length of 60 centimeter.

The crossdetector parallex is given here as well, see [La15]. While the crossband parallax is 0.018 for VNIR and 0.010 for the SWIR detector, respectively. The dimensions of the Silicon CMOS detector are given in [MG10]. While the SWIR detector is based on a MCT sensor.

The following acronyms are used:

  • MSI : multi-spectral instrument

  • MCT : mercury cadmium telluride, HgCdTe

  • TMA : trim mirror anastigmat

  • VNIR : very near infra-red

  • SWIR : short wave infra-red

  • CMOS : silicon complementary metal oxide semiconductor, Si

Examples

>>> from s2d2.read_sentinel2 import list_central_wavelength_msi

make a selection by name:

>>> boi = ['red', 'green', 'blue', 'near infrared']
>>> s2_df = list_central_wavelength_msi()
>>> s2_df = s2_df[s2_df['common_name'].isin(boi)]
>>> s2_df
         wavelength  bandwidth  resolution       name  bandid
B02         492         66          10           blue       1
B03         560         36          10          green       2
B04         665         31          10            red       3
B08         833        106          10  near infrared       7

similarly you can also select by pixel resolution:

>>> s2_df = list_central_wavelength_msi()
>>> tw_df = s2_df[s2_df['resolution']==20]
>>> tw_df.index
Index(['B05', 'B06', 'B07', 'B8A', 'B11', 'B12'], dtype='object')

References

[La15]

Languille et al. “Sentinel-2 geometric image quality commissioning: first results” Proceedings of the SPIE, 2015.

[MG10]

Martin-Gonthier et al. “CMOS detectors for space applications: From R&D to operational program with large volume foundry”, Proceedings of the SPIE conference on sensors, systems, and next generation satellites XIV, 2010.

s2d2.read_sentinel2.dn2toa_s2(I)[source]

convert the digital numbers of Sentinel-2 to top of atmosphere (TOA), see for more details [wwwS2L1C].

Parameters:

I (numpy.ndarray, dim={2,3}, size=(m,n)) – grid with intensities

Returns:

grid with top of atmosphere reflectances

Return type:

numpy.ndarray, dim={2,3}, size=(m,n)

Notes

s2d2.read_sentinel2.read_band_s2(path, band=None)[source]

This function takes as input the Sentinel-2 band name and the path of the folder that the images are stored, reads the image and returns the data as an array

Parameters:
  • path (string) – path of the folder, or full path with filename as well

  • band (string, optional) – Sentinel-2 band name, for example ‘04’, ‘8A’.

Returns:

  • data (numpy.array, size=(_,_)) – array of the band image

  • spatialRef (string) – projection

  • geoTransform (tuple) – affine transformation coefficients

  • targetprj (osr.SpatialReference object) – spatial reference

See also

list_central_wavelength_msi

creates a dataframe for the MSI instrument

read_stack_s2

reading several Sentinel-2 bands at once into a stack

s2d2.mapping_input.read_geo_image

basic function to import geographic imagery data

Examples

>>> from s2d2.read_sentinel2 import read_band_s2
>>> path = '/GRANULE/L1C_T15MXV_A027450_20200923T163313/IMG_DATA/'
>>> band = '02'
>>> _,spatialRef,geoTransform,targetprj = read_band_s2(path, band)
>>> spatialRef
'PROJCS["WGS 84 / UTM zone 15S",GEOGCS["WGS 84",DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-93],
PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],
PARAMETER["false_northing",10000000],UNIT["metre",1,
AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],
AUTHORITY["EPSG","32715"]]'
>>> geoTransform
(600000.0, 10.0, 0.0, 10000000.0, 0.0, -10.0)
>>> targetprj
<osgeo.osr.SpatialReference; proxy of <Swig Object of type
'OSRSpatialReferenceShadow *' at 0x7f9a63ffe450> >
s2d2.read_sentinel2.read_stack_s2(s2_df)[source]

read imagery data of interest into an three dimensional np.array

Parameters:

s2_df (pandas.Dataframe) – metadata and general multispectral information about the MSI instrument that is onboard Sentinel-2

Returns:

  • im_stack (numpy.ndarray, ndim=3) – array of the band image

  • spatialRef (string) – projection

  • geoTransform (tuple, size=(8,1)) – affine transformation coefficients

  • targetprj (osr.SpatialReference object) – spatial reference

See also

list_central_wavelength_msi

creates a dataframe for the MSI instrument

get_s2_image_locations

provides dataframe with specific file locations

read_band_s2

reading a single Sentinel-2 band

Examples

>>> s2_df = list_central_wavelength_msi()
>>> s2_df = s2_df[s2_df['gsd'] == 10]
>>> s2_df,_ = get_s2_image_locations(IM_PATH, s2_df)
>>> im_stack, spatialRef, geoTransform, targetprj = read_stack_s2(s2_df)
s2d2.read_sentinel2._get_geometric_info_from_root(root)[source]
s2d2.read_sentinel2._get_frame_from_geometric_info(geom_info)[source]
s2d2.read_sentinel2._get_image_size_s2_from_root(root, resolution=10)[source]
s2d2.read_sentinel2._get_ul_coord_s2_from_root(root, resolution=10)[source]
s2d2.read_sentinel2._get_geotransform_s2_from_root(root, resolution=10)[source]
s2d2.read_sentinel2._get_crs_s2_from_root(root)[source]
s2d2.read_sentinel2._get_orbit_s2_from_root(root)[source]
s2d2.read_sentinel2._get_spacecraft_s2_from_root(root)[source]
s2d2.read_sentinel2.read_geotransform_s2(path, fname='MTD_TL.xml', resolution=10)[source]

get the mapping transformation of the Sentinel-2 image

Parameters:
  • path (string) – location where the meta data is situated

  • fname (string) – file name of the meta-data file

  • resolution ({float,integer}, unit=meters, default=10) – resolution of the grid

Returns:

geoTransform – affine transformation coefficients

Return type:

tuple, size=(1,6)

See also

s2d2.image_coordinate_tools.map2pix

transform map- to image-coordinates

s2d2.image_coordinate_tools.map2pix

transform image- to map-coordinates

Notes

The metadata is scattered over the file structure of Sentinel-2, L1C

* S2X_MSIL1C_20XX...
├ AUX_DATA
├ DATASTRIP
│  └ DS_XXX_XXXX...
│     └ QI_DATA
│        └ MTD_DS.xml <- metadata about the data-strip
├ GRANULE
│  └ L1C_TXXXX_XXXX...
│     ├ AUX_DATA
│     ├ IMG_DATA
│     ├ QI_DATA
│     └ MTD_TL.xml <- metadata about the tile
├ HTML
├ rep_info
├ manifest.safe
├ INSPIRE.xml
└ MTD_MSIL1C.xml <- metadata about the product
The metadata structure is as follows:

  • MTD_TL.xml

└ n1:Level-1C_Tile_ID

├ n1:General_Info ├ n1:Geometric_Info │ ├ Tile_Geocoding │ │ ├ HORIZONTAL_CS_NAME │ │ ├ HORIZONTAL_CS_CODE │ │ ├ Size : resolution={“10”,”20”,”60”} │ │ │ ├ NROWS │ │ │ └ NCOLS │ │ └ Geoposition │ │ ├ ULX │ │ ├ ULY │ │ ├ XDIM │ │ └ YDIM │ └ Tile_Angles └ n1:Quality_Indicators_Info

The following acronyms are used:

  • DS : datastrip

  • TL : tile

  • QI : quality information

  • AUX : auxiliary

  • MTD : metadata

  • MSI : multi spectral instrument

  • L1C : product specification,i.e.: level 1, processing step C

s2d2.read_sentinel2.read_orbit_number_s2(path, fname='MTD_MSIL1C.xml')[source]

read the orbit number of the Sentinel-2 image from the metadata

s2d2.read_sentinel2.get_local_bbox_in_s2_tile(fname_1, s2dir)[source]
s2d2.read_sentinel2.get_sun_angles_s2_from_root(root, angle='Zenith')[source]
s2d2.read_sentinel2.read_sun_angles_s2(path, fname='MTD_TL.xml')[source]

This function reads the xml-file of the Sentinel-2 scene and extracts an array with sun angles, as these vary along the scene.

Parameters:

path (string) – path where xml-file of Sentinel-2 is situated

Returns:

  • Zn (numpy.array, size=(m,n), dtype=float) – array of the solar zenith angles, in degrees.

  • Az (numpy.array, size=(m,n), dtype=float) – array of the solar azimuth angles, in degrees.

Notes

The computation of the solar angles is done in two steps: 1) Computation of the solar angles in J2000; 2) Transformation of the vector to the mapping frame.

    1. The outputs of the first step is the solar direction normalized vector with the Earth-Sun distance, considering that the direction of the sun is the same at the centre of the Earth and at the centre of the Sentinel-2 satellite.

    1. Attitude of the satellite platform are used to rotate the solar vector to the mapping frame. Also Ground Image Calibration Parameters (GICP Diffuser Model) are used to transform from the satellite to the diffuser, as Sentinel-2 has a forward and backward looking sensor configuration. The diffuser model also has stray-light correction and a Bi-Directional Reflection Function model.

The angle(s) are declared in the following coordinate frame:

     ^ North & y
     |
- <--|--> +
     |
     +----> East & x

The angles related to the sun are as follows:

surface normal              * sun
^                     ^    /
|                     |   /
|-- zenith angle      |  /
| /                   | /|
|/                    |/ | elevation angle
+----                 +------

Two different coordinate system are used here:

indexing   |           indexing    ^ y
system 'ij'|           system 'xy' |
           |                       |
           |       i               |       x
   --------+-------->      --------+-------->
           |                       |
           |                       |
image      | j         map         |
based      v           based       |

The metadata is scattered over the file structure of Sentinel-2, L1C

* S2X_MSIL1C_20XX...
├ AUX_DATA
├ DATASTRIP
│  └ DS_XXX_XXXX...
│     └ QI_DATA
│        └ MTD_DS.xml <- metadata about the data-strip
├ GRANULE
│  └ L1C_TXXXX_XXXX...
│     ├ AUX_DATA
│     ├ IMG_DATA
│     ├ QI_DATA
│     └ MTD_TL.xml <- metadata about the tile
├ HTML
├ rep_info
├ manifest.safe
├ INSPIRE.xml
└ MTD_MSIL1C.xml <- metadata about the product

The metadata structure looks like:

* MTD_TL.xml
└ n1:Level-1C_Tile_ID
   ├ n1:General_Info
   ├ n1:Geometric_Info
   │  ├ Tile_Geocoding
   │  └ Tile_Angles
   │     ├ Sun_Angles_Grid
   │     │  ├ Zenith
   │     │  │  ├ COL_STEP
   │     │  │  ├ ROW_STEP
   │     │  │  └ Values_List
   │     │  └ Azimuth
   │     │     ├ COL_STEP
   │     │     ├ ROW_STEP
   │     │     └ Values_List
   │     ├ Mean_Sun_Angle
   │     └ Viewing_Incidence_Angles_Grids
   └ n1:Quality_Indicators_Info

The following acronyms are used:

  • s2 : Sentinel-2

  • DS : datastrip

  • TL : tile

  • QI : quality information

  • AUX : auxiliary

  • MTD : metadata

  • MSI : multi spectral instrument

  • L1C : product specification,i.e.: level 1, processing step C

s2d2.read_sentinel2.get_view_angles_s2_from_root(root)[source]
s2d2.read_sentinel2.read_view_angles_s2(path, fname='MTD_TL.xml', det_stack=np.array([]), boi_df=None)[source]

This function reads the xml-file of the Sentinel-2 scene and extracts an array with viewing angles of the MSI instrument.

Parameters:
  • path (string) – path where xml-file of Sentinel-2 is situated

  • fname (string) – the name of the metadata file, sometimes this is changed

  • boi_df (pandas.dataframe, default=4) – each band has a somewhat minute but different view angle

Returns:

  • Zn (numpy.ma.array, size=(m,n), dtype=float) – masked array of the solar zenith angles, in degrees.

  • Az (numpy.ma.array, size=(m,n), dtype=float) – masked array of the solar azimuth angles, in degrees.

See also

list_central_wavelength_s2

Notes

The azimuth angle is declared in the following coordinate frame:

     ^ North & y
     |
- <--|--> +
     |
     └----> East & x

The angles related to the satellite are as follows:

     #*#                   #*# satellite
^    /                ^    /|
|   /                 |   / | nadir
|-- zenith angle      |  /  v
| /                   | /|
|/                    |/ | elevation angle
└----- surface        └------

The metadata is scattered over the file structure of Sentinel-2, L1C

* S2X_MSIL1C_20XX...
├ AUX_DATA
├ DATASTRIP
│  └ DS_XXX_XXXX...
│     └ QI_DATA
│        └ MTD_DS.xml <- metadata about the data-strip
├ GRANULE
│  └ L1C_TXXXX_XXXX...
│     ├ AUX_DATA
│     ├ IMG_DATA
│     ├ QI_DATA
│     └ MTD_TL.xml <- metadata about the tile
├ HTML
├ rep_info
├ manifest.safe
├ INSPIRE.xml
└ MTD_MSIL1C.xml <- metadata about the product

The metadata structure looks like:

* MTD_TL.xml
└ n1:Level-1C_Tile_ID
   ├ n1:General_Info
   ├ n1:Geometric_Info
   │  ├ Tile_Geocoding
   │  └ Tile_Angles
   │     ├ Sun_Angles_Grid
   │     ├ Mean_Sun_Angle
   │     └ Viewing_Incidence_Angles_Grids
   │        ├ Zenith
   │        │  ├ COL_STEP
   │        │  ├ ROW_STEP
   │        │  └ Values_List
   │        └ Azimuth
   │           ├ COL_STEP
   │           ├ ROW_STEP
   │           └ Values_List
   └ n1:Quality_Indicators_Info

The following acronyms are used:

  • s2 : Sentinel-2

  • DS : datastrip

  • TL : tile

  • QI : quality information

  • AUX : auxiliary

  • MTD : metadata

  • MSI : multi spectral instrument

  • L1C : product specification,i.e.: level 1, processing step C

s2d2.read_sentinel2.read_mean_sun_angles_s2(path, fname='MTD_TL.xml')[source]

Read the xml-file of the Sentinel-2 scene and extract the mean sun angles.

Parameters:

path (string) – path where xml-file of Sentinel-2 is situated

Returns:

  • Zn (float) – Mean solar zentih angle of the scene, in degrees.

  • Az (float) – Mean solar azimuth angle of the scene, in degrees

Notes

The azimuth angle declared in the following coordinate frame:

     ^ North & y
     |
- <--|--> +
     |
     └----> East & x

The angles related to the sun are as follows:

surface normal              * sun
^                     ^    /
|                     |   /
|-- zenith angle      |  /
| /                   | /|
|/                    |/ | elevation angle
└----                 └------

The metadata is scattered over the file structure of Sentinel-2, L1C

* S2X_MSIL1C_20XX...
├ AUX_DATA
├ DATASTRIP
│  └ DS_XXX_XXXX...
│     └ QI_DATA
│        └ MTD_DS.xml <- metadata about the data-strip
├ GRANULE
│  └ L1C_TXXXX_XXXX...
│     ├ AUX_DATA
│     ├ IMG_DATA
│     ├ QI_DATA
│     └ MTD_TL.xml <- metadata about the tile
├ HTML
├ rep_info
├ manifest.safe
├ INSPIRE.xml
└ MTD_MSIL1C.xml <- metadata about the product

The following acronyms are used:

  • s2 : Sentinel-2

  • DS : datastrip

  • TL : tile

  • QI : quality information

  • AUX : auxiliary

  • MTD : metadata

  • MSI : multi spectral instrument

  • L1C : product specification,i.e.: level 1, processing step C

s2d2.read_sentinel2.read_detector_mask(path_meta, boi, geoTransform)[source]

create array of with detector identification

Sentinel-2 records in a pushbroom fasion, collecting reflectance with a ground resolution of more than 270 kilometers. This data is stacked in the flight direction, and then cut into granules. However, the sensorstrip inside the Multi Spectral Imager (MSI) is composed of several CCD arrays.

This function collects the geometry of these sensor arrays from the meta- data. Since this is stored in a gml-file.

Parameters:
  • path_meta (string) – path where the meta-data is situated.

  • boi (pandas.DataFrame) – list with bands of interest

  • geoTransform (tuple, size={(6,),(8,)}) – affine transformation coefficients

Returns:

numpy.ma.array, size=(msk_dim[0 – array where each pixel has the ID of the detector, of a specific band

Return type:

1],len(boi)), dtype=int8

See also

list_central_wavelength_msi

creates a dataframe for the MSI instrument

read_view_angles_s2

read grid of Sentinel-2 observation angles

Notes

The metadata is scattered over the file structure of Sentinel-2, L1C

* S2X_MSIL1C_20XX...
├ AUX_DATA
├ DATASTRIP
│  └ DS_XXX_XXXX...
│     └ QI_DATA
│        └ MTD_DS.xml <- metadata about the data-strip
├ GRANULE
│  └ L1C_TXXXX_XXXX...
│     ├ AUX_DATA
│     ├ IMG_DATA
│     ├ QI_DATA
│     └ MTD_TL.xml <- metadata about the tile
├ HTML
├ rep_info
├ manifest.safe
├ INSPIRE.xml
└ MTD_MSIL1C.xml <- metadata about the product

The following acronyms are used:

  • DS : datastrip

  • TL : tile

  • QI : quality information

  • AUX : auxiliary

  • MTD : metadata

  • MSI : multi spectral instrument

  • L1C : product specification,i.e.: level 1, processing step C

Examples

>>> from s2d2.read_sentinel2 import (
>>>    list_central_wavelength_msi, read_detector_mask
>>> )
>>> path_meta = '/GRANULE/L1C_T15MXV_A027450_20200923T163313/QI_DATA'
>>> boi = ['red', 'green', 'blue', 'near infrared']
>>> s2_df = list_central_wavelength_msi()
>>> boi_df = s2_df[s2_df['common_name'].isin(boi)]
>>> geoTransform = (600000.0, 10.0, 0.0, 10000000.0, 0.0, -10.0)
>>>
>>> det_stack = read_detector_mask(path_meta, boi_df, geoTransform)
s2d2.read_sentinel2.read_sensing_time_s2(path, fname='MTD_TL.xml')[source]
Parameters:
  • path (string) – path where the meta-data is situated

  • fname (string) – file name of the metadata.

Returns:

time of image acquisition

Return type:

numpy.datetime64

See also

get_s2_granual_id

Notes

The recording time is the average sensing within the tile, which is a combination of forward and backward looking datastrips. Schematically, this might look like:

x recording time of datastrip, i.e.: the start of the strip
× recording time of tile, i.e.: the weighted average
                           _________  datastrip
                 ____x____/        /_________
                /        /        /        /
               /        /        /        /
              /        /        /        /
             /        /        /        /
            /        /        /        /
           /        /        /        /
          /    ┌---/------┐ /        /
         /     |  /       |/        /
        /      | /  ×     /        /
       /       |/        /|       /
      /        /--------/-┘      /
     /        /  tile  /        /
    /        /        /        /
   /        /        /        /
  /        /        /        /
 /        /        /        /
/        _________/        /
_________        /________/

Examples

demonstrate the code when in a Scihub data structure

>>> import os
>>> from s2d2.handler.sentinel2 import get_s2_image_locations
>>> from s2d2.read_sentinel2 import read_sensing_time_s2
>>> fpath = '/Users/Data/'
>>> sname = 'S2A_MSIL1C_20200923T163311_N0209_R140_T15MXV_20200923T200821.SAFE'
>>> fname = 'MTD_MSIL1C.xml'
>>> s2_path = os.path.join(fpath, sname, fname)
>>> s2_df,_ = get_s2_image_locations(fname, s2_df)
>>> s2_df['filepath']
B02 'GRANULE/L1C_T15MXV_A027450_20200923T163313/IMG_DATA/T115MXV...'
B03 'GRANULE/L1C_T15MXV_A027450_20200923T163313/IMG_DATA/T15MXV...'
>>> full_path = '/'.join(s2_df['filepath'][0].split('/')[:-2])
'GRANULE/L1C_T15MXV_A027450_20200923T163313'
>>> rec_time = read_sensing_time_s2(path, fname='MTD_TL.xml')
>>> rec_time
s2d2.read_sentinel2.get_xy_poly_from_gml(gml_struct, idx)[source]
s2d2.read_sentinel2.get_msk_dim_from_gml(gml_struct, geoTransform)[source]
s2d2.read_sentinel2.read_cloud_mask(path_meta, geoTransform)[source]
Parameters:
  • path_meta (string) – directory where meta data is situated, ‘MSK_CLOUDS_B00.gml’ is typically the file of interest

  • geoTransform (tuple) – affine transformation coefficients

Returns:

array which highlights where clouds could be

Return type:

numpy.ndarray, size=(m,n), dtype=int

s2d2.read_sentinel2.read_detector_time_s2(path, fname='MTD_DS.xml', s2_df=None)[source]

get the detector metadata of the relative detector timing

Parameters:
  • path (string) – path where the meta-data is situated

  • fname (string) – file name of the metadata.

Returns:

  • det_time (numpy.array, numpy.datetime64) – detector time

  • det_name (list, size=(13,)) – list of the different detector codes

  • det_meta (numpy.array, size=(13,4)) –

    metadata of the individual detectors, each detector has the following:
    1. spatial resolution [m]

    2. minimal spectral range [nm]

    3. maximum spectral range [nm]

    4. mean spectral range [nm]

  • line_period (float, numpy.timedelta64) – temporal sampling distance

Notes

The sensor blocks are arranged as follows, with ~98 pixels overlap:

    ┌-----┐   ┌-----┐   ┌-----┐   ┌-----┐   ┌-----┐   ┌-----┐
    |DET02|   |DET04|   |DET06|   |SCA08|   |SCA10|   |SCA12|
    └-----┘   └-----┘   └-----┘   └-----┘   └-----┘   └-----┘
┌-----┐   ┌-----┐   ┌-----┐   ┌-----┐   ┌-----┐   ┌-----┐
|DET01|   |DET03|   |SCA05|   |SCA07|   |SCA09|   |SCA11|
└-----┘   └-----┘   └-----┘   └-----┘   └-----┘   └-----┘
a forward looking array, while band order is reverse for aft looking
<-2592 10m pixels->
┌-----------------┐    #*# satellite
|       B02       |     |
├-----------------┤     | flight
|       B08       |     | direction
├-----------------┤     |
|       B03       |     v
├-----------------┤
       etc.
the detector order is B02, B08, B03, B10, B04, B05,
B11, B06, B07, B8A, B12, B01 and B09
s2d2.read_sentinel2.get_flight_bearing_from_detector_mask_s2(Det)[source]
Parameters:

Det (numpy.array, size=(m,n), ndim={2,3}, dtype=integer) – array with numbers of the different detectors in Sentinel-2

Returns:

ψ – general bearing of the satellite

Return type:

float, unit=degrees

s2d2.read_sentinel2.get_raw_imu_s2(ds_path, fname='MTD_DS.xml')[source]
s2d2.read_sentinel2.get_raw_str_s2(ds_path, fname='MTD_DS.xml')[source]
s2d2.read_sentinel2.get_integration_and_sampling_time_s2(ds_path, fname='MTD_DS.xml', s2_dict=None)[source]
Parameters:
  • ds_path (string) – location where metadata of datastrip is situated

  • fname (string, default='MTD_DS.xml') – metadata filename

  • s2_dict (dictionary, default=None) – metadata dictionary, can be used instead of the string based method

Notes

The metadata is scattered over the file structure of Sentinel-2, L1C

* S2X_MSIL1C_20XX...
├ AUX_DATA
│  └ DS_XXX_XXXX...
│     └ QI_DATA
│        └ MTD_DS.xml <- metadata about the data-strip
├ GRANULE
│  └ L1C_TXXXX_XXXX...
│     ├ AUX_DATA
│     ├ IMG_DATA
│     ├ QI_DATA
│     └ MTD_TL.xml <- metadata about the tile
├ HTML
├ rep_info
├ manifest.safe
├ INSPIRE.xml
└ MTD_MSIL1C.xml <- metadata about the product

The following acronyms are used:

  • DS : datastrip

  • TL : tile

  • QI : quality information

  • AUX : auxiliary

  • MTD : metadata

  • MSI : multi spectral instrument

  • L1C : product specification,i.e.: level 1, processing step C