![idl rebin idl rebin](https://img.it610.com/image/info8/f7c5504540e042e89007f76506b2734c.png)
For example: Use /NULL, if no elements match then array will not be modified: array = 5 To avoid this problem, you should either use /NULL or check the Count argument before indexing.
![idl rebin idl rebin](https://www.l3harrisgeospatial.com/docs/html/images/plng13d.gif)
If you use this result as an index into another array without checking for –1 first, then this will return the last element of the array. If the NULL keyword is not set, and all the elements of Array_Expression are zero, then WHERE returns a scalar integer with a value of –1. Frequently the result of WHERE is used as a vector subscript to select elements of an array using given criteria. The length of the resulting vector is equal to the number of nonzero elements in Array_Expression. \n ", \ 103 " Currently only \' neighbour \', \' nearest \', \' linear \', ", \ 104 " and \' spline \' are supported.The WHERE function returns a vector that contains the one-dimensional subscripts of the nonzero elements of Array_Expression. map_coordinates( a, newcoords) 100 return newa 101 else: 102 print " Congrid error: Unrecognized interpolation type. asarray( old) - m1) / ( newdims - m1) 95 newcoords_tr *= deltas 96 97 newcoords_tr -= ofs 98 99 newa = scipy.
![idl rebin idl rebin](https://s1.manualzz.com/store/data/039585262_1-609813beef04e9f612cdc96e2c3d1b14-360x466.png)
transpose( newcoords_dims) 90 # makes a view that affects newcoords 91 92 newcoords_tr += ofs 93 94 deltas = ( n. rank( newcoords)) 87 #make first index last 88 newcoords_dims. transpose( trorder ) 78 79 return newa 80 elif method in : 81 oslices = 82 oldcoords = n. interp1d( olddims, newa, kind= method ) 73 newa = mint( dimlist ) 74 75 if ndims > 1: 76 # need one more transpose to return to original dimensions 77 newa = newa. interp1d( olddims, a, kind= method ) 66 newa = mint( dimlist ) 67 68 trorder = + range( ndims - 1 ) 69 for i in range( ndims - 2, - 1, - 1 ): 70 newa = newa. append( ( old - m1) / ( newdims - m1) \ 60 * ( base + ofs) - ofs ) 61 # specify old dims 62 olddims = 63 64 # first interpolation - for ndims = any 65 mint = scipy. astype( int) 52 newa = a 53 return newa 54 55 elif method in : 56 # calculate new dims 57 for i in range( ndims ): 58 base = n. append( ( old - m1) / ( newdims - m1) \ 50 * ( base + ofs) - ofs ) 51 cd = n. asarray( newdims, dtype= float ) 44 dimlist = 45 46 if method = ' neighbour ': 47 for i in range( ndims ): 48 base = n. " \ 40 " This routine currently only support " \ 41 " rebinning to the same number of dimensions. shape ) 38 if len( newdims ) != ndims: 39 print " dimensions error. 13 14 method: 15 neighbour - closest value from original data 16 nearest and linear - uses n x 1-D interpolations using 17 1d 18 (see Numerical Recipes for validity of use of n 1-D interpolations) 19 spline - uses ndimage.map_coordinates 20 21 centre: 22 True - interpolation points are at the centres of the bins 23 False - points are at the front edge of the bin 24 25 minusone: 26 For example- inarray.shape = (i,j) & new dimensions = (x,y) 27 False - inarray is resampled by factors of (i/x) * (j/y) 28 True - inarray is resampled by(i-1)/(x-1) * (j-1)/(y-1) 29 This prevents extrapolation one element beyond bounds of input array. 9 10 Uses the same parameters and creates the same co-ordinate lookup points 11 as IDL''s congrid routine, which apparently originally came from a VAX/VMS 12 routine of the same name. 8 To use 1-D arrays, first promote them to shape (x,1).
![idl rebin idl rebin](https://docs.mantidproject.org/nightly/_images/01_basic_plot_scripting-2.png)
7 Currently only supports maintaining the same number of dimensions. If you want a float array which correctly averages the input values without rounding, you can do the following instead.Ī.reshape(args,factor,args,factor,).mean(1).mean(2)ġ import numpy as n 2 import scipy.interpolate 3 import scipy.ndimage 4 5 def congrid( a, newdims, method= ' linear ', centre= False, minusone= False): 6 '''Arbitrary resampling of source array to new dimension sizes. If the input is an integer array, the output values will be rounded down.
#Idl rebin code#
The above code returns an array of the same type as the input array. shape 10 lenShape = len( shape) 11 factor = asarray( shape)/ asarray( args) 12 evList = + \ 13 ,factor, '%( i, i) for i in range( lenShape)] + \ 14 + + \ 15 '% i for i in range( lenShape)] 16 print ' '. An array with 6 columns and 4 rows 4 can be reduced to have 6,3,2 or 1 columns and 4,2 or 1 rows. 1 def rebin( a, * args): 2 '''rebin ndarray data into a smaller ndarray of the same rank whose dimensions 3 are factors of the original dimensions.