Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
3d-cqed-analytical/main.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
73 lines (57 sloc)
3.2 KB
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
# ---------------------------------------------------------------------- | |
# MAIN PROGRAM - generated by the Rappture Builder | |
# ---------------------------------------------------------------------- | |
import Rappture | |
from Rappture import RPENC_B64, RPENC_ZB64 | |
import sys | |
import numpy as np | |
import visualization as vis | |
from Rappture.encoding import encode, decode | |
# uncomment these to redirect stdout and stderr | |
# to files for debugging. | |
#sys.stderr = open('debug.err', 'w') | |
#sys.stdout = open('debug.out', 'w') | |
# open the XML file containing the run parameters | |
io = Rappture.PyXml(sys.argv[1]) | |
######################################################### | |
# Get input values from Rappture | |
######################################################### | |
# get input value for input.phase(cavityInput).group(cavityDim).number(cavityX) and convert to m | |
str = io['input.phase(cavityInput).group(cavityDim).number(cavityX).current'].value | |
cavityX = Rappture.Units.convert(str, to="m", units="off") | |
# get input value for input.phase(cavityInput).group(cavityDim).number(cavityY) and convert to m | |
str = io['input.phase(cavityInput).group(cavityDim).number(cavityY).current'].value | |
cavityY = Rappture.Units.convert(str, to="m", units="off") | |
# get input value for input.phase(cavityInput).group(cavityDim).number(cavityZ) and convert to m | |
str = io['input.phase(cavityInput).group(cavityDim).number(cavityZ).current'].value | |
cavityZ = Rappture.Units.convert(str, to="m", units="off") | |
# getting transmon input and parsing that | |
str = io['input.phase(cavityInput).choice(transmonNum)'].value | |
num_transmons = int(str) | |
transmon_locs = np.zeros((num_transmons, 6)) | |
# this is a pretty ugly way to do this, but it should work | |
command_str_pt1 = 'input.phase(transmonInput).group(transmonContainer).group(transmon' | |
command_str_pt2 = ').number(transmon' | |
for i in range(num_transmons): | |
command_str = command_str_pt1 + str(i+1) + command_str_pt2 + str(i+1) | |
transmon_locs[i][0] = Rappture.Units.convert(io[command_str + 'x)'].value, to="m", units="off") | |
transmon_locs[i][1] = Rappture.Units.convert(io[command_str + 'y)'].value, to="m", units="off") | |
transmon_locs[i][2] = Rappture.Units.convert(io[command_str + 'z)'].value, to="m", units="off") | |
transmon_locs[i][3] = Rappture.Units.convert(io[command_str + 'theta)'].value, to="m", units="off") | |
transmon_locs[i][4] = Rappture.Units.convert(io[command_str + 'phi)'].value, to="m", units="off") | |
transmon_locs[i][5] = Rappture.Units.convert(io[command_str + 'length)'].value, to="m", units="off") | |
######################################################### | |
# Add your code here for the main body of your program | |
######################################################### | |
# spit out progress messages as you go along... | |
# Rappture.Utils.progress(0, "Starting...") | |
# Rappture.Utils.progress(5, "Loading data...") | |
#vis.cavity_vis(cavityX, cavityY, cavityZ, transmon_locs) | |
#io['output.image(cavityVis).current'] = encode(open('test_cavity_img.jpg').read(), RPENC_ZB64) | |
# Rappture.Utils.progress(50, "Half-way there") | |
# Rappture.Utils.progress(100, "Done") | |
######################################################### | |
# Save output values back to Rappture | |
######################################################### | |
io.close() | |
sys.exit() |