Description Usage Arguments Value Examples
Similar to R's tapply
this applies a function to cells
defined by indices in a spc data object
1 2 3 | AT.SPC.tapply( spc, INDEX, FUN, mixed.field.arguments = list(E.MeV.u =
"E.mid.MeV.u", fluence.cm2 = "N.per.primary", particle.no = "particle.no"),
additional.arguments = NULL, names.results = NULL)
|
spc |
spc data as returned by |
INDEX |
vector of column names in spc data that should be used as indices (indicating the cells). |
FUN |
Function to be applied - preferably this is a libamtrack
function obeying the standard naming of mixed field variables
|
mixed.field.arguments |
Named list containing the variables necessary
to describe a mixed field (energy, fluence, particle type). The defaults are
set to correspond to the column names used in |
additional.arguments |
Optional additional arguments to |
names.results |
optional vector with names for the returned values of
|
A data frame with the following columns:
index.columns |
Columns for indices given in |
results[] |
Additional columns containing the returned values from
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | ## Not run:
# Load required libraries
require(libamtrack)
require(lattice)
# Use example data set
file.name <- system.file("extdata",
"libamtrack.12C.H2O.active3.MeV27000.zip", package = "libamtrack")
endian <- c("big", "little")[2]
# Read in spc data, we use old style R reader, so endianess has to be given
spc <- AT.SPC.read ( file.name = file.name,
endian = endian,
flavour = "vanilla")$spc
# Translate particle numbers in particle names (looks better)
spc$particle.name <- AT.particle.name.from.particle.no(particle.no =
spc$particle.no)
spc$particle.name <- factor(spc$particle.name)
# Compute and plot dose per primary with depth from spc data
df1 <- AT.SPC.tapply( spc = spc,
INDEX = "depth.g.cm2",
FUN = AT.total.D.Gy,
additional.arguments = list( c("material.no", "1",
FALSE), # Water
c("stopping.power.source.no", "0", FALSE)), # PSTAR
names.results = "D.Gy")
xyplot( D.Gy ~ depth.g.cm2,
df1,
type = "o",
grid = TRUE,
ylab = "dose per primary / Gy",
xlab = "depth / (g/cm2)")
# Compute and plot dose (1 Gy entrance) with depth from spc data
# To do so, first the fluence per primary has to be scaled and then
# AT.SPC.tapply has to be referred to the new non-standard column (default:
# fluence.cm2 = "N.per.primary")
fluence.factor <- 1.0 / df1$D.Gy[1]
# factor between dose per primary (from above) and 2 Gy
spc$fluence.cm2 <- spc$N.per.primary * fluence.factor
df2 <- AT.SPC.tapply( spc = spc,
INDEX = "depth.g.cm2",
FUN = AT.total.D.Gy,
mixed.field.arguments = list( fluence.cm2 = "fluence.cm2",
E.MeV.u = "E.mid.MeV.u",
particle.no = "particle.no"),
additional.arguments = list( c("material.no",
"1",
FALSE), # Water
c("stopping.power.source.no",
"0", FALSE)), # PSTAR
names.results = "D.Gy")
xyplot( D.Gy ~ depth.g.cm2,
df2,
type = "o",
col = "red",
grid = TRUE,
ylab = "dose / Gy",
xlab = "depth / (g/cm2)")
# Compute and plot the dose with depth, but differentiate contribution
# from individual particle species
# Also: use nicer (human-readable) code for material
df3 <- AT.SPC.tapply( spc = spc,
INDEX = c("depth.g.cm2", "particle.name"),
FUN = AT.total.D.Gy,
additional.arguments = list(c("material.no",
"AT.material.no.from.material.name('Water,
Liquid')",
FALSE),
c("stopping.power.source.no",
"0",
FALSE)),
names.results = "D.Gy")
xyplot( log10(D.Gy) ~ depth.g.cm2,
df3,
groups = particle.name,
type = 'o',
grid = TRUE,
auto.key = list(space = 'right'),
ylab = "log10( dose per primary / Gy )",
xlab = 'depth / (g/cm2)')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.