def writePulse(self): '''Write data to files''' numpy.savetxt("data/pulse/time.txt", convert(self.t, ARU_TO_FEMTO)) numpy.savetxt("data/pulse/freq.txt", convert(scipy.fftpack.fftshift(self.omega), ARU_TO_EV)) numpy.savetxt("data/pulse/efield.txt", self.efield) numpy.savetxt("data/pulse/Efield.txt", scipy.fftpack.fftshift(self.Efield)) # print numpy.abs(self.intAC).max() numpy.savetxt("data/pulse/IntAC.txt", self.intAC / self.intAC.max()) temp = pow(abs(self.Efield), 2.0) numpy.savetxt("data/pulse/Efield_intensity.txt", scipy.fftpack.fftshift(temp)) numpy.savetxt("data/pulse/Efield_phase.txt", scipy.fftpack.fftshift(numpy.unwrap(self.Efield_phase))) numpy.savetxt("data/pulse/phase.txt", scipy.fftpack.fftshift(self.phase_mask)) numpy.savetxt("data/pulse/intensity.txt", self.intensity / self.intensity.max()) numpy.savetxt("data/pulse/rabi_freq.txt", 1000.0 * convert(self.rabi_freq, ARU_TO_EV), header='Time dependence of Rabi Frequency (meV)') # print self.detuning,"and",self.rabi_freq numpy.savetxt("data/pulse/detuning.txt", 1000 * convert(self.inst_freq - self.omega_o, ARU_TO_EV), header='Time dependence of detuning (meV)')
def data(self): pulse_data = {"time": convert(self.t, ARU_TO_FEMTO), \ "efield": convert(self.efield, ARU_TO_ELEC), \ "freq": convert(scipy.fftpack.fftshift(self.omega), ARU_TO_EV), \ "Efield": scipy.fftpack.fftshift(self.Efield), \ "intensity": self.intensity/self.intensity.max(), \ "AmpMask": scipy.fftpack.fftshift(self.amp_mask), \ "PhaseMask": scipy.fftpack.fftshift(self.phase_mask)} return pulse_data
def plotIntEfield(self): temp = pow(scipy.fftpack.fftshift(abs(self.Efield)), 2.0) temp = temp / max(temp) plt.plot(convert(scipy.fftpack.fftshift(self.omega), ARU_TO_EV), temp) plt.xlabel('$\hbar\omega$ (eV)') plt.ylabel('$|E(\omega)|^2$') plt.grid(True) plt.xlim( convert(self.omega_o, ARU_TO_EV) - 0.05, convert(self.omega_o, ARU_TO_EV) + 0.05)
def __init__(self, params): self.t_start = params['run_params'].run_t_start self.t_end = params['run_params'].run_t_end self.t_step = params['run_params'].run_t_step # desired time step self.array_len = int((convert(self.t_end, ARU_TO_FEMTO) - convert(self.t_start, ARU_TO_FEMTO)) / convert(self.t_step, ARU_TO_FEMTO)) self.shape = params['pulse_params'].pulse_shape self.chirp = params['pulse_params'].pulse_chirp self.tau = params['pulse_params'].pulse_width self.t_o = params['pulse_params'].pulse_delay self.E_o = params['pulse_params'].pulse_EO self.omega_o = params['pulse_params'].pulse_omega_o self.dipole = params['pulse_params'].pulse_dipole self.phase = params['pulse_params'].pulse_phase self.t = numpy.linspace(self.t_start, self.t_end, self.array_len, endpoint=False) # time array self.omega = 2.0 * PI * scipy.fftpack.fftfreq( self.array_len, d=self.t_step) # (angular) frequency array self.efield = numpy.zeros((self.array_len), 'complex') # time domain electric field self.Efield = numpy.zeros((self.array_len), 'complex') # frequency domain electric field self.intensity = numpy.zeros( self.array_len) # temporal intensity of pulse self.inst_freq = numpy.zeros( self.array_len) # temporal intensity of pulse self.rabi_freq = numpy.zeros( self.array_len) # temporal intensity of pulse self.E_freq = numpy.zeros((self.array_len), 'complex') # frequency domain electric field self.efield_envelope = numpy.zeros( self.array_len) # temporal envelope of electric field abs(efield) self.intAC = numpy.zeros(self.array_len) # intensity autocorrelation # create amplitude mask array - must default to one self.amp_mask = numpy.ones(self.array_len) # create phase mask array - must default to zero self.phase_mask = numpy.zeros(self.array_len, dtype=complex) #self.beta = 1.76/convert(260.0, FEMTO_TO_ARU) self.beta = 1.76 / self.tau self.mu = 0.0 #2.0 self.phase = self.mu * numpy.log( numpy.cosh(self.beta * (self.t - self.t_o))) self.rwa = params['run_params'].run_rwa self.limit = 2.0 * sys.float_info.epsilon self.length = convert(self.tau, ARU_TO_FEMTO) self.delay_fs = convert(self.t_o, ARU_TO_FEMTO)
def plotEfieldPhase(self): plt.plot(convert(scipy.fftpack.fftshift(self.omega), ARU_TO_EV), scipy.fftpack.fftshift(numpy.unwrap(self.Efield_phase))) #plot(convert(scipy.fftpack.fftshift(self.omega), ARU_TO_EV), scipy.fftpack.fftshift(self.phase_mask)) plt.xlabel('$\hbar\omega$ (eV)') plt.ylabel('$\Phi(\omega)$ (radians)') plt.grid(True) plt.axis('tight') plt.xlim( convert(self.omega_o, ARU_TO_EV) - 0.05, convert(self.omega_o, ARU_TO_EV) + 0.05)
def main(): ## predefinition print("本工具可以自定义行列数,根据给定的行列生成A4大小 R x M 的单词卡片") row = input("输入行数:") col = input("输入列数:") source_path = "../data/" save_path = "../src/content/words/" tex_path = "../src/content/" cards_per_page = 6 words = load(source_path) convert(words, save_path) insert(row,col) return
def main(): ## predefinition print("本工具可以自定义行列数,根据给定的行列生成A4大小 R x M 的单词卡片") row = input("输入行数:") col = input("输入列数:") source_path = "../data/" save_path = "../src/content/words/" tex_path = "../src/content/" cards_per_page = 6 words = load(source_path) convert(words, save_path) insert(row, col) return
def buy_video_card(self, model, cur): self.update_money() if self.wallet[cur] < convert(video_card_info[model]['cost'], 'EUR', cur, rates): raise exceptions.TooExpensiveError( "video card '{0}' costs {1}{3}, but you have only {2}{3}". format( model, convert(video_card_info[model]['cost'], 'EUR', cur, rates), self.wallet[cur], cur)) self.wallet[cur] -= convert(video_card_info[model]['cost'], 'EUR', cur, rates) self.video_cards.append(model)
def plotIntensity(self): plt.plot(convert(self.t, ARU_TO_FEMTO), self.intensity / self.intensity.max()) plt.xlabel('time (fs)') plt.ylabel('intensity') plt.grid(True) plt.axis('tight')
def convert_aru(x, config_file, conversion): config = ConfigObj(config_file, configspec='configspec.ini') validator = Validator() result = config.validate(validator) # determine mask that is being used run_mask = config['run']['mask'] param_list = config['masks'][run_mask]['param_list'] NOPTS = len(param_list) x_convert = [] # convert parameters according to conversion factor for i in range(NOPTS): # read in conversion factor param_ARU = param_list[i] + '_ARU' if (conversion == TO_ARU): x_convert.append(config['masks'][run_mask][param_ARU][0]) elif (conversion == FROM_ARU): x_convert.append(config['masks'][run_mask][param_ARU][1]) else: "do nothing" # if conversion is from AREA (in fraction of PI) to ARU, pass extra kwargs if (x_convert[i] == AREA_TO_ARU or x_convert[i] == ARU_TO_AREA): dipole = config['pulse']['dipole'] width = config['pulse']['width'] shape = config['pulse']['shape'] kwargs = {'dipole_moment': dipole, 'pulse_width': width, 'pulse_shape': shape} else: kwargs = {} x[i] = convert(x[i], x_convert[i], **kwargs) return x
def execute(args): if not os.path.isfile(args.input): log.error("Path %s does not exist." % args.input) if (args.rows_per_tile and not args.cols_per_tile) or \ (args.cols_per_tile and not args.rows_per_tile): log.error('You must specifiy both --rows-per-tile and '\ '--cols-per-tile or neither') if args.data_type == 'bit': #TODO: Support bit types log.error('bit datatype not yet supported') convert(args.input, args.output, args.data_type, args.band, args.name, not args.no_verify, args.cols_per_tile, args.rows_per_tile, args.legacy, args.clobber)
def exchange(self, money, cur_1, cur_2): self.update_money() ret = convert(money, cur_1, cur_2, rates) self.wallet[cur_1] -= money self.wallet[cur_2] += ret
def __init__(self, defaultFile=None, *args, **kwargs): super(MDRenderWindow, self).__init__(*args, **kwargs) self.InitUI() if defaultFile: try: self.showMD(convert(open(defaultFile).read())) except: wx.MessageBox('The file wasn\'t found', 'Error', wx.OK | wx.ICON_ERROR)
def execute(args): if os.path.isfile(args.input): log.error("Path %s exists, but is a file." % args.input) if not os.path.isdir(args.input): log.error("Path %s does not exist." % args.input) if (args.rows_per_tile and not args.cols_per_tile) or \ (args.cols_per_tile and not args.rows_per_tile): log.error('You must specifiy both --rows-per-tile and '\ '--cols-per-tile or neither') if args.data_type == 'bit': #TODO: Support bit types log.error('bit datatype not yet supported') flist = os.listdir(args.input) if args.extension: flist = filter(lambda x: x.endswith(args.extension), flist) if not args.rows_per_tile: get_output = lambda f: os.path.join(args.output,os.path.splitext(f)[0] + '.arg') else: get_output = lambda f: args.output for f in flist: path = os.path.join(args.input,f) if not os.path.isfile(path): continue print "Converting %s" % (path) convert(path, get_output(f), args.data_type, args.band, args.name, not args.no_verify, args.cols_per_tile, args.rows_per_tile, args.legacy, args.clobber)
def home_eng(): if request.method == 'POST': # Delete old doc files and images docfilelist = os.listdir("docs/") for df in docfilelist: os.remove("docs/" + df) imfilelist = os.listdir("static/images/") for imf in imfilelist: os.remove("static/images/" + imf) # check if the post request has the file part file = request.files['file'] if file and allowed_file(file.filename): filename = secure_filename(file.filename) slide_path = os.path.join('slides', filename) file.save(slide_path) doc_file = filename.split('.')[0]+ '.docx' doc_path = os.path.join('docs', doc_file) convert(slide_path, doc_path) os.remove(slide_path) return redirect(url_for('converted_file', filename=doc_file)) return render_template('home_eng.html')
def change_crime(collection): '''converting districts to zipcodes''' final = [] count = 0 count2 = 0 for area in collection: d = {} if 'district' in area: district = area['district'] z_c = convert(district) d['zip_code'] = z_c final += [d] if district == 'A1': count += 1 else: count2 += 1 return final
def open(self, e): with wx.FileDialog(self, "Open Markdown File", wildcard="Markdown File (*.md)|*.md", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fileDialog: if fileDialog.ShowModal() == wx.ID_CANCEL: return # the user changed their mind # Proceed loading the file chosen by the user pathname = fileDialog.GetPath() try: with open(pathname, 'r') as file: self.showMD(convert(file.read())) except IOError: wx.LogError("Cannot open file '%s'." % newfile) wx.MessageBox('An Error Occured', 'Error', wx.OK | wx.ICON_ERROR)
def classify(IMAGE_PATH): # Convert the image to JPEG converted_image = convert(IMAGE_PATH) # Resize the image resized_image = resize(converted_image) # Read the input_image input_image = tf.gfile.FastGFile(resized_image, 'rb').read() # Load labels class_labels = [line.rstrip() for line in tf.gfile.GFile(LABELS)] #Load the trained model with tf.gfile.FastGFile(TRAINED_GRAPH, 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) _ = tf.import_graph_def(graph_def, name='') init = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init) # Feed the input_image to the graph and get the prediction softmax_tensor = sess.graph.get_tensor_by_name(FINAL_TENSOR_NAME + ':0') predictions = sess.run(softmax_tensor, {'DecodeJpeg/contents:0': input_image}) # Sort the labels of the prediction in order of confidence sorted_labels = predictions[0].argsort()[-len(predictions[0]):][::-1] print('Classification:') for index in sorted_labels: class_label = class_labels[index] percentage = predictions[0][index] * 100 print(('%s (%.2f' % (class_label, percentage)) + '%)')
def plotIntAC(self): plt.plot(convert(self.t, ARU_TO_FEMTO), self.intAC / self.intAC.max()) plt.xlabel('$t$ (fs)') plt.ylabel('IAC') plt.grid(True)
# create a new XML file with the results mydata = x.tostring(data) myfile = open("items2.xml", "wb+") myfile.write(mydata) # print(convert(AnnotationOutputFormat.TIKA_JSON,AnnotationOutputFormat.TIKA_XML,AnnotationOutputMode.OBJECT,a,"C:/Users/anvitha/Desktop/new")) # print(convert(AnnotationOutputFormat.TIKA_XML,AnnotationOutputFormat.TIKA_JSON,AnnotationOutputMode.OBJECT,data,)) #convert(AnnotationOutputFormat.TIKA_JSON,AnnotationOutputFormat.PASCALVOC_XML,AnnotationOutputMode.FILE,"C:/Users/anvitha/Downloads/Tika json/1b.json","C:/Users/anvitha/Downloads/Tika json") #convert(AnnotationOutputFormat.TIKA_JSON,AnnotationOutputFormat.TIKA_XML,AnnotationOutputMode.FILE,"C:/Users/anvitha/Downloads/Tika json/1b.json","C:/Users/anvitha/Downloads/Tika json") #convert(AnnotationOutputFormat.TIKA_JSON,AnnotationOutputFormat.YOLO_TXT,AnnotationOutputMode.FILE,"C:/Users/anvitha/Downloads/Tika json/1b.json","C:/Users/anvitha/Downloads/Tika json") #convert(AnnotationOutputFormat.TIKA_XML,AnnotationOutputFormat.TIKA_JSON,AnnotationOutputMode.FILE,"C:/Users/anvitha/Downloads/Tika xml/classify_sample.xml","C:/Users/anvitha/Downloads/Tika json") convert(AnnotationOutputFormat.TIKA_XML, AnnotationOutputFormat.TIKA_JSON, AnnotationOutputMode.FILE, "C:/Users/anvitha/Downloads/Tika json/horse_man.xml", "C:/Users/anvitha/Desktop") #convert(AnnotationOutputFormat.TIKA_XML,AnnotationOutputFormat.YOLO_TXT,AnnotationOutputMode.FILE,"C:/Users/anvitha/Downloads/Tika xml/classify_sample.xml","C:/Users/anvitha/Desktop") # Checking the object a = { "annotation": { "data_filename": "horse_man.jpg", "data_type": "image", "data_annotation": { "bounding_box": [{ "classification_label": "french onion soup", "point_2D": ["103,25", "158,156"] }, { "classification_label": "tv",
def sell_video_card(self, model, cur): self.update_money() self.wallet[cur] += convert(video_card_info[model]['cost'], 'EUR', cur, rates) self.video_cards.remove(model)
def eidkernel(params): if (params['laphnoneid_params'].read_kernel): print '\nReading LA Phonon EID Kernel from file...' Omega_eid = numpy.loadtxt('data/eid/Omega_eid.txt', delimiter=',', unpack=True, skiprows=1) K_real_eid = numpy.loadtxt('data/eid/K_real.txt', delimiter=',', unpack=True, skiprows=1) K_imag_eid = numpy.loadtxt('data/eid/K_imag.txt', delimiter=',', unpack=True, skiprows=1) Omega_eid = convert(Omega_eid, EV_TO_ARU) / 1000.0 # convert from meV to ARU K_real_eid = convert(K_real_eid, INV_PICO_TO_ARU) # convert from ps-1 to ARU K_imag_eid = convert(K_imag_eid, EV_TO_ARU) / 1000.0 # convert from meV to ARU ''' subplot(2,1,1) plot(1000.0*convert(Omega_eid, ARU_TO_EV), convert(K_real_eid, ARU_TO_INV_PICO), '-', label='K real') xlabel('Omega (meV)') ylabel('Re[$K(\hbar\Omega)$] (ps$^-1$)') subplot(2,1,2) plot(1000.0*convert(Omega_eid, ARU_TO_EV), 1000.0*convert(K_imag_eid, ARU_TO_EV), '-', label='K imag') xlabel('Rabi Energy $\hbar\Omega$ (meV)') ylabel('Im[$\hbar K(\hbar\Omega)$] (meV)') show() ''' params['laphnoneid_params'].Omega_eid = Omega_eid params['laphnoneid_params'].K_real_eid = K_real_eid params['laphnoneid_params'].K_imag_eid = K_imag_eid else: print '\nCalculating LA Phonon EID Kernel...' # eid parameters from config file omega_c_eid = params['laphnoneid_params'].omega_c_eid alpha_eid = params['laphnoneid_params'].alpha_eid Omega_start_eid = params['laphnoneid_params'].Omega_start_eid Omega_end_eid = params['laphnoneid_params'].Omega_end_eid Omega_step_eid = params['laphnoneid_params'].Omega_step_eid T_eid = params['laphnoneid_params'].T_eid t_start_eid = convert(0.0, FEMTO_TO_ARU) t_end_eid = convert(5000.0, FEMTO_TO_ARU) t_step_eid = convert(0.1, FEMTO_TO_ARU) t_array_len_eid = int((t_end_eid - t_start_eid) / t_step_eid) t_step_eid = (t_end_eid - t_start_eid) / t_array_len_eid t_eid = numpy.linspace(t_start_eid, t_end_eid, t_array_len_eid) def Kt_integrand(omega, t, T): return alpha_eid * omega**3 * numpy.exp( -(omega / omega_c_eid)**2) * numpy.cos(omega * t) / numpy.tanh( H_BAR_ARU * omega / (2.0 * KB_ARU * T_eid)) #return alpha_eid*omega**3*numpy.exp(-(omega/omega_c_eid)**2)*(1-(2/3.0)*pow(omega/omega_c_eid, 2.0)+(1/5.0)*pow(omega/omega_c_eid, 4.0))*numpy.cos(omega*t)/numpy.tanh(H_BAR_ARU*omega/(2.0*KB_ARU*T_eid)) #return alpha_eid*pow(omega, 3.0)*(numpy.exp(-pow(omega/omega_c_eid, 2.0))+0.5*numpy.exp(-pow(omega/(2.5*omega_c_eid), 2.0))-numpy.exp(-pow(omega/(omega_c_eid),2.0)*(1.313)))*numpy.cos(omega*t)/numpy.tanh(H_BAR_ARU*omega/(2.0*KB_ARU*T_eid)) def Kt(t, T): return integrate.quad(Kt_integrand, 0.0, 4.0 * omega_c_eid, args=(t, T_eid))[0] Kt = numpy.vectorize(Kt) Kt_t_T = Kt(t_eid, T_eid) array_len_eid = int((Omega_end_eid - Omega_start_eid) / Omega_step_eid) Omega_step_eid = (Omega_end_eid - Omega_start_eid) / array_len_eid Omega_eid = numpy.linspace(Omega_start_eid, Omega_end_eid, array_len_eid) def K_integrand_real(t, Omega, T): Kt = numpy.interp(t, t_eid, Kt_t_T) return numpy.cos(Omega * t) * Kt def K_integrand_imag(t, Omega, T): Kt = numpy.interp(t, t_eid, Kt_t_T) return numpy.sin(Omega * t) * Kt def K_real(Omega, T): #print convert(Omega, ARU_TO_EV) return integrate.quad(K_integrand_real, 0.0, t_end_eid, args=(Omega, T))[0] def K_imag(Omega, T): #print convert(Omega, ARU_TO_EV) return integrate.quad(K_integrand_imag, 0.0, t_end_eid, args=(Omega, T))[0] K_real = numpy.vectorize(K_real) K_imag = numpy.vectorize(K_imag) K_real_eid = K_real(Omega_eid, T_eid) K_imag_eid = K_imag(Omega_eid, T_eid) #alpha = convert(0.0272, PICO2_TO_ARU) #K_real_eid = (PI/2.0)*alpha*pow(Omega_eid, 3.0)*numpy.exp(-pow(Omega_eid/omega_c_eid, 2.0))/numpy.tanh(Omega_eid/(2.0*KB_ARU*T_eid)) print '...calculation complete.' numpy.savetxt('data/eid/Omega_eid.txt', numpy.transpose(1000.0 * convert(Omega_eid, ARU_TO_EV)), delimiter=',', header='hbar Omega (meV)') numpy.savetxt('data/eid/K_real.txt', numpy.transpose(convert(K_real_eid, ARU_TO_INV_PICO)), delimiter=',', header='Re[K(hbar Omega)] (ps-1)') numpy.savetxt('data/eid/K_imag.txt', numpy.transpose(1000.0 * convert(K_imag_eid, ARU_TO_EV)), delimiter=',', header='Im[hbar K(hbar Omega)] (meV)') plt.subplot(2, 1, 1) plt.plot(1000.0 * convert(Omega_eid, ARU_TO_EV), convert(K_real_eid, ARU_TO_INV_PICO), '-', label='K real') plt.xlabel('Omega (meV)') plt.ylabel('Re[$K(\hbar\Omega)$] (ps$^-1$)') plt.subplot(2, 1, 2) plt.plot(1000.0 * convert(Omega_eid, ARU_TO_EV), 1000.0 * convert(K_imag_eid, ARU_TO_EV), '-', label='K imag') plt.xlabel('Rabi Energy $\hbar\Omega$ (meV)') plt.ylabel('Im[$\hbar K(\hbar\Omega)$] (meV)') # plt.show(block=False) plt.close() params['laphnoneid_params'].Omega_eid = Omega_eid params['laphnoneid_params'].K_real_eid = K_real_eid params['laphnoneid_params'].K_imag_eid = K_imag_eid
--- setup.py.orig 2021-12-29 08:31:32 UTC +++ setup.py @@ -2,7 +2,6 @@ import os import sys from setuptools import setup -from m2r import convert def read(filename): @@ -19,8 +18,8 @@ setup( author="Jayson Reis", author_email="*****@*****.**", description="A pure python module to access memcached via its binary protocol with SASL auth support", - long_description="{0}\n{1}".format( - read("README.rst"), convert(read("CHANGELOG.md")) + long_description="{0}".format( + read("README.rst") ), url="https://github.com/jaysonsantos/python-binary-memcached", packages=["bmemcached", "bmemcached.client"],
datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT') + "\n\n") threshold = 0. for corpus in corpora: for split in glob.glob(predict + os.sep + corpus + os.sep + "*"): split = os.path.basename(split) fold = split[5:] print corpus, split for prediction in glob.glob(predict + os.sep + corpus + os.sep + split + os.sep + "*.out"): resultFile.write("-- BEGIN experiment -- corpus: '" + corpus + "', split: '" + split + "', fold: '" + fold + "', prediction file: '" + prediction + "'\n") n = regex.search(os.path.basename(prediction)).group(1) w = regex.search(os.path.basename(prediction)).group(2) # print n,w convert(prediction) #Convert into expected data format f = open(prediction) auc = readAUC(f) f.close() f = open(prediction) F, prec, rec = readResults(f, threshold) f.close() # print auc, F, prec, rec # write experiment parameters resultFile.write( "INSERT INTO ppiCV (parsertype, parser, corpus, fold, kernel, kernel_script) " + "VALUES ('POS tagger', 'TextPRO (Version06?)', '" + corpus + "', " + fold + ", 'SL', 'jsre; n=" + n + " (n-gram), w=" + w +
def read_config (config_file, configspec_file): # read in configuration file and validate against configspec config = ConfigObj('config.ini', configspec='configspec.ini') validator = Validator() result = config.validate(validator) if result != True: print "Error reading config file" sys.exit(1) #------------------------------------------------------------# # read run parameters dump_to_screen = config['run']['dump'] run_t_start = config['run']['t_start'] run_t_end = config['run']['t_end'] run_t_step = config['run']['t_step'] run_dephasing = config['run']['dephasing'] run_phonon_eid = config['run']['phonon_eid'] run_wl_eid = config['run']['wl_eid'] run_nonmarkovian_eid = config['run']['non_markovian_eid'] run_rwa = config['run']['rwa'] run_mask = config['run']['mask'] run_ampmask = config['run']['ampmask'] run_phasemask = config['run']['phasemask'] NITER = config['run']['NITER'] gate = config['run']['gate'] optimize = config['run']['optimize'] sobol_seed = config['run']['sobol_seed'] show_plot = config['run']['show_plot'] if optimize is True and run_mask != run_ampmask and run_mask != run_phasemask: sys.exit("The mask does not match the ampmask or the phasemask - fix config file.\nProgram exiting now!") # write parameters to screen if requested if dump_to_screen == True: print "reading run parameters..." print "run start time:", run_t_start, "fs" print "run end time:", run_t_end, "fs" print "run time step:", run_t_step, "fs" print "dephasing:", run_dephasing print "phonon eid:", run_phonon_eid print "wl eid:", run_wl_eid print "non markovian eid:", run_nonmarkovian_eid print "rwa:", run_rwa print "mask:", run_mask print "NITER:", NITER print "gate", gate, "\n" # convert run pararmeters to Atomic Rydberg Units (ARU) run_t_start = convert(run_t_start, FEMTO_TO_ARU) # convert run start time from fs to ARU run_t_end = convert(run_t_end, FEMTO_TO_ARU) # convert run start time from fs to ARU run_t_step = convert(run_t_step, FEMTO_TO_ARU) # convert run time step from fs to ARU run_params = RunParams(run_t_start, run_t_end, run_t_step, run_dephasing, run_phonon_eid, run_wl_eid, run_nonmarkovian_eid, run_rwa, run_mask, run_ampmask, run_phasemask, NITER, gate, optimize, sobol_seed, show_plot) #------------------------------------------------------------# # read rkdp parameters rkdp_atol = config['rkdp']['atol'] rkdp_rtol = config['rkdp']['rtol'] rkdp_nsteps_opt = config['rkdp']['nsteps_opt'] rkdp_nsteps_tdep = config['rkdp']['nsteps_tdep'] rkdp_hstart = config['rkdp']['h_start'] rkdp_hmax = config['rkdp']['h_max'] rkdp_tdep_step = config['rkdp']['tdep_step'] # write parameters to screen if requested if dump_to_screen == True: print 'reading rkdp parameters...' print "rkdp absolute tolerance:", rkdp_atol print "rkdp relative tolerance:", rkdp_rtol print "rkdp max steps opt:", rkdp_nsteps_opt print "rkdp max steps tdep:", rkdp_nsteps_tdep print "rkdp initial step size:", rkdp_hstart print "rkdp max steps size:", rkdp_hmax print "tdep step:", rkdp_tdep_step, "\n" # convert time dependent step from fs to ARU rkdp_hstart = convert(rkdp_hstart, FEMTO_TO_ARU) rkdp_hmax = convert(rkdp_hmax, FEMTO_TO_ARU) rkdp_tdep_step = convert(rkdp_tdep_step, FEMTO_TO_ARU) rkdp_params = RkdpParams(rkdp_atol, rkdp_rtol, rkdp_nsteps_opt, rkdp_nsteps_tdep, rkdp_hstart, rkdp_hmax, rkdp_tdep_step) #------------------------------------------------------------# # read in parameters for chosen mask param_list = config['masks'][run_mask]['param_list'] NOPTS = len(param_list) # read in parameters and create tuple with bounds for optimization # note parameters are in the same as param_list x = numpy.zeros(NOPTS) # values of parameters x_lower = numpy.zeros(NOPTS) # values of parameters x_upper = numpy.zeros(NOPTS) # values of parameters x_bounds = () # tuple with bounds for optimization x_convert = [] x_units = [] # read in values and convert to ARU for i in range(NOPTS): # read in parameters x[i] = config['masks'][run_mask][param_list[i]] param_ARU = param_list[i] + '_ARU' x_units.append(config['masks'][run_mask][param_ARU][2]) # read in bounds param_range = param_list[i] + '_range' x_lower[i] = config['masks'][run_mask][param_range][0] x_upper[i] = config['masks'][run_mask][param_range][1] # write parameters to screen if requested if dump_to_screen == True: print 'reading ' + run_mask + ' parameters...' for i in range(NOPTS): print param_list[i], ': Value:', x[i], ', Bounds:', x_lower[i], ',', x_upper[i], x_units[i] print "\n" # convert parameters according to conversion factor for i in range(NOPTS): # read in conversion factor param_ARU = param_list[i] + '_ARU' x_convert.append(config['masks'][run_mask][param_ARU][0]) # if conversion is from AREA (in fraction of PI) to ARU, pass extra kwargs if (x_convert[i] == AREA_TO_ARU): dipole = config['pulse']['dipole'] width = config['pulse']['width'] shape = config['pulse']['shape'] kwargs = {'dipole_moment': dipole, 'pulse_width': width, 'pulse_shape': shape} else: kwargs = {} x[i] = convert(x[i], x_convert[i], **kwargs) x_lower[i] = convert(x_lower[i], x_convert[i], **kwargs) x_upper[i] = convert(x_upper[i], x_convert[i], **kwargs) # add bounds for i-th variable to tuple x_bounds = x_bounds + (numpy.array([x_lower[i], x_upper[i]]), ) mask_params = MaskParams(param_list, x, x_bounds, x_convert, x_units, NOPTS) #------------------------------------------------------------# # read in parameters for ampmask param_list = config['masks'][run_ampmask]['param_list'] NOPTS = len(param_list) # read in parameters and create tuple with bounds for optimization # note parameters are in the same as param_list x = numpy.zeros(NOPTS) # values of parameters x_lower = numpy.zeros(NOPTS) # values of parameters x_upper = numpy.zeros(NOPTS) # values of parameters x_bounds = () # tuple with bounds for optimization x_convert = [] x_units = [] # read in values and convert to ARU for i in range(NOPTS): # read in parameters x[i] = config['masks'][run_ampmask][param_list[i]] param_ARU = param_list[i] + '_ARU' x_units.append(config['masks'][run_ampmask][param_ARU][2]) # read in bounds param_range = param_list[i] + '_range' x_lower[i] = config['masks'][run_ampmask][param_range][0] x_upper[i] = config['masks'][run_ampmask][param_range][1] # write parameters to screen if requested if dump_to_screen == True: print 'reading ' + run_ampmask + ' parameters...' for i in range(NOPTS): print param_list[i], ': Value:', x[i], ', Bounds:', x_lower[i], ',', x_upper[i], x_units[i] print "\n" # convert parameters according to conversion factor for i in range(NOPTS): # read in conversion factor param_ARU = param_list[i] + '_ARU' x_convert.append(config['masks'][run_ampmask][param_ARU][0]) # if conversion is from AREA (in fraction of PI) to ARU, pass extra kwargs if (x_convert[i] == AREA_TO_ARU): dipole = config['pulse']['dipole'] width = config['pulse']['width'] shape = config['pulse']['shape'] kwargs = {'dipole_moment': dipole, 'pulse_width': width, 'pulse_shape': shape} else: kwargs = {} x[i] = convert(x[i], x_convert[i], **kwargs) x_lower[i] = convert(x_lower[i], x_convert[i], **kwargs) x_upper[i] = convert(x_upper[i], x_convert[i], **kwargs) # add bounds for i-th variable to tuple x_bounds = x_bounds + (numpy.array([x_lower[i], x_upper[i]]), ) ampmask_params = AmpMaskParams(param_list, x, x_bounds, x_convert, x_units, NOPTS) #------------------------------------------------------------# # read in parameters for phasemask param_list = config['masks'][run_phasemask]['param_list'] NOPTS = len(param_list) # read in parameters and create tuple with bounds for optimization # note parameters are in the same as param_list x = numpy.zeros(NOPTS) # values of parameters x_lower = numpy.zeros(NOPTS) # values of parameters x_upper = numpy.zeros(NOPTS) # values of parameters x_bounds = () # tuple with bounds for optimization x_convert = [] x_units = [] # read in values and convert to ARU for i in range(NOPTS): # read in parameters x[i] = config['masks'][run_phasemask][param_list[i]] param_ARU = param_list[i] + '_ARU' x_units.append(config['masks'][run_phasemask][param_ARU][2]) # read in bounds param_range = param_list[i] + '_range' x_lower[i] = config['masks'][run_phasemask][param_range][0] x_upper[i] = config['masks'][run_phasemask][param_range][1] # write parameters to screen if requested if dump_to_screen == True: print 'reading ' + run_phasemask + ' parameters...' for i in range(NOPTS): print param_list[i], ': Value:', x[i], ', Bounds:', x_lower[i], ',', x_upper[i], x_units[i] print "\n" # convert parameters according to conversion factor for i in range(NOPTS): # read in conversion factor param_ARU = param_list[i] + '_ARU' x_convert.append(config['masks'][run_phasemask][param_ARU][0]) # if conversion is from AREA (in fraction of PI) to ARU, pass extra kwargs if (x_convert[i] == AREA_TO_ARU): dipole = config['pulse']['dipole'] width = config['pulse']['width'] shape = config['pulse']['shape'] kwargs = {'dipole_moment': dipole, 'pulse_width': width, 'pulse_shape': shape} else: kwargs = {} x[i] = convert(x[i], x_convert[i], **kwargs) x_lower[i] = convert(x_lower[i], x_convert[i], **kwargs) x_upper[i] = convert(x_upper[i], x_convert[i], **kwargs) # add bounds for i-th variable to tuple x_bounds = x_bounds + (numpy.array([x_lower[i], x_upper[i]]), ) phasemask_params = PhaseMaskParams(param_list, x, x_bounds, x_convert, x_units, NOPTS) #------------------------------------------------------------# # read pulse parameters pulse_omega_o = config['pulse']['omega_o'] pulse_detun = config['pulse']['detun'] pulse_width = config['pulse']['width'] pulse_delay = config['pulse']['delay'] pulse_chirp = config['pulse']['chirp'] pulse_shape = config['pulse']['shape'] pulse_pol = config['pulse']['pol'] pol_angle= config['pulse']['pol_angle'] pulse_phase = config['pulse']['phase'] pulse_area = config['pulse']['area'] pulse_dipole = config['pulse']['dipole'] # write parameters to screen if requested if dump_to_screen == True: print "reading pulse parameters..." print "pulse parameters:" print "pulse center freq is:", pulse_omega_o, "eV" print "pulse shape is:", pulse_shape print "pulse phase is:", pulse_phase, "PI radians" print "pulse area is:", pulse_area, "PI radians" print "pulse polarization is:", pulse_pol print "pulse coupling strength is:", pulse_dipole, "Debye\n" # determine unit vector of pulse polarization if pulse_pol == POL_H: pulse_xcomp = complex(1.0, 0.0) pulse_ycomp = complex(0.0, 0.0) elif pulse_pol == POL_V: pulse_xcomp = complex(0.0, 0.0) pulse_ycomp = complex(1.0, 0.0) elif pulse_pol == POL_DIA: pulse_xcomp = (1.0/SQRT2)*complex(1.0, 0.0) pulse_ycomp = (1.0/SQRT2)*complex(1.0, 0.0) elif pulse_pol == POL_ADIA: pulse_xcomp = (1.0/SQRT2)*complex(1.0, 0.0) pulse_ycomp = (1.0/SQRT2)*complex(-1.0, 0.0) elif pulse_pol == POL_LCP: pulse_xcomp = (1.0/SQRT2)*complex(1.0, 0.0) pulse_ycomp = (1.0/SQRT2)*complex(0.0, 1.0) elif pulse_pol == POL_RCP: pulse_xcomp = (1.0/SQRT2)*complex(1.0, 0.0) pulse_ycomp = (1.0/SQRT2)*complex(0.0, -1.0) elif pulse_pol == POL_LIN: pulse_xcomp = (1.0)*complex(numpy.cos(pol_angle*PI), 0.0) pulse_ycomp = (1.0)*complex(numpy.sin(pol_angle*PI), 0.0) else: print "Invalid Pulse Polarization!" # convert from fraction of PI to radians pulse_phase = pulse_phase*PI pulse_area = pulse_area*PI # determine peak electric field for given pulse shape, pulse width, pulse area, and dipole moment if pulse_shape == GAUSSIAN: pulse_EO = H_BAR*pulse_area*pow(GAUSSIAN_CONST/PI, 0.5)/(pulse_dipole*DEBYE_TO_CM*pulse_width*1.0e-15) elif pulse_shape == SECH: pulse_EO = SECH_CONST*H_BAR*pulse_area/(pulse_dipole*DEBYE_TO_CM*PI*pulse_width*1.0e-15) elif pulse_shape == SQUARE: pulse_EO = H_BAR*pulse_area/(pulse_dipole*DEBYE_TO_CM*pulse_width*1.0e-15) elif pulse_shape == LORENTZIAN: pulse_EO = H_BAR*pulse_area/(pulse_dipole*DEBYE_TO_CM*pulse_width*1.0e-15) elif pulse_shape == DICHROMATIC: pulse_EO = H_BAR*pulse_area/(pulse_dipole*DEBYE_TO_CM*pulse_width*1.0e-15) else: print "Invalid Pulse Shape!" # convert pulse pararmeters to Atomic Rydberg Units (ARU) pulse_omega_o = convert(pulse_omega_o, EV_TO_ARU) # convert from eV to ARU (angular frequency) pulse_detun = convert(pulse_detun, EV_TO_ARU) # convert from eV to ARU (angular frequency) pulse_width = convert(pulse_width, FEMTO_TO_ARU) # convert pulse width from fs to ARU pulse_delay = convert(pulse_delay, FEMTO_TO_ARU) # convert pulse width from fs to ARU pulse_EO = convert(pulse_EO, ELEC_TO_ARU) # convert pulse electric field to ARU pulse_chirp = convert(pulse_chirp, FEMTO2_TO_ARU) # convert pulse chirp from fs^2 to ARU # write data to PulseParams data structure pulse_params = PulseParams(pulse_omega_o, pulse_detun, pulse_width, pulse_delay, pulse_chirp, pulse_shape, pulse_pol, pulse_phase, pulse_area, pulse_EO, pulse_dipole, pulse_xcomp, pulse_ycomp) #------------------------------------------------------------# # read quantum dot parameters # write parameters to screen if requested if dump_to_screen == True: print "reading qdot parameters..." qdot_omega_yo = config['qdot']['omega_yo'] qdot_omega_xyfine = config['qdot']['omega_xyfine'] qdot_omega_bind = config['qdot']['omega_bind'] qdot_d_xo = config['qdot']['d_xo'] qdot_d_yo = config['qdot']['d_yo'] qdot_d_xy = config['qdot']['d_xy'] qdot_d_bo = config['qdot']['d_bo'] qdot_d_bx = config['qdot']['d_bx'] qdot_d_by = config['qdot']['d_by'] qdot_T_oo = config['qdot']['T_oo'] qdot_T_xx = config['qdot']['T_xx'] qdot_T_yy = config['qdot']['T_yy'] qdot_T_bb = config['qdot']['T_bb'] qdot_T_xo = config['qdot']['T_xo'] qdot_T_yo = config['qdot']['T_yo'] qdot_T_bo = config['qdot']['T_bo'] qdot_T_xy = config['qdot']['T_xy'] qdot_T_bx = config['qdot']['T_bx'] qdot_T_by = config['qdot']['T_by'] qdot_eid_c = config['qdot']['eid_c'] qdot_eid_b = config['qdot']['eid_b'] initial_state_co_r = config['qdot']['initial_state_co_r'] initial_state_co_phi = config['qdot']['initial_state_co_phi'] initial_state_cx_r = config['qdot']['initial_state_cx_r'] initial_state_cx_phi = config['qdot']['initial_state_cx_phi'] initial_state_cy_r = config['qdot']['initial_state_cy_r'] initial_state_cy_phi = config['qdot']['initial_state_cy_phi'] initial_state_cb_r = config['qdot']['initial_state_cb_r'] initial_state_cb_phi = config['qdot']['initial_state_cb_phi'] desired_state_co_r = config['qdot']['desired_state_co_r'] desired_state_co_phi = config['qdot']['desired_state_co_phi'] desired_state_cx_r = config['qdot']['desired_state_cx_r'] desired_state_cx_phi = config['qdot']['desired_state_cx_phi'] desired_state_cy_r = config['qdot']['desired_state_cy_r'] desired_state_cy_phi = config['qdot']['desired_state_cy_phi'] desired_state_cb_r = config['qdot']['desired_state_cb_r'] desired_state_cb_phi = config['qdot']['desired_state_cb_phi'] # read in initial state and normalize qdot_initial_co = cmath.rect(initial_state_co_r, initial_state_co_phi*PI) qdot_initial_cx = cmath.rect(initial_state_cx_r, initial_state_cx_phi*PI) qdot_initial_cy = cmath.rect(initial_state_cy_r, initial_state_cy_phi*PI) qdot_initial_cb = cmath.rect(initial_state_cb_r, initial_state_cb_phi*PI) qdot_initial_state = numpy.array([qdot_initial_co, qdot_initial_cx, qdot_initial_cy, qdot_initial_cb], dtype=complex) qdot_initial_state = normalize_state(qdot_initial_state) # read in desired state and normalize qdot_desired_co = cmath.rect(desired_state_co_r, desired_state_co_phi*PI) qdot_desired_cx = cmath.rect(desired_state_cx_r, desired_state_cx_phi*PI) qdot_desired_cy = cmath.rect(desired_state_cy_r, desired_state_cy_phi*PI) qdot_desired_cb = cmath.rect(desired_state_cb_r, desired_state_cb_phi*PI) qdot_desired_state = numpy.array([qdot_desired_co, qdot_desired_cx, qdot_desired_cy, qdot_desired_cb], dtype=complex) qdot_desired_state = normalize_state(qdot_desired_state) if dump_to_screen == True: print "Initial State for QDOT1 is: {0}".format(qdot_initial_state) print "Desired State for QDOT1 is: {0}".format(qdot_desired_state) # convert quantum dot parameters to Atomic Rydberg Units (ARU) # convert quantum dot energies from eV to ARU (angular frequency) qdot_omega_yo = convert(qdot_omega_yo, EV_TO_ARU) qdot_omega_xyfine = convert(qdot_omega_xyfine, EV_TO_ARU) qdot_omega_bind = convert(qdot_omega_bind, EV_TO_ARU) # quantum dot dipole moments from Debye to ARU qdot_d_xo = convert(qdot_d_xo, DEBYE_TO_ARU) qdot_d_yo = convert(qdot_d_yo, DEBYE_TO_ARU) qdot_d_xy = convert(qdot_d_xy, DEBYE_TO_ARU) qdot_d_bo = convert(qdot_d_bo, DEBYE_TO_ARU) qdot_d_bx = convert(qdot_d_bx, DEBYE_TO_ARU) qdot_d_by = convert(qdot_d_by, DEBYE_TO_ARU) # quantum dot decay constants from ps to ARU qdot_T_xx = convert(qdot_T_xx, PICO_TO_ARU) qdot_T_yy = convert(qdot_T_yy, PICO_TO_ARU) qdot_T_bb = convert(qdot_T_bb, PICO_TO_ARU) qdot_T_xo = convert(qdot_T_xo, PICO_TO_ARU) qdot_T_yo = convert(qdot_T_yo, PICO_TO_ARU) qdot_T_bo = convert(qdot_T_bo, PICO_TO_ARU) qdot_T_xy = convert(qdot_T_xy, PICO_TO_ARU) qdot_T_bx = convert(qdot_T_bx, PICO_TO_ARU) qdot_T_by = convert(qdot_T_by, PICO_TO_ARU) qdot_eid_c = convert(qdot_eid_c, PICO_TO_ARU) # write data to QDotParams data structure qdot_params = QDotParams(qdot_omega_yo, qdot_omega_xyfine, qdot_omega_bind, qdot_d_xo, qdot_d_yo, qdot_d_xy, qdot_d_bo, qdot_d_bx, qdot_d_by, qdot_T_oo, qdot_T_xx, qdot_T_yy, qdot_T_bb, qdot_T_xo, qdot_T_yo, qdot_T_bo, qdot_T_xy, qdot_T_bx, qdot_T_by, qdot_eid_c, qdot_eid_b, qdot_initial_state, qdot_desired_state) # read and write data for the second quantum dot qdot2_omega_yo = config['qdot2']['omega_yo'] qdot2_omega_xyfine = config['qdot2']['omega_xyfine'] qdot2_omega_bind = config['qdot2']['omega_bind'] qdot2_d_xo = config['qdot2']['d_xo'] qdot2_d_yo = config['qdot2']['d_yo'] qdot2_d_xy = config['qdot2']['d_xy'] qdot2_d_bo = config['qdot2']['d_bo'] qdot2_d_bx = config['qdot2']['d_bx'] qdot2_d_by = config['qdot2']['d_by'] qdot2_T_oo = config['qdot2']['T_oo'] qdot2_T_xx = config['qdot2']['T_xx'] qdot2_T_yy = config['qdot2']['T_yy'] qdot2_T_bb = config['qdot2']['T_bb'] qdot2_T_xo = config['qdot2']['T_xo'] qdot2_T_yo = config['qdot2']['T_yo'] qdot2_T_bo = config['qdot2']['T_bo'] qdot2_T_xy = config['qdot2']['T_xy'] qdot2_T_bx = config['qdot2']['T_bx'] qdot2_T_by = config['qdot2']['T_by'] qdot2_eid_c = config['qdot2']['eid_c'] qdot2_eid_b = config['qdot2']['eid_b'] initial_state_co_r = config['qdot2']['initial_state_co_r'] initial_state_co_phi = config['qdot2']['initial_state_co_phi'] initial_state_cx_r = config['qdot2']['initial_state_cx_r'] initial_state_cx_phi = config['qdot2']['initial_state_cx_phi'] initial_state_cy_r = config['qdot2']['initial_state_cy_r'] initial_state_cy_phi = config['qdot2']['initial_state_cy_phi'] initial_state_cb_r = config['qdot2']['initial_state_cb_r'] initial_state_cb_phi = config['qdot2']['initial_state_cb_phi'] desired_state_co_r = config['qdot2']['desired_state_co_r'] desired_state_co_phi = config['qdot2']['desired_state_co_phi'] desired_state_cx_r = config['qdot2']['desired_state_cx_r'] desired_state_cx_phi = config['qdot2']['desired_state_cx_phi'] desired_state_cy_r = config['qdot2']['desired_state_cy_r'] desired_state_cy_phi = config['qdot2']['desired_state_cy_phi'] desired_state_cb_r = config['qdot2']['desired_state_cb_r'] desired_state_cb_phi = config['qdot2']['desired_state_cb_phi'] # read in initial state and normalize it if necessary qdot2_initial_co = cmath.rect(initial_state_co_r, initial_state_co_phi*PI) qdot2_initial_cx = cmath.rect(initial_state_cx_r, initial_state_cx_phi*PI) qdot2_initial_cy = cmath.rect(initial_state_cy_r, initial_state_cy_phi*PI) qdot2_initial_cb = cmath.rect(initial_state_cb_r, initial_state_cb_phi*PI) qdot2_initial_state = numpy.array([qdot2_initial_co, qdot2_initial_cx, qdot2_initial_cy, qdot2_initial_cb], dtype=complex) qdot2_initial_state = normalize_state(qdot2_initial_state) # read in desired state and normalize it if necessary qdot2_desired_co = cmath.rect(desired_state_co_r, desired_state_co_phi*PI) qdot2_desired_cx = cmath.rect(desired_state_cx_r, desired_state_cx_phi*PI) qdot2_desired_cy = cmath.rect(desired_state_cy_r, desired_state_cy_phi*PI) qdot2_desired_cb = cmath.rect(desired_state_cb_r, desired_state_cb_phi*PI) qdot2_desired_state = numpy.array([qdot2_desired_co, qdot2_desired_cx, qdot2_desired_cy, qdot2_desired_cb], dtype=complex) qdot2_desired_state = normalize_state(qdot2_desired_state) if dump_to_screen == True: print "Initial State for QDOT2 is: {0}".format(qdot2_initial_state) print "Desired State for QDOT2 is: {0}".format(qdot2_desired_state) # convert quantum dot parameters to Atomic Rydberg Units (ARU) # convert quantum dot energies from eV to ARU (angular frequency) qdot2_omega_yo = convert(qdot2_omega_yo, EV_TO_ARU) qdot2_omega_xyfine = convert(qdot2_omega_xyfine, EV_TO_ARU) qdot2_omega_bind = convert(qdot2_omega_bind, EV_TO_ARU) # quantum dot dipole moments from Debye to ARU qdot2_d_xo = convert(qdot2_d_xo, DEBYE_TO_ARU) qdot2_d_yo = convert(qdot2_d_yo, DEBYE_TO_ARU) qdot2_d_xy = convert(qdot2_d_xy, DEBYE_TO_ARU) qdot2_d_bo = convert(qdot2_d_bo, DEBYE_TO_ARU) qdot2_d_bx = convert(qdot2_d_bx, DEBYE_TO_ARU) qdot2_d_by = convert(qdot2_d_by, DEBYE_TO_ARU) # quantum dot decay constants from ps to ARU qdot2_T_xx = convert(qdot2_T_xx, PICO_TO_ARU) qdot2_T_yy = convert(qdot2_T_yy, PICO_TO_ARU) qdot2_T_bb = convert(qdot2_T_bb, PICO_TO_ARU) qdot2_T_xo = convert(qdot2_T_xo, PICO_TO_ARU) qdot2_T_yo = convert(qdot2_T_yo, PICO_TO_ARU) qdot2_T_bo = convert(qdot2_T_bo, PICO_TO_ARU) qdot2_T_xy = convert(qdot2_T_xy, PICO_TO_ARU) qdot2_T_bx = convert(qdot2_T_bx, PICO_TO_ARU) qdot2_T_by = convert(qdot2_T_by, PICO_TO_ARU) qdot2_eid_c = convert(qdot2_eid_c, PICO_TO_ARU) qdot2_params = QDotParams(qdot2_omega_yo, qdot2_omega_xyfine, qdot2_omega_bind, qdot2_d_xo, qdot2_d_yo, qdot2_d_xy, qdot2_d_bo, qdot2_d_bx, qdot2_d_by, qdot2_T_oo, qdot2_T_xx, qdot2_T_yy, qdot2_T_bb, qdot2_T_xo, qdot2_T_yo, qdot2_T_bo, qdot2_T_xy, qdot2_T_bx, qdot2_T_by, qdot2_eid_c, qdot2_eid_b, qdot2_initial_state, qdot2_desired_state) # read and write data for the second quantum dot qdot3_omega_yo = config['qdot3']['omega_yo'] qdot3_omega_xyfine = config['qdot3']['omega_xyfine'] qdot3_omega_bind = config['qdot3']['omega_bind'] qdot3_d_xo = config['qdot3']['d_xo'] qdot3_d_yo = config['qdot3']['d_yo'] qdot3_d_xy = config['qdot3']['d_xy'] qdot3_d_bo = config['qdot3']['d_bo'] qdot3_d_bx = config['qdot3']['d_bx'] qdot3_d_by = config['qdot3']['d_by'] qdot3_T_oo = config['qdot3']['T_oo'] qdot3_T_xx = config['qdot3']['T_xx'] qdot3_T_yy = config['qdot3']['T_yy'] qdot3_T_bb = config['qdot3']['T_bb'] qdot3_T_xo = config['qdot3']['T_xo'] qdot3_T_yo = config['qdot3']['T_yo'] qdot3_T_bo = config['qdot3']['T_bo'] qdot3_T_xy = config['qdot3']['T_xy'] qdot3_T_bx = config['qdot3']['T_bx'] qdot3_T_by = config['qdot3']['T_by'] qdot3_eid_c = config['qdot3']['eid_c'] qdot3_eid_b = config['qdot3']['eid_b'] initial_state_co_r = config['qdot3']['initial_state_co_r'] initial_state_co_phi = config['qdot3']['initial_state_co_phi'] initial_state_cx_r = config['qdot3']['initial_state_cx_r'] initial_state_cx_phi = config['qdot3']['initial_state_cx_phi'] initial_state_cy_r = config['qdot3']['initial_state_cy_r'] initial_state_cy_phi = config['qdot3']['initial_state_cy_phi'] initial_state_cb_r = config['qdot3']['initial_state_cb_r'] initial_state_cb_phi = config['qdot3']['initial_state_cb_phi'] desired_state_co_r = config['qdot3']['desired_state_co_r'] desired_state_co_phi = config['qdot3']['desired_state_co_phi'] desired_state_cx_r = config['qdot3']['desired_state_cx_r'] desired_state_cx_phi = config['qdot3']['desired_state_cx_phi'] desired_state_cy_r = config['qdot3']['desired_state_cy_r'] desired_state_cy_phi = config['qdot3']['desired_state_cy_phi'] desired_state_cb_r = config['qdot3']['desired_state_cb_r'] desired_state_cb_phi = config['qdot3']['desired_state_cb_phi'] # read in initial state and normalize it if necessary qdot3_initial_co = cmath.rect(initial_state_co_r, initial_state_co_phi*PI) qdot3_initial_cx = cmath.rect(initial_state_cx_r, initial_state_cx_phi*PI) qdot3_initial_cy = cmath.rect(initial_state_cy_r, initial_state_cy_phi*PI) qdot3_initial_cb = cmath.rect(initial_state_cb_r, initial_state_cb_phi*PI) qdot3_initial_state = numpy.array([qdot3_initial_co, qdot3_initial_cx, qdot3_initial_cy, qdot3_initial_cb], dtype=complex) qdot3_initial_state = normalize_state(qdot3_initial_state) # read in desired state and normalize it if necessary qdot3_desired_co = cmath.rect(desired_state_co_r, desired_state_co_phi*PI) qdot3_desired_cx = cmath.rect(desired_state_cx_r, desired_state_cx_phi*PI) qdot3_desired_cy = cmath.rect(desired_state_cy_r, desired_state_cy_phi*PI) qdot3_desired_cb = cmath.rect(desired_state_cb_r, desired_state_cb_phi*PI) qdot3_desired_state = numpy.array([qdot3_desired_co, qdot3_desired_cx, qdot3_desired_cy, qdot3_desired_cb], dtype=complex) qdot3_desired_state = normalize_state(qdot3_desired_state) if dump_to_screen == True: print "Initial State for QDOT3 is: {0}".format(qdot3_initial_state) print "Desired State for QDOT3 is: {0}".format(qdot3_desired_state) # convert quantum dot parameters to Atomic Rydberg Units (ARU) # convert quantum dot energies from eV to ARU (angular frequency) qdot3_omega_yo = convert(qdot3_omega_yo, EV_TO_ARU) qdot3_omega_xyfine = convert(qdot3_omega_xyfine, EV_TO_ARU) qdot3_omega_bind = convert(qdot3_omega_bind, EV_TO_ARU) # quantum dot dipole moments from Debye to ARU qdot3_d_xo = convert(qdot3_d_xo, DEBYE_TO_ARU) qdot3_d_yo = convert(qdot3_d_yo, DEBYE_TO_ARU) qdot3_d_xy = convert(qdot3_d_xy, DEBYE_TO_ARU) qdot3_d_bo = convert(qdot3_d_bo, DEBYE_TO_ARU) qdot3_d_bx = convert(qdot3_d_bx, DEBYE_TO_ARU) qdot3_d_by = convert(qdot3_d_by, DEBYE_TO_ARU) # quantum dot decay constants from ps to ARU qdot3_T_xx = convert(qdot3_T_xx, PICO_TO_ARU) qdot3_T_yy = convert(qdot3_T_yy, PICO_TO_ARU) qdot3_T_bb = convert(qdot3_T_bb, PICO_TO_ARU) qdot3_T_xo = convert(qdot3_T_xo, PICO_TO_ARU) qdot3_T_yo = convert(qdot3_T_yo, PICO_TO_ARU) qdot3_T_bo = convert(qdot3_T_bo, PICO_TO_ARU) qdot3_T_xy = convert(qdot3_T_xy, PICO_TO_ARU) qdot3_T_bx = convert(qdot3_T_bx, PICO_TO_ARU) qdot3_T_by = convert(qdot3_T_by, PICO_TO_ARU) qdot3_eid_c = convert(qdot3_eid_c, PICO_TO_ARU) qdot3_params = QDotParams(qdot3_omega_yo, qdot3_omega_xyfine, qdot3_omega_bind, qdot3_d_xo, qdot3_d_yo, qdot3_d_xy, qdot3_d_bo, qdot3_d_bx, qdot3_d_by, qdot3_T_oo, qdot3_T_xx, qdot3_T_yy, qdot3_T_bb, qdot3_T_xo, qdot3_T_yo, qdot3_T_bo, qdot3_T_xy, qdot3_T_bx, qdot3_T_by, qdot3_eid_c, qdot3_eid_b, qdot3_initial_state, qdot3_desired_state) #------------------------------------------------------------# # read la-phonon eid parameters dot_shape = config['laphononeid']['dot_shape'] omega_c_eid = config['laphononeid']['omega_c_eid'] omega_z_eid = config['laphononeid']['omega_z_eid'] alpha_eid = config['laphononeid']['alpha_eid'] Omega_start_eid = config['laphononeid']['Omega_start_eid'] Omega_end_eid = config['laphononeid']['Omega_end_eid'] Omega_step_eid = config['laphononeid']['Omega_step_eid'] omega_end_eid = config['laphononeid']['omega_end_eid'] T_eid = config['laphononeid']['T_eid'] read_kernel = config['laphononeid']['read_kernel'] # write parameters to screen if requested if dump_to_screen and run_phonon_eid: print "LA phonon EID parameters..." print "omega_c_eid:", omega_c_eid, "eV" print "alpha_eid:", alpha_eid, "ps^2" print "Omega_start_eid: ", Omega_start_eid, "eV" print "Omega_end_eid: ", Omega_end_eid, "eV" print "Omega_step_eid: ", Omega_step_eid, "eV" print "T_eid: ", T_eid, "K" # convert eid pararmeters to Atomic Rydberg Units (ARU) omega_c_eid = convert(omega_c_eid, EV_TO_ARU) # convert from eV to ARU omega_z_eid = convert(omega_z_eid, EV_TO_ARU) # convert from eV to ARU alpha_eid = convert(alpha_eid, PICO2_TO_ARU) # convert from ps^2 to ARU Omega_start_eid = convert(Omega_start_eid, EV_TO_ARU) # convert from fs to ARU Omega_end_eid = convert(Omega_end_eid, EV_TO_ARU) # convert from fs to ARU Omega_step_eid = convert(Omega_step_eid, EV_TO_ARU) # convert from fs to ARU # write data to EIDParams data structure laphononeid_params = LAPhononEIDParams(dot_shape,omega_c_eid, omega_z_eid, alpha_eid, Omega_start_eid, Omega_end_eid, Omega_step_eid, T_eid, read_kernel, None , None) #------------------------------------------------------------# # read non-markovian eid parameters kappa_0 = config['nonmarkovian']['kappa_0'] kappa_1 = config['nonmarkovian']['kappa_1'] kappa_2 = config['nonmarkovian']['kappa_2'] # write parameters to screen if requested if dump_to_screen and run_phonon_eid: print "Non-Markovian reservoir EID parameters..." print "kappa_0:", kappa_0, "ps-1" print "kappa_1:", kappa_1, "ps-1" print "kappa_2: ", kappa_2, "ps-1" # convert eid pararmeters to Atomic Rydberg Units (ARU) kappa_0 = convert(kappa_0, INV_PICO_TO_ARU) # convert from ps^-1 to ARU kappa_1 = convert(kappa_1, INV_PICO_TO_ARU) # convert from ps^-1 to ARU kappa_2 = convert(kappa_2, INV_PICO_TO_ARU) # convert from ps^-1 to ARU # write data to EIDParams data structure nonmarkovian_params = NonMarkovianParams(kappa_0, kappa_1, kappa_2) #------------------------------------------------------------# return {'run_params': run_params, 'rkdp_params': rkdp_params, 'mask_params': mask_params, 'ampmask_params': ampmask_params, 'phasemask_params': phasemask_params, 'pulse_params': pulse_params, 'qdot_params': qdot_params, 'qdot2_params': qdot2_params, 'qdot3_params': qdot3_params, 'laphnoneid_params': laphononeid_params, 'nonmarkovian_params': nonmarkovian_params}
regex = re.compile('predictn=(\d+)w=(\d+)\.out') resultFile = open(result, 'w') resultFile.write("-- Date created: " + datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT') + "\n\n") threshold = 0. for corpus in corpora: for split in glob.glob(predict + os.sep + corpus + os.sep + "*"): split = os.path.basename(split) fold = split[5:] print corpus, split for prediction in glob.glob(predict + os.sep + corpus + os.sep + split + os.sep + "*.out"): resultFile.write("-- BEGIN experiment -- corpus: '" + corpus + "', split: '" + split + "', fold: '" + fold + "', prediction file: '" + prediction + "'\n") n = regex.search(os.path.basename(prediction)).group(1) w = regex.search(os.path.basename(prediction)).group(2) print n,w print "###", prediction convert(prediction) #Convert into expected data format f = open(prediction) # change: try: auc= readAUC(f) except: auc = "Null" # print "no auc, division by zero", "#####" f.close() f = open(prediction) F, prec, rec, TP, FP, FN, TN = readResults(f, threshold) f.close() # print auc, F, prec, rec # write experiment parameters
from convert import * import os # Height of images to be inserted in document DOCUMENT_IMAGE_HEIGHT = 200 # w/h-ratio to select images RELEVANT_IMAGE_RATIO = 3 # Bullet list characters BULLET_CHARACTERS = ["->", "–>", "-", "–", "•", " ̈"] NUMBERED_LIST_CHARACTERS = [ "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10." ] if __name__ == '__main__': files = os.listdir("slides") for file in files: if not file.startswith("."): print("Converting file: {}".format(file)) print("Progress:") convert("slides/" + file, "docs/" + file.split(".pdf")[0] + ".docx")
parser.add_argument('-d','--cache', help = 'specify a directory to store raw weather underground data') parser.add_argument('-l','--locations', help = 'specify locations to gather data for') parser.add_argument('-w','--overwrite',action = 'store_true', help = 'discard existing data if output file already exists') parser.add_argument('-s','--startdate', help = 'specify a starting time stamp for relevant new data points') parser.add_argument('-e','--enddate', help = 'specify an ending time stamp for relevant new data points') cfg = parse_config(parser.parse_args()) ts_format = '%Y-%m-%d %H:%M:%S' startdate = datetime.datetime.strptime(cfg.startdate,ts_format) enddate = datetime.datetime.strptime(cfg.enddate,ts_format) datafiles = collections.OrderedDict() lastcall = time.time() for statecities in cfg.locations.split('|'): state,cities = statecities.split(':') datafiles[state] = collections.OrderedDict() for city in cities.split(','): gargs = ( cfg.cache,cfg.apikey,float(cfg.apidelay), state,city,startdate,enddate,lastcall, ) datafiles[state][city],lastcall = gather(*gargs) convert(cfg,datafiles[state][city])
def test_dec2oct(self): self.assertEquals( convert("15", dec, oct), "17")
# input = f.readline() print(input) if (input == ""): time.sleep(0.1) continue # parse data try: a1, a2, a3, b1, b2, b3 = input.strip().split(" ") except: print("Parsing error with: ", input) continue # print(a1, a2, a3, b1, b2, b3) # convert data to cartesian coordinates try: x1, y1, x2, y2 = convert(int(a1), int(a2), int(a3), int(b1), int(b2), int(b3)) if (x1 == -1 and y1 == -1 and x2 == -1 and y2 == -1): continue except: print("Conversion error with: ", input) continue print("converted values", x1, y1, x2, y2) ## ## # turn on corresponding LEDs ## lights(int(x1), int(y1), int(x2), int(y2)) except KeyboardInterrupt: print("quitting") ledsOff() #pass
CONVERT_IMAGE_PATH = "Images/*/*.*" RESIZE = False RESIZE_IMAGE_PATH = "Images/*/*.jpg" DOWNLOAD_MODEL = True MODEL = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz' TRAIN = False CLASSIFY = False CLASSIFY_IMAGE_PATH = "Classify/Panda.jpg" PLOT = True RESULT_FILE = 'result.txt' images_counts = range(50, 650 + 1, 50) class_counts = range(2, 15 + 1) if CONVERT: convert(CONVERT_IMAGE_PATH) if RESIZE: resize(RESIZE_IMAGE_PATH) # Download the pretrained model (Google Inception V3 for our analysis) if DOWNLOAD_MODEL: download_pretrained_model(MODEL) if TRAIN: # Create graph from the pretrained model graph, bottleneck_tensor, image_data_tensor, resized_image_tensor = ( create_graph()) for class_count in class_counts: for images_count in images_counts:
def main(): start_of_the_script = time() MINI_GAME_PATH = argv[1].rstrip('/') # 'D:/Temp/Flappy_bird' output_path = argv[2].rstrip('/') n_times = int(argv[3]) for i in range(n_times): print('\n~ Iteration #{} ~'.format(i + 1) + '\n') # Preparation start_time = time() if os.path.exists( os.path.dirname(output_path + '/New_{}/'.format(i + 1) + '1.txt')): shutil.rmtree(output_path + '/New_{}'.format(i + 1), ignore_errors=True) try: temp_folder = shutil.copytree(MINI_GAME_PATH, MINI_GAME_PATH + '/TEMP_FOLDer') except: shutil.rmtree(MINI_GAME_PATH + '/TEMP_FOLDer', ignore_errors=True) temp_folder = shutil.copytree(MINI_GAME_PATH, MINI_GAME_PATH + '/TEMP_FOLDer') # convert(temp_folder) new_game_path = temp_folder + '/New_{}/'.format(i + 1) if os.path.exists(os.path.dirname(new_game_path + '1.txt')): shutil.rmtree(new_game_path, ignore_errors=True) if os.path.exists('./temp_random_words.txt'): os.remove('./temp_random_words.txt') with open('./random_words.txt', encoding='utf8') as f: content = f.read() with open('./temp_random_words.txt', 'w', encoding='utf8') as fi: fi.write(content) print("--- Preparation: %s seconds ---\n" % (round(time() - start_time, 3))) # Shuffle, rename all directories, files and copy them to a new directory start_time = time() new_paths, used_names = shuffle_and_copy_files(temp_folder, new_game_path) print("--- Shuffle files: %s seconds ---\n" % (round(time() - start_time, 3))) change_file_paths_in_files(temp_folder, new_paths) print("--- Rename files: %s seconds ---\n" % (round(time() - start_time, 3))) # Convert the code start_time = time() convert(new_game_path) print("--- Conversion: %s seconds ---\n" % (round(time() - start_time, 3))) # Remove temp files shutil.copytree(new_game_path, output_path + '/New_{}'.format(i + 1)) shutil.rmtree(temp_folder, ignore_errors=True) os.remove('./temp_random_words.txt') time_1 = round((time() - start_of_the_script) / 60, 3) time_2 = round(time() - start_of_the_script, 3) print("\n--- Script took: {} min ({} sec) ---".format(time_1, time_2))
coordinates2 = get_coordinates(destination2) tz = tzLookup( coordinates2, dt ) # -06:00 # this is that weird service that needs a time string arrive_by2String = timeVariableStamp #+ tz # 2018-7-30T10:0:00-06:00 try: arrive_by2Int = convertStringsToEpoch(arrive_by2String) except: print('failed to convert Time string to Epoch time') # print('fly to', origin2, 'then drive to', destination2, 'arriving by', arrive_by2Int) drive2googleTime = int( lookup(mode, origin2, destination2, arrive_by2Int, trafficModel) / 60) # convert the googletime to safeTime safeTime2 = int(convert(drive2googleTime)) if mode == 'depart at': # calculate the first drive first # lookup timezone coordinates = get_coordinates(origin) tz = tzLookup(coordinates, dt) depart_at1String = timeVariableStamp #+ tz try: depart_at1Int = convertStringsToEpoch(depart_at1String) # print('epoch time =', depart_at1Int) except: print('failed to convert Time string to Epoch time') drive1googleTime = int(