Beispiel #1
0
    def zipToAnimation(self, sourcepath, destpath, filename, framedata):
        destpath = self.folder(destpath)
        workpath = "temp/" + filename
        self.execute("unzip -o " + sourcepath + " -d " + workpath)

        if stddev(framedata) < 1.0:
            # assumed stable framerate
            fr = 1 / round(average(framedata)) * 1000
            self.execute(
                "ffmpeg -framerate %d -i %s/%%6d.jpg -c:v copy %s.mkv" %
                (fr, workpath, destpath + filename))

        else:
            # probably needs variable framerate
            print(
                "\n stddev %.3f, %d frames:\n" %
                (stddev(framedata), len(framedata)), framedata)
            cmd = "convert "
            for i, d in enumerate(framedata):
                cmd += "-delay %d %s/%06d.jpg " % (d / 10, workpath, i)
            cmd += destpath + filename + ".gif"
            self.execute(
                cmd
            )  # we convert to gif and copy the zip too, because gif is trash
            self.execute("cp " + sourcepath + " " + destpath + filename +
                         ".zip")
Beispiel #2
0
 def __init__(self, xs, ys, mb_size, normalize=False):
     if normalize:
         self.xs = (xs - np.mean(xs, axis=0)) / np.stddev(xs, axis=0)
     else:
         self.xs = xs.copy()
     self.ys = ys.copy()
     self.mb_i = 0
     self.mb_size = mb_size
     self.batches_in_epoch = len(xs)//mb_size
Beispiel #3
0
def coupling_vs_r_pupilplane_single(tele: AOtele.AOtele, pupilfields, rcore,
                                    ncore, nclad, wl0):
    k0 = 2 * np.pi / wl0

    fieldshape = pupilfields[0].shape

    #need to generate the available modes
    V = LPmodes.get_V(k0, rcore, ncore, nclad)
    modes = LPmodes.get_modes(V)
    lpfields = []

    for mode in modes:
        if mode[0] == 0:
            lpfields.append(
                normalize(
                    LPmodes.lpfield(xg, yg, mode[0], mode[1], rcore, wl0,
                                    ncore, nclad)))

        else:
            lpfields.append(
                normalize(
                    LPmodes.lpfield(xg, yg, mode[0], mode[1], rcore, wl0,
                                    ncore, nclad, "cos")))
            lpfields.append(
                normalize(
                    LPmodes.lpfield(xg, yg, mode[0], mode[1], rcore, wl0,
                                    ncore, nclad, "sin")))

    lppupilfields = []

    #then backpropagate
    for field in lpfields:
        wf = hc.Wavefront(hc.Field(field.flatten(), tele.focalgrid),
                          wavelength=wl0 * 1.e-6)
        pupil_wf = tele.back_propagate(wf, True)
        lppupilfields.append(pupil_wf.electric_field.reshape(fieldshape))

    lppupilfields = np.array(lppupilfields)
    pupilfields = np.array(pupilfields)

    #compute total overlap
    powers = np.sum(pupilfields * lppupilfields, axes=(1, 2))

    return np.mean(powers), np.stddev(powers)
def nonmaxsup(H,n=100,c=.9):
    
    mindistance = []
    threshold = np.mean(H) + np.stddev(H)
    maxima = getmaxima(H,threshold)
    
    for x,y,z in enumerate(maxima):
        min = np.infinity
        for xx,yy,zz in enumerate(maxima):
            dist = sqrt((x-xx)**2 + (y-yy)**2 )
            if z < c*zz and dist > 0 and dist < min:
                min = dist
                xmin = xx
                ymin = yy

        mindistance.append((xx,yy,min))

    mindistance.sort(key=lambda x:x[2])
    return mindistance[:n]



		
Beispiel #5
0
                        num_states,
                        obs_dim,
                        input_dim,
                        observations="input_driven_obs",
                        observation_kwargs=dict(C=num_categories),
                        transitions="standard")
                    fit_ll = bandit_glmhmm.fit(training_choice,
                                               inputs=training_inpt,
                                               method="em",
                                               num_iters=N_iters,
                                               tolerance=10**-4)
                    i_ll.append(
                        bandit_glmhmm.log_likelihood(test_choices,
                                                     inputs=test_inpt))
                lls.append(np.mean(i_ll))
                lls_var.append(np.stddev(i_ll))
            log_likelihoods[:, fold] = lls

        # Plot Crossvalidation
        sns.pointplot(x=np.arange(5), y=np.mean(log_likelihoods, axis=1))
        plt.xticks(np.arange(5), np.arange(1, 6))
        plt.ylabel('LL')
        plt.xlabel('Number of latents')

    # Fit model
    num_states = 2
    obs_dim = 1
    input_dim = np.shape(meta_inpts[0])[1]
    num_categories = 2
    N_iters = 400  # maximum number of EM iterations. Fitting with stop earlier if increase in LL is below tolerance specified by tolerance parameter
    bandit_glmhmm = ssm.HMM(num_states,
Beispiel #6
0
  setHistTitles(hist,"#mu Reference","N_{Toys}")
  iHist += 1
  for mu in refMus:
      hist.Fill(mu)
  hist.Draw()
  tlatex.SetTextAlign(12)
  tlatex.DrawLatex(gStyle.GetPadLeftMargin(),0.96,PRELIMINARYSTRING)
  tlatex.SetTextAlign(12)
  tlatex.DrawLatex(0.02+gStyle.GetPadLeftMargin(),0.85,"Reference PDF: "+PDFTITLEMAP[refPdfName])
  #tlatex.DrawLatex(0.02+gStyle.GetPadLeftMargin(),0.75,"Alternate PDF: "+PDFTITLEMAP[pdfAltName])
  tlatex.DrawLatex(0.02+gStyle.GetPadLeftMargin(),0.68,"m_{H} = "+str(hmass)+" GeV/c^{2}")
  tlatex.SetTextAlign(32)
  tlatex.DrawLatex(0.99-gStyle.GetPadRightMargin(),0.96,caption)
  tlatex.DrawLatex(0.97-gStyle.GetPadRightMargin(),0.85,"Median: {0:.2f}".format(median(refMus)))
  tlatex.DrawLatex(0.97-gStyle.GetPadRightMargin(),0.75,"Mean: {0:.2f}".format(mean(refMus)))
  tlatex.DrawLatex(0.97-gStyle.GetPadRightMargin(),0.65,"#sigma: {0:.2f}".format(stddev(refMus)))
  line = setYMaxAndDrawVertLines(hist,None)
  canvas.RedrawAxis()
  saveAs(canvas,outputPrefix+"_"+str(hmass)+"_MuRef_Ref"+refPdfName)
  canvas.Clear()

  ## Mu Alt Plot
  hist = root.TH1F("hist"+str(iHist),"",60,-10,10)
  setHistTitles(hist,"#mu Alternate","N_{Toys}")
  iHist += 1
  for mu in altMus:
      hist.Fill(mu)
  hist.Draw()
  tlatex.SetTextAlign(12)
  tlatex.DrawLatex(gStyle.GetPadLeftMargin(),0.96,PRELIMINARYSTRING)
  tlatex.SetTextAlign(12)
Beispiel #7
0
def normalize(dcm):
    pixels = (pixels - np.mean(pixels)) / np.stddev(pixels)
Beispiel #8
0
    begin = datetime.datetime.now()

    total = 0

    done = False
    while not done:
        node = shockObjects.next()['node']

        start = datetime.datetime.now()

        r = requests.get(shockURL + "node/" + node + "?download", auth=(username, password))
        data = r.json        

        downloadTime = datetime.datetime.now() - start

        print "genome " + str(total) + "     " + shockURL + "node/" + node + "?download" + "     " + str(downloadTime)
        total += 1
        times.append(downloadTime.total_seconds())
except Exception, e:
    print str(e)
    print "DONE"

    ntimes = numpy.array(times)

    print "Total time: " + str(datetime.datetime.now() - begin)
    print "Max: " + str(numpy.max(ntimes))
    print "Min: " + str(numpy.min(ntimes))
    print "Average: " + str(numpy.mean(ntimes))
    print "Stddev: " + str(numpy.stddev(ntimes))
 def samplerate_stddev(self):
     "Get the variance of the differential source sample rate"
     return np.stddev(np.reciprocate(np.diff(self.fx)))