Skip to content

Instantly share code, notes, and snippets.

@andyfaff
Created March 10, 2024 02:09
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 andyfaff/fce6fc3fadbaf9633aa3d767412fbab5 to your computer and use it in GitHub Desktop.
Save andyfaff/fce6fc3fadbaf9633aa3d767412fbab5 to your computer and use it in GitHub Desktop.
wott
Function/S wottpy(r0, d0)
variable r0, d0
// Paths must be POSIX paths (using /).
// Paths containing spaces or other nonstandard characters
// must be single-quoted. See Apple Techical Note TN2065 for
// more on shell scripting via AppleScript.
string r0s, d0s
r0s = num2str(r0)
d0s = num2str(d0)
String cmd = ""
cmd += "source ~/.bash_profile\n"
cmd += "conda activate dev3\n"
cmd += "cd /Users/andrew/Documents/Andy/programming/refnx-testdata/data/reduce\n"
cmd += "python wott.py " + r0s + " " + d0s + "\n"
String igorCmd
sprintf igorCmd, "do shell script \"%s\"", cmd
// Print igorCmd // For debugging only
ExecuteScriptText/UNQ igorCmd
Print S_value // For debugging only
return S_value
End
import sys
import numpy as np
from refnx.reduce import PlatypusReduce
def wott(r0: int, d0: int):
r0 = f"PLP{r0:07d}.nx.hdf"
d0 = f"PLP{d0:07d}.nx.hdf"
d0 = PlatypusReduce(d0)
output = d0.reduce(r0)
actual = d0.omega_corrected[0][0]
nominal = d0.reflected_beam.cat.cat['omega'][0]
return actual, nominal
if __name__ == "__main__":
r0 = int(sys.argv[1])
d0 = int(sys.argv[2])
print(wott(r0, d0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment