Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Daniel Scheffler
py_tools_ds
Commits
ef68c862
Commit
ef68c862
authored
Mar 22, 2019
by
Daniel Scheffler
Browse files
Added parameter 'mp_alg'.
parent
30dbee81
Pipeline
#3811
passed with stages
in 1 minute and 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
py_tools_ds/geo/raster/reproject.py
View file @
ef68c862
...
...
@@ -818,8 +818,8 @@ def _initializer(lats, lons, data):
class
SensorMapGeometryTransformer3D
(
object
):
def
__init__
(
self
,
lons
,
lats
,
resamp_alg
=
'nearest'
,
radius_of_influence
=
30
,
**
opts
):
# type: (np.ndarray, np.ndarray, str, int, Any) -> None
def
__init__
(
self
,
lons
,
lats
,
resamp_alg
=
'nearest'
,
radius_of_influence
=
30
,
mp_alg
=
'auto'
,
**
opts
):
# type: (np.ndarray, np.ndarray, str, int,
str,
Any) -> None
"""Get an instance of SensorMapGeometryTransformer.
:param lons: 3D longitude array corresponding to the 3D sensor geometry array
...
...
@@ -829,6 +829,10 @@ class SensorMapGeometryTransformer3D(object):
- resamp_alg: resampling algorithm ('nearest', 'bilinear', 'gauss', 'custom')
- radius_of_influence: <float> Cut off distance in meters (default: 30)
NOTE: keyword is named 'radius' in case of bilinear resampling
- mp_alg multiprocessing algorithm
'bands': parallelize over bands using multiprocessing lib
'tiles': parallelize over tiles using OpenMP
'auto': automatically choose the algorithm
- sigmas: <list of floats or float> [ONLY 'gauss'] List of sigmas to use for the gauss
weighting of each channel 1 to k, w_k = exp(-dist^2/sigma_k^2). If only one channel
is resampled sigmas is a single float value.
...
...
@@ -867,7 +871,7 @@ class SensorMapGeometryTransformer3D(object):
# bands: multiprocessing uses multiprocessing.Pool, implemented in to_map_geometry / to_sensor_geometry
# tiles: multiprocessing uses OpenMP implemented in pykdtree which is used by pyresample
self
.
opts
[
'nprocs'
]
=
opts
.
get
(
'nprocs'
,
multiprocessing
.
cpu_count
())
self
.
mp_alg
=
'bands'
if
self
.
lons
.
shape
[
2
]
>=
opts
[
'nprocs'
]
else
'tiles'
self
.
mp_alg
=
(
'bands'
if
self
.
lons
.
shape
[
2
]
>=
opts
[
'nprocs'
]
else
'tiles'
)
if
mp_alg
==
'auto'
else
mp_alg
@
staticmethod
def
_to_map_geometry_2D
(
kwargs_dict
):
...
...
tests/test_geo/test_raster/test_reproject.py
View file @
ef68c862
...
...
@@ -120,7 +120,9 @@ class Test_SensorMapGeometryTransformer3D(TestCase):
def
test_to_map_geometry_lonlat_3D_geolayer
(
self
):
SMGT
=
SensorMapGeometryTransformer3D
(
lons
=
self
.
lons_3D
,
lats
=
self
.
lats_3D
,
resamp_alg
=
'nearest'
)
resamp_alg
=
'nearest'
,
mp_alg
=
'tiles'
# 'bands', i.e., Pool() causes problems with nosetests
)
# to Lon/Lat
data_mapgeo_3D
,
dem_gt
,
dem_prj
=
SMGT
.
to_map_geometry
(
self
.
data_sensor_geo_3D
,
tgt_prj
=
4326
)
...
...
@@ -137,7 +139,9 @@ class Test_SensorMapGeometryTransformer3D(TestCase):
def
test_to_sensor_geometry
(
self
):
SMGT
=
SensorMapGeometryTransformer3D
(
lons
=
self
.
lons_3D
,
lats
=
self
.
lats_3D
,
resamp_alg
=
'nearest'
)
resamp_alg
=
'nearest'
,
mp_alg
=
'tiles'
# 'bands', i.e., Pool() causes problems with nosetests)
)
dem_sensors_geo
=
SMGT
.
to_sensor_geometry
(
self
.
data_map_geo_3D
,
src_prj
=
32632
,
src_extent
=
self
.
dem_area_extent_coarse_subset_utm
)
self
.
assertIsInstance
(
dem_sensors_geo
,
np
.
ndarray
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment