Skip to content

Commit

Permalink
Add timeplot scaling setting (lanl#58)
Browse files Browse the repository at this point in the history
* add timeplot setting to choose plot scaling based on values

* update change log
  • Loading branch information
shinkle-lanl authored Jan 30, 2024
1 parent b4984e1 commit 02a0278
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ New Features:
- Add nodes for non-adiabatic coupling vectors (NACR) and phase-less loss.
See /examples/excited_states_azomethane.py.

- New MultiGradient node for computing multiple partial derivatives of
using one call to automatic differentiation.
- New MultiGradient node for computing more than one partial derivative
using a single call to automatic differentiation.

Improvements:
-------------
Expand All @@ -24,6 +24,11 @@ Improvements:

- Create Memory parent class to remove redundancy.

- New setting TIMEPLOT_AUTOSCALING. If True (default), time plots with
log-scaling on the axes will only be produced if warranted by the data.
If False, time plots with linear-scaling and log-scaling will be produced
every time.

Bug Fixes:
----------

Expand Down
1 change: 1 addition & 0 deletions hippynn/_settings_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def kernel_handler(kernel_string):
"DEBUG_AUTOINDEXING": (False, strtobool),
"USE_CUSTOM_KERNELS": ("auto", kernel_handler),
"WARN_LOW_DISTANCES": (True, strtobool),
"TIMEPLOT_AUTOSCALING": (True, strtobool),
}

settings = SimpleNamespace(**{k: default for k, (default, handler) in default_settings.items()})
Expand Down
5 changes: 3 additions & 2 deletions hippynn/plotting/timeplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ def plot_over_time(metric_name, metric_data, pltkwd_info, save_dir):

datamin = min(min(arr) for arr in metric_data.values())
datamax = max(max(arr) for arr in metric_data.values())
if datamin > 0 and datamax / datamin > 2:
# if settings.TIMEPLOT_AUTOSCALING is set to True, only produce log-scale plots under certain conditions
if (not settings.TIMEPLOT_AUTOSCALING) or (datamin > 0 and datamax / datamin > 2):
plt.yscale("log")
fname = os.path.join(save_dir, metric_name + "_logplot" + settings.DEFAULT_PLOT_FILETYPE)
plt.savefig(fname)

if max(len(arr) for arr in metric_data.values()) > 10:
if (not settings.TIMEPLOT_AUTOSCALING) or (max(len(arr) for arr in metric_data.values()) > 10):
plt.xscale("log")
fname = os.path.join(save_dir, metric_name + "_loglogplot" + settings.DEFAULT_PLOT_FILETYPE)
plt.savefig(fname)
Expand Down

0 comments on commit 02a0278

Please sign in to comment.