{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(workflow:med_part2_fig1)=\n",
"# Sentinel-3 OLCI Composites"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{hint} \n",
"Execute the notebook on the training platform >>\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"Sentinel-3 OLCI Level-1 data products are available as Full (`OL_1_EFR`) and Reduced Resolution (`OL_1_ERR`) data files. The following notebook shows you how `OL_1_EFR` data are structured and how you can generate true- and false-colour composite images.\n",
"\n",
"Find more information on the OLCI data products in the Sentinel-3 OLCI User Guide.\n",
"\n",
"This notebook provides an introduction to the Sentinel-3 OLCI data and enables you to generate true- and false-colour composite images of the fires in southern Italy and in Greece that occured in August 2021."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Basic Facts\n",
"**Spatial resolution**: `300m` \n",
"**Spatial coverage**: `Global` \n",
"**Revisit time**: `Less than 2 days` \n",
"**Data availability**: `since 2016`\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} How to access the data\n",
"Sentinel-3 OLCI data can be downloaded via the Copernicus Open Access Hub. You need to register for an account before downloading data. \n",
"\n",
"Sentinel-3 OLCI data products are disseminated as `.zip archives`, containing data files in `NetCDF` format.\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"**Load required libraries**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"Collapsed": "false"
},
"outputs": [],
"source": [
"import os\n",
"import xarray as xr\n",
"import numpy as np\n",
"import netCDF4 as nc\n",
"import pandas as pd\n",
"import glob\n",
"\n",
"from IPython.display import HTML\n",
"\n",
"# Python libraries for visualization\n",
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.colors\n",
"from matplotlib.cm import get_cmap\n",
"from matplotlib.axes import Axes\n",
"import cartopy.crs as ccrs\n",
"from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER\n",
"import cartopy.feature as cfeature\n",
"from cartopy.mpl.geoaxes import GeoAxes\n",
"GeoAxes._pcolormesh_patched = Axes.pcolormesh\n",
"\n",
"from skimage import exposure\n",
"\n",
"import warnings\n",
"warnings.simplefilter(action = \"ignore\", category = RuntimeWarning)\n",
"warnings.simplefilter(action = \"ignore\", category = UserWarning)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Load helper functions**"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"%run ../functions.ipynb"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load and browse Sentinel-3 OLCI Level-1 data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Sentinel-3 Level-1 data are dissiminated as `.zip archives` when downloaded."
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"[OPTIONAL] The first step is to unzip file from the zipped archive downloaded. This is optional as we have already unzipped the file for you. This is why the code is commented out."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# import zipfile\n",
"# with zipfile.ZipFile('../data/sentinel-3/olci/2021/08/07/S3B_OL_1_EFR____20210807T085200_20210807T085500_20210808T130135_0179_055_278_2340_LN1_O_NT_002.zip', 'r') as zip_ref:\n",
"# zip_ref.extractall('../data/sentinel-3/olci/2021/08/07/')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The unzipped folder contains 30 data files in `NetCDF` format. Data for each channel is stored in a single `NetCDF` file. Additionally, you get information on `qualityFlags`, `time_coordinates` or `geo_coordinates`.\n",
"\n",
"You can see the names of the 30 data files by looping through the data directory. You see that the channel information follow the same naming and all end with `_radiance.nc`."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"time_coordinates.nc\n",
"Oa01_radiance.nc\n",
"Oa02_radiance.nc\n",
"Oa03_radiance.nc\n",
"Oa04_radiance.nc\n",
"Oa05_radiance.nc\n",
"Oa06_radiance.nc\n",
"Oa07_radiance.nc\n",
"Oa08_radiance.nc\n",
"Oa09_radiance.nc\n",
"Oa10_radiance.nc\n",
"Oa11_radiance.nc\n",
"Oa12_radiance.nc\n",
"Oa13_radiance.nc\n",
"Oa14_radiance.nc\n",
"Oa15_radiance.nc\n",
"Oa16_radiance.nc\n",
"Oa17_radiance.nc\n",
"Oa18_radiance.nc\n",
"Oa19_radiance.nc\n",
"Oa20_radiance.nc\n",
"Oa21_radiance.nc\n",
"qualityFlags.nc\n",
"instrument_data.nc\n",
"removed_pixels.nc\n",
"geo_coordinates.nc\n",
"tie_geo_coordinates.nc\n",
"tie_meteo.nc\n",
"tie_geometries.nc\n"
]
}
],
"source": [
"olci_dir = '../data/sentinel-3/olci/2021/08/07/S3B_OL_1_EFR____20210807T085200_20210807T085500_20210808T130135_0179_055_278_2340_LN1_O_NT_002.SEN3/'\n",
"for i in glob.glob(olci_dir+'*.nc'):\n",
" tmp = i.split('/')\n",
" print(tmp[8])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load OLCI channel information"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As a first step, you can load one channel with xarray's function `open_dataset`. This will help you to understand how the data is structured.\n",
"You see that the data of each channel is a two dimensional data array, with `rows` and `columns` as dimensions. "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
S3IPF PDS 004.1 - i2r4 - Product Data Format Specification - OLCI Level 1, S3IPF PDS 002 - i1r7 - Product Data Format Specification - Product Structures, S3IPF DPM 002 - i2r5 - Detailed Processing Model - OLCI Level 1
resolution :
[ 270 294 ]
source :
IPF-OL-1-EO 06.11
start_time :
2021-08-07T08:52:00.193254Z
stop_time :
2021-08-07T08:55:00.160958Z
title :
OLCI Level 1b Product, Radiance Oa01 Data Set
"
],
"text/plain": [
"\n",
"Dimensions: (rows: 4091, columns: 4865)\n",
"Dimensions without coordinates: rows, columns\n",
"Data variables:\n",
" Oa01_radiance (rows, columns) float32 ...\n",
"Attributes: (12/16)\n",
" absolute_orbit_number: 17105\n",
" ac_subsampling_factor: 64\n",
" al_subsampling_factor: 1\n",
" comment: \n",
" contact: eosupport@copernicus.esa.int\n",
" creation_time: 2021-08-08T13:01:35Z\n",
" ... ...\n",
" references: S3IPF PDS 004.1 - i2r4 - Product Data Format Spec...\n",
" resolution: [ 270 294 ]\n",
" source: IPF-OL-1-EO 06.11\n",
" start_time: 2021-08-07T08:52:00.193254Z\n",
" stop_time: 2021-08-07T08:55:00.160958Z\n",
" title: OLCI Level 1b Product, Radiance Oa01 Data Set"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"olci_xr = xr.open_dataset(olci_dir+'Oa01_radiance.nc')\n",
"olci_xr"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load all channel information into one xarray object"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The next step is to bring the individual data files together into one `xarray` data object. You can do this with xarray's function `open_mfdataset`. Since all channel files have the same data structure, you can combine all channels by coordinates using the keyword argument `by_coords`. The result is a `xarray` object with 21 data variables. Each channel is represented as a data variable."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure(figsize=(10,6))\n",
"olci_xr_mf['Oa08_radiance'].plot.imshow()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load OLCI geographic coordinates"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you want to georeference your image, you have to load the geographic coordinates file. You can load it as xarray with `open_dataset`. The file is called `geo_coordinates.nc`. You see that the file contains three variables: `latitude`, `longitude` and `altitude`.\n",
"\n",
"Let's store the latitude and longitude data as `lat` and `lon` variables respectively."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"