-
Notifications
You must be signed in to change notification settings - Fork 8
/
apply_CosmicRayRemoval.Rd
131 lines (113 loc) · 5.43 KB
/
apply_CosmicRayRemoval.Rd
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/apply_CosmicRayRemoval.R
\name{apply_CosmicRayRemoval}
\alias{apply_CosmicRayRemoval}
\title{Function to remove cosmic rays from an RLum.Data.Spectrum S4 class object}
\usage{
apply_CosmicRayRemoval(
object,
method = "smooth",
method.Pych.smoothing = 2,
method.Pych.threshold_factor = 3,
MARGIN = 2,
verbose = FALSE,
plot = FALSE,
...
)
}
\arguments{
\item{object}{\linkS4class{RLum.Data.Spectrum} or \linkS4class{RLum.Analysis} (\strong{required}): input
object to be treated. This can be also provided as \link{list}. If an \linkS4class{RLum.Analysis} object
is provided, only the \linkS4class{RLum.Data.Spectrum} objects are treated. Please note: this mixing of
objects does not work for a list of \code{RLum.Data} objects.}
\item{method}{\link{character} (\emph{with default}):
Defines method that is applied for cosmic ray removal. Allowed methods are
\code{smooth}, the default, (\link[stats:smooth]{stats::smooth}), \code{smooth.spline} (\link[stats:smooth.spline]{stats::smooth.spline}),
\code{smooth_RLum} \link{smooth_RLum} and \code{Pych}. See details for further information.}
\item{method.Pych.smoothing}{\link{integer} (\emph{with default}):
Smoothing parameter for cosmic ray removal according to Pych (2003).
The value defines how many neighbouring values in each frame are used for smoothing
(e.g., \code{2} means that the two previous and two following values are used).}
\item{method.Pych.threshold_factor}{\link{numeric} (\emph{with default}):
Threshold for zero-bins in the histogram. Small values mean that more peaks
are removed, but signal might be also affected by this removal.}
\item{MARGIN}{\link{integer} (\emph{with default}):
on which part the function cosmic ray removal should be applied on:
\itemize{
\item 1 = along the time axis (line by line),
\item 2 = along the wavelength axis (column by column).
}
\strong{Note:} This argument currently only affects the methods \code{smooth} and \code{smooth.spline}}
\item{verbose}{\link{logical} (\emph{with default}):
Option to suppress terminal output.,}
\item{plot}{\link{logical} (\emph{with default}):
If \code{TRUE} the histograms used for the cosmic-ray removal are returned as plot
including the used threshold. Note: A separate plot is returned for each frame!
Currently only for \code{method = "Pych"} a graphical output is provided.}
\item{...}{further arguments and graphical parameters that will be passed
to the \link[stats:smooth]{stats::smooth}, \link[stats:smooth.spline]{stats::smooth.spline} or \link{smooth_RLum}. See details for more
information.}
}
\value{
Returns same object as input.
}
\description{
The function provides several methods for cosmic-ray removal and spectrum
smoothing \linkS4class{RLum.Data.Spectrum} objects and such objects embedded in \link{list} or
\linkS4class{RLum.Analysis} objects.
}
\details{
\strong{\code{method = "Pych"}}
This method applies the cosmic-ray removal algorithm described by Pych
(2003). Some aspects that are different to the publication:
\itemize{
\item For interpolation between neighbouring values the median and not the mean is used.
\item The number of breaks to construct the histogram is set to: \code{length(number.of.input.values)/2}
}
For further details see references below.
\strong{Other methods}
Arguments supported through \code{...}
\tabular{llll}{
METHOD \tab ARGUMENT \tab TYPE \tab REMARKS\cr
\code{"smooth"} \tab \code{kind} \tab \link{character} \tab see \link[stats:smooth]{stats::smooth} \cr
\tab \code{twiceit} \tab \link{logical} \tab see \link[stats:smooth]{stats::smooth} \cr
\code{"smooth.spline"} \tab \code{spar} \tab \link{numeric} \tab see \link[stats:smooth.spline]{stats::smooth.spline} \cr
\code{"smooth_RLum"} \tab \code{k} \tab \link{numeric} \tab see \link{smooth_RLum}\cr
\tab \code{fill} \tab \link{numeric} \tab see \link{smooth_RLum}\cr
\tab \code{align} \tab \link{character} \tab see \link{smooth_RLum}\cr
\tab \code{method} \tab \link{character} \tab see \link{smooth_RLum}\cr
}
\strong{Best practice}
There is no single silver-bullet-strategy for the cosmic-ray removal, because it depends
on the characteristic of the detector and the chosen settings. For instance,
high values for pixel binning will improve the light output, but also causes
multiple pixels being affected a single cosmic-ray. The same is valid for
longer integration times. The best strategy is to combine methods and ensure
that the spectrum is not distorted on a case-to-case basis.
\strong{How to combine methods?}
Different methods can be combined by applying the method repeatedly to the
dataset (see example).
}
\section{Function version}{
0.4.0
}
\examples{
##(1) - use with your own data and combine (uncomment for usage)
## run two times the default method and smooth with another method
## your.spectrum <- apply_CosmicRayRemoval(your.spectrum, method = "Pych")
## your.spectrum <- apply_CosmicRayRemoval(your.spectrum, method = "Pych")
## your.spectrum <- apply_CosmicRayRemoval(your.spectrum, method = "smooth")
}
\references{
Pych, W., 2004. A Fast Algorithm for Cosmic-Ray Removal from
Single Images. The Astronomical Society of the Pacific 116 (816), 148-153.
\doi{10.1086/381786}
}
\seealso{
\linkS4class{RLum.Data.Spectrum}, \linkS4class{RLum.Analysis}, \link[stats:smooth]{stats::smooth}, \link[stats:smooth.spline]{stats::smooth.spline},
\link{smooth_RLum}
}
\author{
Sebastian Kreutzer, Institute of Geography, Heidelberg University (Germany)
}
\keyword{manip}