Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Conversation

corybrunson
Copy link
Contributor

Occasionally i become uncertain about what my covers are actually doing, and it's takes a while to inspect them via .$interval_bounds() and .$level_sets, for example. It seems natural to want some methods to quickly visualize a cover, with or without the lensed data overlaid. These methods aren't very elegant, but they can very quickly reveal problems with a cover that cause unexpected and otherwise opaque problems for the nerve construction. What do you think? (I've only written a method for FixedIntervalCover.) I ran the following chunks after installing the current version of this inspect branch:

library(Mapper)

# data: uniform sample from the 2-sphere
s2 <- array(stats::rnorm(720 * (2 + 1)), dim = c(720, 2 + 1))
van <- which(apply(s2, 1, norm, "2") == 0)
for (i in van) {
  while (norm(s2[i, ], "2") == 0) {
    s2[i, ] <- stats::rnorm(2 + 1)
  }
}
s2 <- sweep(s2, 1, apply(s2, 1, norm, "2"), FUN = "/")
# data: initialize mapper
m <- MapperRef$new(X = s2)

# lens: project to the first coordinate
f_s2 <- s2[, 1, drop = FALSE]
m$filter <- f_s2
# cover: 5 fixed-length intervals with 50% overlap
c_s2 <- FixedIntervalCover$new(number_intervals = 5, percent_overlap = 50)
c_s2$construct_cover(filter = m$filter)
m$cover <- c_s2
hist(m$filter(), xlim = c(-1.2, 1.2))
m$cover$plot(m$filter, add=TRUE, lwd=2)

# lens: project to the first two coordinates
f_s2 <- s2[, 1:2]
m$filter <- f_s2
# cover: 5-by-5 fixed-length intervals with 40% overlap
c_s2 <- FixedIntervalCover$new(number_intervals = 5, percent_overlap = 40)
c_s2$construct_cover(filter = m$filter)
m$cover <- c_s2
m$cover$plot(m$filter, border = "#00000077")

plot(f_s2, pch = 19, cex = .5)
m$cover$plot(m$filter, border = "#00000077", index = "(3 4)", add = TRUE)

Created on 2019-08-11 by the reprex package (v0.2.1)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant