Stoner.Image.imagefuncs.gridimage(im, points=None, xi=None, method='linear', fill_value=None, rescale=False)[source]

Use scipy.interpolate.griddata() to shift the image to a regular grid of co-ordinates.

  • points (tuple of (x-co-ords,yco-ordsa)) – The actual sampled data co-ordinates

  • xi (tupe of (2D array,2D array)) – The regular grid co-ordinates (as generated by e.g. np.meshgrid())

Keyword Arguments
  • method ("linear","cubic","nearest") – how to interpolate, default is linear

  • fill_value (folat, Callable, None) – What to put when the co-ordinates go out of range (default is None). May be a callable in which case the initial image is presented as the only argument. If None, use the mean value.

  • rescale (bool) – If the x and y co-ordinates are very different in scale, set this to True.


A copy of the modified image. The image data is interpolated and metadata kets “actual_x”,”actual_y”,”sample_ x”,”samp[le_y” are set to give co-ordinates of new grid.


If points and or xi are missed out then we try to construct them from the metadata. For points, the metadata keys “actual-x” and “actual_y” are looked for and for xi, the metadata keys “sample_x” and “sample_y” are used. These are set, for example, by the Stoner.HDF5.SXTMImage loader if the interformeter stage data was found in the file.

The metadata used in this case is then adjusted as well to ensure that repeated application of this method doesn’t change the image after it has been corrected once.