satpp 0.2.0__py3-none-any.whl

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.
Files changed (78) hide show
  1. satpp/__init__.py +29 -0
  2. satpp/astronomy/__init__.py +10 -0
  3. satpp/astronomy/daylight.py +403 -0
  4. satpp/astronomy/solar.py +178 -0
  5. satpp/chlorophyll/__init__.py +12 -0
  6. satpp/chlorophyll/profiles.py +85 -0
  7. satpp/chlorophyll/size_classes.py +39 -0
  8. satpp/chlorophyll/uitz2006.py +101 -0
  9. satpp/config.py +60 -0
  10. satpp/diagnostics/__init__.py +10 -0
  11. satpp/diagnostics/light_fields.py +1038 -0
  12. satpp/diagnostics/model_pages.py +1046 -0
  13. satpp/hybrid.py +963 -0
  14. satpp/light/__init__.py +16 -0
  15. satpp/light/clear_sky.py +328 -0
  16. satpp/light/diurnal.py +59 -0
  17. satpp/light/spectra.py +31 -0
  18. satpp/light/surface.py +139 -0
  19. satpp/light/underwater.py +138 -0
  20. satpp/models/__init__.py +64 -0
  21. satpp/models/abpm.py +201 -0
  22. satpp/models/arrigo08.py +283 -0
  23. satpp/models/arteaga16.py +253 -0
  24. satpp/models/asanuma.py +179 -0
  25. satpp/models/asaoka20.py +140 -0
  26. satpp/models/balch92.py +120 -0
  27. satpp/models/barnes14.py +149 -0
  28. satpp/models/belanger13.py +118 -0
  29. satpp/models/brewin17.py +324 -0
  30. satpp/models/cafe.py +340 -0
  31. satpp/models/cbpm.py +171 -0
  32. satpp/models/cbpm05.py +135 -0
  33. satpp/models/dierssen00.py +87 -0
  34. satpp/models/drpp.py +156 -0
  35. satpp/models/eppley85.py +50 -0
  36. satpp/models/fox22.py +255 -0
  37. satpp/models/globcolour.py +121 -0
  38. satpp/models/goci_abpm.py +244 -0
  39. satpp/models/hill13.py +84 -0
  40. satpp/models/hirata09.py +46 -0
  41. satpp/models/hirawake.py +108 -0
  42. satpp/models/hoepffner94.py +191 -0
  43. satpp/models/howard_yoder.py +148 -0
  44. satpp/models/kahru09.py +54 -0
  45. satpp/models/kameda05.py +152 -0
  46. satpp/models/kiefer_mitchell.py +118 -0
  47. satpp/models/kosc_vgpm.py +164 -0
  48. satpp/models/ma14.py +150 -0
  49. satpp/models/marra03.py +187 -0
  50. satpp/models/morel91.py +164 -0
  51. satpp/models/morel_berthon89.py +82 -0
  52. satpp/models/ondrusek01.py +190 -0
  53. satpp/models/psm.py +122 -0
  54. satpp/models/smyth05.py +330 -0
  55. satpp/models/son05.py +204 -0
  56. satpp/models/tripathy12.py +64 -0
  57. satpp/models/uitz10.py +141 -0
  58. satpp/models/vgpm.py +80 -0
  59. satpp/models/wrm.py +376 -0
  60. satpp/models/zoffoli18.py +104 -0
  61. satpp/optics/__init__.py +28 -0
  62. satpp/optics/attenuation.py +174 -0
  63. satpp/optics/case1.py +108 -0
  64. satpp/optics/cdom.py +44 -0
  65. satpp/optics/euphotic.py +46 -0
  66. satpp/optics/phytoplankton.py +189 -0
  67. satpp/optics/retrieval.py +143 -0
  68. satpp/optics/water.py +193 -0
  69. satpp/physiology/__init__.py +14 -0
  70. satpp/physiology/photoacclimation.py +27 -0
  71. satpp/physiology/pi_curves.py +69 -0
  72. satpp/physiology/quantum_yield.py +52 -0
  73. satpp/physiology/temperature.py +25 -0
  74. satpp/units.py +25 -0
  75. satpp-0.2.0.dist-info/METADATA +80 -0
  76. satpp-0.2.0.dist-info/RECORD +78 -0
  77. satpp-0.2.0.dist-info/WHEEL +4 -0
  78. satpp-0.2.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,85 @@
