Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
847bff6
add magMWdust function, documentation, and lookup table
AngusWright Jun 4, 2026
987c0b0
remove unnecessary eq2gal function
AngusWright Jun 4, 2026
d78e856
remove reference to old code in documentation
AngusWright Jun 4, 2026
77597e9
add catch for empty data, and only display progress during interactiv…
AngusWright Jun 4, 2026
7125a27
check show.status with isTRUE()
AngusWright Jun 4, 2026
d1ef6ae
remove dust key in documentation
AngusWright Jun 4, 2026
c0fbebc
update magMWdust to use lazy-loaded SFD_dust lookup rather than direc…
AngusWright Jun 4, 2026
a828188
update documentation for new dust.data input
AngusWright Jun 4, 2026
f8d91f2
update documentation to descibe the lookup usage
AngusWright Jun 4, 2026
e66a7d1
update magMWdust function to require dlon and dlat when using bespoke…
AngusWright Jun 4, 2026
b9746f1
catch non-numeric dlon and dlat
AngusWright Jun 4, 2026
b0c2190
only require dlon and dlat when plotting polygons
AngusWright Jun 4, 2026
b468e78
remove borders from polygons, tweak defaults for nicer plotting
AngusWright Jun 4, 2026
718ad78
tweak default dlon dlat to reduce edge effects
AngusWright Jun 4, 2026
e9e7adc
update lookup documentation, now uses complete map
AngusWright Jun 4, 2026
5c2da7c
version update
AngusWright Jun 4, 2026
c548a49
update behaviour for latitudes beyond \pm 90 to reflect, rather than …
AngusWright Jun 4, 2026
cacfda4
update magMWdust to use correct default dlat/dlon
AngusWright Jun 4, 2026
15e52ef
remove outdated comment
AngusWright Jun 4, 2026
f183132
add SFD credit to authorship
AngusWright Jun 4, 2026
b7aea6a
move citation to references block in docs
AngusWright Jun 4, 2026
a1fa7a6
add label cex option to magproj
AngusWright Jun 5, 2026
f0359cb
add txtProgressBar to namespace imports for magMWdust
AngusWright Jul 2, 2026
a558a05
add alias to SFD_dust to manual for magMWdust
AngusWright Jul 2, 2026
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
44 changes: 44 additions & 0 deletions R/magMWdust.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#=========================================
#
# File Name : magMWdust.R
# Created By : awright
# Creation Date : 03-06-2026
# Last Modified : Wed Jun 3 13:40:13 2026
#
#=========================================


# Define a plotting helper that overlays Milky Way dust on a projected sky plot.
magMWdust <- function(type = "p", pch = 16, pt.cex = 0.5, opacity.range = c(0, 0.5), whiteblack.percentile = c(0.5, 0.95), stretch = "lin", min.opacity.plot = 0.01, ...) {

# Restrict the drawing style to points or polygons.
if (!type %in% c("pl", "p")) stop("magMWdust function expects type of 'p' (for points) or 'pl' (for polygons) only")
# Read the dust map data, which is a dlon=dlat=1 sampling
dlon <- dlat <- 1
dust_all<-read.csv(system.file("extdata","SFD_dust.csv", package = "magicaxis"))
# Map dust values onto an opacity scale for plotting.
dust_all$map <- magicaxis::magmap(dust_all$ebv, range = opacity.range, hicut = whiteblack.percentile[2], locut = whiteblack.percentile[1], stretch = stretch)$map
Comment thread
AngusWright marked this conversation as resolved.
Outdated
# Drop grid cells that would be too faint to plot usefully.
dust <- dust_all[which(dust_all$map > min.opacity.plot), ]

# Draw filled polygons when polygon mode has been requested.
if (type == "pl") {
# Open a progress bar for the per-cell polygon loop.
pb <- txtProgressBar(style = 3, min = 1, max = nrow(dust))
Comment thread
AngusWright marked this conversation as resolved.
Outdated
# Iterate over each retained sky cell.
for (i in 1:nrow(dust)) {
Comment thread
AngusWright marked this conversation as resolved.
Outdated
# Project and draw the four corners of the current sky cell.
magicaxis::magproj(c(dust$ra[i] - dlon/2, dust$ra[i] - dlon/2, dust$ra[i] + dlon/2, dust$ra[i] + dlon/2), c(dust$dec[i] - dlat/2, dust$dec[i] + dlat/2, dust$dec[i] + dlat/2, dust$dec[i] - dlat/2), type = type, add = TRUE, col = hsv(v = 0, alpha = dust$map[i]), ...)
# Advance the progress bar after drawing the current polygon.
setTxtProgressBar(pb, i)
}
Comment thread
AngusWright marked this conversation as resolved.
Outdated
# Close the progress bar when the polygon layer is complete.
close(pb)
Comment thread
AngusWright marked this conversation as resolved.
Outdated
} else {
# Draw the retained dust grid cells as projected points.
magicaxis::magproj(dust$ra, dust$dec, type = "p", add = TRUE, pch = pch, cex = pt.cex, col = hsv(v = 0, alpha = dust$map), ...)
}
# Return invisibly because this function is used for its plotting side effects.
return(invisible(NULL))
}

Loading