Commit 46eeadd7 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

components.CoReg.COREG:

- refactored keyword 'multiproc' to 'CPUs' -> CPUs parameter passed by COREG_LOCAL is now properly handled
- equalize_pixGrids(): added a print statement

components.CoReg_local.COREG_LOCAL:
- __init__(): updated COREG call

coreg_cmd:
- run_global_coreg() updated COREG call

- updated __version__
parent a18134d5
......@@ -117,7 +117,7 @@ class COREG(object):
out_gsd=None, target_xyGrid=None, resamp_alg_deshift='cubic', resamp_alg_calc='cubic',
footprint_poly_ref=None, footprint_poly_tgt=None, data_corners_ref=None, data_corners_tgt=None,
nodata=(None,None), calc_corners=True, binary_ws=True, mask_baddata_ref=None, mask_baddata_tgt=None,
multiproc=True, force_quadratic_win=True, progress=True, v=False, path_verbose_out=None, q=False,
CPUs=None, force_quadratic_win=True, progress=True, v=False, path_verbose_out=None, q=False,
ignore_errors=False):
"""Detects and corrects global X/Y shifts between a target and refernce image. Geometric shifts are calculated
......@@ -184,7 +184,8 @@ class COREG(object):
geographic extent and projection like 'im_ref'. The mask is used to
check if the chosen matching window position is valid in the sense of
useful data. Otherwise this window position is rejected.
:param multiproc(bool): enable multiprocessing (default: 1)
:param CPUs(int): number of CPUs to use during pixel grid equalization
(default: None, which means 'all CPUs available')
:param force_quadratic_win(bool): force a quadratic matching window (default: 1)
:param progress(bool): show progress bars (default: True)
:param v(bool): verbose mode (default: False)
......@@ -229,7 +230,7 @@ class COREG(object):
self.rspAlg_DS = resamp_alg_deshift
self.rspAlg_calc = resamp_alg_calc
self.calc_corners = calc_corners
self.mp = multiproc
self.CPUs = CPUs
self.bin_ws = binary_ws
self.force_quadratic_win = force_quadratic_win
self.v = v
......@@ -378,8 +379,10 @@ class COREG(object):
Equalize image grids and projections of reference and target image (align target to reference).
"""
if not (prj_equal(self.ref.prj, self.shift.prj) and self.ref.xygrid_specs==self.shift.xygrid_specs):
if not self.q: print("Equalizing pixel grids and projections of reference and target image...")
self.shift.arr = self.shift[:,:,self.shift.band4match]
self.shift.reproject_to_new_grid(prototype=self.ref)
self.shift.reproject_to_new_grid(prototype=self.ref, CPUs=self.CPUs)
def show_image_footprints(self):
......@@ -701,7 +704,7 @@ class COREG(object):
out_bounds = ([tgt_xmin, tgt_ymin, tgt_xmax, tgt_ymax]),
rspAlg = _dict_rspAlg_rsp_Int[self.rspAlg_calc],
in_nodata = self.otherWin.nodata,
CPUs = None if self.mp else 1,
CPUs = self.CPUs,
progress = False) [:2]
if self.matchWin.shape != self.otherWin.shape:
......@@ -1277,7 +1280,7 @@ class COREG(object):
match_gsd = self.match_gsd,
target_xyGrid = self.target_xyGrid,
nodata = self.shift.nodata,
CPUs = None if self.mp else 1,
CPUs = self.CPUs,
progress = self.progress,
v = self.v,
q = self.q)
......@@ -1305,7 +1308,7 @@ class COREG(object):
if not self.q: print('\nWriting output...')
ds_im2shift = gdal.Open(self.shift.path)
if not ds_im2shift.GetDriver().ShortName == 'ENVI': # FIXME laaangsam
if self.mp:
if self.CPUs is not None and self.CPUs>1:
IO.convert_gdal_to_bsq__mp(self.shift.path, self.path_out)
else:
os.system('gdal_translate -of ENVI %s %s' %(self.shift.path, self.path_out))
......
......@@ -190,7 +190,7 @@ class COREG_LOCAL(object):
max_iter = max_iter,
max_shift = max_shift,
nodata = nodata,
multiproc = self.CPUs is None or self.CPUs > 1,
CPUs = self.CPUs,
binary_ws = self.bin_ws,
progress = self.progress,
v = v,
......
......@@ -214,6 +214,7 @@ class Geom_Quality_Grid(object):
def get_CoRegPoints_table(self):
assert self.XY_points is not None and self.XY_mapPoints is not None
# create a dataframe containing 'geometry','POINT_ID','X_IM','Y_IM','X_UTM','Y_UTM' (convert imCoords to mapCoords
XYarr2PointGeom = np.vectorize(lambda X,Y: Point(X,Y), otypes=[Point])
geomPoints = np.array(XYarr2PointGeom(self.XY_mapPoints[:,0],self.XY_mapPoints[:,1]))
......@@ -234,6 +235,7 @@ class Geom_Quality_Grid(object):
GDF.loc[:,['X_IM' ,'Y_IM' ]] = self.XY_points
GDF.loc[:,['X_UTM','Y_UTM']] = self.XY_mapPoints
# exclude offsite points and points on bad data mask
GDF = self._exclude_bad_XYpos(GDF)
......
......@@ -56,7 +56,7 @@ def run_global_coreg(args):
data_corners_tgt = args.cor1,
nodata = args.nodata,
calc_corners = args.calc_cor,
multiproc = args.mp,
CPUs = None if args.mp else 1,
binary_ws = args.bin_ws,
mask_baddata_ref = args.mask_ref,
mask_baddata_tgt = args.mask_tgt,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment