Commit 03e8e8a0 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

added Python 2.7 compatibility

COREG:
- some modifications in order to ensure Python 2.7 compatibility
- pyfftw is now only imported if available

Geom_Quality_Grid:
- some modifications in order to ensure Python 2.7 compatibility

MAIN:
- CoReg_Sat root directory is automatically added to PATH
- py_tools_ds root directory is automatically added to PATH (expected to be in CoReg_Sat root directory)
parent 7d20be9e
......@@ -7,11 +7,15 @@ import shutil
import subprocess
import time
import warnings
from copy import copy
# custom
import gdal
import numpy as np
import pyfftw
try:
import pyfftw
except ImportError:
pass
from shapely.geometry import Point
# internal modules
......@@ -398,9 +402,9 @@ class COREG(object):
is_avail_rsp_average = int(gdal.VersionInfo()[0]) >= 2 #FIXME move to output image generation
if not is_avail_rsp_average:
warnings.warn("The GDAL version on this server does not yet support the resampling algorithm "
"'average'. This can affect the correct detection of subpixel shifts. To avoid this "
"please update GDAL to a version above 2.0.0!")
warnings.warn("The GDAL version on this server does not yet support the resampling algorithm 'average'. "
"This can affect the correct detection of subpixel shifts. To avoid this please update GDAL "
"to a version above 2.0.0!")
self.matchWin.imParams = self.ref if self.grid2use=='ref' else self.shift
self.otherWin.imParams = self.shift if self.grid2use=='ref' else self.ref
......@@ -782,7 +786,7 @@ class COREG(object):
def _get_updated_map_info(self):
original_map_info = geotransform2mapinfo(self.shift.gt, self.shift.prj)
self.updated_map_info = original_map_info.copy()
self.updated_map_info = copy(original_map_info)
self.updated_map_info[3] = str(float(original_map_info[3]) + self.x_shift_map)
self.updated_map_info[4] = str(float(original_map_info[4]) + self.y_shift_map)
if not self.q: print('Original map info:', original_map_info)
......
......@@ -138,7 +138,7 @@ class Geom_Quality_Grid(object):
pointID = coreg_kwargs['pointID']
del coreg_kwargs['pointID']
CR = COREG(global_shared_imref, global_shared_im2shift, **coreg_kwargs, multiproc=False)
CR = COREG(global_shared_imref, global_shared_im2shift, multiproc=False, **coreg_kwargs)
CR.calculate_spatial_shifts()
CR_res = [int(CR.matchWin.imDimsYX[0]), int(CR.matchWin.imDimsYX[1]),
......@@ -464,7 +464,7 @@ class Geom_Quality_Grid(object):
# get LonLat coordinates for all points
get_LonLat = lambda X, Y: transform_any_prj(self.im2shift.projection, 4326, X, Y)
GDF['LonLat'] = [*GDF['geometry'].map(lambda geom: get_LonLat(*tuple(np.array(geom.coords.xy)[:,0])))]
GDF['LonLat'] = list(GDF['geometry'].map(lambda geom: get_LonLat(*tuple(np.array(geom.coords.xy)[:,0]))))
# get colors for all points
#vmin = min(GDF[GDF[attribute2plot] != self.outFillVal][attribute2plot])
......@@ -476,9 +476,9 @@ class Geom_Quality_Grid(object):
# add quality grid to map
#plot_point = lambda row: ax.plot(*map2show(*row['LonLat']), marker='o', markersize=7.0, alpha=1.0, color=row['color'])
#GDF.apply(plot_point, axis=1)
GDF['plt_XY'] = [*GDF['LonLat'].map(lambda ll: map2show(*ll))]
GDF['plt_X'] = [*GDF['plt_XY'].map(lambda XY: XY[0])]
GDF['plt_Y'] = [*GDF['plt_XY'].map(lambda XY: XY[1])]
GDF['plt_XY'] = list(GDF['LonLat'].map(lambda ll: map2show(*ll)))
GDF['plt_X'] = list(GDF['plt_XY'].map(lambda XY: XY[0]))
GDF['plt_Y'] = list(GDF['plt_XY'].map(lambda XY: XY[1]))
points = plt.scatter(GDF['plt_X'],GDF['plt_Y'], c=GDF[attribute2plot],
#cmap=palette, marker='o', s=50, alpha=1.0)
cmap=palette, marker='.', s=50, alpha=1.0)
......
......@@ -18,6 +18,7 @@ except ImportError:
from osgeo import ogr
# internal modules
from py_tools_ds.ptds import GeoArray
from py_tools_ds.ptds.geo.coord_calc import calc_FullDataset_corner_positions
from py_tools_ds.ptds.geo.coord_trafo import pixelToMapYX, imYX2mapYX
from py_tools_ds.ptds import GeoArray
......
......@@ -5,6 +5,7 @@ __author__ = "Daniel Scheffler"
import time
import sys
import os
# custom
try:
......@@ -21,7 +22,17 @@ except ImportError:
from osgeo import ogr
# internal modules
from CoReg_Sat import COREG, __version__
try:
from CoReg_Sat import COREG, __version__
except ImportError:
sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..')))
from CoReg_Sat import COREG, __version__
try:
import py_tools_ds
except ImportError:
sys.path.append(os.path.abspath(os.path.dirname(__file__))) # append CoReg_Sat root directory
import py_tools_ds
......
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