currentscape.currents¶
Currents class.
As in https://datadryad.org/stash/dataset/doi:10.5061/dryad.d0779mb. Some functions are based on scripts from the susmentioned article, that are under the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication license.
Classes
All current plotting methods to be inherited by the Currents class. |
|
|
Class containing current data. |
- class currentscape.currents.CurrentPlottingMixin[source]¶
Bases:
object
All current plotting methods to be inherited by the Currents class.
- plot(c, row, rows_tot, cmap, positive=True)[source]¶
Plot all the positive (or negative) currents.
- Parameters:
c (dict) – config
row (int) – row of subplot
rows_tot (int) – total number of subplots in the figure
cmap (matplotlib.colors.Colormap) – colormap
positive (bool) – True to plot positive currents subplot. False to plot negative currents subplot
- plot_overall_contribution(ax, data, c, cmap)[source]¶
Plot one pie chart of either positive or negative currents contribution.
- Parameters:
ax (matplotlib.axes) – pie chart axis
data (ndarray of ndarrays) – positive or negative currents data
c (dict) – config
cmap (matplotlib.colors.Colormap) – colormap
- plot_overall_contributions(c, row, rows_tot, cmap)[source]¶
Plot positive and negative pie charts of currents summed over the whole simulation.
- Parameters:
c (dict) – config
row (int) – row of subplot
rows_tot (int) – total number of subplots in the figure
cmap (matplotlib.colors.Colormap) – colormap
Plot current percentages.
- Parameters:
c (dict) – config
row (int) – row of subplot
rows_tot (int) – total number of subplots in the figure
cmap (matplotlib.colors.Colormap) – colormap
Plot current percentage using imshow.
- Parameters:
c (dict) – config
row (int) – row of subplot
rows_tot (int) – total number of subplots in the figure
cmap (matplotlib.colors.Colormap) – colormap
- plot_sum(c, row, rows_tot, positive=True)[source]¶
Plot outward or inward current sum in log scale.
- Parameters:
c (dict) – config
row (int) – row of subplot
rows_tot (int) – total number of subplots in the figure
positive (bool) – True to plot positive currents subplot. False to plot negative currents subplot
- class currentscape.currents.Currents(data, c, time=None)[source]¶
Bases:
CurrentPlottingMixin
,DataSet
Class containing current data.
- create_black_line(resy, lw)[source]¶
Create a black line to separate inward and outward current shares.
- Parameters:
resy (int) – y-axis resolution (must be high >>1000 or else rounding errors produce white pixels)
lw (int) – black line (separating the two currentscape plots) thickness in percentage of the plot height.
- create_cscape_image(resy, lw)[source]¶
Create currentscape image.
- Parameters:
resy (int) – y-axis resolution (must be high >>1000 or else rounding errors produce white pixels)
lw (int) – black line (separating the two currentscape plots) thickness in percentage of the plot height.
- data_processing(reorder_)[source]¶
Separate into positive and negative currents.
Remove 0s arrays. Reorder if asked. Record reordered name indexes. Return the sum and the fraction with its reordered indexes.
- Parameters:
reorder (bool) – whether to reorder the currents or not
- Returns: A tuple (pos_norm, neg_norm, normapos, normaneg), with
pos_norm (ndarray of ndarrays): arrays containing norm of positive currents
neg_norm (ndarray of ndarrays): arrays containing (-1)* norm of negative currents
normapos (ndarray): summed positive currents
normaneg (ndarray): summed (absolute values of) negative currents
- reorder_currents_and_names(cnorm_pos, cnorm_neg)[source]¶
Reorder positive currents, negative currents, and current names.
Reorder from overall largest contribution to smallest contribution. Reordering the current names (for legend display) is not essential, but is more pleasant to the eye.
- Parameters:
cnorm_pos (ndarray of ndarrays) – arrays containing norm of positive currents
cnorm_neg (ndarray of ndarrays) – arrays containing (-1)* norm of negative currents
- Returns:
trimmed and reordered positive currents array trimmed and reordered negative currents array indexes that currents (in the pos array) used to have in the original curr array indexes that currents (in the neg array) used to have in the original curr array