コード例 #1
0
 def __init__(self,**kwargs):
     Geom.__init__(self,**kwargs)
     self.name = "forceLayout"
     self._id = 'forceLayout'
     self._build_js()
     self._build_css()
     self.styles = dict([(k[0].replace('_','-'), k[1]) for k in kwargs.items()])
コード例 #2
0
ファイル: line.py プロジェクト: ABcDexter/d3py
 def __init__(self,x,y,**kwargs):
     Geom.__init__(self,**kwargs)
     self.x = x
     self.y = y
     self.params = [x,y]
     self.debug = True
     self.name = "line"
     self._build_js()
     self._build_css()
コード例 #3
0
 def __init__(self, x, y, **kwargs):
     Geom.__init__(self, **kwargs)
     self.x = x
     self.y = y
     self.params = [x, y]
     self.debug = True
     self.name = "line"
     self._build_js()
     self._build_css()
コード例 #4
0
ファイル: point.py プロジェクト: cheekybastard/d3py
 def __init__(self,x,y,c=None,**kwargs):
     Geom.__init__(self, **kwargs)
     self.x = x
     self.y = y
     self.c = c
     self._id = 'point_%s_%s_%s'%(self.x,self.y,self.c)
     self.params = [x,y,c]
     self.name = "point"
     self.build_css()
     self.build_js()
コード例 #5
0
ファイル: area.py プロジェクト: ABcDexter/d3py
 def __init__(self,x,yupper,ylower,**kwargs):
     Geom.__init__(self,**kwargs)
     self.x = x
     self.yupper = yupper
     self.ylower = ylower
     self.params = [x, yupper, ylower]
     self.debug = True
     self.name = "area"
     self._build_js()
     self._build_css()
コード例 #6
0
 def __init__(self, x, yupper, ylower, **kwargs):
     Geom.__init__(self, **kwargs)
     self.x = x
     self.yupper = yupper
     self.ylower = ylower
     self.params = [x, yupper, ylower]
     self.debug = True
     self.name = "area"
     self._build_js()
     self._build_css()
コード例 #7
0
ファイル: xaxis.py プロジェクト: andrewgiessel/d3py
 def __init__(self,x, **kwargs):
     """
     x : string
         name of the column you want to use to define the x-axis
     """
     Geom.__init__(self, **kwargs)
     self.x = x
     self.params = [x]
     self._id = 'xaxis'
     self.name = 'xaxis'
     self.build_css()
     self.build_js()
コード例 #8
0
ファイル: ac_init.py プロジェクト: ansobolev/shs
 def init_geom(self):
     bravais = self.bravais.GetValue()
     alat, unit = self.alat.GetValue()
     sc = self.sc.GetValue()
     dist = self.dist.GetValue()
     if len(self.types) == 0:
         comp = dict(zip([il.GetValue() for il in self.type_label], [ifs.GetValue() for ifs in self.typefs]))
     else:
         comp = dict(zip(self.types, [ifs.GetValue() for ifs in self.typefs]))
     g = Geom()
     g.initialize(bravais, comp, sc, alat, unit, dist_level=dist)
     g.geom2opts()
     return g.opts["AtomicCoordinatesAndAtomicSpecies"]
コード例 #9
0
ファイル: axis.py プロジェクト: mynameisfiber/d3py
 def __init__(self, var, orient=None, **kwargs):
     """
     var : string
         name of the column you want to use to define the axis
     """
     Geom.__init__(self, **kwargs)
     self.var = var
     self.orient = orient
     self.params = [var]
     self._id = '%s_axis'%var
     self.name = '%s_axis'%var
     self.build_css()
     self.build_js()
コード例 #10
0
ファイル: axis.py プロジェクト: AbhishikthaReddy/d3py
 def __init__(self, var, orient=None, **kwargs):
     """
     var : string
         name of the column you want to use to define the axis
     """
     Geom.__init__(self, **kwargs)
     self.var = var
     self.orient = orient
     self.params = [var]
     self._id = '%s_axis' % var
     self.name = '%s_axis' % var
     self.build_css()
     self.build_js()
コード例 #11
0
ファイル: xaxis.py プロジェクト: xeniaqian94/d3py
 def __init__(self, x, label=None, **kwargs):
     """
     x : string
         name of the column you want to use to define the x-axis
     """
     Geom.__init__(self, **kwargs)
     self.x = x
     self.label = label if label else x
     self.params = [x]
     self._id = 'xaxis'
     self.name = 'xaxis'
     self._build_css()
     self._build_js()
