From 6b7112241be8b6815fba08669ec5ce8ddef1d907 Mon Sep 17 00:00:00 2001 From: Marco De Donno Date: Fri, 8 Jun 2018 17:00:25 +0200 Subject: [PATCH] Change the default calculation of the bounderies if not provided in the parameters --- TPS/TPSpy/__init__.py | 30 ++++++++++++++++------ TPS/__init__.py | 60 +++++++++++++++++++++++++++++++------------ TPS/config.py | 6 ----- 3 files changed, 66 insertions(+), 30 deletions(-) diff --git a/TPS/TPSpy/__init__.py b/TPS/TPSpy/__init__.py index a415239..73bae1d 100644 --- a/TPS/TPSpy/__init__.py +++ b/TPS/TPSpy/__init__.py @@ -265,10 +265,17 @@ def grid( *args, **kwargs ): """ g = kwargs.get( "g" ) res = kwargs.get( "res", CONF_res ) - minx = kwargs.get( "minx", CONF_minx ) - maxx = kwargs.get( "maxx", CONF_maxx ) - miny = kwargs.get( "miny", CONF_miny ) - maxy = kwargs.get( "maxy", CONF_maxy ) + minx, miny = np.amin( g[ 'src' ], axis = 0 ) - 2 + maxx, maxy = np.amax( g[ 'src' ], axis = 0 ) + 2 + + if "minx" in kwargs: + minx = kwargs[ 'minx' ] + if "miny" in kwargs: + miny = kwargs[ 'miny' ] + if "maxx" in kwargs: + maxx = kwargs[ 'maxx' ] + if "maxy" in kwargs: + maxy = kwargs[ 'maxy' ] minor_step = kwargs.get( "minor_step", CONF_minorstep ) major_step = kwargs.get( "major_step", CONF_majorstep ) @@ -340,10 +347,17 @@ def r( *args, **kwargs ): else: g = kwargs.get( "g" ) - minx = kwargs.get( "minx", CONF_minx ) - maxx = kwargs.get( "maxx", CONF_maxx ) - miny = kwargs.get( "miny", CONF_miny ) - maxy = kwargs.get( "maxy", CONF_maxy ) + minx, miny = np.amin( g[ 'src' ], axis = 0 ) - 2 + maxx, maxy = np.amax( g[ 'src' ], axis = 0 ) + 2 + + if "minx" in kwargs: + minx = kwargs[ 'minx' ] + if "miny" in kwargs: + miny = kwargs[ 'miny' ] + if "maxx" in kwargs: + maxx = kwargs[ 'maxx' ] + if "maxy" in kwargs: + maxy = kwargs[ 'maxy' ] nbstep = 200 stepx = ( maxx - minx ) / nbstep diff --git a/TPS/__init__.py b/TPS/__init__.py index 997628e..0333819 100644 --- a/TPS/__init__.py +++ b/TPS/__init__.py @@ -577,10 +577,17 @@ def TPS_grid( **kwargs ): """ g = kwargs.get( "g" ) - minx = kwargs.get( "minx", CONF_minx ) - maxx = kwargs.get( "maxx", CONF_maxx ) - miny = kwargs.get( "miny", CONF_miny ) - maxy = kwargs.get( "maxy", CONF_maxy ) + minx, miny = np.amin( g[ 'src' ], axis = 0 ) - 2 + maxx, maxy = np.amax( g[ 'src' ], axis = 0 ) + 2 + + if "minx" in kwargs: + minx = kwargs[ 'minx' ] + if "miny" in kwargs: + miny = kwargs[ 'miny' ] + if "maxx" in kwargs: + maxx = kwargs[ 'maxx' ] + if "maxy" in kwargs: + maxy = kwargs[ 'maxy' ] plotpoints = kwargs.get( "plotpoints", True ) @@ -682,10 +689,17 @@ def TPS_range( **kwargs ): """ g = kwargs.get( "g" ) - minx = kwargs.get( "minx", CONF_minx ) - maxx = kwargs.get( "maxx", CONF_maxx ) - miny = kwargs.get( "miny", CONF_miny ) - maxy = kwargs.get( "maxy", CONF_maxy ) + minx, miny = np.amin( g[ 'src' ], axis = 0 ) - 2 + maxx, maxy = np.amax( g[ 'src' ], axis = 0 ) + 2 + + if "minx" in kwargs: + minx = kwargs[ 'minx' ] + if "miny" in kwargs: + miny = kwargs[ 'miny' ] + if "maxx" in kwargs: + maxx = kwargs[ 'maxx' ] + if "maxy" in kwargs: + maxy = kwargs[ 'maxy' ] return TPSModule.r( g, minx, maxx, miny, maxy ) @@ -726,10 +740,17 @@ def TPS_revertGrid( **kwargs ): else: g = kwargs.get( "g" ) - minx = kwargs.get( "minx", CONF_minx ) - maxx = kwargs.get( "maxx", CONF_maxx ) - miny = kwargs.get( "miny", CONF_miny ) - maxy = kwargs.get( "maxy", CONF_maxy ) + minx, miny = np.amin( g[ 'src' ], axis = 0 ) - 2 + maxx, maxy = np.amax( g[ 'src' ], axis = 0 ) + 2 + + if "minx" in kwargs: + minx = kwargs[ 'minx' ] + if "miny" in kwargs: + miny = kwargs[ 'miny' ] + if "maxx" in kwargs: + maxx = kwargs[ 'maxx' ] + if "maxy" in kwargs: + maxy = kwargs[ 'maxy' ] gridSize = kwargs.get( "gridSize", CONF_gridSize ) @@ -778,10 +799,17 @@ def TPS_revertDownSampling( **kwargs ): """ g = kwargs.get( "g" ) - minx = kwargs.get( "minx", CONF_minx ) - maxx = kwargs.get( "maxx", CONF_maxx ) - miny = kwargs.get( "miny", CONF_miny ) - maxy = kwargs.get( "maxy", CONF_maxy ) + minx, miny = np.amin( g[ 'src' ], axis = 0 ) - 2 + maxx, maxy = np.amax( g[ 'src' ], axis = 0 ) + 2 + + if "minx" in kwargs: + minx = kwargs[ 'minx' ] + if "miny" in kwargs: + miny = kwargs[ 'miny' ] + if "maxx" in kwargs: + maxx = kwargs[ 'maxx' ] + if "maxy" in kwargs: + maxy = kwargs[ 'maxy' ] gridSize = kwargs.get( "gridSize", CONF_gridSize ) diff --git a/TPS/config.py b/TPS/config.py index 88812e1..51fcc24 100644 --- a/TPS/config.py +++ b/TPS/config.py @@ -14,12 +14,6 @@ CONF_ncores = 8 # Number of pixels to add as margin to the images CONF_dm = 5 -# Default zone of interest -CONF_minx = 0 -CONF_maxx = 25.4 -CONF_miny = 0 -CONF_maxy = 25.4 - # Steps CONF_majorstep = 1 CONF_minorstep = 0.02 -- GitLab