Skip to content

Commit

Permalink
Merge pull request #151 from yreynaud/yann
Browse files Browse the repository at this point in the history
Add RCM in XSAR
  • Loading branch information
agrouaze authored Apr 18, 2023
2 parents 4be05be + 8288038 commit 3f31df1
Show file tree
Hide file tree
Showing 27 changed files with 2,774 additions and 376 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,56 @@ Sentinel1 Level 1 python reader for efficient xarray/dask based processor

# Install

## Conda

1) Install xsar (this will only permit to use Sentinel1)

```
conda install -c conda-forge xsar
```
2) Add optional dependencies

- Add use of Radarsat2 :

```
conda install -c conda-forge xradarsat2
```

- Add use of RCM

```
pip install git+https://github.com/umr-lops/xarray-safe-rcm.git
```

## Pypi

1) Install xsar (this will only permit to use Sentinel1)

```
pip install xsar
```
2) install xsar with optional dependencies (to use Radarsat2, RCM...)

- Install xsar including Radarsat2 :

```
pip install xsar[RS2]
```

- Install xsar including RCM :

```
pip install git+https://github.com/umr-lops/xarray-safe-rcm.git
pip install xsar
```

- Install xsar including Radarsat2 and RCM:

```
pip install git+https://github.com/umr-lops/xarray-safe-rcm.git
pip install xsar[RS2]
```


```python
>>> import xsar
Expand Down
Binary file modified docs/_static/uml/classes_all_attributes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/uml/packages_all_attributes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 22 additions & 6 deletions docs/basic_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,33 @@ API reference

Base classes
============
.. automodule:: xsar
:members: BaseMeta, BaseDataset
.. autoclass:: BaseMeta
:members:


.. autoclass:: BaseDataset
:members:

XSAR Meta classes
=================
.. automodule:: xsar
:members: Sentinel1Meta, RadarSat2Meta
.. autoclass:: Sentinel1Meta
:members:

.. autoclass:: RadarSat2Meta
:members:

.. autoclass:: RcmMeta
:members:

XSAR Dataset classes
====================
.. automodule:: xsar
:members: Sentinel1Dataset, RadarSat2Dataset
.. autoclass:: Sentinel1Dataset
:members:

.. autoclass:: RadarSat2Dataset
:members:

.. autoclass:: RcmDataset
:members:


67 changes: 67 additions & 0 deletions docs/examples/mask.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,73 @@
"source": [
"ds['sigma0_land'].sel(pol='VH').plot(vmin=0)"
]
},
{
"cell_type": "markdown",
"id": "3cf12c23-ddb1-4040-ac11-2c8209de7ded",
"metadata": {
"tags": []
},
"source": [
"## RCM example"
]
},
{
"cell_type": "markdown",
"id": "5967453d-ad6f-480b-8d6a-6d89484088ff",
"metadata": {
"tags": []
},
"source": [
"[xsar.RcmDataset.dataset](../basic_api.rst#xsar.RcmDataset.dataset) has a `land_mask` variable by default, rasterized from [cartopy.feature.NaturalEarthFeature('physical', 'land', '10m')](https://scitools.org.uk/cartopy/docs/latest/matplotlib/feature_interface.html#cartopy.feature.NaturalEarthFeature)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "679635f2-186d-47da-b3d2-e762d5ad82a4",
"metadata": {},
"outputs": [],
"source": [
"import warnings\n",
"warnings.filterwarnings('ignore')"
]
},
{
"cell_type": "markdown",
"id": "5f6eb695-4e2b-4b84-9953-822029979929",
"metadata": {},
"source": [
"### Mask sigma0 over land\n",
"\n",
"Replacing `sigma0` values with `nan` over ocean can be done with `xarray.where`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5c9934b5-4752-4076-b03c-d575c46f5994",
"metadata": {},
"outputs": [],
"source": [
"\n",
"ds = xsar.open_dataset(xsar.get_test_file('RCM1_OK2460179_PK2462841_1_SCLND_20230301_072431_VV_VH_GRD'), resolution='1000m')\n",
"\n",
"# apply land_mask. The final transpose is done to preserve dimensions ordering\n",
"ds['sigma0_land'] = xr.where(ds['land_mask'], ds['sigma0'], np.nan).transpose(*ds['sigma0'].dims)\n",
"ds['sigma0_land']\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db2f79fc-7c23-4a52-bc0f-93d05293d853",
"metadata": {},
"outputs": [],
"source": [
"ds['sigma0_land'].sel(pol='VH').plot(vmin=0)"
]
}
],
"metadata": {
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/projections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@
"\n",
"crs = CRS({\n",
" 'proj': 'aeqd',\n",
" 'lat_0': xsar_obj.s1meta.footprint.centroid.y,\n",
" 'lon_0': xsar_obj.s1meta.footprint.centroid.x,\n",
" 'lat_0': xsar_obj.sar_meta.footprint.centroid.y,\n",
" 'lon_0': xsar_obj.sar_meta.footprint.centroid.x,\n",
" 'x_0': 0,\n",
" 'y_0': 0,\n",
" 'ellps': 'WGS84'\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/radarsat2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"metadata": {},
"outputs": [],
"source": [
"rs2ds.rs2meta"
"rs2ds.sar_meta"
]
},
{
Expand Down Expand Up @@ -270,7 +270,7 @@
"metadata": {},
"outputs": [],
"source": [
"dn_low_res = load_digital_number(rs2ds.rs2meta.dt, resolution=resolution, resampling=resampling, chunks=chunks)['digital_numbers'].ds\n",
"dn_low_res = load_digital_number(rs2ds.sar_meta.dt, resolution=resolution, resampling=resampling, chunks=chunks)['digital_numbers'].ds\n",
"dn_low_res"
]
},
Expand Down
Loading

0 comments on commit 3f31df1

Please sign in to comment.