12
12
from datetime import datetime
13
13
from typing import Tuple , Union
14
14
15
- import rasterio
16
15
import sqlalchemy
17
16
from bdc_catalog .models import (Band , BandSRC , Collection , CompositeFunction ,
18
17
GridRefSys , Item , MimeType , Quicklook ,
19
18
ResolutionUnit , SpatialRefSys , Tile )
20
- from bdc_catalog .models .base_sql import BaseModel , db
19
+ from bdc_catalog .models .base_sql import db
21
20
from geoalchemy2 import func
22
21
from geoalchemy2 .shape import from_shape
23
22
from rasterio .crs import CRS
24
23
from rasterio .warp import transform
25
24
from shapely .geometry import Polygon
26
- from werkzeug .exceptions import BadRequest , Conflict , NotFound
25
+ from werkzeug .exceptions import BadRequest , NotFound
27
26
28
27
from .config import ITEM_PREFIX
29
- from .constants import (CENTER_WAVELENGTH , CLEAR_OBSERVATION_ATTRIBUTES ,
30
- CLEAR_OBSERVATION_NAME , COG_MIME_TYPE ,
31
- DATASOURCE_ATTRIBUTES , FULL_WIDTH_HALF_MAX ,
28
+ from .constants import (CLEAR_OBSERVATION_ATTRIBUTES , CLEAR_OBSERVATION_NAME ,
29
+ COG_MIME_TYPE , DATASOURCE_ATTRIBUTES ,
32
30
PROVENANCE_ATTRIBUTES , PROVENANCE_NAME ,
33
- REVISIT_BY_SATELLITE , SRID_ALBERS_EQUAL_AREA ,
34
- SRID_BDC_GRID , TOTAL_OBSERVATION_ATTRIBUTES ,
31
+ SRID_ALBERS_EQUAL_AREA , TOTAL_OBSERVATION_ATTRIBUTES ,
35
32
TOTAL_OBSERVATION_NAME )
36
33
from .forms import CollectionForm
37
- from .maestro import (blend , merge_warped , orchestrate , posblend ,
38
- prepare_merge , publish , solo )
34
+ from .maestro import (blend , harmonization , merge_warped , orchestrate ,
35
+ posblend , prepare_harm , prepare_merge , publish , solo )
39
36
from .services import CubeServices
40
37
from .utils .image import validate_merges
41
- from .utils .processing import (format_version , generate_hash_md5 ,
42
- get_cube_name , get_cube_parts , get_date ,
38
+ from .utils .processing import (format_version , get_cube_parts , get_date ,
43
39
get_or_create_model )
44
40
from .utils .serializer import DecimalEncoder , Serializer
45
41
from .utils .timeline import Timeline
@@ -59,6 +55,10 @@ def continue_process_stream(self, params_list):
59
55
if 'channel' in params and params ['channel' ] == 'kinesis' :
60
56
solo (self , params_list )
61
57
58
+ # dispatch HARMONIZATION
59
+ elif params ['action' ] == 'harmonization' :
60
+ harmonization (self , params )
61
+
62
62
# dispatch MERGE
63
63
elif params ['action' ] == 'merge' :
64
64
merge_warped (self , params )
@@ -246,7 +246,7 @@ def _create_cube_definition(self, cube_id: str, params: dict) -> dict:
246
246
collection = cube ,
247
247
min_value = 0 ,
248
248
max_value = 10000 if is_not_cloud else 4 ,
249
- nodata = - 9999 if is_not_cloud else 255 ,
249
+ nodata = band [ 'nodata' ] ,
250
250
scale = 0.0001 if is_not_cloud else 1 ,
251
251
data_type = data_type ,
252
252
resolution_x = params ['resolution' ],
@@ -287,7 +287,8 @@ def _create_cube_definition(self, cube_id: str, params: dict) -> dict:
287
287
_ = self .get_or_create_band (cube .id , ** PROVENANCE_ATTRIBUTES , resolution_unit_id = resolution_meter .id ,
288
288
resolution_x = params ['resolution' ], resolution_y = params ['resolution' ])
289
289
290
- if params .get ('is_combined' ) and function != 'MED' :
290
+ landsat_harm = params ['parameters' ].get ('landsat_harmonization' )
291
+ if landsat_harm and landsat_harm .get ('datasets' ) and function != 'MED' :
291
292
_ = self .get_or_create_band (cube .id , ** DATASOURCE_ATTRIBUTES , resolution_unit_id = resolution_meter .id ,
292
293
resolution_x = params ['resolution' ], resolution_y = params ['resolution' ])
293
294
@@ -465,6 +466,15 @@ def get_cube_status(self, cube_name):
465
466
error = 0
466
467
), 200
467
468
469
+
470
+ def start_harmonization_process (self , params ):
471
+ _ = prepare_harm (self , params ['scenes' ], params ['bucket_dst' ], params ['bucket_angles' ])
472
+
473
+ return dict (
474
+ message = 'Harmonization processing started with succesfully'
475
+ ), 200
476
+
477
+
468
478
def start_process (self , params ):
469
479
response = {}
470
480
datacube_identify = f'{ params ["datacube" ]} -{ params ["datacube_version" ]} '
0 commit comments