1- import logging
2- import os
3-
1+ #
2+ # Leak correction methods
3+ #
44import numpy as np
55from matplotlib import pyplot as plt
66
@@ -55,7 +55,7 @@ def get_leak_corrected(current, voltages, times, ramp_start_index,
5555
5656
5757def fit_linear_leak (current , voltage , times , ramp_start_index , ramp_end_index ,
58- save_fname = None , output_dir = None , figsize = (5.54 , 7 )):
58+ save_fname = None , figsize = (5.54 , 7 )):
5959 """
6060 Fits linear leak to a leak ramp, returning
6161
@@ -64,8 +64,6 @@ def fit_linear_leak(current, voltage, times, ramp_start_index, ramp_end_index,
6464 @param ramp_start_index: the index of the observation where the leak ramp begins
6565 @param ramp_end_index: the index of the observation where the leak ramp ends
6666 @param save_fname: if set, a debugging figure will be made and stored with this name
67- @param output_dir: if ``save_fname`` is set, this directory will be used to store
68- the figure, and created if it does not exist
6967 @param figsize: if ``save_fname`` is set, the figure size.
7068
7169 @return: the linear regression parameters obtained from fitting the leak
@@ -106,26 +104,26 @@ def fit_linear_leak(current, voltage, times, ramp_start_index, ramp_end_index,
106104 time_range = (0 , times .max () / 5 )
107105
108106 # Current vs time
109- ax1 .set_title (r'\textbf{a}' , loc = 'left' , usetex = True )
107+ ax1 .set_title (r'\textbf{a}' , loc = 'left' )
110108 ax1 .set_xlabel (r'$t$ (ms)' )
111109 ax1 .set_ylabel (r'$I_\mathrm{obs}$ (pA)' )
112110 ax1 .set_xticklabels ([])
113111 ax1 .set_xlim (* time_range )
114112
115113 # Voltage vs time
116- ax2 .set_title (r'\textbf{b}' , loc = 'left' , usetex = True )
114+ ax2 .set_title (r'\textbf{b}' , loc = 'left' )
117115 ax2 .set_xlabel (r'$t$ (ms)' )
118116 ax2 .set_ylabel (r'$V_\mathrm{cmd}$ (mV)' )
119117 ax2 .set_xlim (* time_range )
120118
121119 # Current vs voltage
122- ax3 .set_title (r'\textbf{c}' , loc = 'left' , usetex = True )
120+ ax3 .set_title (r'\textbf{c}' , loc = 'left' )
123121 ax3 .set_xlabel (r'$V_\mathrm{cmd}$ (mV)' )
124122 ax3 .set_ylabel (r'$I_\mathrm{obs}$ (pA)' )
125123
126124 ax4 .set_xlabel (r'$t$ (ms)' )
127125 ax4 .set_ylabel (r'current (pA)' )
128- ax4 .set_title (r'\textbf{d}' , loc = 'left' , usetex = True )
126+ ax4 .set_title (r'\textbf{d}' , loc = 'left' )
129127
130128 start_t = times [ramp_start_index ]
131129 end_t = times [ramp_end_index ]
@@ -152,14 +150,8 @@ def fit_linear_leak(current, voltage, times, ramp_start_index, ramp_end_index,
152150 alpha = 0.5 , label = r'$I_\mathrm{obs} - I_\mathrm{L}$' )
153151 ax4 .legend (frameon = False )
154152
155- if not os .path .exists (output_dir ):
156- os .makedirs (output_dir )
157-
158- if output_dir :
159- try :
160- fig .savefig (os .path .join (output_dir , save_fname ))
161- plt .close (fig )
162- except Exception as exc :
163- logging .warning (str (exc ))
153+ if save_fname is not None :
154+ fig .savefig (save_fname )
155+ plt .close (fig )
164156
165157 return (b_0 , b_1 ), I_leak
0 commit comments