Learn R Programming

ProFit (version 1.3.3)

profitMakePlots: Plot Image, Model and Residuals

Description

Plots appropriately scaled data and model images, along with a residual (data-model) image, and histograms of the residuals.

Usage

profitMakePlots(image, modelimage, region, sigma, errischisq = FALSE, maxsigma = 5,
cmap = rev(colorRampPalette(brewer.pal(9, "RdYlBu"))(100)), 
errcmap = rev(c("#B00000",colorRampPalette(brewer.pal(9,'RdYlBu'))(100)[2:99],"#0000B0")),
plotchisq = FALSE, dofs, skewtparm=NULL)

Arguments

image

Numeric matrix; containing an image to plot (usually the data).

modelimage

Numeric matrix; containing another image to plot and compare to (usually the model).

region

Logical matrix; defining the region of the data that the model was actually fit to.

sigma

Numeric matrix; containing errors on the data (assumed to be the Gaussian sigma).

errischisq

Logical flag; to be set if error specifies the chi-squared statistic in each pixel rather than sigma.

maxsigma

The maximum range of sigma deviations displayed.

cmap

Optional vector; colour map to use for plots of the image, model, and error.

errcmap

Optional vector; colour map to use for plots of the chi-squared residuals (see errischisq).

plotchisq

Logical flag; to determine if the function should plot a map and a histogram of chi^2, where chi = ((image-model)/error)[region]. If specified, it will also plot a color bar and a histogram of chi.

dofs

Numeric vector; of degrees-of-freedom (up to length 2), used only if plotchisq is set.

skewtparm

Numeric vector (length 4); parameters of a skewed t-distribution to plot on the residual histogram. Used only if plotchisq is set and calls the sn package's sn::dst function.

Value

No return value; the function only generates plots.

Details

This function makes useful diagnostic plots to judge how well a model fits the data. The plotchisq option is particlarly useful for judging how well the residuals (and their squares) are described by a normal (or chi-square) distribution, and whether there is any spatial structure in the residuals.

See Also

profitLikeModel, profitMakeModel

Examples

Run this code
# NOT RUN {
# Load ProFit example data

# There are 2 data source options: KiDS or SDSS (the galaxies are the same)

datasource='KiDS' 

# Now we can extract out the example files we have available for fitting by checking the
# contents of the directory containing the example FITS files:

data('ExampleInit')
ExampleFiles=list.files(system.file("extdata",datasource,package="ProFit"))
ExampleIDs=unlist(strsplit(ExampleFiles[grep('fitim',ExampleFiles)],'fitim.fits'))
print(ExampleIDs)

# There are 10 example galaxies included. Here we run example 1:

useID=ExampleIDs[1]

image = readFITS(system.file("extdata", paste(datasource,'/',useID,'fitim.fits',sep=''),
package="ProFit"))$imDat
sigma = readFITS(system.file("extdata", paste(datasource,'/',useID,'sigma.fits',sep=''),
package="ProFit"))$imDat
segim = readFITS(system.file("extdata", paste(datasource,'/',useID,'segim.fits',sep=''),
package="ProFit"))$imDat

noise = sigma
set.seed(666)
noise[] = rnorm(length(noise),mean=0,sd=noise)
region = segim == segim[dim(segim)[1]/2,dim(segim)[2]/2]

profitMakePlots(image = image, modelimage = image+noise, region = region, sigma = sigma, 
  errischisq = FALSE, plotchisq = TRUE, dofs = c(2))
# }

Run the code above in your browser using DataLab