jerlov 0.1.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.
- jerlov-0.1.1/LICENSE +201 -0
- jerlov-0.1.1/NOTICE +13 -0
- jerlov-0.1.1/PKG-INFO +201 -0
- jerlov-0.1.1/README.md +176 -0
- jerlov-0.1.1/jerlov/__init__.py +51 -0
- jerlov-0.1.1/jerlov/_data.py +113 -0
- jerlov-0.1.1/jerlov/colour.py +255 -0
- jerlov-0.1.1/jerlov/data/__init__.py +1 -0
- jerlov-0.1.1/jerlov/data/austin1986_kd.csv +91 -0
- jerlov-0.1.1/jerlov/data/austin1986_model.csv +72 -0
- jerlov-0.1.1/jerlov/data/cie1931_2deg_cmf.csv +472 -0
- jerlov-0.1.1/jerlov/data/cie_d65.csv +98 -0
- jerlov-0.1.1/jerlov/data/jerlov1976_kd.csv +4161 -0
- jerlov-0.1.1/jerlov/data/smart2007_b_from_c.csv +31 -0
- jerlov-0.1.1/jerlov/data/solonenko2015_iop.csv +851 -0
- jerlov-0.1.1/jerlov/data/williamson2022_iop.csv +6013 -0
- jerlov-0.1.1/jerlov/data/williamson2022_measured.csv +153 -0
- jerlov-0.1.1/jerlov/scene.py +259 -0
- jerlov-0.1.1/jerlov/sources.py +179 -0
- jerlov-0.1.1/jerlov/water.py +337 -0
- jerlov-0.1.1/jerlov.egg-info/PKG-INFO +201 -0
- jerlov-0.1.1/jerlov.egg-info/SOURCES.txt +29 -0
- jerlov-0.1.1/jerlov.egg-info/dependency_links.txt +1 -0
- jerlov-0.1.1/jerlov.egg-info/requires.txt +11 -0
- jerlov-0.1.1/jerlov.egg-info/top_level.txt +1 -0
- jerlov-0.1.1/pyproject.toml +32 -0
- jerlov-0.1.1/setup.cfg +4 -0
- jerlov-0.1.1/tests/test_api.py +147 -0
- jerlov-0.1.1/tests/test_colour.py +219 -0
- jerlov-0.1.1/tests/test_reproduces_papers.py +223 -0
- jerlov-0.1.1/tests/test_scene.py +219 -0
jerlov-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 T. Ishibashi
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
jerlov-0.1.1/NOTICE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
jerlov
|
|
2
|
+
Copyright 2026 T. Ishibashi
|
|
3
|
+
|
|
4
|
+
This product includes data derived from:
|
|
5
|
+
|
|
6
|
+
Williamson, C. A. and Hollins, R. C. (2022), "Dataset to accompany paper:
|
|
7
|
+
Measured inherent optical properties of Jerlov water types", figshare,
|
|
8
|
+
https://doi.org/10.6084/m9.figshare.20290782 (Version 3).
|
|
9
|
+
(c) Crown copyright (2022), Dstl. Licensed under the Open Government
|
|
10
|
+
Licence v3.0: http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3
|
|
11
|
+
|
|
12
|
+
Coefficient tables are additionally derived from the publications listed in
|
|
13
|
+
DATA.md, which records the provenance of every value.
|
jerlov-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jerlov
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Inherent optical properties of Jerlov water types, with provenance
|
|
5
|
+
Author: T. Ishibashi
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Keywords: ocean optics,Jerlov water types,inherent optical properties
|
|
8
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
License-File: NOTICE
|
|
16
|
+
Requires-Dist: numpy>=1.22
|
|
17
|
+
Provides-Extra: plot
|
|
18
|
+
Requires-Dist: matplotlib; extra == "plot"
|
|
19
|
+
Provides-Extra: test
|
|
20
|
+
Requires-Dist: pytest; extra == "test"
|
|
21
|
+
Provides-Extra: build
|
|
22
|
+
Requires-Dist: openpyxl; extra == "build"
|
|
23
|
+
Requires-Dist: colour-science; extra == "build"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# jerlov
|
|
27
|
+
|
|
28
|
+
Inherent optical properties of the Jerlov optical water types, with
|
|
29
|
+
provenance.
|
|
30
|
+
|
|
31
|
+
[](https://doi.org/10.5281/zenodo.22321312)
|
|
32
|
+
|
|
33
|
+
https://github.com/tishibashi-cpu/jerlov
|
|
34
|
+
|
|
35
|
+
*Working name; not yet released.*
|
|
36
|
+
|
|
37
|
+
Every coefficient carries the source it came from. Values that a published
|
|
38
|
+
table got wrong are flagged rather than quietly repaired, and quantities that
|
|
39
|
+
the data do not determine are refused rather than guessed.
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import jerlov
|
|
43
|
+
|
|
44
|
+
w = jerlov.water("III") # Williamson & Hollins (2022) by default
|
|
45
|
+
w.a(550), w.b(550), w.c(550)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Why the source is part of the API
|
|
49
|
+
|
|
50
|
+
The same Jerlov water type has different coefficients in different papers, and
|
|
51
|
+
the differences are not small. Solonenko & Mobley (2015) obtained a and b by
|
|
52
|
+
inverting Kd; Williamson & Hollins (2022) measured them. At 510 nm their
|
|
53
|
+
scattering coefficients differ by up to a factor of 2.6.
|
|
54
|
+
|
|
55
|
+
The equations differ too. Both papers use the scattering model of Haltrin
|
|
56
|
+
(1999), but with different constants: Haltrin's Eq. (6) gives a
|
|
57
|
+
small-particle coefficient of 1.151302, and Solonenko & Mobley print and
|
|
58
|
+
compute with 1.513. Reproducing a published table therefore needs that
|
|
59
|
+
paper's own constant, so constants are attached to sources.
|
|
60
|
+
|
|
61
|
+
## What this package will not do
|
|
62
|
+
|
|
63
|
+
- **Extrapolate.** Asking for a wavelength outside the data raises.
|
|
64
|
+
- **Fill a gap.** Where a published value is wrong and could not be
|
|
65
|
+
recovered, the value is NaN and stays NaN through interpolation.
|
|
66
|
+
- **Supply bb.** The backscattering coefficient is not determined by the
|
|
67
|
+
Jerlov classification. Deriving it from the particle concentrations of the
|
|
68
|
+
two sources gives answers differing by up to a factor of 31, so
|
|
69
|
+
`Water.bb` requires an explicit `backscatter_ratio`.
|
|
70
|
+
|
|
71
|
+
## Provenance warnings
|
|
72
|
+
|
|
73
|
+
Interpolating across a value that a paper got wrong gives a number that looks
|
|
74
|
+
no different from a sound one. `ProvenanceWarning` is the only thing that
|
|
75
|
+
tells them apart.
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
>>> w = jerlov.water("5C", source="solonenko2015")
|
|
79
|
+
>>> w.b(650)
|
|
80
|
+
ProvenanceWarning: b for Jerlov 5C rests on flagged values:
|
|
81
|
+
reconstructed at 650 nm. ...
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`Water.caveats()` returns everything known to be doubtful about that water.
|
|
85
|
+
|
|
86
|
+
## Sources
|
|
87
|
+
|
|
88
|
+
| key | a, b from | types | range |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `williamson2022` | measurement | IB-5C | 300-800 nm |
|
|
91
|
+
| `solonenko2015` | inversion of Kd | I-9C | 300-700 nm |
|
|
92
|
+
| `jerlov1976` | Kd only | I-9C | 300-715 nm |
|
|
93
|
+
| `austin1986` | Kd only, replacement values | I-1C | 350-700 nm |
|
|
94
|
+
|
|
95
|
+
`jerlov.SOURCES` holds the full citation, DOI and caveats for each.
|
|
96
|
+
|
|
97
|
+
## Looking at something through water
|
|
98
|
+
|
|
99
|
+
For a horizontal path, the observed radiance splits into the target's light
|
|
100
|
+
that survived and the light the water added along the way:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
import numpy as np, jerlov
|
|
104
|
+
|
|
105
|
+
wl = np.arange(450., 651., 50.)
|
|
106
|
+
iops = jerlov.water("III")
|
|
107
|
+
kd = jerlov.water("III", source="austin1986")
|
|
108
|
+
|
|
109
|
+
scene = jerlov.Scene.at_depth(iops, 10.0, np.ones_like(wl), wl, kd=kd)
|
|
110
|
+
b_inf = jerlov.veiling_radiance_estimate(
|
|
111
|
+
iops, scene.downwelling, wl, backscatter_ratio=0.015
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
obs = scene.observe(np.full_like(wl, 0.8), distance_m=5.0,
|
|
115
|
+
veiling_radiance=b_inf)
|
|
116
|
+
obs.direct, obs.veiling, obs.radiance
|
|
117
|
+
obs.veiling_fraction # how much of what you see is just water
|
|
118
|
+
obs.contrast(background) # against another target down the same path
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`veiling_radiance` has no default. B_inf depends on the backscattering
|
|
122
|
+
coefficient and the phase function, and neither follows from the water type.
|
|
123
|
+
`veiling_radiance_estimate` gives the usual single-scattering approximation
|
|
124
|
+
for callers with nothing better, but it has to be asked for.
|
|
125
|
+
|
|
126
|
+
Deliberate limits, all recorded in `DECISIONS.md`:
|
|
127
|
+
|
|
128
|
+
- **Horizontal paths only.** Observer and target at the same depth.
|
|
129
|
+
- **No forward-scatter blur.** This is the radiance of one point, not the
|
|
130
|
+
sharpness of an image.
|
|
131
|
+
- **Lambertian targets.**
|
|
132
|
+
|
|
133
|
+
## What colour is that
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
white = scene.downwelling / np.pi # a perfect diffuser at that depth
|
|
137
|
+
rgb = jerlov.spectrum_to_srgb(obs.radiance, wl, white=white)
|
|
138
|
+
|
|
139
|
+
jerlov.spectrum_to_xyz(spectrum, wl) # unnormalised CIE XYZ
|
|
140
|
+
jerlov.integrate_response(spectrum, wl, sensitivity, sensitivity_wl)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`white` has no default. A radiance spectrum has no colour until something is
|
|
144
|
+
called white, and underwater the useful reference is usually the downwelling
|
|
145
|
+
irradiance at that depth rather than daylight. Both are legitimate and they
|
|
146
|
+
answer different questions:
|
|
147
|
+
|
|
148
|
+
| white | question answered |
|
|
149
|
+
|---|---|
|
|
150
|
+
| downwelling at depth | what a diver's adapted eye, or a camera white-balanced *there*, sees |
|
|
151
|
+
| daylight at the surface | what a camera set at the surface records |
|
|
152
|
+
|
|
153
|
+
`integrate_response` takes any spectral sensitivity: three camera channels,
|
|
154
|
+
or a set of photoreceptor absorbances.
|
|
155
|
+
|
|
156
|
+
Two silent errors are checked rather than assumed:
|
|
157
|
+
|
|
158
|
+
- **Coverage.** A spectrum spanning 450-650 nm integrated against colour
|
|
159
|
+
matching functions spanning 360-830 nm quietly drops the ends. Every
|
|
160
|
+
integration reports how much of the observer it actually covered and warns
|
|
161
|
+
when it is not essentially all of it.
|
|
162
|
+
- **Gamut.** Underwater colours often fall outside sRGB. Clipping changes
|
|
163
|
+
them, so `GamutWarning` says so.
|
|
164
|
+
|
|
165
|
+
## Other entry points
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
# Reconstruct a Kd spectrum from one measured value (Austin & Petzold 1986).
|
|
169
|
+
jerlov.kd_spectrum(kd=0.06, wavelength_nm=490, at=[440, 550, 650])
|
|
170
|
+
|
|
171
|
+
# Estimate b from a transmissometer's c (Smart 2007).
|
|
172
|
+
jerlov.b_from_c(c=0.5, wavelength_nm=555, bw=0.0019, cw=0.0659)
|
|
173
|
+
|
|
174
|
+
# Use your own measurements; they take exactly the same path.
|
|
175
|
+
jerlov.Water.from_measurements(wavelengths, a=..., b=...)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Provenance and design
|
|
179
|
+
|
|
180
|
+
`DATA.md` records, for every shipped table, where it came from, what was
|
|
181
|
+
verified, and what is known to be wrong with it. Eleven defects in the source
|
|
182
|
+
literature are documented there, six of them confirmed.
|
|
183
|
+
|
|
184
|
+
`DECISIONS.md` records why the package is shaped the way it is, including the
|
|
185
|
+
alternatives that were rejected and why.
|
|
186
|
+
|
|
187
|
+
## Licence
|
|
188
|
+
|
|
189
|
+
Apache-2.0. The Williamson & Hollins data are Crown copyright, Dstl, under
|
|
190
|
+
the Open Government Licence v3.0; see `NOTICE`.
|
|
191
|
+
|
|
192
|
+
## Citation
|
|
193
|
+
|
|
194
|
+
Cite the concept DOI, which always resolves to the latest version:
|
|
195
|
+
|
|
196
|
+
> Ishibashi, T. jerlov: inherent optical properties of Jerlov water types,
|
|
197
|
+
> with provenance. Zenodo. https://doi.org/10.5281/zenodo.22321312
|
|
198
|
+
|
|
199
|
+
Please also cite the sources the coefficients came from; they are listed with
|
|
200
|
+
their DOIs at the top of `DATA.md`. The package is a carrier for other
|
|
201
|
+
people's measurements, and this work does not replace citing them.
|
jerlov-0.1.1/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# jerlov
|
|
2
|
+
|
|
3
|
+
Inherent optical properties of the Jerlov optical water types, with
|
|
4
|
+
provenance.
|
|
5
|
+
|
|
6
|
+
[](https://doi.org/10.5281/zenodo.22321312)
|
|
7
|
+
|
|
8
|
+
https://github.com/tishibashi-cpu/jerlov
|
|
9
|
+
|
|
10
|
+
*Working name; not yet released.*
|
|
11
|
+
|
|
12
|
+
Every coefficient carries the source it came from. Values that a published
|
|
13
|
+
table got wrong are flagged rather than quietly repaired, and quantities that
|
|
14
|
+
the data do not determine are refused rather than guessed.
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import jerlov
|
|
18
|
+
|
|
19
|
+
w = jerlov.water("III") # Williamson & Hollins (2022) by default
|
|
20
|
+
w.a(550), w.b(550), w.c(550)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Why the source is part of the API
|
|
24
|
+
|
|
25
|
+
The same Jerlov water type has different coefficients in different papers, and
|
|
26
|
+
the differences are not small. Solonenko & Mobley (2015) obtained a and b by
|
|
27
|
+
inverting Kd; Williamson & Hollins (2022) measured them. At 510 nm their
|
|
28
|
+
scattering coefficients differ by up to a factor of 2.6.
|
|
29
|
+
|
|
30
|
+
The equations differ too. Both papers use the scattering model of Haltrin
|
|
31
|
+
(1999), but with different constants: Haltrin's Eq. (6) gives a
|
|
32
|
+
small-particle coefficient of 1.151302, and Solonenko & Mobley print and
|
|
33
|
+
compute with 1.513. Reproducing a published table therefore needs that
|
|
34
|
+
paper's own constant, so constants are attached to sources.
|
|
35
|
+
|
|
36
|
+
## What this package will not do
|
|
37
|
+
|
|
38
|
+
- **Extrapolate.** Asking for a wavelength outside the data raises.
|
|
39
|
+
- **Fill a gap.** Where a published value is wrong and could not be
|
|
40
|
+
recovered, the value is NaN and stays NaN through interpolation.
|
|
41
|
+
- **Supply bb.** The backscattering coefficient is not determined by the
|
|
42
|
+
Jerlov classification. Deriving it from the particle concentrations of the
|
|
43
|
+
two sources gives answers differing by up to a factor of 31, so
|
|
44
|
+
`Water.bb` requires an explicit `backscatter_ratio`.
|
|
45
|
+
|
|
46
|
+
## Provenance warnings
|
|
47
|
+
|
|
48
|
+
Interpolating across a value that a paper got wrong gives a number that looks
|
|
49
|
+
no different from a sound one. `ProvenanceWarning` is the only thing that
|
|
50
|
+
tells them apart.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
>>> w = jerlov.water("5C", source="solonenko2015")
|
|
54
|
+
>>> w.b(650)
|
|
55
|
+
ProvenanceWarning: b for Jerlov 5C rests on flagged values:
|
|
56
|
+
reconstructed at 650 nm. ...
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`Water.caveats()` returns everything known to be doubtful about that water.
|
|
60
|
+
|
|
61
|
+
## Sources
|
|
62
|
+
|
|
63
|
+
| key | a, b from | types | range |
|
|
64
|
+
|---|---|---|---|
|
|
65
|
+
| `williamson2022` | measurement | IB-5C | 300-800 nm |
|
|
66
|
+
| `solonenko2015` | inversion of Kd | I-9C | 300-700 nm |
|
|
67
|
+
| `jerlov1976` | Kd only | I-9C | 300-715 nm |
|
|
68
|
+
| `austin1986` | Kd only, replacement values | I-1C | 350-700 nm |
|
|
69
|
+
|
|
70
|
+
`jerlov.SOURCES` holds the full citation, DOI and caveats for each.
|
|
71
|
+
|
|
72
|
+
## Looking at something through water
|
|
73
|
+
|
|
74
|
+
For a horizontal path, the observed radiance splits into the target's light
|
|
75
|
+
that survived and the light the water added along the way:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import numpy as np, jerlov
|
|
79
|
+
|
|
80
|
+
wl = np.arange(450., 651., 50.)
|
|
81
|
+
iops = jerlov.water("III")
|
|
82
|
+
kd = jerlov.water("III", source="austin1986")
|
|
83
|
+
|
|
84
|
+
scene = jerlov.Scene.at_depth(iops, 10.0, np.ones_like(wl), wl, kd=kd)
|
|
85
|
+
b_inf = jerlov.veiling_radiance_estimate(
|
|
86
|
+
iops, scene.downwelling, wl, backscatter_ratio=0.015
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
obs = scene.observe(np.full_like(wl, 0.8), distance_m=5.0,
|
|
90
|
+
veiling_radiance=b_inf)
|
|
91
|
+
obs.direct, obs.veiling, obs.radiance
|
|
92
|
+
obs.veiling_fraction # how much of what you see is just water
|
|
93
|
+
obs.contrast(background) # against another target down the same path
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`veiling_radiance` has no default. B_inf depends on the backscattering
|
|
97
|
+
coefficient and the phase function, and neither follows from the water type.
|
|
98
|
+
`veiling_radiance_estimate` gives the usual single-scattering approximation
|
|
99
|
+
for callers with nothing better, but it has to be asked for.
|
|
100
|
+
|
|
101
|
+
Deliberate limits, all recorded in `DECISIONS.md`:
|
|
102
|
+
|
|
103
|
+
- **Horizontal paths only.** Observer and target at the same depth.
|
|
104
|
+
- **No forward-scatter blur.** This is the radiance of one point, not the
|
|
105
|
+
sharpness of an image.
|
|
106
|
+
- **Lambertian targets.**
|
|
107
|
+
|
|
108
|
+
## What colour is that
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
white = scene.downwelling / np.pi # a perfect diffuser at that depth
|
|
112
|
+
rgb = jerlov.spectrum_to_srgb(obs.radiance, wl, white=white)
|
|
113
|
+
|
|
114
|
+
jerlov.spectrum_to_xyz(spectrum, wl) # unnormalised CIE XYZ
|
|
115
|
+
jerlov.integrate_response(spectrum, wl, sensitivity, sensitivity_wl)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`white` has no default. A radiance spectrum has no colour until something is
|
|
119
|
+
called white, and underwater the useful reference is usually the downwelling
|
|
120
|
+
irradiance at that depth rather than daylight. Both are legitimate and they
|
|
121
|
+
answer different questions:
|
|
122
|
+
|
|
123
|
+
| white | question answered |
|
|
124
|
+
|---|---|
|
|
125
|
+
| downwelling at depth | what a diver's adapted eye, or a camera white-balanced *there*, sees |
|
|
126
|
+
| daylight at the surface | what a camera set at the surface records |
|
|
127
|
+
|
|
128
|
+
`integrate_response` takes any spectral sensitivity: three camera channels,
|
|
129
|
+
or a set of photoreceptor absorbances.
|
|
130
|
+
|
|
131
|
+
Two silent errors are checked rather than assumed:
|
|
132
|
+
|
|
133
|
+
- **Coverage.** A spectrum spanning 450-650 nm integrated against colour
|
|
134
|
+
matching functions spanning 360-830 nm quietly drops the ends. Every
|
|
135
|
+
integration reports how much of the observer it actually covered and warns
|
|
136
|
+
when it is not essentially all of it.
|
|
137
|
+
- **Gamut.** Underwater colours often fall outside sRGB. Clipping changes
|
|
138
|
+
them, so `GamutWarning` says so.
|
|
139
|
+
|
|
140
|
+
## Other entry points
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
# Reconstruct a Kd spectrum from one measured value (Austin & Petzold 1986).
|
|
144
|
+
jerlov.kd_spectrum(kd=0.06, wavelength_nm=490, at=[440, 550, 650])
|
|
145
|
+
|
|
146
|
+
# Estimate b from a transmissometer's c (Smart 2007).
|
|
147
|
+
jerlov.b_from_c(c=0.5, wavelength_nm=555, bw=0.0019, cw=0.0659)
|
|
148
|
+
|
|
149
|
+
# Use your own measurements; they take exactly the same path.
|
|
150
|
+
jerlov.Water.from_measurements(wavelengths, a=..., b=...)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Provenance and design
|
|
154
|
+
|
|
155
|
+
`DATA.md` records, for every shipped table, where it came from, what was
|
|
156
|
+
verified, and what is known to be wrong with it. Eleven defects in the source
|
|
157
|
+
literature are documented there, six of them confirmed.
|
|
158
|
+
|
|
159
|
+
`DECISIONS.md` records why the package is shaped the way it is, including the
|
|
160
|
+
alternatives that were rejected and why.
|
|
161
|
+
|
|
162
|
+
## Licence
|
|
163
|
+
|
|
164
|
+
Apache-2.0. The Williamson & Hollins data are Crown copyright, Dstl, under
|
|
165
|
+
the Open Government Licence v3.0; see `NOTICE`.
|
|
166
|
+
|
|
167
|
+
## Citation
|
|
168
|
+
|
|
169
|
+
Cite the concept DOI, which always resolves to the latest version:
|
|
170
|
+
|
|
171
|
+
> Ishibashi, T. jerlov: inherent optical properties of Jerlov water types,
|
|
172
|
+
> with provenance. Zenodo. https://doi.org/10.5281/zenodo.22321312
|
|
173
|
+
|
|
174
|
+
Please also cite the sources the coefficients came from; they are listed with
|
|
175
|
+
their DOIs at the top of `DATA.md`. The package is a carrier for other
|
|
176
|
+
people's measurements, and this work does not replace citing them.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Inherent optical properties of Jerlov water types.
|
|
2
|
+
|
|
3
|
+
Every coefficient carries its source, and values that a published table got
|
|
4
|
+
wrong are flagged rather than quietly repaired.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .colour import (
|
|
8
|
+
CoverageWarning,
|
|
9
|
+
GamutWarning,
|
|
10
|
+
cie_1931_cmf,
|
|
11
|
+
d65,
|
|
12
|
+
integrate_response,
|
|
13
|
+
spectrum_to_srgb,
|
|
14
|
+
spectrum_to_xyz,
|
|
15
|
+
xyz_to_srgb,
|
|
16
|
+
)
|
|
17
|
+
from .scene import Observation, Scene, veiling_radiance_estimate
|
|
18
|
+
from .sources import SOURCES, Source, get_source
|
|
19
|
+
from .water import (
|
|
20
|
+
MissingQuantityError,
|
|
21
|
+
ProvenanceWarning,
|
|
22
|
+
Water,
|
|
23
|
+
b_from_c,
|
|
24
|
+
kd_spectrum,
|
|
25
|
+
water,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"SOURCES",
|
|
30
|
+
"Scene",
|
|
31
|
+
"Observation",
|
|
32
|
+
"veiling_radiance_estimate",
|
|
33
|
+
"spectrum_to_xyz",
|
|
34
|
+
"spectrum_to_srgb",
|
|
35
|
+
"xyz_to_srgb",
|
|
36
|
+
"integrate_response",
|
|
37
|
+
"cie_1931_cmf",
|
|
38
|
+
"d65",
|
|
39
|
+
"GamutWarning",
|
|
40
|
+
"CoverageWarning",
|
|
41
|
+
"Source",
|
|
42
|
+
"get_source",
|
|
43
|
+
"Water",
|
|
44
|
+
"water",
|
|
45
|
+
"kd_spectrum",
|
|
46
|
+
"b_from_c",
|
|
47
|
+
"ProvenanceWarning",
|
|
48
|
+
"MissingQuantityError",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
__version__ = "0.1.1"
|