Skip to content

Instantly share code, notes, and snippets.

@heinrichvk
Created October 20, 2015 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heinrichvk/0a6e6477ea2e9c1ef737 to your computer and use it in GitHub Desktop.
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:
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