Skip to content

Commit 98d2516

Browse files
author
Martin Hangaard Hansen
authored
Merge pull request #110 from mhangaard/cathub_update
change default colormap and misc
2 parents 9f4c003 + 336bb20 commit 98d2516

File tree

8 files changed

+310
-269
lines changed

8 files changed

+310
-269
lines changed

catmap/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
#Standard dependencies
1+
# Standard dependencies
22
import os
33
import sys
44
import inspect
55
import time
66
try:
77
import cPickle as pickle
8-
except:
8+
except (ImportError, ModuleNotFoundError):
99
import _pickle as pickle
1010

1111
import re
1212
from copy import copy
1313
from string import Template
1414

15-
#Non-standard dependencies
15+
# Non-standard dependencies
1616
import numpy as np
1717
try:
1818
from scipy.interpolate import InterpolatedUnivariateSpline as spline
1919
except ImportError:
20-
def spline_wrapper(x_data, y_data, k=3): # input kwarg k is intentionally ignored
20+
# input kwarg k is intentionally ignored.
21+
def spline_wrapper(x_data, y_data, k=3):
2122
# behaves like scipy.interpolate.InterpolatedUnivariateSpline for k=1
2223
def spline_func(x):
23-
return np.interp(x, map(float,x_data), map(float,y_data)) # loss of precision here
24+
# loss of precision here
25+
return np.interp(x, map(float,x_data), map(float,y_data))
2426
return spline_func
2527
spline = spline_wrapper
2628

catmap/analyze/analysis_base.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -111,38 +111,38 @@ class MapPlot:
111111
:param aspect:
112112
:type aspect:
113113
114-
:param subplots_adjust_kwargs: Dictionary of keyword arguments for adjusting matplotlib subplots
114+
:param subplots_adjust_kwargs: Dictionary of keyword arguments for
115+
adjusting matplotlib subplots
115116
:type subplots_adjust_kwargs: dict
116117
117118
.. todo:: Some missing descriptions
118119
"""
119120
def __init__(self):
120-
defaults = dict(
121-
resolution_enhancement = 1,
122-
min = None,
123-
max = None,
124-
n_ticks = 8,
125-
plot_function = None,
126-
colorbar = True,
127-
colormap = plt.cm.jet,
128-
axis_label_decimals = 2,
129-
log_scale = False,
130-
descriptor_labels = ['X_descriptor','Y_descriptor'],
131-
default_descriptor_pt_args = {'marker':'o'},
132-
default_descriptor_label_args = {},
133-
descriptor_pt_args = {},
134-
descriptor_label_args = {},
135-
include_descriptors = False,
136-
plot_size = 4,
137-
aspect = None,
138-
subplots_adjust_kwargs = {'hspace':0.35,'wspace':0.35,
139-
'bottom':0.15}
140-
)
121+
defaults = dict(resolution_enhancement=1,
122+
min=None,
123+
max=None,
124+
n_ticks=8,
125+
plot_function=None,
126+
colorbar=True,
127+
colormap=plt.cm.YlGnBu_r,
128+
axis_label_decimals=2,
129+
log_scale=False,
130+
descriptor_labels=['X_descriptor', 'Y_descriptor'],
131+
default_descriptor_pt_args={'marker': 'o'},
132+
default_descriptor_label_args={},
133+
descriptor_pt_args={},
134+
descriptor_label_args={},
135+
include_descriptors=False,
136+
plot_size=4,
137+
aspect=None,
138+
subplots_adjust_kwargs={'hspace': 0.35,
139+
'wspace': 0.35,
140+
'bottom': 0.15})
141141

142142
for key in defaults:
143143
val = defaults[key]
144-
if not hasattr(self,key):
145-
setattr(self,key,val)
144+
if not hasattr(self, key):
145+
setattr(self, key, val)
146146
elif getattr(self,key) is None:
147147
setattr(self,key,val)
148148

catmap/analyze/matrix_map.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .analysis_base import *
22
from .vector_map import *
33

4+
45
class MatrixMap(VectorMap):
56
"""
67
.. todo:: __doc__

catmap/analyze/scaling.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
from .analysis_base import *
1+
from .analysis_base import ScalingPlot, ReactionModelWrapper
22

3-
class ScalingAnalysis(ScalingPlot,ReactionModelWrapper):
3+
4+
class ScalingAnalysis(ScalingPlot, ReactionModelWrapper):
45
"""
56
.. todo:: __doc__
67
"""
7-
def __init__(self,reaction_model):
8+
def __init__(self, reaction_model):
89
self._rxm = reaction_model
910
self.scaling_mode = 'linear'
10-
ScalingPlot.__init__(self,self.descriptor_names,
11-
self.descriptor_dict,self.surface_names,
12-
self.parameter_dict,
13-
self.plotter_scaling_function,
14-
self.plotter_x_axis_function)
11+
ScalingPlot.__init__(self, self.descriptor_names,
12+
self.descriptor_dict, self.surface_names,
13+
self.parameter_dict,
14+
self.plotter_scaling_function,
15+
self.plotter_x_axis_function)
1516

16-
def plotter_scaling_function(self,descriptors,**kwargs):
17+
def plotter_scaling_function(self, descriptors, **kwargs):
1718
"""
1819
.. todo:: __doc__
1920
"""
2021
descriptors = list(descriptors)
21-
return self.scaler.get_electronic_energies(descriptors,**kwargs)
22+
return self.scaler.get_electronic_energies(descriptors, **kwargs)
2223

23-
def plotter_x_axis_function(self,descriptors,**kwargs):
24+
def plotter_x_axis_function(self, descriptors, **kwargs):
2425
"""
2526
.. todo:: __doc__
2627
"""
@@ -32,24 +33,24 @@ def plotter_x_axis_function(self,descriptors,**kwargs):
3233
self.coefficient_matrix = C
3334
else:
3435
C = self.coefficient_matrix
35-
for ads,c in zip(
36-
self.adsorbate_names+self.transition_state_names,C):
36+
for ads, c in zip(
37+
self.adsorbate_names+self.transition_state_names, C):
3738
x_dict[ads] = sum(
38-
[c[i]*a for i,a in enumerate(descriptors)]) + c[-1]
39+
[c[i]*a for i, a in enumerate(descriptors)]) + c[-1]
3940
lab = ''
40-
for i,a in enumerate(self.descriptor_names):
41-
c_print = round(c[i],self.descriptor_decimal_precision)
41+
for i, a in enumerate(self.descriptor_names):
42+
c_print = round(c[i], self.descriptor_decimal_precision)
4243
if c_print != 0:
4344
lab += str(c_print)+'*$E_{'+str(a)+'}$+'
44-
const = round(c[-1],self.descriptor_decimal_precision)
45+
const = round(c[-1], self.descriptor_decimal_precision)
4546
if const > 0:
4647
lab += '+' + str(const)
4748
elif const < 0:
4849
lab += '-' + str(-const)
49-
lab = lab.replace('++','+')
50-
lab = lab.replace('+-','-')
50+
lab = lab.replace('++', '+')
51+
lab = lab.replace('+-', '-')
5152
labels[ads] = lab
52-
return x_dict,labels
53+
return x_dict, labels
5354

5455
def get_error(self):
5556
"""
@@ -58,4 +59,3 @@ def get_error(self):
5859
if not self.scaling_error:
5960
self.plot(save=False)
6061
return self.scaling_error
61-

catmap/analyze/vector_map.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .analysis_base import *
22
from string import Template
33

4+
45
class VectorMap(MapPlot, ReactionModelWrapper):
56
"""
67
.. todo:: __doc__

0 commit comments

Comments
 (0)