def logspace(min, max, num, **kwargs):
"""
Returns log-spaced bins. Same as numpy.logspace except the min and max are the min and max
not log10(min) and log10(max)
Parameters
==========
min : float
minimum value
max : float
maximum value
num : integer
number of log spaced bins
Other Parameters
================
kwargs : dict
additional keywords passed into matplotlib.dates.num2date
Returns
=======
out : array
log-spaced bins from min to max in a numpy array
Notes
=====
This function works on both numbers and datetime objects
Examples
========
>>> import spacepy.toolbox as tb
>>> tb.logspace(1, 100, 5)
array([ 1. , 3.16227766, 10. , 31.6227766 , 100. ])
See Also
========
geomspace
linspace
"""
if isinstance(min, datetime.datetime):
from matplotlib.dates import date2num, num2date
ans = num2date(np.logspace(np.log10(date2num(min)), np.log10(date2num(max)), num, **kwargs))
ans = spt.no_tzinfo(ans)
return np.array(ans)
else:
return np.logspace(np.log10(min), np.log10(max), num, **kwargs)
评论列表
文章目录