CoReg gives ValueError: `min_samples` must be in range (0, <number-of-samples>)`
When running CoReg for the following granule S2A_MSIL1C_20201028T102141_N0209_R065_T32UNB_20201028T111435.SAFE/GRANULE/L1C_T32UNB_A027947_20201028T102429
, we get the following error:
Note: array has been downsampled to 1000 x 1000 for faster visualization.
20201106-11:20:59:INFO::coreg:/home/gts2/data/S2A_L2A_v0.14/32U/NB/2020/S2A_MSIL2A_20201028T102141_N0209_R065_T32UNB_20201028T111435.SAFE/GRANULE/L2A_T32UNB_A027947_20201028T102429.p_20201106_11:01:45/IMG_DATA/R20m/L2A_T32UNB_20201028T102141_B11_20m_coreg.jp2
20201106-11:20:59:INFO::Use local shift algorithm.
20201106-11:20:59:INFO::Grid_res: 183, ref band used: 1, window size: (256, 256)
20201106-11:21:02:INFO::Start correct shifts.
20201106-11:21:30:ERROR::ValueError('`min_samples` must be in range (0, <number-of-samples>)')
Traceback (most recent call last):
File "/usr/local/python/.pyenv/versions/gts2_python_3.8.6/lib/python3.8/site-packages/sicor-0.15.2-py3.8.egg/sicor/sicor_ac.py", line 223, in coreg_s2
cr.correct_shifts()
File "/usr/local/python/.pyenv/versions/gts2_python_3.8.6/lib/python3.8/site-packages/arosics-1.2.0-py3.8.egg/arosics/CoReg_local.py", line 633, in correct_shifts
self.calculate_spatial_shifts()
File "/usr/local/python/.pyenv/versions/gts2_python_3.8.6/lib/python3.8/site-packages/arosics-1.2.0-py3.8.egg/arosics/CoReg_local.py", line 350, in calculate_spatial_shifts
self._tiepoint_grid.get_CoRegPoints_table()
File "/usr/local/python/.pyenv/versions/gts2_python_3.8.6/lib/python3.8/site-packages/arosics-1.2.0-py3.8.egg/arosics/Tie_Point_Grid.py", line 418, in get_CoRegPoints_table
GDF_filt, new_columns = TPR.run_filtering(level=self.tieP_filter_level)
File "/usr/local/python/.pyenv/versions/gts2_python_3.8.6/lib/python3.8/site-packages/arosics-1.2.0-py3.8.egg/arosics/Tie_Point_Grid.py", line 880, in run_filtering
marked_recs = self._RANSAC_outlier_detection(ransacInGDF) # type: Series
File "/usr/local/python/.pyenv/versions/gts2_python_3.8.6/lib/python3.8/site-packages/arosics-1.2.0-py3.8.egg/arosics/Tie_Point_Grid.py", line 970, in _RANSAC_outlier_detection
ransac((src_coords, est_coords), AffineTransform,
File "/usr/local/python/.pyenv/versions/gts2_python_3.8.6/lib/python3.8/site-packages/skimage/measure/fit.py", line 798, in ransac
raise ValueError("`min_samples` must be in range (0, <number-of-samples>)")
ValueError: `min_samples` must be in range (0, <number-of-samples>)
20201106-11:21:30:INFO::Cleanup and exit...
To reproduce the error the following code:
class Test_Issue70(unittest.TestCase):
def test_coreg_local(self):
import dill
with open('/home/gfz-fe/scheffler/temp/coreg_issue70/kwargs_dump_assertionerror_issue_70.dill', 'rb') as inF:
kw = dill.load(inF)
kw['r_b4match'] = 1
kw['q'] = False
CRL = COREG_LOCAL(**kw)
CRL.calculate_spatial_shifts()
CRL.correct_shifts()
if CRL.success:
CRL.view_CoRegPoints(figsize=(20, 20), backgroundIm='tgt', hide_filtered=False)
else:
print('Result not co-registered.')
And the following dump file can be used:/misc/gts2/setup_files/test_data/kwargs_dump_assertionerror_issue_70b.dill
.
The issue was identified/extracted in https://gitext.gfz-potsdam.de/EnMAP/sicor/-/issues/70#note_33646.
Edited by Daniel Scheffler