def create_score_object(path,
                        use_images=False,
                        composer='noname',
                        title='unknown'):
    count = len(os.listdir(path))
    if use_images:
        i_a.convert_images_to_textfile(count, path)

    measure_arrays = f_a.get_data_from_file()

    d_a.search_for_incorrect_measures(measure_arrays)

    key1 = (d_a.get_key(measure_arrays))

    key.Key(key1)

    score_object = score.Score(key1, composer, title)
    bass_part_object = part.Part('bass')
    treble_part_object = part.Part('treble')

    previous_measures = [None, None]  # 0: Left, 1: Right

    for index, measure in enumerate(measure_arrays):
        #print(str(index) + ': ' + str(len(measure)))
        if index == len(measure_arrays) - 1:
            tied_notes = []
        else:
            tied_notes = d_a.analyze_for_ties(measure,
                                              measure_arrays[index + 1])

        temp = d_a.analyze_pressed_keys(measure)
        bass_measure_part = temp[0]
        treble_measure_part = temp[1]

        temp = c_m.abc_both_hands(bass_measure_part, treble_measure_part,
                                  len(measure), tied_notes, previous_measures)
        bass_measure_object = temp[0]
        treble_measure_object = temp[1]

        bass_part_object.add(bass_measure_object)
        treble_part_object.add(treble_measure_object)

        previous_measures = [bass_measure_object,
                             treble_measure_object]  # 0: Left, 1: Right

    score_object.add([treble_part_object, bass_part_object])

    return score_object
Ejemplo n.º 2
0
def haloMassPlot(Mh, starHalo, folder):

    Nhalo = len(Mh)

    Nbins = 8
    n, bin_edges = np.histogram(Mh, bins=Nbins)

    sfr = np.empty(Nbins, dtype=np.object)

    for i in range(Nbins):
        sfr[i] = np.zeros(32)

    for b in range(Nbins):
        star = part.Part(0, 1)
        weight = 0
        for HALO in range(Nhalo):
            if Mh[HALO] > bin_edges[b] and Mh[HALO] < bin_edges[b + 1]:
                star.append(starHalo[HALO])
                weight += 1

        lab = "%s<Mhalo<%s" % ("{:.2e}".format(
            physique.m2mo(bin_edges[b], folder)), "{:.2e}".format(
                physique.m2mo(bin_edges[b + 1], folder)))
        fromPop(star, folder, lab, weight)

    plt.legend()
    plt.show(block=False)
Ejemplo n.º 3
0
def getHalo(par, tag, den, HALO):
    mask = np.where(tag == HALO)
    nmask = len(mask[0])

    halo = part.Part(nmask, 0)
    halo.mask(par, mask)

    return halo, getCenter(halo, den[mask]), getRvir(halo)
Ejemplo n.º 4
0
    def loadJSON(self, filename):
        with open(filename) as json_file:
            existingParts = json.load(json_file)
            for jsonPart in existingParts['Parts']:
                newpart = part.Part(jsonPart['Part Name'], jsonPart['Type'],
                                    jsonPart['Volume'])
                self.parts.append(newpart)

        return self.parts
Ejemplo n.º 5
0
def findStar(center, Rvir, star, tree):

    if tree:
        mask3, dump = tree.locatenear(center, Rvir)
    else:
        mask3 = []

    nmask3 = len(mask3)

    starshalo = part.Part(nmask3, 1)

    if nmask3 != 0:
        starshalo.mask(star, mask3)

    return starshalo, np.array(mask3, dtype=np.int32)
Ejemplo n.º 6
0
def fromSnap_2(file, lab):

    folder, filename = IO.splitPath(file)

    if "star." in filename:
        star = 1
    else:
        star = 0
    s = 10 + star

    param = IO.Params(folder=folder).get()
    L = float(param["unit_l"]) / 3.085677e16 / 1e6

    nproc = IO.getNproc(file)

    for proc in range(nproc):
        Ntot, a, data = part.read1proc(file + ".p" + str(proc).zfill(5))
        stars = part.Part(Ntot, star)
        i = 0
        for j in range(0, data.shape[0], s):
            stars.define(data[j:j + s], i)
            i += 1

        if len(stars.mass):
            b = 32
            n0, bin_edges = np.histogram(stars.age, bins=b)

            z = physique.a2z(physique.t2a(bin_edges))

            n = len(n0)
            sfr = np.zeros(n)
            for i in range(n):
                sfr[i] = physique.m2mo(
                    stars.mass[0] *
                    (n0[i]), folder) / float(bin_edges[i + 1] -
                                             bin_edges[i]) / pow(L, 3)

            plt.semilogy(z[:-1], sfr)

            plt.xlabel('z')
            plt.ylabel(r'$M_{\odot}.yrs^{-1}.(Mpc.h^{-1})^{-3}$')
            plt.ylim(1e-6, 1)

            plt.legend()
    plt.show(block=False)
Ejemplo n.º 7
0
            QLabel("Количество составляющих в окне:", self))
        self.tab_layout.addWidget(QLabel("Составляющие окна:"))
        self.setLayout(self.tab_layout)


class Example(QWidget):
    def __init__(self):
        super().__init__()

        self.initUI()

    def chose_windows_parts(self, state):
        self.windows_parts.clear()
        if state == "1":
            self.windows_parts.addItems(self.windows_one)
        if state == "2":
            self.windows_parts.addItems(self.windows_two)
        if state == "3":
            self.windows_parts.addItems(self.windows_three)

    def initUI(self):

        self.show()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    wizard = Figures(part.Part())
    wizard.show()
    sys.exit(app.exec_())
Ejemplo n.º 8
0
 def addPart(self, name, type, volume):
     mypart = part.Part(name, type, volume)
     print([i.getName() for i in self.parts])
     self.parts.append(mypart)
     self.parts.sort()
     print([i.getName() for i in self.parts])
Ejemplo n.º 9
0
#!/usr/bin/python

import part
from time import sleep
from arasClientUi import arasClientUi

#scan barcode and retrieve part
partItem = part.Part("111")
#assign builder name
partItem.Builder = "Admin"
partItem.StartBuild()
#show serial number
#show 1st instruction
#wait for buttons

ui = arasClientUi()

instructions = partItem.Instructions
for key, instruction in instructions.iteritems():
    #print key, instruction.instructionText, instruction.sequence, instruction.imageUrl
    ui.writeCompleteInstruction(instruction.instructionText,
                                instruction.imageUrl)
    sleep(2)

#sleep(3)
partItem.CompleteBuild()
#press start (StartBuild)
#   start time (right button)
#   get new serial number
#   print serial number
#   show first instruction
Ejemplo n.º 10
0
 def addPart(self, name, type, volume):
     mypart = part.Part(name, type, volume)
     self.parts.append(mypart)