s2-rut-python 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- s2_rut_python-0.0.1/LICENSE +165 -0
- s2_rut_python-0.0.1/MANIFEST.in +2 -0
- s2_rut_python-0.0.1/PKG-INFO +127 -0
- s2_rut_python-0.0.1/README.md +99 -0
- s2_rut_python-0.0.1/docs/conf.py +149 -0
- s2_rut_python-0.0.1/examples/run_example.py +117 -0
- s2_rut_python-0.0.1/examples/temporary_example.py +202 -0
- s2_rut_python-0.0.1/pyproject.toml +50 -0
- s2_rut_python-0.0.1/s2_rut_python/__init__.py +9 -0
- s2_rut_python-0.0.1/s2_rut_python/_vendor.py +19 -0
- s2_rut_python-0.0.1/s2_rut_python/_version.py +21 -0
- s2_rut_python-0.0.1/s2_rut_python/interface.py +500 -0
- s2_rut_python-0.0.1/s2_rut_python/tests/__init__.py +0 -0
- s2_rut_python-0.0.1/s2_rut_python/tests/test_interface.py +291 -0
- s2_rut_python-0.0.1/s2_rut_python.egg-info/PKG-INFO +127 -0
- s2_rut_python-0.0.1/s2_rut_python.egg-info/SOURCES.txt +25 -0
- s2_rut_python-0.0.1/s2_rut_python.egg-info/dependency_links.txt +1 -0
- s2_rut_python-0.0.1/s2_rut_python.egg-info/requires.txt +14 -0
- s2_rut_python-0.0.1/s2_rut_python.egg-info/top_level.txt +6 -0
- s2_rut_python-0.0.1/setup.cfg +30 -0
- s2_rut_python-0.0.1/setup.py +7 -0
- s2_rut_python-0.0.1/third-party/Source/S2RUT.py +477 -0
- s2_rut_python-0.0.1/third-party/Source/S2Reader.py +695 -0
- s2_rut_python-0.0.1/third-party/Source/S2Reader_band.py +675 -0
- s2_rut_python-0.0.1/third-party/run_rut.py +303 -0
- s2_rut_python-0.0.1/versioneer.py +1883 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: s2_rut_python
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Pure Python port of ESA's Sentinel-2 radiometric uncertainty tool
|
|
5
|
+
Author-email: Maddie Stedman <maddie.stedman@npl.co.uk>
|
|
6
|
+
Project-URL: Homepage, http://gitlab.npl.co.uk/eco/tools/s2_rut_python
|
|
7
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
8
|
+
Classifier: Programming Language :: Python
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: matplotlib
|
|
16
|
+
Requires-Dist: xarray
|
|
17
|
+
Requires-Dist: obsarray
|
|
18
|
+
Requires-Dist: processor_tools
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
21
|
+
Requires-Dist: tox; extra == "dev"
|
|
22
|
+
Requires-Dist: sphinx; extra == "dev"
|
|
23
|
+
Requires-Dist: sphinx_book_theme; extra == "dev"
|
|
24
|
+
Requires-Dist: sphinx_rtd_theme; extra == "dev"
|
|
25
|
+
Requires-Dist: ipython; extra == "dev"
|
|
26
|
+
Requires-Dist: sphinx_design; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# s2_rut_python
|
|
30
|
+
|
|
31
|
+
Pure Python portion of Javi's Sentinel-2 radiometric uncertainty tool.
|
|
32
|
+
|
|
33
|
+
## Beta Version
|
|
34
|
+
|
|
35
|
+
**WARNING:** This software is a beta version, results should be used with caution. Please share any feedback you have after using the tool.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
Files are read into an xarray format for use with our other tools. eoio capabilities are used for accessing and extracting the metadata, used for calculating the uncertainties.
|
|
40
|
+
|
|
41
|
+
Band selection takes one band or a list of **Sentinel-2 band names**: B01, B02, B03, B04, B05, B06, B07, B08, B8A, B09, B10, B11, B12.
|
|
42
|
+
|
|
43
|
+
The current interface entry point is `S2RUTTool` and uncertainties can be returned either:
|
|
44
|
+
|
|
45
|
+
* grouped by correlation component (`u_systematic_<band>`, `u_random_<band>`), or
|
|
46
|
+
* per contributor (for example `u_noise_<band>`).
|
|
47
|
+
|
|
48
|
+
Each individual type of components is categorised according to Gorrono *et al.* (2017).
|
|
49
|
+
|
|
50
|
+
Usage of this module is as follows:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from s2_rut_python.interface import S2RUTTool
|
|
54
|
+
|
|
55
|
+
s2rut = S2RUTTool()
|
|
56
|
+
ds_out = s2rut.run(
|
|
57
|
+
ds=s2_ds,
|
|
58
|
+
data_vars=['B01'],
|
|
59
|
+
group_unc=True,
|
|
60
|
+
)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
To run per-contributor uncertainties:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
ds_out = s2rut.run(
|
|
67
|
+
ds=s2_ds,
|
|
68
|
+
data_vars=['B01'],
|
|
69
|
+
group_unc=False,
|
|
70
|
+
)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
To limit contributors to a subset:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
ds_out = s2rut.run(
|
|
77
|
+
ds=s2_ds,
|
|
78
|
+
data_vars=['B01'],
|
|
79
|
+
group_unc=False,
|
|
80
|
+
subset_unc=['noise', 'adc', 'gamma'],
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Uncertainty variables are stored in the obsarray uncertainty accessor (for example `ds_out.unc['B01']`). Reflectance zero-values are masked to `NaN` before return.
|
|
85
|
+
|
|
86
|
+
## Example
|
|
87
|
+
|
|
88
|
+
An up-to-date runnable example is available in `examples/run_example.py`. It demonstrates reading Sentinel-2 L1C data with eoio, selecting an ROI subset for the current product, running `S2RUTTool.run(...)`, and plotting reflectance, random uncertainty [%], and systematic uncertainty [%].
|
|
89
|
+
|
|
90
|
+
### Virtual environment
|
|
91
|
+
|
|
92
|
+
It's always recommended to make a virtual environment for each of your python projects. Use your preferred virtual environment manager if you want and activate it for the rest of these commands. If you're unfamiliar, read https://realpython.com/python-virtual-environments-a-primer/. You can set one up using:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
python -m venv venv
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
and then activate it on Windows by using `venv/Scripts/activate`.
|
|
99
|
+
|
|
100
|
+
## Installation
|
|
101
|
+
|
|
102
|
+
Install your package and its dependencies by using:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
pip install -e .
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
For developing the package, you'll want to install the pre-commit hooks as well. Type:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pre-commit install
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Note that from now on when you commit, `black` will check your code for styling errors. If it finds any it will correct them, but the commit will be aborted. This is so that you can check its work before you continue. If you're happy, just commit again.
|
|
117
|
+
|
|
118
|
+
## Compatibility
|
|
119
|
+
|
|
120
|
+
## Authors
|
|
121
|
+
|
|
122
|
+
s2_rut_python has been developed by `Rasma Ormane <rasma.ormane@npl.co.uk>`_. `Sam Hunt <sam.hunt@npl.co.uk>`_. and `Maddie Stedman <maddie.stedman@npl.co.uk>`_.
|
|
123
|
+
|
|
124
|
+
## Citations
|
|
125
|
+
|
|
126
|
+
Gorrono, J.; Fomferra, N.; Peters, M.; Gascon, F.; Underwood, C.I.; Fox, N.P.; Kirches, G.; Brockmann, C.
|
|
127
|
+
A Radiometric Uncertainty Tool for the Sentinel 2 Mission. Remote Sens. 2017, 9, 178. https://doi.org/10.3390/rs9020178
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# s2_rut_python
|
|
2
|
+
|
|
3
|
+
Pure Python portion of Javi's Sentinel-2 radiometric uncertainty tool.
|
|
4
|
+
|
|
5
|
+
## Beta Version
|
|
6
|
+
|
|
7
|
+
**WARNING:** This software is a beta version, results should be used with caution. Please share any feedback you have after using the tool.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Files are read into an xarray format for use with our other tools. eoio capabilities are used for accessing and extracting the metadata, used for calculating the uncertainties.
|
|
12
|
+
|
|
13
|
+
Band selection takes one band or a list of **Sentinel-2 band names**: B01, B02, B03, B04, B05, B06, B07, B08, B8A, B09, B10, B11, B12.
|
|
14
|
+
|
|
15
|
+
The current interface entry point is `S2RUTTool` and uncertainties can be returned either:
|
|
16
|
+
|
|
17
|
+
* grouped by correlation component (`u_systematic_<band>`, `u_random_<band>`), or
|
|
18
|
+
* per contributor (for example `u_noise_<band>`).
|
|
19
|
+
|
|
20
|
+
Each individual type of components is categorised according to Gorrono *et al.* (2017).
|
|
21
|
+
|
|
22
|
+
Usage of this module is as follows:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from s2_rut_python.interface import S2RUTTool
|
|
26
|
+
|
|
27
|
+
s2rut = S2RUTTool()
|
|
28
|
+
ds_out = s2rut.run(
|
|
29
|
+
ds=s2_ds,
|
|
30
|
+
data_vars=['B01'],
|
|
31
|
+
group_unc=True,
|
|
32
|
+
)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To run per-contributor uncertainties:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
ds_out = s2rut.run(
|
|
39
|
+
ds=s2_ds,
|
|
40
|
+
data_vars=['B01'],
|
|
41
|
+
group_unc=False,
|
|
42
|
+
)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
To limit contributors to a subset:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
ds_out = s2rut.run(
|
|
49
|
+
ds=s2_ds,
|
|
50
|
+
data_vars=['B01'],
|
|
51
|
+
group_unc=False,
|
|
52
|
+
subset_unc=['noise', 'adc', 'gamma'],
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Uncertainty variables are stored in the obsarray uncertainty accessor (for example `ds_out.unc['B01']`). Reflectance zero-values are masked to `NaN` before return.
|
|
57
|
+
|
|
58
|
+
## Example
|
|
59
|
+
|
|
60
|
+
An up-to-date runnable example is available in `examples/run_example.py`. It demonstrates reading Sentinel-2 L1C data with eoio, selecting an ROI subset for the current product, running `S2RUTTool.run(...)`, and plotting reflectance, random uncertainty [%], and systematic uncertainty [%].
|
|
61
|
+
|
|
62
|
+
### Virtual environment
|
|
63
|
+
|
|
64
|
+
It's always recommended to make a virtual environment for each of your python projects. Use your preferred virtual environment manager if you want and activate it for the rest of these commands. If you're unfamiliar, read https://realpython.com/python-virtual-environments-a-primer/. You can set one up using:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
python -m venv venv
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
and then activate it on Windows by using `venv/Scripts/activate`.
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
Install your package and its dependencies by using:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install -e .
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
For developing the package, you'll want to install the pre-commit hooks as well. Type:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pre-commit install
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Note that from now on when you commit, `black` will check your code for styling errors. If it finds any it will correct them, but the commit will be aborted. This is so that you can check its work before you continue. If you're happy, just commit again.
|
|
89
|
+
|
|
90
|
+
## Compatibility
|
|
91
|
+
|
|
92
|
+
## Authors
|
|
93
|
+
|
|
94
|
+
s2_rut_python has been developed by `Rasma Ormane <rasma.ormane@npl.co.uk>`_. `Sam Hunt <sam.hunt@npl.co.uk>`_. and `Maddie Stedman <maddie.stedman@npl.co.uk>`_.
|
|
95
|
+
|
|
96
|
+
## Citations
|
|
97
|
+
|
|
98
|
+
Gorrono, J.; Fomferra, N.; Peters, M.; Gascon, F.; Underwood, C.I.; Fox, N.P.; Kirches, G.; Brockmann, C.
|
|
99
|
+
A Radiometric Uncertainty Tool for the Sentinel 2 Mission. Remote Sens. 2017, 9, 178. https://doi.org/10.3390/rs9020178
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#
|
|
3
|
+
# s2_rut_python documentation build configuration file, created by
|
|
4
|
+
# cookiecutter
|
|
5
|
+
#
|
|
6
|
+
# This file is execfile()d with the current directory set to its
|
|
7
|
+
# containing dir.
|
|
8
|
+
#
|
|
9
|
+
# Note that not all possible configuration values are present in this
|
|
10
|
+
# autogenerated file.
|
|
11
|
+
#
|
|
12
|
+
# All configuration values have a default; values that are commented out
|
|
13
|
+
# serve to show the default.
|
|
14
|
+
|
|
15
|
+
import s2_rut_python
|
|
16
|
+
|
|
17
|
+
project_title = "s2_rut_python".replace("_", " ").title()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# -- General configuration ---------------------------------------------
|
|
21
|
+
|
|
22
|
+
# If your documentation needs a minimal Sphinx version, state it here.
|
|
23
|
+
#
|
|
24
|
+
# needs_sphinx = '1.0'
|
|
25
|
+
|
|
26
|
+
# Attempt to make links automatially
|
|
27
|
+
default_role = "code"
|
|
28
|
+
|
|
29
|
+
# Add any Sphinx extension module names here, as strings. They can be
|
|
30
|
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
|
31
|
+
# CFAB added napolean to support google-style docstrings
|
|
32
|
+
extensions = [
|
|
33
|
+
"sphinx.ext.autodoc",
|
|
34
|
+
"sphinx.ext.autosummary",
|
|
35
|
+
"sphinx.ext.intersphinx",
|
|
36
|
+
"sphinx.ext.viewcode",
|
|
37
|
+
"sphinx.ext.napoleon",
|
|
38
|
+
"IPython.sphinxext.ipython_directive",
|
|
39
|
+
"IPython.sphinxext.ipython_console_highlighting",
|
|
40
|
+
"sphinx_design",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
# Add any paths that contain templates here, relative to this directory.
|
|
44
|
+
templates_path = ["_templates"]
|
|
45
|
+
|
|
46
|
+
# The suffix(es) of source filenames.
|
|
47
|
+
# You can specify multiple suffix as a list of string:
|
|
48
|
+
#
|
|
49
|
+
# source_suffix = ['.rst', '.md']
|
|
50
|
+
source_suffix = ".rst"
|
|
51
|
+
|
|
52
|
+
# The master toctree document.
|
|
53
|
+
master_doc = "index"
|
|
54
|
+
|
|
55
|
+
# General information about the project.
|
|
56
|
+
project = project_title
|
|
57
|
+
copyright = "Jacob Fahy"
|
|
58
|
+
author = "Jacob Fahy"
|
|
59
|
+
|
|
60
|
+
# The version info for the project you're documenting, acts as replacement
|
|
61
|
+
# for |version| and |release|, also used in various other places throughout
|
|
62
|
+
# the built documents.
|
|
63
|
+
#
|
|
64
|
+
# The short X.Y version.
|
|
65
|
+
version = s2_rut_python.__version__
|
|
66
|
+
# The full version, including alpha/beta/rc tags.
|
|
67
|
+
release = s2_rut_python.__version__
|
|
68
|
+
|
|
69
|
+
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
70
|
+
# for a list of supported languages.
|
|
71
|
+
#
|
|
72
|
+
# This is also used if you do content translation via gettext catalogs.
|
|
73
|
+
# Usually you set "language" from the command line for these cases.
|
|
74
|
+
language = None
|
|
75
|
+
|
|
76
|
+
# List of patterns, relative to source directory, that match files and
|
|
77
|
+
# directories to ignore when looking for source files.
|
|
78
|
+
# This patterns also effect to html_static_path and html_extra_path
|
|
79
|
+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|
80
|
+
|
|
81
|
+
# The name of the Pygments (syntax highlighting) style to use.
|
|
82
|
+
pygments_style = "sphinx"
|
|
83
|
+
|
|
84
|
+
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
|
85
|
+
todo_include_todos = False
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# -- Options for HTML output -------------------------------------------
|
|
89
|
+
|
|
90
|
+
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
91
|
+
# a list of builtin themes.
|
|
92
|
+
#
|
|
93
|
+
html_theme = "sphinx_book_theme"
|
|
94
|
+
|
|
95
|
+
# Theme options are theme-specific and customize the look and feel of a
|
|
96
|
+
# theme further. For a list of options available for each theme, see the
|
|
97
|
+
# documentation.
|
|
98
|
+
#
|
|
99
|
+
html_theme_options = {
|
|
100
|
+
"announcement": "<strong>Beta Version:</strong> This software is a beta version, results should be used with caution. Please share any feedback you have after using the tool.",
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# Add any paths that contain custom static files (such as style sheets) here,
|
|
104
|
+
# relative to this directory. They are copied after the builtin static files,
|
|
105
|
+
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
106
|
+
html_static_path = ["_static"]
|
|
107
|
+
|
|
108
|
+
# -- Options for HTMLHelp output ---------------------------------------
|
|
109
|
+
|
|
110
|
+
# Output file base name for HTML help builder.
|
|
111
|
+
htmlhelp_basename = "s2_rut_pythondoc"
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# -- Options for LaTeX output ------------------------------------------
|
|
115
|
+
|
|
116
|
+
latex_elements = {
|
|
117
|
+
# The paper size ('letterpaper' or 'a4paper').
|
|
118
|
+
#
|
|
119
|
+
# 'papersize': 'letterpaper',
|
|
120
|
+
# The font size ('10pt', '11pt' or '12pt').
|
|
121
|
+
#
|
|
122
|
+
# 'pointsize': '10pt',
|
|
123
|
+
# Additional stuff for the LaTeX preamble.
|
|
124
|
+
#
|
|
125
|
+
# 'preamble': '',
|
|
126
|
+
# Latex figure (float) alignment
|
|
127
|
+
#
|
|
128
|
+
# 'figure_align': 'htbp',
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# Grouping the document tree into LaTeX files. List of tuples
|
|
132
|
+
# (source start file, target name, title, author, documentclass
|
|
133
|
+
# [howto, manual, or own class]).
|
|
134
|
+
latex_documents = [
|
|
135
|
+
(
|
|
136
|
+
"content/user/user_guide",
|
|
137
|
+
"user_manual.tex",
|
|
138
|
+
"{}: User Guide".format(project_title),
|
|
139
|
+
"Jacob Fahy",
|
|
140
|
+
"manual",
|
|
141
|
+
),
|
|
142
|
+
(
|
|
143
|
+
"content/user/atbd",
|
|
144
|
+
"atbd.tex",
|
|
145
|
+
"{}: Algorithm Theoretical Basis Document".format(project_title),
|
|
146
|
+
"Jacob Fahy",
|
|
147
|
+
"manual",
|
|
148
|
+
),
|
|
149
|
+
]
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""example: read a Sentinel-2 L1C SAFE product and run S2-RUT."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import glob
|
|
5
|
+
import socket
|
|
6
|
+
|
|
7
|
+
import matplotlib.pyplot as plt
|
|
8
|
+
from eoio import read
|
|
9
|
+
from shapely import wkt
|
|
10
|
+
|
|
11
|
+
from s2_rut_python.interface import S2RUTTool
|
|
12
|
+
|
|
13
|
+
if (
|
|
14
|
+
socket.gethostname() == "lyon.npl.co.uk"
|
|
15
|
+
or socket.gethostname() == "leipzig.npl.co.uk"
|
|
16
|
+
or "leiden" in socket.gethostname()
|
|
17
|
+
):
|
|
18
|
+
DATA_DIRECTORY = "/mnt/t/data/"
|
|
19
|
+
else:
|
|
20
|
+
DATA_DIRECTORY = r"T:\ECO\EOServer\data"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Define input path from test datasets
|
|
24
|
+
SAFE_PATH = os.path.join(
|
|
25
|
+
DATA_DIRECTORY,
|
|
26
|
+
"unittest_datasets",
|
|
27
|
+
"S2MSIL1C",
|
|
28
|
+
"S2A_MSIL1C_20251128T111431_N0511_R137_T30UXE_20251128T121631.SAFE",
|
|
29
|
+
)
|
|
30
|
+
print("SAFE PATH:", SAFE_PATH)
|
|
31
|
+
|
|
32
|
+
# Define ROI
|
|
33
|
+
roi_string = "POLYGON ((\
|
|
34
|
+
-0.913910 53.786950,\
|
|
35
|
+
-0.382900 53.776490,\
|
|
36
|
+
-0.406240 53.464690,\
|
|
37
|
+
-0.925060 53.474770,\
|
|
38
|
+
-0.913910 53.786950\
|
|
39
|
+
))"
|
|
40
|
+
|
|
41
|
+
geom = wkt.loads(roi_string)
|
|
42
|
+
|
|
43
|
+
# Read the dataset with eoio, selecting only a few bands and auxiliary variables for efficiency.
|
|
44
|
+
bands = ["B01", "B03", "B09"]
|
|
45
|
+
ds = read(
|
|
46
|
+
SAFE_PATH,
|
|
47
|
+
vars_sel={
|
|
48
|
+
"meas": bands,
|
|
49
|
+
"aux": [
|
|
50
|
+
"solar_zenith_angle",
|
|
51
|
+
"solar_azimuth_angle",
|
|
52
|
+
"viewing_zenith_angle",
|
|
53
|
+
"viewing_azimuth_angle",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
read_params={
|
|
57
|
+
"use_chunks": True,
|
|
58
|
+
"metadata_level": "all",
|
|
59
|
+
"save_extracted": True,
|
|
60
|
+
"ave_va_det": True,
|
|
61
|
+
},
|
|
62
|
+
subset={"roi": geom, "roi_crs": "EPSG:4326"},
|
|
63
|
+
processors={
|
|
64
|
+
"interpolate": {
|
|
65
|
+
"coords": ["y_5000m", "x_5000m"],
|
|
66
|
+
"data_vars": ["solar_zenith_angle"],
|
|
67
|
+
"target_grid": [["y_60m", "y_10m"], ["x_60m", "x_10m"]],
|
|
68
|
+
"method": "linear",
|
|
69
|
+
"inplace": False,
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Run S2-RUT on the dataset, computing both random and systematic uncertainties.
|
|
75
|
+
print("Running S2-RUT")
|
|
76
|
+
rut = S2RUTTool()
|
|
77
|
+
ds_out = rut.run(ds=ds, data_vars=bands, group_unc=True)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# Create a single grid plot: rows = bands, columns = [reflectance, random [%], systematic [%]].
|
|
81
|
+
fig, axes = plt.subplots(
|
|
82
|
+
nrows=len(bands),
|
|
83
|
+
ncols=3,
|
|
84
|
+
figsize=(15, 4 * len(bands)),
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# Handle single band case (axes is 1D instead of 2D).
|
|
88
|
+
if len(bands) == 1:
|
|
89
|
+
axes = axes.reshape(1, -1)
|
|
90
|
+
|
|
91
|
+
for i, band in enumerate(bands):
|
|
92
|
+
# Column 0: Reflectance
|
|
93
|
+
ds_out[band].plot(ax=axes[i, 0], robust=True)
|
|
94
|
+
axes[i, 0].set_title(f"{band} Reflectance")
|
|
95
|
+
axes[i, 0].set_xlabel("")
|
|
96
|
+
axes[i, 0].set_ylabel("")
|
|
97
|
+
|
|
98
|
+
# Column 1: Random uncertainty [%]
|
|
99
|
+
random_unc_pct = 100.0 * ds_out[f"u_random_{band}"] / ds_out[band]
|
|
100
|
+
random_unc_pct.plot(ax=axes[i, 1], robust=True)
|
|
101
|
+
axes[i, 1].set_title(f"{band} Random Uncertainty [%]")
|
|
102
|
+
axes[i, 1].set_xlabel("")
|
|
103
|
+
axes[i, 1].set_ylabel("")
|
|
104
|
+
|
|
105
|
+
# Column 2: Systematic uncertainty [%]
|
|
106
|
+
sys_unc_pct = 100.0 * ds_out[f"u_systematic_{band}"] / ds_out[band]
|
|
107
|
+
sys_unc_pct.plot(ax=axes[i, 2], robust=True)
|
|
108
|
+
axes[i, 2].set_title(f"{band} Systematic Uncertainty [%]")
|
|
109
|
+
axes[i, 2].set_xlabel("")
|
|
110
|
+
axes[i, 2].set_ylabel("")
|
|
111
|
+
|
|
112
|
+
plt.tight_layout()
|
|
113
|
+
plt.savefig("s2rut_example.png")
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if __name__ == "__main__":
|
|
117
|
+
pass
|