Пример #1
0
    def __init__(self, dsname):
	"""Create and return an open CTF dataset object. You may open many
	CTF datasets at once by creating many instances of this class."""

	self.dsData = None      # set this now so __del__ won't complain

	if dsname[-1] == '/':
	    dsname = dsname[:-1]
	b = os.path.basename(dsname)
	if b[-3:] != '.ds':
	    raise Exception, "%s is not a dataset name" % dsname
	self.dsname = dsname
	self.setname = b[:-3]

	# Open files. We allow the .meg4 file to be absent.

	res4name = self.getDsFileNameExt('.res4')
	self.r = ctf.readRes4(res4name)
	try:
	    meg4name = self.getDsFileNameExt('.meg4')
	    self.dsData = dsData(self.r, meg4name)  # handle to open .meg4 file
	except:
	    pass

	# A mapping from channel name to number, backwards compatible name.

	self.channel = self.r.chanIndex

	# Get the marks, if any.

	self.marks = markers(dsname)

	# Get the dewar coordinates of the head from the .hc file, if any.

	hc = self.getDsFileNameExt('.hc')
	try:
	    n, l, r = getHC(hc, 'dewar')
	    self.dewar = n, l, r

	    # compute the transform into the head frame
	    self.dewar_to_head = fid.fid(n, l, r)

	    # compute the head coordinates in the head frame
	    self.head = [fid.fid_transform(self.dewar_to_head, x) for x in self.dewar]
	except:
	    pass
Пример #2
0
def dsopen(dsname):
	if dsname[-1] == '/':
		dsname = dsname[:-1]
	s = os.path.splitext(dsname)
	if s[1] != '.ds':
		raise Exception, "%s is not a dataset name" % dsname

	# get the SWIG wrapper for MEGH and change its class

	ds = ctf.dsopen(dsname)
	ds.__class__ = dsWrap

	# create a mapping from channel name to number

	d = {}
	for m in range(ds.getNumberOfChannels()):
	    n = ds.getChannelName(m).split('-')[0]
	    d[n] = m
	ds.channel = d

	# get the marks, if any
	ds.marks = markers(dsname)

	# get the dewar coordinates of the head from the hc file, if any
	hc = ds.dsname + '/' + ds.setname + '.hc'
	try:
		n, l, r = getHC(hc, 'dewar')
		ds.dewar = n, l, r

		# compute the transform into the head frame
		ds.dewar_to_head = fid.fid(n, l, r)

		# compute the head coordinates in the head frame
		ds.head = [fid.fid_transform(ds.dewar_to_head, x) for x in ds.dewar]
	except:
		pass
	return ds
Пример #3
0
    # figure name
    figfile = f'../example/Gcurves/MoZr-T{T}.png'

    # preparing graphics
    plt.cla()
    ax.set_xlim([0, 1])
    ax.set_xlabel(r'$x_\mathrm{Zr}$')
    ax.set_ylabel(r'$G_m$ (J/mol)')
    ax.text(0.03, .95, f'$T={T}$ K', transform=ax.transAxes)

    # calculating hull and tielines
    Gdata, hull, vertices = ch.hull(x, T, MoZr)
    tielines, nt = ch.tielines(vertices, Gdata, dx)

    # showing free energy curves
    mkr = markers.markers()
    for phase in MoZr:
        if phase.kind == 'sol':
            ax.plot(x,
                    phase.G(x, T),
                    next(mkr),
                    markersize=4,
                    label=phase.label)
        elif phase.kind == 'stq':
            ax.plot(phase.xB, phase.G(T), 'o', label=phase.label, markersize=8)

    # showing tielines
    for i in range(0, nt, 2):
        ax.plot(Gdata[tielines[i:i + 2], 0],
                Gdata[tielines[i:i + 2], 1],
                'b-o',
Пример #4
0
		n = len(c)
		for s in slist:
			if c == s[0:n]:
				l.append(s)
		if len(l) > 0:
			clist1.extend(l)
		else:
			printerror("channel %s not found" % c)
			sys.exit(1)

cnames = ', '.join(clist)
clist = clist1

# Look at the markers and construct the list of trials.

marks = markers(dsname)

for marker in mlist:
	if not marks.has_key(marker):
		printerror("unknown marker '%s'" % marker)
		sys.exit(1)

if len(mlist) == 0:
	# if no marks, use the start of each trial
	tlist = zip(range(ntrials), [0]*ntrials)
else:
	tlist = []
	for marker in mlist:
		tlist.extend(marks[marker])

# Filter out unwanted trials.