|
71 | 71 | "from_parameter": "data"
|
72 | 72 | },
|
73 | 73 | "runtime": "Python",
|
74 |
| - "udf": "\"\"\"\nImport the biopar library and the BioParNp class to calculate the FAPAR index.\nIt is the Python implementation of biophyscial parameter computation, \nas described here: http://step.esa.int/docs/extra/ATBD_S2ToolBox_L2B_V1.1.pdf\n\"\"\"\nfrom functools import lru_cache\nimport numpy as np\nfrom typing import Dict\nfrom numpy import cos, radians\n\nfrom openeo.udf.xarraydatacube import XarrayDataCube\nfrom biopar.bioparnp import BioParNp\n\n\n@lru_cache(maxsize=6)\ndef get_bioparrun(biopar) -> BioParNp:\n return BioParNp(version='3band', parameter=biopar, singleConfig = True)\n \n\ndef apply_datacube(cube: XarrayDataCube, context: Dict) -> XarrayDataCube:\n ds_date = cube.get_array()\n\n ### LOAD THE DIFFERENT REQUIRED BANDS FOR THE 8-BAND FAPAR\n scaling_bands = 0.0001\n\n saa = ds_date.sel(bands='sunAzimuthAngles')\n sza = ds_date.sel(bands=\"sunZenithAngles\")\n vaa = ds_date.sel(bands=\"viewAzimuthMean\")\n vza = ds_date.sel(bands=\"viewZenithMean\")\n\n B03 = ds_date.sel(bands='B03') * scaling_bands\n B04 = ds_date.sel(bands='B04') * scaling_bands\n B8 = ds_date.sel(bands='B08') * scaling_bands\n\n g1 = cos(radians(vza))\n g2 = cos(radians(sza))\n g3 = cos(radians(saa - vaa))\n\n #### FLATTEN THE ARRAY ####\n flat = list(map(lambda arr: arr.flatten(),\n [B03.values, B04.values, B8.values, g1.values, g2.values, g3.values]))\n bands = np.array(flat)\n\n #### CALCULATE THE BIOPAR BASED ON THE BANDS #####\n \n image = get_bioparrun('FAPAR').run(bands,\n output_scale=1,\n output_dtype=np.float32,\n minmax_flagging=False) # netcdf algorithm\n as_image = image.reshape((g1.shape))\n\n ## SET NOTDATA TO NAN\n as_image[np.where(np.isnan(B03))] = np.nan\n xr_biopar = vza.copy()\n xr_biopar.values = as_image\n return XarrayDataCube(xr_biopar)" |
| 74 | + "udf": "\"\"\"\nImport the biopar library and the BioParNp class to calculate the FAPAR index.\nIt is the Python implementation of biophysical parameter computation, \nas described here: http://step.esa.int/docs/extra/ATBD_S2ToolBox_L2B_V1.1.pdf\n\"\"\"\nfrom functools import lru_cache\nimport numpy as np\nfrom typing import Dict\nfrom numpy import cos, radians\n\nfrom openeo.udf.xarraydatacube import XarrayDataCube\nfrom biopar.bioparnp import BioParNp\n\n\n@lru_cache(maxsize=6)\ndef get_bioparrun(biopar) -> BioParNp:\n return BioParNp(version='3band', parameter=biopar, singleConfig = True)\n \n\ndef apply_datacube(cube: XarrayDataCube, context: Dict) -> XarrayDataCube:\n ds_date = cube.get_array()\n\n ### LOAD THE DIFFERENT REQUIRED BANDS FOR THE 8-BAND FAPAR\n scaling_bands = 0.0001\n\n saa = ds_date.sel(bands='sunAzimuthAngles')\n sza = ds_date.sel(bands=\"sunZenithAngles\")\n vaa = ds_date.sel(bands=\"viewAzimuthMean\")\n vza = ds_date.sel(bands=\"viewZenithMean\")\n\n B03 = ds_date.sel(bands='B03') * scaling_bands\n B04 = ds_date.sel(bands='B04') * scaling_bands\n B8 = ds_date.sel(bands='B08') * scaling_bands\n\n g1 = cos(radians(vza))\n g2 = cos(radians(sza))\n g3 = cos(radians(saa - vaa))\n\n #### FLATTEN THE ARRAY ####\n flat = list(map(lambda arr: arr.flatten(),\n [B03.values, B04.values, B8.values, g1.values, g2.values, g3.values]))\n bands = np.array(flat)\n\n #### CALCULATE THE BIOPAR BASED ON THE BANDS #####\n \n image = get_bioparrun('FAPAR').run(bands,\n output_scale=1,\n output_dtype=np.float32,\n minmax_flagging=False) # netcdf algorithm\n as_image = image.reshape((g1.shape))\n\n ## SET NOTDATA TO NAN\n as_image[np.where(np.isnan(B03))] = np.nan\n xr_biopar = vza.copy()\n xr_biopar.values = as_image\n return XarrayDataCube(xr_biopar)" |
75 | 75 | },
|
76 | 76 | "result": true
|
77 | 77 | }
|
|
160 | 160 | },
|
161 | 161 | {
|
162 | 162 | "name": "spatial_extent",
|
163 |
| - "description": "Limits the data to process to the specified bounding box or polygons.\nFor raster data, the process loads the pixel into the data cube if the point at the pixel center intersects with the bounding box or any of the polygons (as defined in the Simple Features standard by the OGC).\nFor vector data, the process loads the geometry into the data cube if the geometry is fully within the bounding box or any of the polygons (as defined in the Simple Features standard by the OGC). Empty geometries may only be in the data cube if no spatial extent has been provided.\nEmpty geometries are ignored.\nSet this parameter to null to set no limit for the spatial extent.", |
164 |
| - "schema": [ |
165 |
| - { |
166 |
| - "title": "Bounding Box", |
167 |
| - "type": "object", |
168 |
| - "subtype": "bounding-box", |
169 |
| - "required": [ |
170 |
| - "west", |
171 |
| - "south", |
172 |
| - "east", |
173 |
| - "north" |
174 |
| - ], |
175 |
| - "properties": { |
176 |
| - "west": { |
177 |
| - "description": "West (lower left corner, coordinate axis 1).", |
178 |
| - "type": "number" |
179 |
| - }, |
180 |
| - "south": { |
181 |
| - "description": "South (lower left corner, coordinate axis 2).", |
182 |
| - "type": "number" |
183 |
| - }, |
184 |
| - "east": { |
185 |
| - "description": "East (upper right corner, coordinate axis 1).", |
186 |
| - "type": "number" |
187 |
| - }, |
188 |
| - "north": { |
189 |
| - "description": "North (upper right corner, coordinate axis 2).", |
190 |
| - "type": "number" |
191 |
| - }, |
192 |
| - "base": { |
193 |
| - "description": "Base (optional, lower left corner, coordinate axis 3).", |
194 |
| - "type": [ |
195 |
| - "number", |
196 |
| - "null" |
197 |
| - ], |
198 |
| - "default": null |
199 |
| - }, |
200 |
| - "height": { |
201 |
| - "description": "Height (optional, upper right corner, coordinate axis 3).", |
202 |
| - "type": [ |
203 |
| - "number", |
204 |
| - "null" |
205 |
| - ], |
206 |
| - "default": null |
207 |
| - }, |
208 |
| - "crs": { |
209 |
| - "description": "Coordinate reference system of the extent, specified as as [EPSG code](http://www.epsg-registry.org/) or [WKT2 CRS string](http://docs.opengeospatial.org/is/18-010r7/18-010r7.html). Defaults to `4326` (EPSG code 4326) unless the client explicitly requests a different coordinate reference system.", |
210 |
| - "anyOf": [ |
211 |
| - { |
212 |
| - "title": "EPSG Code", |
213 |
| - "type": "integer", |
214 |
| - "subtype": "epsg-code", |
215 |
| - "minimum": 1000, |
216 |
| - "examples": [ |
217 |
| - 3857 |
218 |
| - ] |
219 |
| - }, |
220 |
| - { |
221 |
| - "title": "WKT2", |
222 |
| - "type": "string", |
223 |
| - "subtype": "wkt2-definition" |
224 |
| - } |
225 |
| - ], |
226 |
| - "default": 4326 |
227 |
| - } |
228 |
| - } |
229 |
| - }, |
230 |
| - { |
231 |
| - "title": "Vector data cube", |
232 |
| - "description": "Limits the data cube to the bounding box of the given geometries in the vector data cube. For raster data, all pixels inside the bounding box that do not intersect with any of the polygons will be set to no data (`null`). Empty geometries are ignored.", |
233 |
| - "type": "object", |
234 |
| - "subtype": "datacube", |
235 |
| - "dimensions": [ |
236 |
| - { |
237 |
| - "type": "geometry" |
238 |
| - } |
239 |
| - ] |
240 |
| - }, |
241 |
| - { |
242 |
| - "title": "No filter", |
243 |
| - "description": "Don't filter spatially. All data is included in the data cube.", |
244 |
| - "type": "null" |
245 |
| - } |
246 |
| - ] |
| 163 | + "description": "Limits the data to process to the specified polygons.\nFor raster data, the process loads the pixel into the data cube if the point at the pixel center intersects with any of the polygons (as defined in the Simple Features standard by the OGC).\nFor vector data, the process loads the geometry into the data cube if the geometry is fully within the bounding box or any of the polygons (as defined in the Simple Features standard by the OGC). Empty geometries may only be in the data cube if no spatial extent has been provided.\nEmpty geometries are ignored.\nSet this parameter to null to set no limit for the spatial extent.", |
| 164 | + "schema": { |
| 165 | + "type": "object", |
| 166 | + "subtype": "geojson" |
| 167 | + } |
247 | 168 | },
|
248 | 169 | {
|
249 | 170 | "name": "raw",
|
|
0 commit comments