Last active
December 17, 2015 10:09
-
-
Save baptiste/5592168 to your computer and use it in GitHub Desktop.
R wrapper for adda runs
This file contains hidden or 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
| adda_spectrum = function(shape = "ellipsoid", | |
| dimensions = c(1,1), | |
| lambda = 0.5, | |
| radius = 0.100, | |
| m = 1.5 + 0.2i , | |
| medium.index = 1.46, | |
| dpl = ceiling(10 * abs(m)), | |
| test = TRUE) { | |
| command <-paste("echo ./adda -shape ", shape, dimensions[1], dimensions[2], | |
| "-lambda ", lambda / medium.index , | |
| "-dpl ", dpl, | |
| "-size ", 2 * radius, | |
| "-m ", Re(m) / medium.index , | |
| Im(m) / medium.index ) | |
| message("dpl = ", dpl) | |
| message(system(command, intern=TRUE)) | |
| if(test) return() # don't actually run the command | |
| # extract the results of interest | |
| resultadda <- system(paste(command, "| bash"), intern = TRUE) | |
| Cext <- as.numeric(unlist(strsplit(grep("Cext",resultadda,val=T)[1:2],s="="))[c(2,4)]) | |
| Cabs <- as.numeric(unlist(strsplit(grep("Cabs",resultadda,val=T)[1:2],s="="))[c(2,4)]) | |
| Csca <- Cext - Cabs | |
| c(Cext[1], Cext[2], Cabs[1], Cabs[2], Csca[1], Csca[2]) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment