Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/profitUtility.R

A simple function to add together two matrices. The base matrix must be equal in size or larger than the matrix being added, and some pixels of the added matrix must fall inside the base matrix.

1 | ```
profitAddMats(matbase, matadd, addloc = c(1, 1), plot = FALSE, ...)
``` |

`matbase` |
The base matrix to be added onto (the output will be the same size as the base matrix). |

`matadd` |
The matrix to be added (this cannot be larger than the base matrix). |

`addloc` |
The reference ID of the corner pixel to use when adding matadd. This will be the position at which matadd[1,1] is added, i.e. the default c(1,1) means the two matrices are lined up on the bottom-left pixel when plotted as an image. This can be negative or larger than dim(matbase), which means only a subset of the matadd matrix is added to matbase. |

`plot` |
Logical; should a |

`...` |
Further arguments to be passed to |

In practice this function is a convenient low level routine that us used by `profitMakePointSource`

. It is unlikely the user will use it directly.

By ProFit convention the bottom-left part of the bottom-left pixel when plotting the image matrix is c(0,0) and the top-right part of the bottom-left pixel is c(1,1), i.e. the mid-point of pixels are half integer values in x and y.

To confuse things a bit, when R plots an image of a matrix it is transposed and re-ordered vertically to how it appears if you print the matrix directly to screen, i.e. compare print(matrix(1:4,2,2)) and image(matrix(1:4,2,2)). The lowest value (1) is top-left when printed but bottom-left when displayed using image (the red pixel). Both are "correct": the issue is whether you consider the first element of a matrix to be the Cartesian x position (movement in x) or a row element (movement in y). Matrices in maths are always written top-left first where the first argument refers to row number, but images by convention are accessed in a Cartesian sense. Hence [3,4] in a maths matrix means 3 down and 4 right from the top-left, but 3 right and 4 up from the bottom-left in an image.

Matrix; a matrix the same size as matbase, with a region of it added to by the values in matadd.

Aaron Robotham

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
model = list(
sersic = list(
xcen = c(180, 60),
ycen = c(90, 10),
mag = c(15, 13),
re = c(14, 5),
nser = c(3, 10),
ang = c(46, 80),
axrat = c(0.4, 0.6),
box = c(0.5,-0.5)
)
)
# We can add a PSF to an image of two Sersic profiles:
magimage(profitAddMats(matbase=profitMakeModel(model, dim=c(200,200))$z,
matadd=profitMakePointSource(), addloc=c(50,150)))
``` |

ProFit documentation built on July 23, 2019, 9:04 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.