1
+
2
+ """Vertical Chl profiles.
3
+
4
+ Functions
5
+ ---------
6
+ shifted_gaussian
7
+ ``B(z) = B0 + h / (sigma sqrt(2 pi)) exp(-(z - zm)^2 / (2 sigma^2))``
8
+ (Platt et al. 1988; Sathyendranath & Platt 1989).
9
+ sinusodal_profile
10
+ The same shape parameterised by rho and scaled so that B(0) equals the surface
11
+ Chl (PSM; the name is historical).
12
+ """
13
+ import numpy as np
14
+
15
+ from .. import config
16
+
17
+
18
+ def shifted_gaussian(z, B0, zm, h, sigma):
19
+ """Shifted-Gaussian Chl profile.
20
+
21
+ Parameters
22
+ ----------
23
+ z : float or array_like
24
+ Depth [m].
25
+ B0 : float
26
+ Background Chl [mg m-3].
27
+ zm : float
28
+ Depth of the Chl maximum [m].
29
+ h : float
30
+ Chl in the peak above the background [mg m-2].
31
+ sigma : float
32
+ Width of the peak [m].
33
+
34
+ Returns
35
+ -------
36
+ float or ndarray
37
+ Chl [mg m-3].
38
+ """
39
+ return (B0 + h / (sigma * np.sqrt(2 * np.pi))
40
+ * np.exp(-(z - zm) ** 2 / (2 * sigma ** 2)))
41
+
42
+
43
+ def sinusodal_profile(chl, sigma=24, rho=0.86, z_m=60, depths=None, mld=None):
44
+ """Shifted-Gaussian Chl profile scaled to the surface Chl.
45
+
46
+ The name is kept for compatibility; the profile is Gaussian.
47
+
48
+ Parameters
49
+ ----------
50
+ chl : float or ndarray
51
+ Surface (satellite) Chl [mg m-3].
52
+ sigma : float, optional
53
+ Width of the peak [m]. Default 24.
54
+ rho : float, optional
55
+ Ratio of the peak height to the total biomass at `z_m`, ``H / (H + B0)``.
56
+ Default 0.86.
57
+ z_m : float, optional
58
+ Depth of the Chl maximum [m]. Default 60.
59
+ depths : ndarray, optional
60
+ Depths [m]. Default ``config.depths``.
61
+ mld : float, optional
62
+ Only return depths down to the mixed-layer depth [m].
63
+
64
+ Returns
65
+ -------
66
+ ndarray
67
+ Chl [mg m-3] at `depths`, shape ``chl.shape + depths.shape``.
68
+ """
69
+ depths = config.depths if depths is None else depths
70
+ if mld is not None:
71
+ depths = depths[depths<=mld]
72
+ B_0 = chl / (1 + (rho / (1 - rho)) * np.exp(-z_m ** 2 / (2 * sigma ** 2)))
73
+ h = sigma * (rho / (1 - rho)) * B_0 * np.sqrt(2 * np.pi)
74
+ gauss_height = h / (sigma * np.sqrt(2*np.pi))
75
+
76
+ c_arr = -0.5 * ( (depths - z_m) / sigma ) ** 2
77
+ # Only the Gaussian term is set to zero where it would underflow; the background B_0
78
+ # remains (previously the whole profile was zeroed, giving log10(0) in the PSM light
79
+ # profile).
80
+ gauss = np.where(np.abs(c_arr) > 675., 0.0, np.exp(np.maximum(c_arr, -675.)))
81
+ if np.iterable(chl):
82
+ chl_profile = gauss_height[...,None] * gauss + B_0[...,None]
83
+ else:
84
+ chl_profile = gauss_height * gauss + B_0
85
+ return chl_profile
@@ -0,0 +1,39 @@
1
+
2
+ """Phytoplankton size-class fractions of Chl (Brewin et al. 2010, 2015)."""
3
+ import numpy as np
4
+
5
+ cm_pn = 0.77
6
+ s_pn = 0.94 / cm_pn
7
+ cm_p = 0.13
8
+ s_p = 0.80 / cm_p
9
+
10
+ def brewin(chl):
11
+ """Chl in pico-, nano- and microphytoplankton (Brewin et al. 2010).
12
+
13
+ Parameters
14
+ ----------
15
+ chl : float or array_like
16
+ Total Chl [mg m-3].
17
+
18
+ Returns
19
+ -------
20
+ pico_chl, nano_chl, micro_chl : float or ndarray
21
+ Chl in each size class [mg m-3], at least zero.
22
+
23
+ References
24
+ ----------
25
+ Brewin, R. J. W. et al. (2010). A three-component model of phytoplankton size
26
+ class for the Atlantic Ocean. Ecological Modelling, 221, 1472-1483.
27
+ """
28
+ #compute fractions
29
+ pico_chl = cm_p * (1.0 - np.exp(-s_p * chl))
30
+ nano_chl = cm_pn * (1.0 - np.exp(-s_pn * chl)) - pico_chl
31
+ micro_chl = chl - (cm_pn * (1.0 - np.exp(-s_pn * chl)))
32
+ pico_chl = np.atleast_1d(np.where(pico_chl>=0, pico_chl, 0))
33
+ nano_chl = np.atleast_1d(np.where(nano_chl>=0, nano_chl, 0))
34
+ micro_chl = np.atleast_1d(np.where(micro_chl>=0, micro_chl, 0))
35
+ if not np.iterable(chl):
36
+ pico_chl = pico_chl.item()
37
+ nano_chl = nano_chl.item()
38
+ micro_chl = micro_chl.item()
39
+ return pico_chl, nano_chl, micro_chl
@@ -0,0 +1,101 @@
1
+ """Size-class Chl profiles of Uitz et al. (2006).
2
+
3
+ In stratified water the trophic class S1-S9 is set by surface Chl, and each size
4
+ class (micro, nano, pico) has a dimensionless profile on ``zeta = z / Zeu``,
5
+ ``c(zeta) = Cb - s zeta + Cmax exp(-((zeta - zeta_max) / dzeta)^2)`` (Eq. 7),
6
+ scaled by the euphotic-layer Chl content ``<Chl>_Zeu / Zeu``. In mixed water
7
+ (Zeu < MLD) each class keeps its surface share (Table 6), uniform with depth. Zeu
8
+ follows Morel & Maritorena (2001).
9
+
10
+ References
11
+ ----------
12
+ Uitz, J., Claustre, H., Morel, A. & Hooker, S. B. (2006). Vertical distribution
13
+ of phytoplankton communities in open ocean: An assessment based on surface
14
+ chlorophyll. Journal of Geophysical Research, 111, C08005.
15
+ """
16
+ import numpy as np
17
+
18
+ from ..optics.euphotic import zeu_morel_maritorena2001
19
+
20
+ CLASSES = ("micro", "nano", "pico")
21
+
22
+ # Uitz et al. (2006) Table 3 (Chl_surf bounds of S1..S9) and Table 5 (profile parameters
23
+ # Cb, s, Cmax, zeta_max, dzeta per class)
24
+ S_BOUNDS = [0.04, 0.08, 0.12, 0.2, 0.3, 0.4, 0.8, 2.2]
25
+ PROFILE = {
26
+ "micro": [(0.036, 0.020, 0.122, 1.012, 0.532), (0.071, 0.020, 0.173, 0.885, 0.406),
27
+ (0.076, 0.021, 0.126, 0.835, 0.424), (0.071, 0.021, 0.160, 0.776, 0.546),
28
+ (0.145, 0.050, 0.163, 0.700, 0.479), (0.173, 0.044, 0.161, 0.600, 0.508),
29
+ (0.237, 0.077, 0.158, 0.521, 0.543), (0.331, 0.105, 0.278, 0.451, 0.746),
30
+ (0.891, 0.302, 0.000, 0.277, 1.014)],
31
+ "nano": [(0.138, 0.033, 0.764, 0.980, 0.451), (0.129, 0.014, 0.589, 0.899, 0.454),
32
+ (0.142, 0.000, 0.463, 0.872, 0.526), (0.192, 0.037, 0.400, 0.782, 0.535),
33
+ (0.188, 0.055, 0.418, 0.650, 0.640), (0.331, 0.132, 0.294, 0.501, 0.516),
34
+ (0.201, 0.084, 0.350, 0.402, 0.724), (0.227, 0.081, 0.198, 0.181, 0.690),
35
+ (0.171, 0.000, 0.088, 0.375, 0.352)],
36
+ "pico": [(0.222, 0.114, 0.906, 0.970, 0.352), (0.242, 0.109, 0.627, 0.977, 0.427),
37
+ (0.254, 0.099, 0.437, 0.969, 0.634), (0.271, 0.100, 0.255, 0.858, 0.637),
38
+ (0.159, 0.052, 0.176, 0.574, 0.650), (0.176, 0.071, 0.129, 0.458, 0.626),
39
+ (0.009, 0.000, 0.251, 0.239, 0.943), (0.094, 0.040, 0.109, 0.187, 0.618),
40
+ (0.051, 0.023, 0.000, 0.052, 0.417)],
41
+ }
42
+ # Uitz et al. (2006) Table 6, global mixed waters (Southern waters excluded): f in %
43
+ M_BOUNDS = [0.4, 0.8, 1.0, 4.0]
44
+ M_FRACTIONS = [(18.0, 50.7, 31.2), (24.1, 49.8, 26.2), (28.1, 57.2, 14.7),
45
+ (52.2, 38.1, 9.7), (90.9, 5.3, 3.7)]
46
+
47
+
48
+ def chl_zeu_stratified(chl):
49
+ """Chl content of the euphotic layer in stratified water (Uitz et al. 2006).
50
+
51
+ Parameters
52
+ ----------
53
+ chl : float
54
+ Surface Chl [mg m-3].
55
+
56
+ Returns
57
+ -------
58
+ float
59
+ ``<Chl>_Zeu`` [mg m-2].
60
+ """
61
+ return 36.1 * chl ** 0.357 if chl <= 1 else 37.7 * chl ** 0.615
62
+
63
+
64
+ def class_profiles(chl, mld, z):
65
+ """Chl profiles of the three size classes.
66
+
67
+ Parameters
68
+ ----------
69
+ chl : float
70
+ Surface Chl [mg m-3].
71
+ mld : float
72
+ Mixed-layer depth [m].
73
+ z : ndarray
74
+ Depths [m].
75
+
76
+ Returns
77
+ -------
78
+ profiles : dict
79
+ Chl [mg m-3] at `z` keyed by class ('micro', 'nano', 'pico').
80
+ regime : {'stratified', 'mixed'}
81
+ Water type.
82
+ zeu : float
83
+ Euphotic depth [m].
84
+ """
85
+ ctot = chl_zeu_stratified(chl)
86
+ zeu = zeu_morel_maritorena2001(ctot)
87
+ if zeu < mld: # mixed water
88
+ k = int(np.searchsorted(M_BOUNDS, chl))
89
+ f = np.array(M_FRACTIONS[k]) / 100.0
90
+ prof = {c: np.full(z.shape, chl * f[i]) for i, c in enumerate(CLASSES)}
91
+ ctot_m = 42.1 * chl ** 0.538 # Table 4, mixed
92
+ return prof, "mixed", zeu_morel_maritorena2001(ctot_m)
93
+ k = int(np.searchsorted(S_BOUNDS, chl))
94
+ zeta = z / zeu
95
+ scale = ctot / zeu
96
+ prof = {}
97
+ for c in CLASSES:
98
+ cb, s, cmax, zm, dz = PROFILE[c][k]
99
+ prof[c] = np.maximum(cb - s * zeta + cmax * np.exp(-((zeta - zm) / dz) ** 2),
100
+ 0) * scale
101
+ return prof, "stratified", zeu
satpp/config.py ADDED
@@ -0,0 +1,60 @@
1
+ """Default grids of the PSM.
2
+
3
+ Attributes
4
+ ----------
5
+ phyto_wl : ndarray
6
+ Wavelengths of the phytoplankton absorption tables, 400-700 nm at 5 nm.
7
+ wavelengths : ndarray
8
+ Default model wavelengths [nm] (same as `phyto_wl`).
9
+ depths : ndarray
10
+ Default depths [m], 0-249.5 m at 0.5 m.
11
+ yellow_substance : float
12
+ CDOM absorption at 440 nm as a fraction of aph(440).
13
+ """
14
+
15
+
16
+ import numpy as np
17
+
18
+ #from scatter import calc_aw, calc_ay, calc_bbr, calc_bw
19
+
20
+ phyto_wl = np.array([400, 405, 410, 415, 420, 425, 430, 435, 440, 445, 450, 455,
21
+ 460, 465, 470, 475, 480, 485, 490, 495, 500, 505, 510, 515,
22
+ 520, 525, 530, 535, 540, 545, 550, 555, 560, 565, 570, 575,
23
+ 580, 585, 590, 595, 600, 605, 610, 615, 620, 625, 630, 635,
24
+ 640, 645, 650, 655, 660, 665, 670, 675, 680, 685, 690, 695,
25
+ 700])
26
+ depths = np.arange(0,250,0.5)
27
+ yellow_substance = 0.3
28
+
29
+ wavelengths = phyto_wl
30
+
31
+ """def attenuation_dataframe(wavelengths=None):
32
+
33
+ wls = phyto_wl if wavelengths is None else wavelengths
34
+ ay = calc_ay(wls)
35
+ bbr = calc_bbr(wls)
36
+ bw = calc_bw(wls)
37
+ aw = calc_aw(wls)
38
+ d_lambda = np.append(np.diff(wls), np.diff(wls)[-1])
39
+ return pd.DataFrame({"wls":wls, "ay":ay, "bbr":bbr, "bw":bw, "aw":aw,
40
+ "d_lambda":d_lambda})"""
41
+
42
+ """test_case = dict(year = 2010,
43
+ month = 6
44
+ date = dt.date(year, month, 1)
45
+ date = date + dt.timedelta(days=14)
46
+ iday = date.timetuple().tm_yday
47
+ lat=60
48
+ lon=-30
49
+ chl = 1.5
50
+ par = 25.0
51
+ mld = 30.
52
+ sigma=24.0
53
+ rho = 0.86
54
+ zm = 60
55
+ bathymetry = 200
56
+ b_zero = chl / (1 + (rho / (1 - rho)) * np.exp(-zm ** 2 / (2 * sigma ** 2)))
57
+ h = sigma * (rho / (1 - rho)) * b_zero * np.sqrt(2 * np.pi)
58
+ Cloud=0.0
59
+ yellow_substance=0.3
60
+ num_time_steps=12}"""
@@ -0,0 +1,10 @@
1
+ """Tools that run several models side by side.
2
+
3
+ Modules
4
+ -------
5
+ light_fields
6
+ The noon underwater light field of each model.
7
+ model_pages
8
+ The standard figures of the model pages (imported on demand, needs matplotlib).
9
+ """
10
+ from . import light_fields # noqa: F401