Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Here is a code snippet from the R script that we used to calculate the weighted average of brightness for given disks:
sum <- 0
total_weight <- 0
for (i in 1:length(pixels$x_shift)) {
x_shift <- pixels$x_shift[i]
y_shift <- pixels$y_shift[i]
coords <- get_lat_lon(x_0 + x_shift, y_0 + y_shift)
dist <- distGeo(c(lon_0, lat_0), c(coords[2], coords[1]))
weight <- cloud_base / (cloud_base^2 + dist^2)^(3/2)
sum <- sum + weight * matr[x_0 + x_shift, y_0 + y_shift]
total_weight <- total_weight + weight
return(sum / total_weight)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.