コード例 #12
0
 def __init__(self,y, label=None, **kwargs):
     """
     y : string
         name of the column you want to use to define the y-axis
     """
     Geom.__init__(self, **kwargs)
     self.y = y
     self.label = label if label else y
     self.params = [y]
     self._id = 'yaxis'
     self.name = 'yaxis'
     self._build_css()
     self._build_js()
コード例 #13
0
ファイル: bar.py プロジェクト: andrewgiessel/d3py
 def __init__(self,x,y,**kwargs):
     """
     This is a vertical bar chart - the height of each bar represents the 
     magnitude of each class
     
     x : string
         name of the column that contains the class labels
     y : string
         name of the column that contains the magnitude of each class
     """
     Geom.__init__(self,**kwargs)
     self.x = x
     self.y = y
     self.name = "bar"
     self._id = 'bar_%s_%s'%(self.x,self.y)
     self.build_js()
     self.build_css()
     self.params = [x,y]
     self.styles = dict([(k[0].replace('_','-'), k[1]) for k in kwargs.items()])
コード例 #14
0
ファイル: bar.py プロジェクト: cheekybastard/d3py
 def __init__(self, x, y, **kwargs):
     """
     This is a vertical bar chart - the height of each bar represents the 
     magnitude of each class
     
     x : string
         name of the column that contains the class labels
     y : string
         name of the column that contains the magnitude of each class
     """
     Geom.__init__(self, **kwargs)
     self.x = x
     self.y = y
     self.name = "bar"
     self._id = 'bar_%s_%s' % (self.x, self.y)
     self.build_js()
     self.build_css()
     self.params = [x, y]
     self.styles = dict([(k[0].replace('_', '-'), k[1])
                         for k in kwargs.items()])
コード例 #15
0
ファイル: Stream.py プロジェクト: coquellen/NanoPeakCell
def parse_stream(streamfile):
    append = 0
    crystal = 0
    count_shots = 0
    count_crystals = 0
    frame_stream = []
    frames = []
    head_check = 0
    header = ''
    geom = Geom()
    stream = open(streamfile)
    all_reflections = []
    REFLECTIONS = 0
    PEAKS = 0
    GEOM_FLAG = 0
    geom = ''
    filenames = []
    indexed = []

    for index, line in enumerate(stream):
        ### GEt header
        while (head_check == 0):

            header += line
            if '----- Begin geometry file -----' in line: GEOM_FLAG = 1

            if GEOM_FLAG: geom += line

            #if GEOM_FLAG:
            #    if line.startswith('clen'):
            #        #print line.split('=')
            #        geom.distance = float(line.split('=')[1].split(';')[0].strip())
            #    if 'corner_x' in line:
            #        geom.bx = -1 * float(line.split('=')[1].split(';')[0].strip())
            #    if 'corner_y' in line:
            #        geom.by = -1 * float(line.split('=')[1].split(';')[0].strip())
            #    if 'res' in line:
            #        geom.ps = 1 / float(line.split('=')[1].split(';')[0].strip())
            #    if 'photon_energy' in line:
            #        geom.energy = float(line.split('=')[1].split(';')[0].strip())
            #        geom.wl = 12398.425 / geom.energy
            #    if 'max_fs' in line:
            #        geom.max_fs = float(line.split('=')[1].split(';')[0].strip())
            #    if 'max_ss' in line:
            #        geom.max_ss = float(line.split('=')[1].split(';')[0].strip())

            if '----- End geometry file -----' in line: GEOM_FLAG = 0
            break

        ### Get beginning of an image
        if 'Begin chunk' in line:
            count_shots += 1
            append = 1
            head_check = 1
            # frame_stream.append(l)

        ### If
        elif 'Image filename' in line:
            frame = Frame()
            frame.filename = line.split()[2].strip()
            filenames.append(frame.filename)

        # The division by 10 is to convert from nm-1 to Angstrom-1
        elif 'indexed_by' in line:
            if 'none' not in line:
                count_crystals += 1
                crystal = 1
                frame.indexing = line.split()[2].strip()
                indexed.append(frame.filename)
            else:
                frame.indexing = 'none'

            #SACLA specific - not needed
            # try:
            #    f = os.path.split(filename)[1]
            #    tag = os.path.splitext(f)[0].split('tag_')[1]
            #    frame.timeline = tag
            #except:
            #    pass

        elif 'diffraction_resolution_limit' in line:
            res = float(line.split()[5])
            frame.res = res

        elif 'Cell parameters' in line:
            a0, b0, c0 = line.split()[2:5]
            frame.a = float(a0)
            frame.b = float(b0)
            frame.c = float(c0)
        elif 'astar' in line:
            x, y, z = line.split()[2:5]
            frame.astar[0] = float(x) / 10
            frame.astar[1] = float(y) / 10
            frame.astar[2] = float(z) / 10

        elif 'bstar' in line:
            x, y, z = line.split()[2:5]
            frame.bstar[0] = float(x) / 10
            frame.bstar[1] = float(y) / 10
            frame.bstar[2] = float(z) / 10

        elif 'cstar' in line:
            x, y, z = line.split()[2:5]
            frame.cstar[0] = float(x) / 10
            frame.cstar[1] = float(y) / 10
            frame.cstar[2] = float(z) / 10

        elif 'End of reflections' in line:
            REFLECTIONS = 0

        elif 'End of peak list' in line:
            PEAKS = 0

        elif "End chunk" in line:
            if crystal == 1:
                #frame_stream.append(line)
                #frame.all = frame_stream
                frames.append(frame)
            append = 0
            frame_stream = []
            crystal = 0

        if REFLECTIONS:
            h, k, l, I, SIG, P, BKG, X, Y = line.split()[0:9]
            # bkg, x, y = line.split()[6:9]
            # SNR = float(line.split()[3]) / float(line.split()[4])
            frame.reflections.append([
                int(h),
                int(k),
                int(l),
                float(I),
                float(SIG),
                float(BKG),
                float(X),
                float(Y)
            ])  # geom.get_resolution(float(x), float(y)) ])
            #frame.hkl_stream.append(line)

        #if append == 1: frame_stream.append(line)
        if PEAKS:
            X, Y, RES, I, panel = line.split()
            frame.peaks.append(
                [float(X),
                 float(Y),
                 float(RES),
                 float(I),
                 str(panel)])
        if '  h    k    l          I   sigma(I)' in line:
            REFLECTIONS = 1
            #append = 0
        if '  fs/px   ss/px (1/d)/nm^-1   Intensity' in line:
            PEAKS = 1

        #if count_shots % 1000 == 0: print '%7i frames parsed, %7i crystals found\r' % (count_shots, count_crystals),
        sys.stdout.flush()

    #print '%7i frames parsed, %7i crystals found\r' % (count_shots, count_crystals),
    #sys.stdout.flush()
    #print

    return header, frames, geom, all_reflections
コード例 #16
0
ファイル: Stream.py プロジェクト: coquellen/NanoPeakCell
    def parse_stream(self):
        crystal = 0
        count_shots = 0
        count_crystals = 0
        self.frames = []
        self.header = ''
        geom = Geom()
        stream = open(self.streamfile)
        all_reflections = []
        head_check = 0
        REFLECTIONS = 0
        PEAKS = 0
        GEOM_FLAG = 0
        self.geom = ''
        self.filenames = []
        self.indexed = []
        emit = 0

        for index, line in enumerate(stream):
            prt = 0
            ### GEt header
            while (head_check == 0):

                self.header += line
                if '----- Begin geometry file -----' in line: GEOM_FLAG = 1

                if GEOM_FLAG: self.geom += line

                # if GEOM_FLAG:
                #    if line.startswith('clen'):
                #        #print line.split('=')
                #        geom.distance = float(line.split('=')[1].split(';')[0].strip())
                #    if 'corner_x' in line:
                #        geom.bx = -1 * float(line.split('=')[1].split(';')[0].strip())
                #    if 'corner_y' in line:
                #        geom.by = -1 * float(line.split('=')[1].split(';')[0].strip())
                #    if 'res' in line:
                #        geom.ps = 1 / float(line.split('=')[1].split(';')[0].strip())
                #    if 'photon_energy' in line:
                #        geom.energy = float(line.split('=')[1].split(';')[0].strip())
                #        geom.wl = 12398.425 / geom.energy
                #    if 'max_fs' in line:
                #        geom.max_fs = float(line.split('=')[1].split(';')[0].strip())
                #    if 'max_ss' in line:
                #        geom.max_ss = float(line.split('=')[1].split(';')[0].strip())

                if '----- End geometry file -----' in line:
                    GEOM_FLAG = 0
                    self.sendGEOM.emit(self.geom)
                break

            ### Get beginning of an image
            if 'Begin chunk' in line:
                count_shots += 1
                append = 1
                head_check = 1
                # frame_stream.append(l)

            ### If
            elif 'Image filename' in line:
                frame = Frame()
                frame.filename = line.split()[2].strip()
                self.filenames.append(frame.filename)

            # The division by 10 is to convert from nm-1 to Angstrom-1
            elif 'indexed_by' in line:
                if 'none' not in line:
                    count_crystals += 1
                    crystal = 1
                    frame.indexing = line.split()[2].strip()
                    self.indexed.append(frame.filename)
                else:
                    frame.indexing = 'none'

            elif 'diffraction_resolution_limit' in line:
                res = float(line.split()[5])
                frame.res = res

            elif 'Cell parameters' in line:
                a0, b0, c0 = line.split()[2:5]
                frame.a = float(a0)
                frame.b = float(b0)
                frame.c = float(c0)
            elif 'astar' in line:
                x, y, z = line.split()[2:5]
                frame.astar[0] = float(x) / 10
                frame.astar[1] = float(y) / 10
                frame.astar[2] = float(z) / 10

            elif 'bstar' in line:
                x, y, z = line.split()[2:5]
                frame.bstar[0] = float(x) / 10
                frame.bstar[1] = float(y) / 10
                frame.bstar[2] = float(z) / 10

            elif 'cstar' in line:
                x, y, z = line.split()[2:5]
                frame.cstar[0] = float(x) / 10
                frame.cstar[1] = float(y) / 10
                frame.cstar[2] = float(z) / 10

            elif 'End of reflections' in line:
                REFLECTIONS = 0

            elif 'End of peak list' in line:
                PEAKS = 0

            elif "End chunk" in line:
                prt = 1
                if crystal == 1:
                    # frame_stream.append(line)
                    # frame.all = frame_stream
                    self.frames.append(frame)
                crystal = 0

            if REFLECTIONS:
                h, k, l, I, SIG, P, BKG, X, Y, panel = line.split()[0:10]
                frame.reflections.append([
                    int(h),
                    int(k),
                    int(l),
                    float(I),
                    float(SIG),
                    float(BKG),
                    float(X),
                    float(Y),
                    str(panel)
                ])  # geom.get_resolution(float(x), float(y)) ])
                # frame.hkl_stream.append(line)

            # if append == 1: frame_stream.append(line)
            if PEAKS:
                X, Y, RES, I, panel = line.split()
                frame.peaks.append(
                    [float(X),
                     float(Y),
                     float(RES),
                     float(I),
                     str(panel)])

            if '   h    k    l          I   sigma(I)' in line:
                REFLECTIONS = 1
                # append = 0
            if '  fs/px   ss/px (1/d)/nm^-1   Intensity' in line:
                PEAKS = 1

            if count_shots % 500 == 0 and count_shots > 500 and prt == 1:
                prt = 0
                print('%7i frames parsed, %7i crystals found' %
                      (count_shots, count_crystals))
                if emit == 0:

                    self.update.emit([self.filenames, self.indexed])
                emit += 1
                if emit % 4 == 0:
                    self.info.emit((count_shots, count_crystals))
            sys.stdout.flush()

        print('%7i frames parsed, %7i crystals found\r' %
              (count_shots, count_crystals))
        #sys.stdout.flush()
        self.info.emit((count_shots, count_crystals))
        self.moveToThread(self.mainThread)
        self.finished.emit()
        self.update.emit([self.filenames, self.indexed])
