cars 1.0.0rc1__cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.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.
Potentially problematic release.
This version of cars might be problematic. Click here for more details.
- cars/__init__.py +74 -0
- cars/applications/__init__.py +37 -0
- cars/applications/application.py +117 -0
- cars/applications/application_constants.py +29 -0
- cars/applications/application_template.py +146 -0
- cars/applications/auxiliary_filling/__init__.py +29 -0
- cars/applications/auxiliary_filling/abstract_auxiliary_filling_app.py +104 -0
- cars/applications/auxiliary_filling/auxiliary_filling_algo.py +475 -0
- cars/applications/auxiliary_filling/auxiliary_filling_from_sensors_app.py +630 -0
- cars/applications/auxiliary_filling/auxiliary_filling_wrappers.py +90 -0
- cars/applications/dem_generation/__init__.py +30 -0
- cars/applications/dem_generation/abstract_dem_generation_app.py +116 -0
- cars/applications/dem_generation/bulldozer_config/base_config.yaml +42 -0
- cars/applications/dem_generation/bulldozer_dem_app.py +655 -0
- cars/applications/dem_generation/bulldozer_memory.py +55 -0
- cars/applications/dem_generation/dem_generation_algo.py +107 -0
- cars/applications/dem_generation/dem_generation_constants.py +32 -0
- cars/applications/dem_generation/dem_generation_wrappers.py +323 -0
- cars/applications/dense_match_filling/__init__.py +30 -0
- cars/applications/dense_match_filling/abstract_dense_match_filling_app.py +242 -0
- cars/applications/dense_match_filling/fill_disp_algo.py +113 -0
- cars/applications/dense_match_filling/fill_disp_constants.py +39 -0
- cars/applications/dense_match_filling/fill_disp_wrappers.py +83 -0
- cars/applications/dense_match_filling/zero_padding_app.py +302 -0
- cars/applications/dense_matching/__init__.py +30 -0
- cars/applications/dense_matching/abstract_dense_matching_app.py +261 -0
- cars/applications/dense_matching/census_mccnn_sgm_app.py +1460 -0
- cars/applications/dense_matching/cpp/__init__.py +0 -0
- cars/applications/dense_matching/cpp/dense_matching_cpp.cpython-312-i386-linux-gnu.so +0 -0
- cars/applications/dense_matching/cpp/dense_matching_cpp.py +94 -0
- cars/applications/dense_matching/cpp/includes/dense_matching.hpp +58 -0
- cars/applications/dense_matching/cpp/meson.build +9 -0
- cars/applications/dense_matching/cpp/src/bindings.cpp +13 -0
- cars/applications/dense_matching/cpp/src/dense_matching.cpp +207 -0
- cars/applications/dense_matching/dense_matching_algo.py +401 -0
- cars/applications/dense_matching/dense_matching_constants.py +89 -0
- cars/applications/dense_matching/dense_matching_wrappers.py +951 -0
- cars/applications/dense_matching/disparity_grid_algo.py +588 -0
- cars/applications/dense_matching/loaders/__init__.py +23 -0
- cars/applications/dense_matching/loaders/config_census_sgm_default.json +31 -0
- cars/applications/dense_matching/loaders/config_census_sgm_homogeneous.json +30 -0
- cars/applications/dense_matching/loaders/config_census_sgm_mountain_and_vegetation.json +30 -0
- cars/applications/dense_matching/loaders/config_census_sgm_shadow.json +30 -0
- cars/applications/dense_matching/loaders/config_census_sgm_sparse.json +36 -0
- cars/applications/dense_matching/loaders/config_census_sgm_urban.json +30 -0
- cars/applications/dense_matching/loaders/config_mapping.json +13 -0
- cars/applications/dense_matching/loaders/config_mccnn.json +28 -0
- cars/applications/dense_matching/loaders/global_land_cover_map.tif +0 -0
- cars/applications/dense_matching/loaders/pandora_loader.py +593 -0
- cars/applications/dsm_filling/__init__.py +32 -0
- cars/applications/dsm_filling/abstract_dsm_filling_app.py +101 -0
- cars/applications/dsm_filling/border_interpolation_app.py +270 -0
- cars/applications/dsm_filling/bulldozer_config/base_config.yaml +44 -0
- cars/applications/dsm_filling/bulldozer_filling_app.py +279 -0
- cars/applications/dsm_filling/exogenous_filling_app.py +333 -0
- cars/applications/grid_generation/__init__.py +30 -0
- cars/applications/grid_generation/abstract_grid_generation_app.py +142 -0
- cars/applications/grid_generation/epipolar_grid_generation_app.py +327 -0
- cars/applications/grid_generation/grid_correction_app.py +496 -0
- cars/applications/grid_generation/grid_generation_algo.py +388 -0
- cars/applications/grid_generation/grid_generation_constants.py +46 -0
- cars/applications/grid_generation/transform_grid.py +88 -0
- cars/applications/ground_truth_reprojection/__init__.py +30 -0
- cars/applications/ground_truth_reprojection/abstract_ground_truth_reprojection_app.py +137 -0
- cars/applications/ground_truth_reprojection/direct_localization_app.py +629 -0
- cars/applications/ground_truth_reprojection/ground_truth_reprojection_algo.py +275 -0
- cars/applications/point_cloud_outlier_removal/__init__.py +30 -0
- cars/applications/point_cloud_outlier_removal/abstract_outlier_removal_app.py +385 -0
- cars/applications/point_cloud_outlier_removal/outlier_removal_algo.py +392 -0
- cars/applications/point_cloud_outlier_removal/outlier_removal_constants.py +43 -0
- cars/applications/point_cloud_outlier_removal/small_components_app.py +527 -0
- cars/applications/point_cloud_outlier_removal/statistical_app.py +531 -0
- cars/applications/rasterization/__init__.py +30 -0
- cars/applications/rasterization/abstract_pc_rasterization_app.py +183 -0
- cars/applications/rasterization/rasterization_algo.py +534 -0
- cars/applications/rasterization/rasterization_constants.py +38 -0
- cars/applications/rasterization/rasterization_wrappers.py +634 -0
- cars/applications/rasterization/simple_gaussian_app.py +1152 -0
- cars/applications/resampling/__init__.py +28 -0
- cars/applications/resampling/abstract_resampling_app.py +187 -0
- cars/applications/resampling/bicubic_resampling_app.py +762 -0
- cars/applications/resampling/resampling_algo.py +614 -0
- cars/applications/resampling/resampling_constants.py +36 -0
- cars/applications/resampling/resampling_wrappers.py +309 -0
- cars/applications/sparse_matching/__init__.py +30 -0
- cars/applications/sparse_matching/abstract_sparse_matching_app.py +498 -0
- cars/applications/sparse_matching/sift_app.py +735 -0
- cars/applications/sparse_matching/sparse_matching_algo.py +360 -0
- cars/applications/sparse_matching/sparse_matching_constants.py +68 -0
- cars/applications/sparse_matching/sparse_matching_wrappers.py +238 -0
- cars/applications/triangulation/__init__.py +32 -0
- cars/applications/triangulation/abstract_triangulation_app.py +227 -0
- cars/applications/triangulation/line_of_sight_intersection_app.py +1243 -0
- cars/applications/triangulation/pc_transform.py +552 -0
- cars/applications/triangulation/triangulation_algo.py +371 -0
- cars/applications/triangulation/triangulation_constants.py +38 -0
- cars/applications/triangulation/triangulation_wrappers.py +259 -0
- cars/bundleadjustment.py +757 -0
- cars/cars.py +177 -0
- cars/conf/__init__.py +23 -0
- cars/conf/geoid/egm96.grd +0 -0
- cars/conf/geoid/egm96.grd.hdr +15 -0
- cars/conf/input_parameters.py +156 -0
- cars/conf/mask_cst.py +35 -0
- cars/core/__init__.py +23 -0
- cars/core/cars_logging.py +402 -0
- cars/core/constants.py +191 -0
- cars/core/constants_disparity.py +50 -0
- cars/core/datasets.py +140 -0
- cars/core/geometry/__init__.py +27 -0
- cars/core/geometry/abstract_geometry.py +1119 -0
- cars/core/geometry/shareloc_geometry.py +598 -0
- cars/core/inputs.py +568 -0
- cars/core/outputs.py +176 -0
- cars/core/preprocessing.py +722 -0
- cars/core/projection.py +843 -0
- cars/core/roi_tools.py +215 -0
- cars/core/tiling.py +774 -0
- cars/core/utils.py +164 -0
- cars/data_structures/__init__.py +23 -0
- cars/data_structures/cars_dataset.py +1541 -0
- cars/data_structures/cars_dict.py +74 -0
- cars/data_structures/corresponding_tiles_tools.py +186 -0
- cars/data_structures/dataframe_converter.py +185 -0
- cars/data_structures/format_transformation.py +297 -0
- cars/devibrate.py +689 -0
- cars/extractroi.py +264 -0
- cars/orchestrator/__init__.py +23 -0
- cars/orchestrator/achievement_tracker.py +125 -0
- cars/orchestrator/cluster/__init__.py +37 -0
- cars/orchestrator/cluster/abstract_cluster.py +244 -0
- cars/orchestrator/cluster/abstract_dask_cluster.py +375 -0
- cars/orchestrator/cluster/dask_cluster_tools.py +103 -0
- cars/orchestrator/cluster/dask_config/README.md +94 -0
- cars/orchestrator/cluster/dask_config/dask.yaml +21 -0
- cars/orchestrator/cluster/dask_config/distributed.yaml +70 -0
- cars/orchestrator/cluster/dask_config/jobqueue.yaml +26 -0
- cars/orchestrator/cluster/dask_config/reference_confs/dask-schema.yaml +137 -0
- cars/orchestrator/cluster/dask_config/reference_confs/dask.yaml +26 -0
- cars/orchestrator/cluster/dask_config/reference_confs/distributed-schema.yaml +1009 -0
- cars/orchestrator/cluster/dask_config/reference_confs/distributed.yaml +273 -0
- cars/orchestrator/cluster/dask_config/reference_confs/jobqueue.yaml +212 -0
- cars/orchestrator/cluster/dask_jobqueue_utils.py +204 -0
- cars/orchestrator/cluster/local_dask_cluster.py +116 -0
- cars/orchestrator/cluster/log_wrapper.py +1075 -0
- cars/orchestrator/cluster/mp_cluster/__init__.py +27 -0
- cars/orchestrator/cluster/mp_cluster/mp_factorizer.py +212 -0
- cars/orchestrator/cluster/mp_cluster/mp_objects.py +535 -0
- cars/orchestrator/cluster/mp_cluster/mp_tools.py +93 -0
- cars/orchestrator/cluster/mp_cluster/mp_wrapper.py +505 -0
- cars/orchestrator/cluster/mp_cluster/multiprocessing_cluster.py +873 -0
- cars/orchestrator/cluster/mp_cluster/multiprocessing_profiler.py +399 -0
- cars/orchestrator/cluster/pbs_dask_cluster.py +207 -0
- cars/orchestrator/cluster/sequential_cluster.py +139 -0
- cars/orchestrator/cluster/slurm_dask_cluster.py +234 -0
- cars/orchestrator/orchestrator.py +905 -0
- cars/orchestrator/orchestrator_constants.py +29 -0
- cars/orchestrator/registry/__init__.py +23 -0
- cars/orchestrator/registry/abstract_registry.py +143 -0
- cars/orchestrator/registry/compute_registry.py +106 -0
- cars/orchestrator/registry/id_generator.py +116 -0
- cars/orchestrator/registry/replacer_registry.py +213 -0
- cars/orchestrator/registry/saver_registry.py +363 -0
- cars/orchestrator/registry/unseen_registry.py +118 -0
- cars/orchestrator/tiles_profiler.py +279 -0
- cars/pipelines/__init__.py +26 -0
- cars/pipelines/conf_resolution/conf_final_resolution.yaml +5 -0
- cars/pipelines/conf_resolution/conf_first_resolution.yaml +2 -0
- cars/pipelines/conf_resolution/conf_intermediate_resolution.yaml +2 -0
- cars/pipelines/default/__init__.py +26 -0
- cars/pipelines/default/default_pipeline.py +786 -0
- cars/pipelines/parameters/__init__.py +0 -0
- cars/pipelines/parameters/advanced_parameters.py +417 -0
- cars/pipelines/parameters/advanced_parameters_constants.py +69 -0
- cars/pipelines/parameters/application_parameters.py +71 -0
- cars/pipelines/parameters/depth_map_inputs.py +0 -0
- cars/pipelines/parameters/dsm_inputs.py +918 -0
- cars/pipelines/parameters/dsm_inputs_constants.py +25 -0
- cars/pipelines/parameters/output_constants.py +52 -0
- cars/pipelines/parameters/output_parameters.py +454 -0
- cars/pipelines/parameters/sensor_inputs.py +842 -0
- cars/pipelines/parameters/sensor_inputs_constants.py +49 -0
- cars/pipelines/parameters/sensor_loaders/__init__.py +29 -0
- cars/pipelines/parameters/sensor_loaders/basic_classif_loader.py +86 -0
- cars/pipelines/parameters/sensor_loaders/basic_image_loader.py +98 -0
- cars/pipelines/parameters/sensor_loaders/pivot_classif_loader.py +90 -0
- cars/pipelines/parameters/sensor_loaders/pivot_image_loader.py +105 -0
- cars/pipelines/parameters/sensor_loaders/sensor_loader.py +93 -0
- cars/pipelines/parameters/sensor_loaders/sensor_loader_template.py +71 -0
- cars/pipelines/parameters/sensor_loaders/slurp_classif_loader.py +86 -0
- cars/pipelines/pipeline.py +119 -0
- cars/pipelines/pipeline_constants.py +31 -0
- cars/pipelines/pipeline_template.py +139 -0
- cars/pipelines/unit/__init__.py +26 -0
- cars/pipelines/unit/unit_pipeline.py +2850 -0
- cars/starter.py +167 -0
- cars-1.0.0rc1.dist-info/METADATA +292 -0
- cars-1.0.0rc1.dist-info/RECORD +200 -0
- cars-1.0.0rc1.dist-info/WHEEL +6 -0
- cars-1.0.0rc1.dist-info/entry_points.txt +8 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# coding: utf8
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2020 Centre National d'Etudes Spatiales (CNES).
|
|
5
|
+
#
|
|
6
|
+
# This file is part of CARS
|
|
7
|
+
# (see https://github.com/CNES/cars).
|
|
8
|
+
#
|
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
# you may not use this file except in compliance with the License.
|
|
11
|
+
# You may obtain a copy of the License at
|
|
12
|
+
#
|
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
#
|
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
# See the License for the specific language governing permissions and
|
|
19
|
+
# limitations under the License.
|
|
20
|
+
#
|
|
21
|
+
"""
|
|
22
|
+
This module contains the saver registry class
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Standard imports
|
|
27
|
+
import logging
|
|
28
|
+
import os
|
|
29
|
+
import traceback
|
|
30
|
+
|
|
31
|
+
# CARS imports
|
|
32
|
+
from cars.orchestrator.registry.abstract_registry import (
|
|
33
|
+
AbstractCarsDatasetRegistry,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class CarsDatasetsRegistrySaver(AbstractCarsDatasetRegistry):
|
|
38
|
+
"""
|
|
39
|
+
CarsDatasetsRegistrySaver
|
|
40
|
+
This registry manages the saving of arriving future results
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def __init__(self, id_generator):
|
|
44
|
+
"""
|
|
45
|
+
Init function of CarsDatasetsRegistrySaver
|
|
46
|
+
|
|
47
|
+
:param id_generator: id generator
|
|
48
|
+
:type id_generator: IdGenerator
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
super().__init__(id_generator)
|
|
52
|
+
self.registered_cars_datasets_savers = []
|
|
53
|
+
|
|
54
|
+
def get_cars_ds(self, future_result):
|
|
55
|
+
"""
|
|
56
|
+
Get a list of registered CarsDataset
|
|
57
|
+
|
|
58
|
+
:param obj: object to get cars dataset from
|
|
59
|
+
|
|
60
|
+
:return corresponding CarsDataset
|
|
61
|
+
:rtype: CarsDataset
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
obj_id = self.get_future_cars_dataset_id(future_result)
|
|
65
|
+
cars_ds_saver = self.get_cars_ds_saver_corresponding_id(obj_id)
|
|
66
|
+
if cars_ds_saver is None:
|
|
67
|
+
return None
|
|
68
|
+
return cars_ds_saver.cars_ds
|
|
69
|
+
|
|
70
|
+
def get_cars_datasets_list(self):
|
|
71
|
+
"""
|
|
72
|
+
Get a list of registered CarsDataset
|
|
73
|
+
|
|
74
|
+
:return list of CarsDataset
|
|
75
|
+
:rtype: list(CarsDataset)
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
cars_ds_list = []
|
|
79
|
+
|
|
80
|
+
for cars_ds_saver in self.registered_cars_datasets_savers:
|
|
81
|
+
cars_ds_list.append(cars_ds_saver.cars_ds)
|
|
82
|
+
|
|
83
|
+
return cars_ds_list
|
|
84
|
+
|
|
85
|
+
def cars_dataset_in_registry(self, cars_ds):
|
|
86
|
+
"""
|
|
87
|
+
Check if a CarsDataset is already registered, return id if exists
|
|
88
|
+
|
|
89
|
+
:param cars_ds: cars dataset
|
|
90
|
+
:type cars_ds: CarsDataset
|
|
91
|
+
|
|
92
|
+
:return : True if in registry, if of cars dataset
|
|
93
|
+
:rtype : Tuple(bool, int)
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
in_registry = False
|
|
97
|
+
registered_id = None
|
|
98
|
+
for obj in self.registered_cars_datasets_savers:
|
|
99
|
+
if cars_ds == obj.cars_ds:
|
|
100
|
+
in_registry = True
|
|
101
|
+
registered_id = obj.obj_id
|
|
102
|
+
break
|
|
103
|
+
|
|
104
|
+
return in_registry, registered_id
|
|
105
|
+
|
|
106
|
+
def get_cars_ds_saver_corresponding_cars_dataset(self, cars_ds):
|
|
107
|
+
"""
|
|
108
|
+
Get the SingleCarsDatasetSaver corresponding to given cars dataset
|
|
109
|
+
|
|
110
|
+
:param cars_ds: cars dataset
|
|
111
|
+
|
|
112
|
+
:return : single cars dataset saver
|
|
113
|
+
:rtype : SingleCarsDatasetSaver
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
cars_ds_saver = None
|
|
117
|
+
for obj in self.registered_cars_datasets_savers:
|
|
118
|
+
if cars_ds == obj.cars_ds:
|
|
119
|
+
cars_ds_saver = obj
|
|
120
|
+
break
|
|
121
|
+
|
|
122
|
+
return cars_ds_saver
|
|
123
|
+
|
|
124
|
+
def get_cars_ds_saver_corresponding_id(self, obj_id):
|
|
125
|
+
"""
|
|
126
|
+
Get the SingleCarsDatasetSaver corresponding to given id
|
|
127
|
+
|
|
128
|
+
:param obj_id: cars dataset id
|
|
129
|
+
:type obj_id: int
|
|
130
|
+
|
|
131
|
+
:return : single cars dataset saver
|
|
132
|
+
:rtype : SingleCarsDatasetSaver
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
cars_ds_saver = None
|
|
136
|
+
for obj in self.registered_cars_datasets_savers:
|
|
137
|
+
if obj_id == obj.obj_id:
|
|
138
|
+
cars_ds_saver = obj
|
|
139
|
+
break
|
|
140
|
+
|
|
141
|
+
return cars_ds_saver
|
|
142
|
+
|
|
143
|
+
def save(self, future_result):
|
|
144
|
+
"""
|
|
145
|
+
Save future result
|
|
146
|
+
|
|
147
|
+
:param future_result: xr.Dataset or pd.DataFrame
|
|
148
|
+
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
obj_id = self.get_future_cars_dataset_id(future_result)
|
|
152
|
+
cars_ds_saver = self.get_cars_ds_saver_corresponding_id(obj_id)
|
|
153
|
+
|
|
154
|
+
if cars_ds_saver is not None:
|
|
155
|
+
# save
|
|
156
|
+
if future_result is not None:
|
|
157
|
+
cars_ds_saver.save(future_result)
|
|
158
|
+
else:
|
|
159
|
+
logging.debug("Future result tile is None -> not saved")
|
|
160
|
+
|
|
161
|
+
def add_file_to_save( # pylint: disable=too-many-positional-arguments
|
|
162
|
+
self,
|
|
163
|
+
file_name,
|
|
164
|
+
cars_ds,
|
|
165
|
+
tag=None,
|
|
166
|
+
dtype=None,
|
|
167
|
+
nodata=None,
|
|
168
|
+
optional_data=False,
|
|
169
|
+
save_by_pair=False,
|
|
170
|
+
):
|
|
171
|
+
"""
|
|
172
|
+
Add file corresponding to cars_dataset to registered_cars_datasets
|
|
173
|
+
|
|
174
|
+
:param file_name: file name to save futures to
|
|
175
|
+
:type file_name: str
|
|
176
|
+
:param cars_ds: CarsDataset to register
|
|
177
|
+
:type cars_ds: CarsDataset
|
|
178
|
+
:param tag: tag to save
|
|
179
|
+
:type tag: str
|
|
180
|
+
:param dtype: dtype
|
|
181
|
+
:type dtype: str
|
|
182
|
+
:param nodata: no data value
|
|
183
|
+
:type nodata: float
|
|
184
|
+
:param optional_data: True if the data is optionnal
|
|
185
|
+
:type optional_data: bool
|
|
186
|
+
:param save_by_pair:
|
|
187
|
+
:type save_by_pair: bool
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
if not self.cars_dataset_in_registry(cars_ds)[0]:
|
|
191
|
+
# Generate_id
|
|
192
|
+
new_id = self.id_generator.get_new_id(cars_ds)
|
|
193
|
+
# create CarsDataset saver
|
|
194
|
+
cars_ds_saver = SingleCarsDatasetSaver(new_id, cars_ds)
|
|
195
|
+
# add to list
|
|
196
|
+
self.registered_cars_datasets_savers.append(cars_ds_saver)
|
|
197
|
+
else:
|
|
198
|
+
cars_ds_saver = self.get_cars_ds_saver_corresponding_cars_dataset(
|
|
199
|
+
cars_ds
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
# update cars_ds_saver
|
|
203
|
+
cars_ds_saver.add_file(
|
|
204
|
+
file_name,
|
|
205
|
+
tag=tag,
|
|
206
|
+
dtype=dtype,
|
|
207
|
+
nodata=nodata,
|
|
208
|
+
optional_data=optional_data,
|
|
209
|
+
save_by_pair=save_by_pair,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
def cleanup(self):
|
|
213
|
+
"""
|
|
214
|
+
Cleanup function.
|
|
215
|
+
|
|
216
|
+
Close correctly all opened files.
|
|
217
|
+
|
|
218
|
+
"""
|
|
219
|
+
for obj in self.registered_cars_datasets_savers:
|
|
220
|
+
obj.cleanup()
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class SingleCarsDatasetSaver:
|
|
224
|
+
"""
|
|
225
|
+
SingleCarsDatasetSaver
|
|
226
|
+
|
|
227
|
+
Structure managing the descriptors of each CarsDataset.
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
def __init__(self, obj_id, cars_ds):
|
|
231
|
+
"""
|
|
232
|
+
Init function of SingleCarsDatasetSaver
|
|
233
|
+
|
|
234
|
+
"""
|
|
235
|
+
|
|
236
|
+
self.obj_id = obj_id
|
|
237
|
+
self.cars_ds = cars_ds
|
|
238
|
+
|
|
239
|
+
self.file_names = []
|
|
240
|
+
self.optional_data_list = []
|
|
241
|
+
self.tags = []
|
|
242
|
+
self.dtypes = []
|
|
243
|
+
self.nodatas = []
|
|
244
|
+
self.descriptors = []
|
|
245
|
+
self.save_pc_by_pair_list = []
|
|
246
|
+
self.already_seen = False
|
|
247
|
+
self.count = 0
|
|
248
|
+
self.folder_name = None
|
|
249
|
+
|
|
250
|
+
def add_file( # pylint: disable=too-many-positional-arguments
|
|
251
|
+
self,
|
|
252
|
+
file_name,
|
|
253
|
+
tag=None,
|
|
254
|
+
dtype=None,
|
|
255
|
+
nodata=None,
|
|
256
|
+
optional_data=False,
|
|
257
|
+
save_by_pair=False,
|
|
258
|
+
):
|
|
259
|
+
"""
|
|
260
|
+
Add file to current CarsDatasetSaver
|
|
261
|
+
|
|
262
|
+
:param file_name: file name to save futures to
|
|
263
|
+
:type file_name: str
|
|
264
|
+
:param tag: tag to save
|
|
265
|
+
:type tag: str
|
|
266
|
+
:param dtype: dtype
|
|
267
|
+
:type dtype: str
|
|
268
|
+
:param nodata: no data value
|
|
269
|
+
:type nodata: float
|
|
270
|
+
:param optional_data: True if the data is optionnal
|
|
271
|
+
:type optional_data: bool
|
|
272
|
+
"""
|
|
273
|
+
|
|
274
|
+
self.file_names.append(file_name)
|
|
275
|
+
self.tags.append(tag)
|
|
276
|
+
self.dtypes.append(dtype)
|
|
277
|
+
self.nodatas.append(nodata)
|
|
278
|
+
self.optional_data_list.append(optional_data)
|
|
279
|
+
self.save_pc_by_pair_list.append(save_by_pair)
|
|
280
|
+
|
|
281
|
+
def save(self, future_result): # noqa: C901 : too complex
|
|
282
|
+
"""
|
|
283
|
+
Save future result
|
|
284
|
+
|
|
285
|
+
:param future_result: xr.Dataset or pandas.DataFrame
|
|
286
|
+
|
|
287
|
+
"""
|
|
288
|
+
|
|
289
|
+
try:
|
|
290
|
+
if self.cars_ds.dataset_type == "arrays":
|
|
291
|
+
if not self.already_seen:
|
|
292
|
+
# generate descriptors
|
|
293
|
+
for count, file_name in enumerate(self.file_names):
|
|
294
|
+
if self.tags[count] in future_result.keys():
|
|
295
|
+
desc = self.cars_ds.generate_descriptor(
|
|
296
|
+
future_result,
|
|
297
|
+
file_name,
|
|
298
|
+
tag=self.tags[count],
|
|
299
|
+
dtype=self.dtypes[count],
|
|
300
|
+
nodata=self.nodatas[count],
|
|
301
|
+
)
|
|
302
|
+
self.descriptors.append(desc)
|
|
303
|
+
else:
|
|
304
|
+
self.descriptors.append(None)
|
|
305
|
+
self.already_seen = True
|
|
306
|
+
|
|
307
|
+
for count, file_name in enumerate(self.file_names):
|
|
308
|
+
if self.tags[count] in future_result.keys():
|
|
309
|
+
self.cars_ds.run_save(
|
|
310
|
+
future_result,
|
|
311
|
+
file_name,
|
|
312
|
+
tag=self.tags[count],
|
|
313
|
+
descriptor=self.descriptors[count],
|
|
314
|
+
)
|
|
315
|
+
else:
|
|
316
|
+
log_message = "{} is not consistent.".format(
|
|
317
|
+
self.tags[count].capitalize()
|
|
318
|
+
)
|
|
319
|
+
if self.optional_data_list[count]:
|
|
320
|
+
logging.debug(log_message)
|
|
321
|
+
else:
|
|
322
|
+
logging.warning(log_message)
|
|
323
|
+
elif self.cars_ds.dataset_type == "points":
|
|
324
|
+
# type points
|
|
325
|
+
if not self.already_seen:
|
|
326
|
+
# create tmp_folder
|
|
327
|
+
self.folder_name = self.file_names[0]
|
|
328
|
+
if not os.path.exists(self.folder_name):
|
|
329
|
+
os.makedirs(self.folder_name)
|
|
330
|
+
self.already_seen = True
|
|
331
|
+
self.cars_ds.run_save(
|
|
332
|
+
future_result,
|
|
333
|
+
os.path.join(self.folder_name, repr(self.count)),
|
|
334
|
+
overwrite=not self.already_seen,
|
|
335
|
+
save_by_pair=self.save_pc_by_pair_list[0],
|
|
336
|
+
)
|
|
337
|
+
self.count += 1
|
|
338
|
+
|
|
339
|
+
else:
|
|
340
|
+
logging.error(
|
|
341
|
+
"Saving {} CarsDataset not implemeted".format(
|
|
342
|
+
self.cars_ds.dataset_type
|
|
343
|
+
)
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
except: # pylint: disable=W0702 # noqa: B001, E722
|
|
347
|
+
logging.error(traceback.format_exc())
|
|
348
|
+
logging.error("Tile not saved")
|
|
349
|
+
|
|
350
|
+
def cleanup(self):
|
|
351
|
+
"""
|
|
352
|
+
Cleanup function
|
|
353
|
+
|
|
354
|
+
Close properly all opened files
|
|
355
|
+
|
|
356
|
+
"""
|
|
357
|
+
|
|
358
|
+
# close raster files
|
|
359
|
+
for desc in self.descriptors:
|
|
360
|
+
if desc is not None:
|
|
361
|
+
desc.close()
|
|
362
|
+
|
|
363
|
+
# TODO merge point clouds ?
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# coding: utf8
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2020 Centre National d'Etudes Spatiales (CNES).
|
|
5
|
+
#
|
|
6
|
+
# This file is part of CARS
|
|
7
|
+
# (see https://github.com/CNES/cars).
|
|
8
|
+
#
|
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
# you may not use this file except in compliance with the License.
|
|
11
|
+
# You may obtain a copy of the License at
|
|
12
|
+
#
|
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
#
|
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
# See the License for the specific language governing permissions and
|
|
19
|
+
# limitations under the License.
|
|
20
|
+
#
|
|
21
|
+
"""
|
|
22
|
+
This module contains the unseen registry class
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
# CARS imports
|
|
26
|
+
from cars.orchestrator.registry.abstract_registry import (
|
|
27
|
+
AbstractCarsDatasetRegistry,
|
|
28
|
+
)
|
|
29
|
+
from cars.orchestrator.registry.replacer_registry import (
|
|
30
|
+
SingleCarsDatasetReplacer,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class CarsDatasetRegistryUnseen(AbstractCarsDatasetRegistry):
|
|
35
|
+
"""
|
|
36
|
+
CarsDatasetRegistryUnseen
|
|
37
|
+
This registry manages the unseen CarsDataset, that might be needed
|
|
38
|
+
to get infos
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__(self, id_generator):
|
|
42
|
+
"""
|
|
43
|
+
Init function of CarsDatasetRegistryUnseen
|
|
44
|
+
|
|
45
|
+
:param id_generator: id generator
|
|
46
|
+
:type id_generator: IdGenerator
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
super().__init__(id_generator)
|
|
50
|
+
self.registered_cars_datasets_unseen = []
|
|
51
|
+
|
|
52
|
+
def get_cars_ds(self, future_result):
|
|
53
|
+
"""
|
|
54
|
+
Get a list of registered CarsDataset
|
|
55
|
+
|
|
56
|
+
:param obj: object to get cars dataset from
|
|
57
|
+
|
|
58
|
+
:return corresponding CarsDataset
|
|
59
|
+
:rtype: CarsDataset
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
def cars_dataset_in_registry(self, cars_ds):
|
|
65
|
+
"""
|
|
66
|
+
Check if a CarsDataset is already registered, return id if exists
|
|
67
|
+
|
|
68
|
+
:param cars_ds: cars dataset
|
|
69
|
+
:type cars_ds: CarsDataset
|
|
70
|
+
|
|
71
|
+
:return : True if in registry, if of cars dataset
|
|
72
|
+
:rtype : Tuple(bool, int)
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
in_registry = False
|
|
76
|
+
registered_id = None
|
|
77
|
+
for obj in self.registered_cars_datasets_unseen:
|
|
78
|
+
if cars_ds == obj.cars_ds:
|
|
79
|
+
in_registry = True
|
|
80
|
+
registered_id = obj.obj_id
|
|
81
|
+
break
|
|
82
|
+
|
|
83
|
+
return in_registry, registered_id
|
|
84
|
+
|
|
85
|
+
def add_cars_ds_to_unseen(self, cars_ds):
|
|
86
|
+
"""
|
|
87
|
+
Add cars dataset to unseen registry, and
|
|
88
|
+
get corresponding id
|
|
89
|
+
|
|
90
|
+
:param cars_ds: cars dataset
|
|
91
|
+
:type cars_ds: CarsDataset
|
|
92
|
+
|
|
93
|
+
:return : id
|
|
94
|
+
:rtype : int
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
# Generate_id
|
|
98
|
+
new_id = self.id_generator.get_new_id(cars_ds)
|
|
99
|
+
# create CarsDataset replacer (same storage)
|
|
100
|
+
unseen_obj = SingleCarsDatasetReplacer(cars_ds, new_id)
|
|
101
|
+
self.registered_cars_datasets_unseen.append(unseen_obj)
|
|
102
|
+
|
|
103
|
+
return new_id
|
|
104
|
+
|
|
105
|
+
def get_cars_datasets_list(self):
|
|
106
|
+
"""
|
|
107
|
+
Get a list of registered CarsDataset
|
|
108
|
+
|
|
109
|
+
:return list of CarsDataset
|
|
110
|
+
:rtype: list(CarsDataset)
|
|
111
|
+
|
|
112
|
+
"""
|
|
113
|
+
cars_ds_list = []
|
|
114
|
+
|
|
115
|
+
for cars_ds_saver in self.registered_cars_datasets_unseen:
|
|
116
|
+
cars_ds_list.append(cars_ds_saver.cars_ds)
|
|
117
|
+
|
|
118
|
+
return cars_ds_list
|