Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
21 changes: 21 additions & 0 deletions R/profuseMultiBand.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ profuseMultiBandFound2Fit = function(image_list,
star_con_fit = TRUE,
star_circ = TRUE,
tightcrop = TRUE,
offset_list = NULL,
wave = NULL,
smooth.parm = NULL,
parm_ProSpect = NULL,
Expand All @@ -48,6 +49,25 @@ profuseMultiBandFound2Fit = function(image_list,
magzero = rep(magzero, Nim)
}

if(is.null(offset_list)){
offset_list = vector("list", Nim)
}else{
if(!is.list(offset_list)){
stop("offset_list must be a list when provided.")
}
if(length(offset_list) == 1){
offset_list = rep(list(offset_list[[1]]), Nim)
}
if(length(offset_list) != Nim){
stop("offset_list must be NULL, length 1, or the same length as image_list.")
}
for(i in 1:Nim){
if(!is.null(offset_list[[i]]) && (!is.numeric(offset_list[[i]]) || length(offset_list[[i]]) != 2)){
stop("Each non-NULL offset_list element must be a numeric [X,Y] vector of length 2.")
}
}
}

for(i in 1:Nim){
if(autoclip){
image_med = median(image_list[[i]], na.rm=TRUE)
Expand Down Expand Up @@ -267,6 +287,7 @@ profuseMultiBandFound2Fit = function(image_list,
magzero = magzero[i],
algo.func = 'LD',
verbose = FALSE,
offset = offset_list[[i]],
rough = fit_rough,
nbenchconv = nbenchconv
)
Expand Down
13 changes: 8 additions & 5 deletions man/profuseMultiBand.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ profuseMultiBandFound2Fit(image_list, segim_list = NULL, segim_global = NULL,
Ncomp = 2, loc = NULL, cutbox = NULL, psf_list = NULL, nbenchconv = 0L, magdiff = 2.5,
magzero = NULL, gain = NULL, resamp = NULL, doprofit = NULL, sing_nser = 2,
bulge_nser = 4, disk_nser = 1, sing_nser_fit = TRUE, bulge_nser_fit = FALSE,
disk_nser_fit = FALSE, bulge_circ = TRUE, nser_upper = 5.3, star_rough = TRUE,
fit_rough = FALSE, psf_dim = c(51, 51), star_con = 2, star_con_fit = TRUE,
star_circ = TRUE, tightcrop = TRUE, wave = NULL, smooth.parm = NULL,
parm_ProSpect = NULL, data_ProSpect = NULL, logged_ProSpect = NULL,
intervals_ProSpect = NULL, autoclip = TRUE, roughpedestal = TRUE, ...)
disk_nser_fit = FALSE, bulge_circ = TRUE, nser_upper = 5.3, star_rough = TRUE,
fit_rough = FALSE, psf_dim = c(51, 51), star_con = 2, star_con_fit = TRUE,
star_circ = TRUE, tightcrop = TRUE, offset_list = NULL, wave = NULL, smooth.parm = NULL,
parm_ProSpect = NULL, data_ProSpect = NULL, logged_ProSpect = NULL,
intervals_ProSpect = NULL, autoclip = TRUE, roughpedestal = TRUE, ...)

profuseMultiBandDoFit(image_list, MF2F = NULL, parm_global = c("sersic.xcen1",
"sersic.ycen1", "sersic.re1", "sersic.ang2", "sersic.axrat2"), Ncomp = 2,
Expand Down Expand Up @@ -123,6 +123,9 @@ Logical; optional, should the star be forced to be circular? If TRUE this means
}
\item{tightcrop}{
Logical; optional, should the image be cut down to the tightest fitting box that fully contains the segmentation map? This might be a good idea if the parent image is very large (cuts down on memory allocation etc), but might be a bad idea if you want to know the exact position of your source with the frame, e.g. \option{xcen} and \option{ycen} in the \option{modellist} are relative to the new tightly cropped image not the original cropped image.
}
\item{offset_list}{
List; optional, per-band offsets to pass into \code{\link{profitSetupData}} \option{offset}. This can be used to track known [X,Y] positional shifts between images so a shared physical model is correctly projected into each band. If NULL (default) then no offsets are used. If length 1 it is recycled to all bands. Otherwise, \option{offset_list} must have the same length as \option{image_list}. Each non-NULL element should be a numeric [X,Y] vector of length 2.
}
\item{wave}{
Numeric vector; optional. This is only relevant if you are providing smoothing functions via \option{smooth.parm}. If provided it should be the wavelength of each image in \option{image_list}, where \option{image_list} then needs to be in ascending (blue to red) wavelength order.
Expand Down
2 changes: 1 addition & 1 deletion vignettes/ProFuse-Multi-Images.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ HighFit2$parm

## Fully Automatic Multi-band Fitting

**ProFit** v2.0.0 and upwards support highly automated multi-band fitting via the **profuseMultiBandFound2Fit** and **profuseMultiBandDoFit** functions. These require the images provided to be exactly registered and cropped to the desired level (no offset or cut out options here). If this is not the case, then lower level functions (i.e. those above) probably need to be used instead. These functions will find stars and create per band PSFs automatically, so they might well cover the major use cases for many people.
**ProFit** v2.0.0 and upwards support highly automated multi-band fitting via the **profuseMultiBandFound2Fit** and **profuseMultiBandDoFit** functions. These require images to be cropped to the desired level, and now support per-band positional offsets via `offset_list` when required. If your data still need more complex registration/cutout handling than this, then lower level functions (i.e. those above) probably need to be used instead. These functions will find stars and create per band PSFs automatically, so they might well cover the major use cases for many people.

As an example we can load in 9 bands of data that come included in the **ProFound** package, and cut out around a bright spiral galaxy:

Expand Down
Loading