Skip to content

Commit

Permalink
Merge pull request #110 from mhangaard/cathub_update
Browse files Browse the repository at this point in the history
change default colormap and misc
  • Loading branch information
Martin Hangaard Hansen authored Dec 10, 2018
2 parents 9f4c003 + 336bb20 commit 98d2516
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 269 deletions.
12 changes: 7 additions & 5 deletions catmap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
#Standard dependencies
# Standard dependencies
import os
import sys
import inspect
import time
try:
import cPickle as pickle
except:
except (ImportError, ModuleNotFoundError):
import _pickle as pickle

import re
from copy import copy
from string import Template

#Non-standard dependencies
# Non-standard dependencies
import numpy as np
try:
from scipy.interpolate import InterpolatedUnivariateSpline as spline
except ImportError:
def spline_wrapper(x_data, y_data, k=3): # input kwarg k is intentionally ignored
# input kwarg k is intentionally ignored.
def spline_wrapper(x_data, y_data, k=3):
# behaves like scipy.interpolate.InterpolatedUnivariateSpline for k=1
def spline_func(x):
return np.interp(x, map(float,x_data), map(float,y_data)) # loss of precision here
# loss of precision here
return np.interp(x, map(float,x_data), map(float,y_data))
return spline_func
spline = spline_wrapper

Expand Down
48 changes: 24 additions & 24 deletions catmap/analyze/analysis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,38 +111,38 @@ class MapPlot:
:param aspect:
:type aspect:
:param subplots_adjust_kwargs: Dictionary of keyword arguments for adjusting matplotlib subplots
:param subplots_adjust_kwargs: Dictionary of keyword arguments for
adjusting matplotlib subplots
:type subplots_adjust_kwargs: dict
.. todo:: Some missing descriptions
"""
def __init__(self):
defaults = dict(
resolution_enhancement = 1,
min = None,
max = None,
n_ticks = 8,
plot_function = None,
colorbar = True,
colormap = plt.cm.jet,
axis_label_decimals = 2,
log_scale = False,
descriptor_labels = ['X_descriptor','Y_descriptor'],
default_descriptor_pt_args = {'marker':'o'},
default_descriptor_label_args = {},
descriptor_pt_args = {},
descriptor_label_args = {},
include_descriptors = False,
plot_size = 4,
aspect = None,
subplots_adjust_kwargs = {'hspace':0.35,'wspace':0.35,
'bottom':0.15}
)
defaults = dict(resolution_enhancement=1,
min=None,
max=None,
n_ticks=8,
plot_function=None,
colorbar=True,
colormap=plt.cm.YlGnBu_r,
axis_label_decimals=2,
log_scale=False,
descriptor_labels=['X_descriptor', 'Y_descriptor'],
default_descriptor_pt_args={'marker': 'o'},
default_descriptor_label_args={},
descriptor_pt_args={},
descriptor_label_args={},
include_descriptors=False,
plot_size=4,
aspect=None,
subplots_adjust_kwargs={'hspace': 0.35,
'wspace': 0.35,
'bottom': 0.15})

for key in defaults:
val = defaults[key]
if not hasattr(self,key):
setattr(self,key,val)
if not hasattr(self, key):
setattr(self, key, val)
elif getattr(self,key) is None:
setattr(self,key,val)

Expand Down
1 change: 1 addition & 0 deletions catmap/analyze/matrix_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .analysis_base import *
from .vector_map import *


class MatrixMap(VectorMap):
"""
.. todo:: __doc__
Expand Down
42 changes: 21 additions & 21 deletions catmap/analyze/scaling.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
from .analysis_base import *
from .analysis_base import ScalingPlot, ReactionModelWrapper

class ScalingAnalysis(ScalingPlot,ReactionModelWrapper):

class ScalingAnalysis(ScalingPlot, ReactionModelWrapper):
"""
.. todo:: __doc__
"""
def __init__(self,reaction_model):
def __init__(self, reaction_model):
self._rxm = reaction_model
self.scaling_mode = 'linear'
ScalingPlot.__init__(self,self.descriptor_names,
self.descriptor_dict,self.surface_names,
self.parameter_dict,
self.plotter_scaling_function,
self.plotter_x_axis_function)
ScalingPlot.__init__(self, self.descriptor_names,
self.descriptor_dict, self.surface_names,
self.parameter_dict,
self.plotter_scaling_function,
self.plotter_x_axis_function)

def plotter_scaling_function(self,descriptors,**kwargs):
def plotter_scaling_function(self, descriptors, **kwargs):
"""
.. todo:: __doc__
"""
descriptors = list(descriptors)
return self.scaler.get_electronic_energies(descriptors,**kwargs)
return self.scaler.get_electronic_energies(descriptors, **kwargs)

def plotter_x_axis_function(self,descriptors,**kwargs):
def plotter_x_axis_function(self, descriptors, **kwargs):
"""
.. todo:: __doc__
"""
Expand All @@ -32,24 +33,24 @@ def plotter_x_axis_function(self,descriptors,**kwargs):
self.coefficient_matrix = C
else:
C = self.coefficient_matrix
for ads,c in zip(
self.adsorbate_names+self.transition_state_names,C):
for ads, c in zip(
self.adsorbate_names+self.transition_state_names, C):
x_dict[ads] = sum(
[c[i]*a for i,a in enumerate(descriptors)]) + c[-1]
[c[i]*a for i, a in enumerate(descriptors)]) + c[-1]
lab = ''
for i,a in enumerate(self.descriptor_names):
c_print = round(c[i],self.descriptor_decimal_precision)
for i, a in enumerate(self.descriptor_names):
c_print = round(c[i], self.descriptor_decimal_precision)
if c_print != 0:
lab += str(c_print)+'*$E_{'+str(a)+'}$+'
const = round(c[-1],self.descriptor_decimal_precision)
const = round(c[-1], self.descriptor_decimal_precision)
if const > 0:
lab += '+' + str(const)
elif const < 0:
lab += '-' + str(-const)
lab = lab.replace('++','+')
lab = lab.replace('+-','-')
lab = lab.replace('++', '+')
lab = lab.replace('+-', '-')
labels[ads] = lab
return x_dict,labels
return x_dict, labels

def get_error(self):
"""
Expand All @@ -58,4 +59,3 @@ def get_error(self):
if not self.scaling_error:
self.plot(save=False)
return self.scaling_error

1 change: 1 addition & 0 deletions catmap/analyze/vector_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .analysis_base import *
from string import Template


class VectorMap(MapPlot, ReactionModelWrapper):
"""
.. todo:: __doc__
Expand Down
Loading

0 comments on commit 98d2516

Please sign in to comment.