diff --git a/TPS/TPSpy/__init__.py b/TPS/TPSpy/__init__.py index a41523990da7ec0738acbfd0d607ebe27e33ed3a..73bae1dcceea3b99cef7c0447a5e0ace589ed35b 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 997628e814b994d90805af29bd7f296c641d5221..0333819688e1ba3cac1c99fc22b04bc33d7fdb9f 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 88812e1aa1bbd4a9d5a107ac2ec925f34fdba89e..51fcc24a32e15ee9a673186616e93bed8d293a4a 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