Skip to content

Commit

Permalink
Pydv 263 range considerations in getyminmax and getx (#264)
Browse files Browse the repository at this point in the history
* Getymax returns all pairings in range
  • Loading branch information
rusu24edward authored Apr 20, 2022
1 parent 6dcbe32 commit ca2576f
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: pydv-3.0.7
release_name: PyDV 3.0.7
tag_name: pydv-3.1.0
release_name: PyDV 3.1.0
draft: false
prerelease: false
4 changes: 2 additions & 2 deletions pydv/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = u'3.0'
version = u'3.1'
# The full version, including alpha/beta/rc tags.
release = u'3.0.7'
release = u'3.1.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
16 changes: 10 additions & 6 deletions pydv/docs/curve_inquiry_cmds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,23 @@ Calculate the mean and standard deviation for the curves and display the results
[PyDV]: stats <curve-list>
**getymin - 2.4.2**
-------------------
getymin
-------

Return the minimum y-value for the curve within the specified domain. If no domain is given, then the full domain range is used.
Return xy-parings of the x values with the corresponding minimum y-value for the
curve within the specified domain. If no domain is given, then the full domain
range is used.

.. code::
[PyDV]: getymin <curve> [<xmin> <xmax>]
**getymax - 2.4.2**
-------------------
getymax
-------

Return the maximum y-value for the curve within the specified domain. If no domain is given, then the full domain range is used.
Return xy-parings of the x values with the corresponding maximum y-value for the
curve within the specified domain. If no domain is given, then the full domain
range is used.

.. code::
Expand Down
8 changes: 8 additions & 0 deletions pydv/docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Release Notes
=============

3.1.0
-----
`getymin` and `getymax` will now return a list of x, y pairs for the min/max value.
If there is a domain specified, these functions will only return points in that
domain.



3.0.7
-----
* Fixed a bug in PyDV internal when using min and max over a range.
Expand Down
14 changes: 7 additions & 7 deletions pydv/pdv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1850,10 +1850,10 @@ def do_getymax(self, line):

idx = pdvutil.getCurveIndex(line[0], self.plotlist)
cur = self.plotlist[idx]
plotname, maxy = pydvif.getymax(cur, xlow, xhi)
plotname, xy_values = pydvif.getymax(cur, xlow, xhi)
print('\nCurve ' + plotname)
print(' ymax: %.6f' % maxy)
print('')
for x, y in xy_values:
print(' x: %.6e y: %.6e\n' % (x, y))
except:
print('error - usage: getymax <curve> [<xmin> <xmax>]')
if self.debug:
Expand Down Expand Up @@ -1890,10 +1890,10 @@ def do_getymin(self, line):

idx = pdvutil.getCurveIndex(line[0], self.plotlist)
cur = self.plotlist[idx]
plotname, miny = pydvif.getymin(cur, xlow, xhi)
plotname, xy_values = pydvif.getymin(cur, xlow, xhi)
print('\nCurve ' + plotname)
print(' ymin: %.6f' % miny)
print('')
for x, y in xy_values:
print(' x: %.6e y: %.6e\n' % (x, y))
except:
print('error - usage: getymin <curve> [<xmin> <xmax>]')
if self.debug:
Expand Down Expand Up @@ -6678,7 +6678,7 @@ def tickFormat(self, axis, logscale, ticks, tickformat):

def console_run(self):
while True:
self.cmdloop('\n\tPython Data Visualizer 3.0.7 - 04.19.2022\n\tType "help" for more information.\n\n')
self.cmdloop('\n\tPython Data Visualizer 3.1.0 - 04.20.2022\n\tType "help" for more information.\n\n')
print('\n Starting Python Console...\n Ctrl-D to return to PyDV\n')
console = code.InteractiveConsole(locals())
console.interact()
Expand Down
4 changes: 2 additions & 2 deletions pydv/pdvplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __init__(self, pydvcmd):
here = path.abspath(path.dirname(__file__))

# Setup Application
self.setWindowTitle('Python Data Visualizer 3.0.7')
self.setWindowTitle('Python Data Visualizer 3.1.0')
self.setWindowIcon(QIcon(path.join(here, 'img/app_icon3.png')))
self._pydvcmd = pydvcmd

Expand Down Expand Up @@ -519,7 +519,7 @@ def __aboutQt(self):

def __aboutPyDV(self):
QMessageBox.about(self, self.tr('About PyDV'), self.tr('<h2>About PyDV</h2>'
'<p style="font-family:courier; font-size:40%;">version 3.0.7</p>'
'<p style="font-family:courier; font-size:40%;">version 3.1.0</p>'
'<p style="font-family:verdana;"><a href="https://pydv.readthedocs.io/en/latest/">PyDV</a> is a 1D graphics tool, heavily based on the ULTRA plotting tool.</p>'
'<p style="font-family:courier; font-size:-1;">Copyright &copy; 2011-2020, Lawrence Livermore National Security, LLC.</p>'
'<p style="font-family:veranda; font-size:80%;">Written by: Edward Rusu, Kevin Griffin, Mason Kwiat, and Douglas S. Miller</p>'
Expand Down
27 changes: 17 additions & 10 deletions pydv/pydvpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2686,15 +2686,17 @@ def getymax(c, xmin=None, xmax=None):
:param xmax: the maximum x-value for the sub-domain
:type xmax: float, optional
:return: str -- curve name
ymax -- the maximum y-value for the specified domain
list -- a list of tuples where each tuple contains the x-value and
the max y-value.
"""
if xmin is not None:
r = __get_sub_range(c.x, xmin, xmax)
ymax = max(c.y[r[0]:r[1]+1])
else:
ymax = max(c.y)
xy_pairs_at_max = getx(c, ymax, xmin, xmax)

return __toCurveString(c), ymax
return __toCurveString(c), xy_pairs_at_max


def getymin(c, xmin=None, xmax=None):
Expand All @@ -2708,15 +2710,17 @@ def getymin(c, xmin=None, xmax=None):
:param xmax: the maximum x-value for the sub-domain
:type xmax: float, optional
:return: str -- curve name
ymin -- the minimum y-value for the specified domain
list -- a list of tuples where each tuple contains the x-value and
the min y-value.
"""
if xmin is not None:
r = __get_sub_range(c.x, xmin, xmax)
ymin = min(c.y[r[0]:r[1]+1])
else:
ymin = min(c.y)
xy_pairs_at_min = getx(c, ymin, xmin, xmax)

return __toCurveString(c), ymin
return __toCurveString(c), xy_pairs_at_min


def correlate(c1, c2, mode='valid'):
Expand Down Expand Up @@ -3380,7 +3384,7 @@ def getrange(curvelist):
return ranges


def getx(c, value):
def getx(c, value, xmin=None, xmax=None):
"""
Get the x values of the curve for a given y.
Expand All @@ -3397,11 +3401,12 @@ def getx(c, value):
:return: list -- A list of tuples where each tuple contains the x value, and the given y
"""
xypairs = list()
r = __get_sub_range(c.x, xmin, xmax)

if float(value) < np.amin(c.y) or float(value) > np.amax(c.y):
raise ValueError('y-value out of range')

for i in range(len(c.y)):
for i in range(r[0], r[1] + 1):
if c.y[i] == float(value):
xypairs.append((c.x[i], float(value)))
else:
Expand All @@ -3411,10 +3416,12 @@ def getx(c, value):

if c.y[i] < float(value) < ymax:
x = np.interp(float(value), [c.y[i], ymax], [c.x[i], c.x[i+1]])
xypairs.append((x, float(value)))
if x <= r[1]:
xypairs.append((x, float(value)))
elif ymax < float(value) < c.y[i]:
x = np.interp(float(value), [ymax, c.y[i]], [c.x[i+1], c.x[i]])
xypairs.append((x, float(value)))
if x <= r[1]:
xypairs.append((x, float(value)))

return xypairs

Expand Down Expand Up @@ -3939,8 +3946,8 @@ def __get_sub_range(x, low, high):
If low or high is not specified, the corresponding return
will be None.
"""
min_idx = np.where(x >= low)[0][0] if low is not None else None
max_idx = np.where(x <= high)[0][-1] if high is not None else None
min_idx = np.where(x >= low)[0][0] if low is not None else 0
max_idx = np.where(x <= high)[0][-1] if high is not None else len(x) - 1
return min_idx, max_idx


Expand Down
2 changes: 1 addition & 1 deletion pydv/scripts/date.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
04.19.2022
04.20.2022
2 changes: 1 addition & 1 deletion pydv/scripts/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.7
3.1.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name='PyDV',
version='3.0.7',
version='3.1.0',
description='PyDV: Python Data Visualizer',
long_description=long_description,
author='Edward Rusu',
Expand Down

0 comments on commit ca2576f

Please sign in to comment.