私の問題は、以下のコードを実行すると、次の不可解なエラーが発生することです
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
関数のために表示されます: scipy.ndimage.interpolation.shift(input, shift, output=None, order=3, mode='constant', cval=0.0, prefilter=True)
「 https://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.ndimage.interpolation.shift.html#scipy-ndimageで与えられた関数の定義のために、私にとっては不可解です。 -補間シフト"
定義には次のように記載されています。
"shift : フロートまたはシーケンス、オプション
軸に沿ったシフト。フロートの場合、シフトは各軸で同じです。シーケンスの場合、shift には各軸に対して 1 つの値が含まれている必要があります。」
エラーは、値が int であるべきであることを明示的に示していますが、定義は浮動小数点値を明示的に要求しています。「シフト」に整数値を挿入してみましたが、コードは正常に機能しました。データをndarrayに移動しようとしましたが、それでもエラーが発生しました。
だから私がしたいのは、サブピクセル解像度で、「coords」配列の浮動小数点数に従って画像をシフトすることです。定義またはエラー メッセージが正しく理解できません。関数の実装が機能しない理由を知りたいです。
pa_float = [float(x) for x in pa_list]
dist_float =[float(x) for x in dist_list]
pa_rad_list = np.radians(pa_float)
x_coord = np.multiply(np.cos(pa_rad_list), dist_float)*(-1)*(512)
y_coord = np.multiply(np.sin(pa_rad_list), dist_float)*(512)
# The first number in x_coord and the first number in y_coord represent the first coordinate pair.... and so on for the second..n th
coords = np.column_stack((x_coord,y_coord)) # shape (72,12)
for data in glob.glob(ImageFolderPath+'/*icn.rest_avg.fits'):
scidata0 = fits.getdata(data,0)
scidata0[0,0,:,:] = ndimage.interpolation.shift(scidata0[0,0,:,:], coords[data,:], order=3,mode='nearest',prefilter=True)
finalarray.append(scidata0)