Created
October 20, 2015 09:04
-
-
Save heinrichvk/0a6e6477ea2e9c1ef737 to your computer and use it in GitHub Desktop.
Here is a code snippet from the R script that we used to calculate the weighted average of brightness for given disks:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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