Skip to content

Commit

Permalink
Added distance target range plotting to distance/time plot, added .pn…
Browse files Browse the repository at this point in the history
…g figures in data/
  • Loading branch information
jschneidewind committed Mar 8, 2022
1 parent f6355ae commit 39bf3a8
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 11 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion data/PEC/Base/PEC_Base.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Name | Value
--- | ---
show | False
save | False
pdf | True
pdf | False
dpi | 500
base_string | Base
title_string | Target cost range:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions data/PV_E/Base/PV_E_Base.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Name | Value
--- | ---
show | False
save | False
pdf | True
pdf | False
dpi | 500
base_string | Base
title_string | Target cost range:
Expand Down Expand Up @@ -247,7 +247,7 @@ Name | Value
--- | ---
show | False
save | False
pdf | True
pdf | False
dpi | 500
fig_width | 5.5
fig_height | 4.5
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
17 changes: 17 additions & 0 deletions data/PV_E/Historical_Data/PV_E_Distance_Time.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Name | Method Name | Arguments
plot_distance_histogram_log | plot_distance_histogram | {'show': False, 'save': False, 'dpi': 400, 'pdf': True, 'image_kwargs': {'path': 'pyH2A.Other~PV_E_Clipart.png'}}
plot_distance_cost_log | plot_distance_cost_relationship | {'show': False, 'save': False, 'dpi': 300, 'pdf': False, 'image_kwargs': {'path': 'pyH2A.Other~PV_E_Clipart.png'}}
plot_distance_time | plot_distance_time_relationship | Arguments - Time Analysis - distance_time_plot
plot_distance_time_no_table | plot_distance_time_relationship | Arguments - Time Analysis - distance_time_plot_no_table

# Arguments - Time Analysis - distance_time_plot

Expand All @@ -162,8 +163,24 @@ show | True
save | False
dpi | 500
pdf | True
color_future | False
image_kwargs | {'path': 'pyH2A.Other~PV_E_Clipart.png'}

# Arguments - Time Analysis - distance_time_plot_no_table

Name | Value
--- | ---
show | False
save | False
name | Distance_Time_Relationship_No_Table
dpi | 500
pdf | False
parameter_table | False
color_future | False
target_distances | [0.5, 0.6]
plot_kwargs | {'left': 0.34, 'right': 0.96, 'bottom': 0.13, 'top': 0.96, 'fig_width': 6.2, 'fig_height': 4.0}
image_kwargs | {'x': -0.37, 'zoom': 0.092, 'y': 0.5, 'path': 'pyH2A.Other~PV_E_Clipart.png'}

# Methods - Monte_Carlo_Analysis

Name | Method Name | Arguments
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion data/Photocatalytic/Base/Photocatalytic_Base.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Name | Value
--- | ---
show | False
save | False
pdf | True
pdf | False
dpi | 500
base_string | Base
title_string | Target cost range:
Expand Down
4 changes: 2 additions & 2 deletions data/pyH2A_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ def test():
print(Energy(285.83 * (1000./2.) * con.Avogadro, kJmol).J)

def main():
#pv_e_base()
pv_e_base()
#pv_e_limit()
#pv_e_distance_time()
#pec_base()
#pec_limit()
#pec_limit_no_concentration()
photocatalytic_base()
#photocatalytic_base()
#photocatalytic_limit()
#technology_comparison()
#test()
Expand Down
4 changes: 2 additions & 2 deletions doc/plugins/Plugin_Guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pyH2A follows the open-closed principle, meaning that new plugins can be interfa
Structure
---------

Plugins are single ``.py`` files, which contain a class with the same name as the filename (this shared name should include the term ``Plugin``). This class is instantiated during pyH2A runtime. The file may also contain other classes and functions, which serve the central class.
Plugins are single ``.py`` files, which contain a class with the same name as the filename (this shared name should include the term ``Plugin``). This class is instantiated during pyH2A runtime. Instantiation requires two arguments: ``dcf``, which is discounted cash flow object (generated during pyH2A runtime) and ``print_info``, which is a flag to control printing of additional runtime information (this flag is passed to :func:`~pyH2A.Utilities.input_modification.insert`) The file may also contain other classes and functions, which serve the central class.

