Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions R/magband.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,6 @@
return = temp
}

".Last.magroj"<-
local({
val <- list(
projection = "",
parameters = NULL,
orientation = NULL,
centre = NULL,
longlim = NULL,
latlim = NULL
)
function(new) if(!missing(new)) val <<- new else val
})

magband=function(crosseq = 0, peaklat = 0, width=10, res=1000, ...){
longlo=.Last.magproj()$longlim[1]
Expand Down
41 changes: 16 additions & 25 deletions R/magbin.R
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
tempambig = output$nn.idx[distorder]
remdupe = duplicated(tempambig, incomparables=NA)
output$nn.idx[distorder][remdupe] = NA
output$output$nn.dists[distorder][remdupe] = NA
output$nn.dists[distorder][remdupe] = NA

# if(exactcount){
# if(shape=='hex' | shape=='hexagon'){
Expand Down Expand Up @@ -356,30 +356,21 @@ plot.magbin = function(x, colramp=hcl.colors(21), colstretch='lin', sizestretch=
ParmOff(magplot, c(list(NA, NA, xlim=xlim, ylim=ylim), dots))
}
}
#magplot(NA, NA, xlim=x$xlim, ylim=x$ylim, ...)
for(i in 1:dim(x$bins)[1]){
if(!is.na(colmap$map[i])){
if(is.na(x$dustlim)){
if(x$shape=='hex' | x$shape=='hexagon'){
.drawhex(x$bins[i,'x'], x$bins[i,'y'], unitcell=x$step*sizemap[i], col=colramp[colmap$map[i]], border=NA, direction=x$direction)
}
if(x$shape=='sq' | x$shape=='square'){
.drawsquare(x$bins[i,'x'], x$bins[i,'y'], unitcell=x$step*sizemap[i], col=colramp[colmap$map[i]], border=NA)
}
if(x$shape=='tri' | x$shape=='triangle' | x$shape=='trihex'){
.drawtriangle(x$bins[i,'x'], x$bins[i,'y'], unitcell=x$step*sizemap[i], col=colramp[colmap$map[i]], border=NA, type=x$bins[i,'type'], direction=x$direction)
}
}else if(x$bins[i,'count'] > x$dustlim){
if(x$shape=='hex' | x$shape=='hexagon'){
.drawhex(x$bins[i,'x'], x$bins[i,'y'], unitcell=x$step*sizemap[i], col=colramp[colmap$map[i]], border=NA, direction=x$direction)
}
if(x$shape=='sq' | x$shape=='square'){
.drawsquare(x$bins[i,'x'], x$bins[i,'y'], unitcell=x$step*sizemap[i], col=colramp[colmap$map[i]], border=NA)
}
if(x$shape=='tri' | x$shape=='triangle' | x$shape=='trihex'){
.drawtriangle(x$bins[i,'x'], x$bins[i,'y'], unitcell=x$step*sizemap[i], col=colramp[colmap$map[i]], border=NA, type=x$bins[i,'type'], direction=x$direction)
}
}
# Determine the drawing function once outside the loop (shape is constant).
# After the dustlim filter above, all remaining bins already satisfy count > dustlim,
# so we only need to skip bins where the colour map produced NA.
draw_bins <- which(!is.na(colmap$map))
if(x$shape == 'hex' | x$shape == 'hexagon'){
for(i in draw_bins){
.drawhex(x$bins[i,'x'], x$bins[i,'y'], unitcell=x$step*sizemap[i], col=colramp[colmap$map[i]], border=NA, direction=x$direction)
}
}else if(x$shape == 'sq' | x$shape == 'square'){
for(i in draw_bins){
.drawsquare(x$bins[i,'x'], x$bins[i,'y'], unitcell=x$step*sizemap[i], col=colramp[colmap$map[i]], border=NA)
}
}else if(x$shape == 'tri' | x$shape == 'triangle' | x$shape == 'trihex'){
for(i in draw_bins){
.drawtriangle(x$bins[i,'x'], x$bins[i,'y'], unitcell=x$step*sizemap[i], col=colramp[colmap$map[i]], border=NA, type=x$bins[i,'type'], direction=x$direction)
}
}
if(!is.null(x$dust)){
Expand Down
2 changes: 1 addition & 1 deletion R/magmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ magmap = function( data,
} else if (type == 'rank') {
locut = 1
hicut = length(data[good])
data[good][order(data[good])] = locut:hicut
data[good] <- rank(data[good], ties.method = 'average')
} else{
stop(type, ' is not a valid type option!')
}
Expand Down
12 changes: 6 additions & 6 deletions man/magclip.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Magical sigma clipping
}
\description{
This function does intelligent autoamtic sigma-clipping of data. This is optionally used by \code{\link{magplot}} and \code{\link{maghist}}.
This function does intelligent automatic sigma-clipping of data. This is optionally used by \code{\link{magplot}} and \code{\link{maghist}}.
}
\usage{
magclip(x, sigma = 'auto', clipiters = 5, sigmasel = 1, estimate = 'both', extra = TRUE)
Expand All @@ -19,7 +19,7 @@ Numeric; the values to be clipped. This can reasonably be a vector, a matrix or
The level of sigma clipping to be done. If set to default of 'auto' it will dynamically choose a sigma level to cut at based on the length of x (or the clipped version once iterations have started), i.e.: sigma=qnorm(1-2/length(x)). This have the effect of removing unlikely values based on the chance of them occurring, i.e. there is roughly a 50\% chance of a 3.5 / 4.6 sigma Normal fluctuation occurring when you have 10,000 / 10,000,000 values, hence choosing this value dynamically is usually the best option.
}
\item{clipiters}{
The maximum number of sigma clipping iterations to attempt. It will break out sooner than this if the iterations have converged. The default of 5 is usually plenty (up to the contamination being towards the 50\% level). The number of actual iterations is returns as \option{clipiters}.
The maximum number of sigma clipping iterations to attempt. It will break out sooner than this if the iterations have converged. The default of 5 is usually plenty (up to the contamination being towards the 50\% level). The number of actual iterations is returned as \option{clipiters}.
}
\item{sigmasel}{
The quantile to use when trying to estimate the true standard-deviation of the Normal distribution. if contamination is low then the default of 1 is about optimal in terms of S/N, but you might need to make the value lower when contamination is very high.
Expand All @@ -28,17 +28,17 @@ The quantile to use when trying to estimate the true standard-deviation of the N
Character; determines which side/s of the distribution are used to estimate Normal properties. The default is to use both sides (both) giving better S/N, but if you know that your contamination only comes from positive flux sources (e.g., astronomical data when trying to select sky pixels) then you should only use the lower side to determine Normal statistics (lo). Similarly if the contamination is on the low side then you should use the higher side to determine Normal statistics (hi).
}
\item{extra}{
Logical; if TRUE then \option{clip} and \option{range} are computed and returns, else these are set to NA to reduce computation and memory.
Logical; if TRUE then \option{clip} and \option{range} are computed and returned, else these are set to NA to reduce computation and memory.
}
}
\details{
If you know more sepcific details about your data then you should probably carry out a thorough likelihood analysis, but the ad-hoc clipping done in \code{magclip} works pretty well in practice.
If you know more specific details about your data then you should probably carry out a thorough likelihood analysis, but the ad-hoc clipping done in \code{magclip} works pretty well in practice.
}
\value{
A list containing three items:

\item{x}{Numeric vector; the cliped \option{x} values.}
\item{clip}{Locial; logic of which values were clipped with the same type and shape attributes as the input \option{x} (i.e. if the original \option{x} was a matrix then \option{clip} would also be a matrix that matches element to element).}
\item{x}{Numeric vector; the clipped \option{x} values.}
\item{clip}{Logical; logic of which values were clipped with the same type and shape attributes as the input \option{x} (i.e. if the original \option{x} was a matrix then \option{clip} would also be a matrix that matches element to element).}
\item{range}{The data range of clipped \option{x} values returned.}
\item{clipiters}{The number of iterations made, which might be less than the input \option{clipiters} since it might converge faster.}
}
Expand Down
2 changes: 1 addition & 1 deletion man/magmap.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Value remapper
}
\description{
This function allows the use to remap a vector of values onto a different system. For instance you might have values stretching from -10 to 100 which you want mapped from 0 to 2/3 so you can then sue the output as an input for point colour or size. It allows clipping of values, rejection of bad values, and log stretching.
This function allows the use to remap a vector of values onto a different system. For instance you might have values stretching from -10 to 100 which you want mapped from 0 to 2/3 so you can then use the output as an input for point colour or size. It allows clipping of values, rejection of bad values, and log stretching.
}
\usage{
magmap(data, locut = 0, hicut = 1, flip = FALSE, range = c(0, 2/3), type = "quan",
Expand Down
4 changes: 2 additions & 2 deletions man/magrun.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ The standard deviations in the x bins. This is a two column data.frame if 'diff'
\item{ysd}{
The standard deviations in the y bins. This is a two column data.frame if 'diff' is set to FALSE, giving the y-sd and y+sd values, or a single vector if 'diff' is set to TRUE. If Nscale is set to TRUE then this is also divided by sqrt the contributing objects in each bin.
}
\item{bincen}{
\item{bincens}{
The bin centres used in the chosen binning direction.
}
\item{binlim}{
\item{binlims}{
The bin limits used in the chosen binning direction.
}
\item{Nbins}{
Expand Down
Loading
Loading