Fix the stereographic projection issue.
The matplotlib function changed. A new keyword is needed to make the plotting "pcolormesh" function works. This keyword is "shading='gouraud'"
This commit is contained in:
parent
de70cc04a1
commit
af72a764e5
|
@ -889,7 +889,7 @@ class _DataSetView(object):
|
||||||
R_ticks = 2 * np.tan(np.radians(theta_ticks/2.))
|
R_ticks = 2 * np.tan(np.radians(theta_ticks/2.))
|
||||||
#R = np.tan(np.radians(theta/2.))
|
#R = np.tan(np.radians(theta/2.))
|
||||||
X, Y = np.meshgrid(np.radians(phi), R)
|
X, Y = np.meshgrid(np.radians(phi), R)
|
||||||
im = axes.pcolormesh(X, Y, Xsec)
|
im = axes.pcolormesh(X, Y, Xsec, shading='gouraud')
|
||||||
axes.set_yticks(R_ticks)
|
axes.set_yticks(R_ticks)
|
||||||
axes.set_yticklabels(theta_ticks)
|
axes.set_yticklabels(theta_ticks)
|
||||||
|
|
||||||
|
|
|
@ -235,8 +235,8 @@ class DataSet(object):
|
||||||
float: '{:<20.10e}', complex: 's'}
|
float: '{:<20.10e}', complex: 's'}
|
||||||
self._formats = ((np.integer, '{:<20d}'),
|
self._formats = ((np.integer, '{:<20d}'),
|
||||||
(np.floating, '{:<20.10e}'),
|
(np.floating, '{:<20.10e}'),
|
||||||
(np.complex, '({0.real:<.10e} {0.imag:<.10e}j)'),
|
(complex, '({0.real:<.10e} {0.imag:<.10e}j)'),
|
||||||
(np.bool, '{:s}'),
|
(bool, '{:s}'),
|
||||||
(str, '{:s}'))
|
(str, '{:s}'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -450,9 +450,13 @@ class DataSet(object):
|
||||||
:return: The cluster
|
:return: The cluster
|
||||||
:rtype: :py:class:`ase.Atoms`
|
:rtype: :py:class:`ase.Atoms`
|
||||||
"""
|
"""
|
||||||
|
p = self.get_parameter(group='Cluster', name='cluster')['value']
|
||||||
s = StringIO()
|
s = StringIO()
|
||||||
s.write(self.get_parameter(group='Cluster', name='cluster')['value'])
|
s.write(self.get_parameter(group='Cluster', name='cluster')['value'])
|
||||||
return ase.io.read(s, format='xyz')
|
s.seek(0)
|
||||||
|
#return ase.io.read(s, format='xyz')
|
||||||
|
cluster = list(read_xyz(s))[-1]
|
||||||
|
return cluster
|
||||||
|
|
||||||
|
|
||||||
def select(self, *args, **kwargs):
|
def select(self, *args, **kwargs):
|
||||||
|
@ -785,13 +789,13 @@ class Data(object):
|
||||||
dset = output.add_dset(dset_name)
|
dset = output.add_dset(dset_name)
|
||||||
dset.notes = fd['DATA'][dset_name].attrs['notes']
|
dset.notes = fd['DATA'][dset_name].attrs['notes']
|
||||||
for h5dset in fd['DATA'][dset_name]:
|
for h5dset in fd['DATA'][dset_name]:
|
||||||
dset.add_columns(**{h5dset: fd['DATA'][dset_name][h5dset].value})
|
dset.add_columns(**{h5dset: fd['DATA'][dset_name][h5dset][...]})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
vfile = LooseVersion(fd['MsSpec viewer metainfo'].attrs['version'])
|
vfile = LooseVersion(fd['MsSpec viewer metainfo'].attrs['version'])
|
||||||
if vfile > LooseVersion(msspec.__version__):
|
if vfile > LooseVersion(msspec.__version__):
|
||||||
raise NameError('File was saved with a more recent format')
|
raise NameError('File was saved with a more recent format')
|
||||||
xml = fd['MsSpec viewer metainfo']['info'].value.tostring()
|
xml = fd['MsSpec viewer metainfo']['info'][...].tobytes()
|
||||||
root = etree.fromstring(xml)
|
root = etree.fromstring(xml)
|
||||||
for elt0 in root.iter('parameters'):
|
for elt0 in root.iter('parameters'):
|
||||||
dset_name = elt0.attrib['dataset']
|
dset_name = elt0.attrib['dataset']
|
||||||
|
@ -854,7 +858,7 @@ class Data(object):
|
||||||
#win.show()
|
#win.show()
|
||||||
#Gtk.main()
|
#Gtk.main()
|
||||||
app = _Application(self)
|
app = _Application(self)
|
||||||
exit_status = app.run(sys.argv)
|
exit_status = app.run()#sys.argv)
|
||||||
sys.exit(exit_status)
|
sys.exit(exit_status)
|
||||||
|
|
||||||
class _Application(Gtk.Application):
|
class _Application(Gtk.Application):
|
||||||
|
@ -947,7 +951,8 @@ class _DataSetView(object):
|
||||||
if np.shape(values)[0] == 1:
|
if np.shape(values)[0] == 1:
|
||||||
xvalues = list(range(len(values[0])))
|
xvalues = list(range(len(values[0])))
|
||||||
axes.bar(xvalues, values[0], label=label,
|
axes.bar(xvalues, values[0], label=label,
|
||||||
picker=5)
|
# picker=5
|
||||||
|
)
|
||||||
axes.set_xticks(xvalues)
|
axes.set_xticks(xvalues)
|
||||||
else:
|
else:
|
||||||
if proj in ('ortho', 'stereo'):
|
if proj in ('ortho', 'stereo'):
|
||||||
|
@ -961,7 +966,7 @@ class _DataSetView(object):
|
||||||
R_ticks = 2 * np.tan(np.radians(theta_ticks/2.))
|
R_ticks = 2 * np.tan(np.radians(theta_ticks/2.))
|
||||||
#R = np.tan(np.radians(theta/2.))
|
#R = np.tan(np.radians(theta/2.))
|
||||||
X, Y = np.meshgrid(np.radians(phi), R)
|
X, Y = np.meshgrid(np.radians(phi), R)
|
||||||
im = axes.pcolormesh(X, Y, Xsec)
|
im = axes.pcolormesh(X, Y, Xsec, shading='gouraud')
|
||||||
axes.set_yticks(R_ticks)
|
axes.set_yticks(R_ticks)
|
||||||
axes.set_yticklabels(theta_ticks)
|
axes.set_yticklabels(theta_ticks)
|
||||||
|
|
||||||
|
@ -969,7 +974,7 @@ class _DataSetView(object):
|
||||||
|
|
||||||
elif proj == 'polar':
|
elif proj == 'polar':
|
||||||
values[0] = np.radians(values[0])
|
values[0] = np.radians(values[0])
|
||||||
axes.plot(*values, label=label, picker=5,
|
axes.plot(*values, label=label, #picker=5,
|
||||||
marker=opts['marker'])
|
marker=opts['marker'])
|
||||||
else:
|
else:
|
||||||
if scale == 'semilogx':
|
if scale == 'semilogx':
|
||||||
|
@ -980,7 +985,7 @@ class _DataSetView(object):
|
||||||
pltcmd = axes.loglog
|
pltcmd = axes.loglog
|
||||||
else:
|
else:
|
||||||
pltcmd = axes.plot
|
pltcmd = axes.plot
|
||||||
pltcmd(*values, label=label, picker=5,
|
pltcmd(*values, label=label, #picker=5,
|
||||||
marker=opts['marker'])
|
marker=opts['marker'])
|
||||||
axes.grid(opts['grid'])
|
axes.grid(opts['grid'])
|
||||||
axes.set_title(opts['title'])
|
axes.set_title(opts['title'])
|
||||||
|
@ -988,6 +993,7 @@ class _DataSetView(object):
|
||||||
axes.set_ylabel(opts['ylabel'])
|
axes.set_ylabel(opts['ylabel'])
|
||||||
axes.set_xlim(*opts['xlim'])
|
axes.set_xlim(*opts['xlim'])
|
||||||
axes.set_ylim(*opts['ylim'])
|
axes.set_ylim(*opts['ylim'])
|
||||||
|
#axes.set_pickradius(5)
|
||||||
if label:
|
if label:
|
||||||
axes.legend()
|
axes.legend()
|
||||||
axes.autoscale(enable=opts['autoscale'])
|
axes.autoscale(enable=opts['autoscale'])
|
||||||
|
@ -1242,7 +1248,7 @@ class _DataWindow(Gtk.ApplicationWindow):
|
||||||
def on_close(self, action, param):
|
def on_close(self, action, param):
|
||||||
if self.data.is_dirty():
|
if self.data.is_dirty():
|
||||||
dlg = Gtk.Dialog(title="Warning: Unsaved data",
|
dlg = Gtk.Dialog(title="Warning: Unsaved data",
|
||||||
transient_for=self, flags=Gtk.DialogFlags.MODAL)
|
transient_for=self, modal=True)
|
||||||
dlg.add_buttons(Gtk.STOCK_YES, Gtk.ResponseType.YES,
|
dlg.add_buttons(Gtk.STOCK_YES, Gtk.ResponseType.YES,
|
||||||
Gtk.STOCK_NO, Gtk.ResponseType.NO)
|
Gtk.STOCK_NO, Gtk.ResponseType.NO)
|
||||||
dlg.set_default_size(150, 100)
|
dlg.set_default_size(150, 100)
|
||||||
|
@ -1474,9 +1480,14 @@ class OLD_DataWindow(wx.Frame):
|
||||||
cluster_viewer = ClusterViewer(win, size=wx.Size(480, 340))
|
cluster_viewer = ClusterViewer(win, size=wx.Size(480, 340))
|
||||||
|
|
||||||
dset = self.data[self._current_dset]
|
dset = self.data[self._current_dset]
|
||||||
s = StringIO()
|
#s = StringIO()
|
||||||
s.write(dset.get_parameter(group='Cluster', name='cluster')['value'])
|
#s.write(dset.get_parameter(group='Cluster', name='cluster')['value'])
|
||||||
atoms = ase.io.read(s, format='xyz')
|
#_s = dset.get_parameter(group='Cluster', name='cluster')['value']
|
||||||
|
#print(_s)
|
||||||
|
# rewind to the begining of the string
|
||||||
|
#s.seek(0)
|
||||||
|
#atoms = ase.io.read(s, format='xyz')
|
||||||
|
atoms = dset.get_cluster()
|
||||||
cluster_viewer.set_atoms(atoms, rescale=True, center=True)
|
cluster_viewer.set_atoms(atoms, rescale=True, center=True)
|
||||||
cluster_viewer.rotate_atoms(0., 180.)
|
cluster_viewer.rotate_atoms(0., 180.)
|
||||||
cluster_viewer.rotate_atoms(-45., -45.)
|
cluster_viewer.rotate_atoms(-45., -45.)
|
||||||
|
@ -1677,7 +1688,7 @@ class OLD_DataWindow(wx.Frame):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if True:
|
if False:
|
||||||
data = Data('all my data')
|
data = Data('all my data')
|
||||||
dset = data.add_dset('Dataset 0')
|
dset = data.add_dset('Dataset 0')
|
||||||
X = np.arange(0, 20)
|
X = np.arange(0, 20)
|
||||||
|
@ -1713,6 +1724,7 @@ if __name__ == "__main__":
|
||||||
view.select('x', 'y')
|
view.select('x', 'y')
|
||||||
|
|
||||||
data.view()
|
data.view()
|
||||||
#import sys
|
exit()
|
||||||
#data = Data.load(sys.argv[1])
|
import sys
|
||||||
#data.view()
|
data = Data.load(sys.argv[1])
|
||||||
|
data.view()
|
||||||
|
|
Loading…
Reference in New Issue