The overall idea is that during instantiation, the class reads information from ``dcf.inp`` (the directory generated from the input file), processes the information and inserts new information into ``dcf.inp``. ``dcf.inp`` is the medium of information exchange between plugins and by inserting information there, the results of the plugin affect the outcome of the discounted cashflow analysis.
The overall idea is that during instantiation, the class reads information from ``dcf.inp`` (the dictionary generated from the input file), processes the information and inserts new information into ``dcf.inp``. ``dcf.inp`` is the medium of information exchange between plugins and by inserting information there, the results of the plugin affect the outcome of the discounted cashflow analysis.

Example
-------
Expand Down
2 changes: 1 addition & 1 deletion src/pyH2A.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pyH2A
Version: 0.0a7
Version: 0.0a8
Summary: A framework for the analysis of hydrogen production cost
Home-page: https://github.com/jschneidewind/pyH2A
Author: Jacob Schneidewind
Expand Down
47 changes: 45 additions & 2 deletions src/pyH2A/Analysis/Development_Distance_Time_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,24 @@ def plot_distance_cost_relationship(self, ax = None, figure_lean = True,
figure.execute()
return figure.fig

def plot_distance_indicator(self, ax, target_distances, model, years, color, ylim_lower):

idx = find_nearest(model, target_distances)

x = years[idx[0]:idx[1]+1]
y = model[idx[0]:idx[1]+1]
y_lower = np.ones(len(x)) * ylim_lower

ax.fill_between(x, y, y_lower, color = color)

# for i in idx:
# x_coord = years[i]
# y_coord = model[i]

# ax.annotate('', xy = (x_coord, y_coord),
# xytext = (x_coord, ylim_lower),
# arrowprops={'arrowstyle': '-', 'ls': 'dashed', 'color': color})

def plot_distance_time_relationship(self, ax = None, figure_lean = True,
legend_loc = 'upper left',
xlabel_string = 'Year',
Expand All @@ -483,7 +501,9 @@ def plot_distance_time_relationship(self, ax = None, figure_lean = True,
linear_label_string = 'Linear model',
datapoint_label_string = ' historical distance',
markersize = 10,
color_future = True,
parameter_table = True,
target_distances = None,
table_kwargs = {}, image_kwargs = {}, plot_kwargs = {},
**kwargs):
'''Ploting relationship between time and development distance based on
Expand All @@ -510,8 +530,13 @@ def plot_distance_time_relationship(self, ax = None, figure_lean = True,
is the display name of the model.
markersize : float, optional
Size of markers in scatter plot.
color_future : bool, optional
Boolean flag to control if past or future region of plot is colored.
parameter_table : bool, optional
If parameter_table is True, the parameter table is shown in the plot.
target_distances : ndarray, optional
Target distance range as an 1D array with two entries ([lower_limit, higher_limit]),
which is highlighted in the plot.
image_kwargs: dict, optional
Dictionary containing optional keyword arguments for
:func:`~pyH2A.Utilities.output_utilities.insert_image`
Expand Down Expand Up @@ -552,10 +577,18 @@ def plot_distance_time_relationship(self, ax = None, figure_lean = True,
ax.plot(self.years, self.distances, '.', color = self.color, markersize = markersize,
label = self.display_name + datapoint_label_string)

xlim = ax.get_xlim()
ax.set_xlim(left = xlim[0], right = np.amax(self.years_extended))

ylim = ax.get_ylim()
ax.set_ylim(ylim)

ax.axhspan(0, 1, color = cm(0.5), alpha = 0.1)
ax.axvspan(self.base_year, np.amax(self.years_extended), color = cm(0.75), alpha = 0.1)

ax.set_xlim(right = np.amax(self.years_extended))
if color_future:
ax.axvspan(self.base_year, np.amax(self.years_extended), color = cm(0.75), alpha = 0.1)
else:
ax.axvspan(xlim[0], self.base_year, color = cm(0.75), alpha = 0.1)

ax.set_xlabel(xlabel_string)
ax.set_ylabel(ylabel_string)
Expand All @@ -569,6 +602,16 @@ def plot_distance_time_relationship(self, ax = None, figure_lean = True,
if image_kwargs['path'] is not None:
insert_image(ax = ax, **image_kwargs)

if target_distances is not None:
ax.axhspan(target_distances[0], target_distances[1], color = 'gray', alpha = 0.3)

self.plot_distance_indicator(ax, target_distances, self.linear_distance_model,
self.years_extended, cm(0.25), ylim[0])

self.plot_distance_indicator(ax, target_distances, self.expo_distance_model,
self.years_extended, cm(0.0), ylim[0])


if figure_lean is True:
figure.execute()
return figure.fig
Expand Down

0 comments on commit 39bf3a8

Please sign in to comment.