コード例 #17
0
ファイル: Stream.py プロジェクト: coquellen/NanoPeakCell
 def __init__(self, streamfile, mainThread=None):
     super(CrystFELStreamLight, self).__init__()
     self.streamfile = streamfile
     self.mainThread = mainThread
     self.geometry = Geom()
コード例 #18
0
    def grad_Y(self, u, Y):
        NYs = self.iYobs.size
        NY = Y.size
        cols = self.iYobs
        rows = np.arange(NYs)
        vals = np.full(NYs, 1.0)
        Hy = sps.coo_matrix((vals, (rows, cols)), shape=(NYs, NY))
        return sps.vstack([-Hy, np.sqrt(self.gamma) * self.L])


if __name__ == '__main__':

    L = np.array([1.0, 1.0])
    N = np.array([32, 32])

    g = Geom(L, N)
    g.calculate()

    ul = 2.0
    ur = 1.0
    bc = BC(g)
    bc.dirichlet(g, "left", ul)
    bc.dirichlet(g, "right", ur)

    # Hydraulic conductivity
    npr.seed(0)
    se = SEKernel(std_dev=1.0, cor_len=0.15, std_dev_noise=0.0)
    CY = se.covar(g.cells.centroids.T, g.cells.centroids.T)
    Nc = np.prod(N)
    Y = se.sample(CY, npr.randn(Nc))
    K = np.exp(Y)