@@ -86,26 +86,6 @@ def blend(ci: Array, cx: Array) -> Array:
8686 super ().__init__ (f )
8787
8888
89- class Mbr (ToF ):
90- """The maximum band ratio function."""
91-
92- def __init__ (self ):
93- def f (x ):
94- """
95- Returns the common logarithm of the maximum band ratio.
96-
97- :param x: Remote sensing reflectance, shape (n_wavebands, ...).
98- The last waveband refers to green.
99- :returns: The common logarithm of the maximum band ratio,
100- shape(...).
101- """
102- B = jnp .maximum .reduce (x [:- 1 ]) # noqa: N806
103- G = x [- 1 ] # noqa: N806
104- return jnp .log10 (B / G )
105-
106- super ().__init__ (f )
107-
108-
10989class OCI (ToM ):
11090 """NASA's ocean colour chlorophyll index (OCI) model function."""
11191
@@ -155,57 +135,56 @@ def estimate(
155135 return np .array ([- 0.4287 , 230.47 ])
156136
157137
158- class OCx (ToM , ABC ):
159- """
160- NASA's OCx family of chlorophyll model functions.
161-
162- Needs values of maximum common logarithm of remote sensing
163- reflectance band ratios (:class:`Mbr`) as input. Used for
164- chlorophyll retrievals above 0.35 mg m-3.
165- """
138+ class OCX (ToM , ABC ):
139+ """NASA's OCX family of chlorophyll model functions."""
166140
167141 n : Literal [2 , 3 , 4 , 5 , 6 ]
168142 """The number of polynomial coefficients."""
169143
170144 def __init__ (self , n : Literal [2 , 3 , 4 , 5 , 6 ]):
171- """
172- Creates a new model function instance.
173-
174- :param n: The number of polynomial coefficients.
175- """
176- self .n = n
145+ """Creates a new model function instance."""
177146
178147 def f (p , x ):
179- """
148+ r """
180149 The model function.
181150
182- :param p: The model parameters, shape (n_parameters,).
183- :param x: The common logarithm of maximum band ratios.
184- :returns: The chlorophyll concentration.
185- """
186- return jnp .power (10.0 , jnp .polyval (p [::- 1 ], x ))
187-
188- super ().__init__ (f )
151+ Let :math:`p = (p_0, \dots p_4) \in \mathbb{R}^{5}` be the
152+ model parameters and let :math:`\lambda = (\lambda_1,\dots
153+ \lambda_\mathrm{m}) \in \mathbb{R}^{m}` denote the central
154+ wavelengths of :math:`m-1 \ge 2` wavebands in the blue, and
155+ a single waveband :math:`\lambda_{m}` in the green.
156+ Further let
189157
158+ .. math::
159+ x = R_\mathrm{rs}(\lambda) \in \mathbb{R}^{m}
190160
191- class Olci (OCx ):
192- """
193- The OC4 model function for Sentinel-3 OLCI.
161+ denote the function inputs. Then:
194162
195- Applicable to OLCI with maximum common logarithm of 443/560,
196- 490/560 or 510/560 remote sensing reflectance band ratio as
197- input.
198- """
163+ :param p: The parameters :math:`p \in \mathbb{R}^{5}`.
164+ :param x: The inputs :math:`x \in \mathbb{R}^{m}`.
165+ :returns: The chlorophyll concentration (mg m-3).
166+ """
167+ return jnp .power (
168+ 10.0 ,
169+ jnp .polyval (
170+ p [::- 1 ], jnp .log10 (jnp .maximum .reduce (x [:- 1 ]) / x [- 1 ])
171+ ),
172+ )
199173
200- def __init__ (self ):
201- """Creates a new model function instance."""
202- super ().__init__ (5 )
174+ super ().__init__ (f )
203175
204176 def estimate (
205177 self ,
206178 x : np .ndarray | None = None ,
207179 y : np .ndarray | None = None ,
208- preset : str | None = None ,
180+ preset : Literal [ "CZCS" , "OLCI" ] | None = "OLCI" ,
209181 ) -> np .ndarray :
210- """Returns the OC4 default parameter values for OLCI."""
211- return np .array ([0.42540 , - 3.21679 , 2.86907 , - 0.62628 , - 1.09333 ])
182+ pars = [0.42540 , - 3.21679 , 2.86907 , - 0.62628 , - 1.09333 ]
183+ match preset :
184+ case "CZCS" :
185+ pars = [0.31841 , - 4.56386 , 8.63979 , - 8.41411 , 1.91532 ]
186+ case "OLCI" :
187+ pass
188+ case _:
189+ pass
190+ return np .array (pars )
0 commit comments