Navigation
class ImageAssistant( object ) | Source |
---|
ImageAssistant contains 2 methods to assist with more dimensional fitting.
- getIndices Generates indices for data arrays of any dimension.
To be used as input in the Fitter classes. - resizeData Resizes the data arrays into a 1-dimensional array.
To be used as data in the Fitter.
Example
ymap = numpy.arange( 6, dtype=float ).reshape( 2, 3 )
ias = ImageAssistant()
ky = ias.getIndices( ymap )
print( ky.shape )
(6,2)
print( ky[4,0], ky[4,1], ymap[ ky[4,0], ky[4,1] ] )
1 0 4
ias = ImageAssistant( order='F')
ky = ias.getIndices( ymap )
print( ky.shape )
(6,2)
print( ky[4,0], ky[4,1], ymap[ ky[4,1], ky[4,0] ] )
0 1 4
## Suppose y is a 2-dimensional map of something
aass = ImageAssistant( )
input = aass.getIndices( y )
fitter = Fitter( input, some2dModel )
pars = fitter.fit( aass.resizeData( y ) )
yfit = some2dModel.result( input ) # Double1d
yfit2d = aass.resizeData( yfit, shape=y.shape ) # Double2d
Author Do Kester
ImageAssistant( order='C' ) |
---|
Helper class to construct from an image, the input arrays needed for the Fitters.
Parameters
- order : 'C' or 'F'
set index view according to character
'C' orders from slow to fast
'F' orders from fast to slow
getIndices( ya, order='C' ) |
---|
To be used as input in the Fitter classes.
Parameters
- ya : map
array of y ( data ) values for which an indexed array - order : 'C' or 'F'
set index view according to character
Returns
- numpy.array of ints : the indices of the pixels
getPositions( ymap, order='C', center=True, deproject=None ) |
---|
Parameters
- ya : map
array of y ( data ) values for which an indexed array - order : 'C' or 'F'
set index view according to character - center : bool
if True, return the positions of the center of the pixels.
otherwise the (left,lower) corner - deproject : callable
Deprojection method: from projected map to sky position,
returning (x,y,...) position given the map indices (ix,iy,...)
Default: returning the indices as floats (+0.5 if center)
Returns
numpy.array of floats : the positions of the pixels
getydata( ya ) |
---|
Parameters
- ya : array_like
map to be reshaped
resizeData( res, shape=None ) |
---|
Parameters
- res : array_like
result of the fit as a 1-dim array - shape : tuple of int
dimensional lengths of the reconstructable map
default remembered from a call to getIndices