{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Sentinel 1 SAR GRD Data with satpy"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2021-05-21T06:36:39.337354Z",
"iopub.status.busy": "2021-05-21T06:36:39.336947Z",
"iopub.status.idle": "2021-05-21T06:36:47.580046Z",
"shell.execute_reply": "2021-05-21T06:36:47.578791Z",
"shell.execute_reply.started": "2021-05-21T06:36:39.337323Z"
}
},
"outputs": [],
"source": [
"!pip install satpy rioxarray rasterio"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Reading single bands"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Getting the filenames"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2021-05-21T06:36:47.582351Z",
"iopub.status.busy": "2021-05-21T06:36:47.581991Z",
"iopub.status.idle": "2021-05-21T06:36:50.571415Z",
"shell.execute_reply": "2021-05-21T06:36:50.570247Z",
"shell.execute_reply.started": "2021-05-21T06:36:47.582316Z"
}
},
"outputs": [],
"source": [
"from satpy import Scene, find_files_and_readers\n",
"from datetime import datetime\n",
"\n",
"files = find_files_and_readers(\n",
" base_dir=\"/home/a001673/data/satellite/Sentinel-1/\",\n",
" # Bay of bothnia\n",
" start_time=datetime(2020, 3, 14, 15, 49, 13),\n",
" end_time=datetime(2020, 3, 16, 15, 49, 40),\n",
" reader='sar-c_safe')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Read the HH-polarized measurement as a `xarray.DataArray`"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"execution": {
"iopub.execute_input": "2021-05-21T06:44:52.756745Z",
"iopub.status.busy": "2021-05-21T06:44:52.756249Z",
"iopub.status.idle": "2021-05-21T06:44:55.811011Z",
"shell.execute_reply": "2021-05-21T06:44:55.809702Z",
"shell.execute_reply.started": "2021-05-21T06:44:52.756705Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"
<xarray.DataArray (y: 10717, x: 10474)>\n",
"dask.array<clip, shape=(10717, 10474), dtype=float64, chunksize=(4096, 4096), chunktype=numpy.ndarray>\n",
"Coordinates:\n",
" * y (y) int64 0 1 2 3 4 5 6 ... 10711 10712 10713 10714 10715 10716\n",
" * x (x) int64 0 1 2 3 4 5 6 ... 10468 10469 10470 10471 10472 10473\n",
" band int64 1\n",
" spatial_ref int64 0\n",
" crs object +proj=longlat +type=crs\n",
"Attributes: (12/18)\n",
" name: measurement\n",
" sensor: sar-c\n",
" wavelength: [5.4, 5.405, 5.41]\n",
" resolution: 80\n",
" polarization: hh\n",
" calibration: gamma\n",
" ... ...\n",
" platform_name: s1b\n",
" start_time: 2020-03-15 05:04:28\n",
" end_time: 2020-03-15 05:05:32\n",
" area: Shape: (10717, 10474)\\nLons: <xarray.DataArray 'int...\n",
" _satpy_id: DataID(name='measurement', polarization='hh', resol...\n",
" ancillary_variables: []
dask.array<chunksize=(4096, 4096), meta=np.ndarray>
\n",
"\n",
"\n",
"\n",
" \n",
" | Array | Chunk | \n",
" \n",
" \n",
" Bytes | 898.00 MB | 134.22 MB | \n",
" Shape | (10717, 10474) | (4096, 4096) | \n",
" Count | 1592 Tasks | 9 Chunks | \n",
" Type | float64 | numpy.ndarray | \n",
" \n",
" \n",
" | \n",
"\n",
"\n",
" | \n",
"
\n",
"
- name :
- measurement
- sensor :
- sar-c
- wavelength :
- [5.4, 5.405, 5.41]
- resolution :
- 80
- polarization :
- hh
- calibration :
- gamma
- quantity :
- natural
- coordinates :
- ('longitude', 'latitude')
- file_type :
- safe_measurement
- standard_name :
- backscatter
- units :
- 1
- modifiers :
- ()
- platform_name :
- s1b
- start_time :
- 2020-03-15 05:04:28
- end_time :
- 2020-03-15 05:05:32
- area :
- Shape: (10717, 10474)\n",
"Lons: <xarray.DataArray 'interpolate-ac84ed279e77fedb5c73a807b6acbe44' (y: 10717, x: 10474)>\n",
"dask.array<interpolate, shape=(10717, 10474), dtype=float64, chunksize=(4096, 4096), chunktype=numpy.ndarray>\n",
"Dimensions without coordinates: y, x\n",
"Attributes: (12/14)\n",
" gcps: [GroundControlPoint(row=0.0, col=0.0, x=27.57830525...\n",
" crs: EPSG:4326\n",
" name: longitude\n",
" resolution: 80\n",
" file_type: safe_measurement\n",
" standard_name: longitude\n",
" ... ...\n",
" modifiers: ()\n",
" start_time: 2020-03-15 05:04:28\n",
" end_time: 2020-03-15 05:05:32\n",
" _satpy_id: DataID(name='longitude', polarization='hh', resolut...\n",
" long_name: longitude\n",
" ancillary_variables: []\n",
"Lats: <xarray.DataArray 'interpolate-70ac27447600fd57e6f119649ccb456b' (y: 10717, x: 10474)>\n",
"dask.array<interpolate, shape=(10717, 10474), dtype=float64, chunksize=(4096, 4096), chunktype=numpy.ndarray>\n",
"Dimensions without coordinates: y, x\n",
"Attributes: (12/14)\n",
" gcps: [GroundControlPoint(row=0.0, col=0.0, x=27.57830525...\n",
" crs: EPSG:4326\n",
" name: latitude\n",
" resolution: 80\n",
" file_type: safe_measurement\n",
" standard_name: latitude\n",
" ... ...\n",
" modifiers: ()\n",
" start_time: 2020-03-15 05:04:28\n",
" end_time: 2020-03-15 05:05:32\n",
" _satpy_id: DataID(name='latitude', polarization='hh', resoluti...\n",
" long_name: latitude\n",
" ancillary_variables: []
- _satpy_id :
- DataID(name='measurement', polarization='hh', resolution=80, calibration=<calibration.gamma>, quantity=<quantity.natural>, modifiers=())
- ancillary_variables :
- []
"
],
"text/plain": [
"\n",
"dask.array\n",
"Coordinates:\n",
" * y (y) int64 0 1 2 3 4 5 6 ... 10711 10712 10713 10714 10715 10716\n",
" * x (x) int64 0 1 2 3 4 5 6 ... 10468 10469 10470 10471 10472 10473\n",
" band int64 1\n",
" spatial_ref int64 0\n",
" crs object +proj=longlat +type=crs\n",
"Attributes: (12/18)\n",
" name: measurement\n",
" sensor: sar-c\n",
" wavelength: [5.4, 5.405, 5.41]\n",
" resolution: 80\n",
" polarization: hh\n",
" calibration: gamma\n",
" ... ...\n",
" platform_name: s1b\n",
" start_time: 2020-03-15 05:04:28\n",
" end_time: 2020-03-15 05:05:32\n",
" area: Shape: (10717, 10474)\\nLons: