Skip to content

Commit 650da13

Browse files
authored
Merge pull request #617 from opendatacube/doc_updates
Documentation updates
2 parents 3d2422c + a1e8096 commit 650da13

File tree

5 files changed

+41
-25
lines changed

5 files changed

+41
-25
lines changed

docs/configuration.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ All examples in this documentation will always be presented in Python syntax. J
3636
note that there are some important differences:
3737

3838
1. JSON string literals must always be delimited with double quotes - so no Python-style single quote strings!
39-
2. JSON boolean literals are all lowercase (`true`, `false`) and Python boolean literals are title case (e.g.
40-
`True`, `False`)
39+
2. JSON boolean literals are all lowercase (``true``, ``false``) and Python boolean literals are title case (e.g.
40+
``True``, ``False``)
4141
3. JSON does not allow commas after the last element of lists and objects (dictionaries in Python terms).
4242
4. JSON does not support comments of any kind.
4343

@@ -332,7 +332,7 @@ Internationalisation/Translation of Metadata
332332
++++++++++++++++++++++++++++++++++++++++++++
333333

334334
Once you have extracted your metadata into a single file, separate from the main body of configuration,
335-
as described `above<#metadata-separation>`_, generate a translation catalog for every language you want
335+
as described `above <#metadata-separation>`_, generate a translation catalog for every language you want
336336
translations for - including the "native" language that your messages file is already in:
337337

338338
::
@@ -365,13 +365,17 @@ Once the translations have been placed in translations directory, they must be c
365365

366366
This creates the following machine-readable message (.mo) files:
367367

368+
::
369+
368370
/config/translations/en/LC_MESSAGES/my_ows_project.mo
369371
/config/translations/de/LC_MESSAGES/my_ows_project.mo
370372
/config/translations/fr/LC_MESSAGES/my_ows_project.mo
371373
/config/translations/sw/LC_MESSAGES/my_ows_project.mo
372374

373-
You can now update the `global section of your OWS Configuration<>`_ and restart the web service and
374-
you are serving multi-lingually! (Adjust your client's "Accept-Languages" header to test.)
375+
You can now update the
376+
`global section of your OWS Configuration <https://datacube-ows.readthedocs.io/en/latest/cfg_global.html#metadata-separation-and-internationalisation>`_
377+
section and restart the web service and
378+
you are serving multi-lingually! (Adjust your client's "Accept-Language" header to test.)
375379

376380
General Config Structure
377381
------------------------

docs/style_howto_color_ramp.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ so ``ocean_r`` is the reverse - from white through darker blues to dark green.
6464
So now we get white in the negative and zero areas, with positive areas
6565
getting darkening blues with close to 1.0 being dark green.
6666

67+
This configuration also demonstrates another method for defining the index - with
68+
a simple expression language instead of referencing an explicit python function.
69+
The expression language includes band names and literal numbers, as well as simple
70+
arthimetic operators like `+ - / *` and parentheses for precedence.
71+
6772
::
6873

6974
ndvi_unidirection_cfg = {
70-
"index_function": {
71-
"function": "datacube_ows.band_utils.norm_diff",
72-
"mapped_bands": True,
73-
"kwargs": {"band1": "nir", "band2": "red"},
74-
},
75-
"mpl_ramp": "ocean_r",
75+
"index_expression": "(nir-red)/(nir+red)",
76+
"mpl_ramp": "ocean_r", # ocean_r is the "ocean" ramp, reversed.
7677
"range": [0.0, 1.0]
7778
}
7879

docs/style_howto_components.rst

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ If we wanted a greyscale image of a single band (say red), you could do this:
105105
Example: Mixing bands
106106
+++++++++++++++++++++
107107

108-
What if we want to mix more than one band to make each channel? Here we average all three visible bands
108+
What if we want to mix more than one band to make each channel? We can simply add more bands to the
109+
various colour channel dictionaries, with multiplying factors. Normally we ensure that the multiplying
110+
factors for each channel sum to 1.0, so the result is a (possibly weighted) average of the input bands,
111+
but this is not enforced.
112+
113+
Here we average all three visible bands
109114
into the red channel, put near infra-red in the green channel and average the two shortwave infrared
110115
bands to make the blue channel:
111116

@@ -114,16 +119,22 @@ bands to make the blue channel:
114119
all_bands_cfg = {
115120
"components": {
116121
"red": {
117-
"red": 0.333,
118-
"green": 0.333,
119-
"blue": 0.333,
122+
# Weighting factors should sum to (close to) 1.0
123+
# 0.333 + 0.333 + 0.333 = 0.999 ~ 1.0
124+
"red": 0.333,
125+
"green": 0.333,
126+
"blue": 0.333,
120127
},
121128
"green": {
122-
"nir": 1.0
129+
# Weighting factors should sum to (close to) 1.0
130+
# So use 1.0 for a single band.
131+
"nir": 1.0
123132
},
124133
"blue": {
125-
"swir1": 0.5,
126-
"swir2": 0.5,
134+
# Weighting factors should sum to (close to) 1.0
135+
# 0.5 + 0.5 = 1.0
136+
"swir1": 0.5,
137+
"swir2": 0.5,
127138
},
128139
},
129140
"scale_range": (50, 3000),

docs/style_howto_components_nonlinear.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ For example, given this function, containing a simple unscaled implementation of
4646

4747
def ndvi(data):
4848
# Returns data in range (-1, 1)
49-
return (data["nir"] - data["red"]) / (data["nir"] + data["red")
49+
return (data["nir"] - data["red"]) / (data["nir"] + data["red"])
5050

5151

5252
Using ``"green": ndvi,`` in the components dictionary would sort of work, but would
@@ -62,7 +62,7 @@ not what we want. We can add scaling like this:
6262
# Scale to [-1.0 - 1.0] to [0 - 255]
6363
scaled = ((unscaled + 1.0) * 255/2).clip(0, 255)
6464

65-
returned scaled
65+
return scaled
6666

6767
r_ndvi_b_fullrange_cfg = {
6868
"components": {
@@ -103,7 +103,6 @@ for a more streamlined solution to scaling:
103103
Example: red-ndvi-blue (half scale)
104104
+++++++++++++++++++++++++++++++++++
105105

106-
107106
::
108107

109108
from datacube_ows.styles.api import scalable

docs/style_howto_transparency.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ vegetation (npv)" band mapped to blue.
9191
"components": {
9292
"red": {"bs": 1.0},
9393
"green": {"pv": 1.0},
94-
"blue": {"npv": 1.0}},
94+
"blue": {"npv": 1.0}
95+
},
9596
"scale_range": [0.0, 100.0],
96-
}
9797
}
9898

9999
.. image:: https://user-images.githubusercontent.com/4548530/113671209-66c2d600-96f9-11eb-8354-43a64ec1d134.png
@@ -117,9 +117,9 @@ keep in the image - pixels that fail any of the pq_mask rules will be transparen
117117
"components": {
118118
"red": {"bs": 1.0},
119119
"green": {"pv": 1.0},
120-
"blue": {"npv": 1.0}},
121-
"scale_range": [0.0, 100.0],
120+
"blue": {"npv": 1.0}
122121
},
122+
"scale_range": [0.0, 100.0],
123123
"pq_masks": [
124124
# Pixels must match all flags to remain visible.
125125
{
@@ -303,6 +303,7 @@ transparent with values between 0 and 0.5 shown partially transparent:
303303
},
304304
"scale_range": (50, 3000),
305305
}
306+
306307
.. image:: https://user-images.githubusercontent.com/4548530/113795937-5d854800-9791-11eb-9a49-25ea8cbced64.png
307308
:width: 600
308309

0 commit comments

Comments
 (0)