PYTHON MEAN
Name:
Type:
Purpose:
Compute the mean for a variable using Python.
Description:
This command is primarily a proof of concept command as the mean
of a variable can be computed using the MEAN command.
This command works as follows:
- It is assumed that Python and any needed Python packages
(e.g., numpy) are already installed on the local platform.
This specific command does not require any additional Python
packages.
- The Python script, mean.py, that computes the mean is stored in
the "scripts" subdirectory of the Dataplot auxiliary files.
The default Linux/Unix location is "/usr/local/lib/dataplot" and
the default Windows location is
"C:\Program Files (x86)\NIST\DATAPLOT". However, the location on
your local platform may vary.
- The values for the variable for which the mean is to be computed
are written to the file "dpst1f.dat" in the current directory.
- The following command is executed
SYSTEM python <path>script/mean.py > dpst2f.dat
with <path> denoting the the location of the Dataplot
auxiliary files. The file "dpst2f.dat" will contain the
computed mean value.
- The computed mean will be saved in a user specified Dataplot
parameter.
This initial PYTHON command was designed to create the basic structure
for incorporating Python-based commands into Dataplot. It is
anticipated that additional non-trivial Python-based commands will be
added in subsequent Dataplot releases.
Syntax:
LET <par> = PYTHON MEAN <y>
<SUBSET/EXCEPT/FOR qualification>
where <y> is the response variable;
<par> is a parameter where the computed mean is
stored;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
LET A = PYTHON MEAN Y1
LET A = PYTHON MEAN Y1 SUBSET TAG > 2
Note:
Note:
Both Python 2 and Python 3 are currently actively supported. If both
Python 2 and Python 3 are installed on your local platform, you can
use the following command to specify which version to run
SET PYTHON VERSION <2/3/DEFAULT>
Specifying "2" will run "python2", specifying "3" will run "python3"
and specifying "DEFAULT" will run "python" (i.e., the default on your
local platform).
The Dataplot written scripts will be written to the Python 3
standard. However, if you only have Python 2 on your system, you can
modify the "mean.py" script to be compatible with Python 2 (for this
command, only the "print" commands should need to be changed). We do
not anticipate providing both Python 2 and Python 3 versions of the
scripts.
Note:
You can use the CAPTURE
SCRIPT command to create Python scripts from within a Dataplot
macro. You can then use the SYSTEM command to execute that script.
That is, something like
CAPTURE SCRIPT file.py
... Python commands here ...
END OF CAPTURE
SYSTEM file.py
Default:
Synonyms:
Related Commands:
MEAN
|
=
|
Compute the mean of a variable.
|
SYSTEM
|
=
|
Execute an operating system command.
|
Applications:
Implementation Date:
Program:
SKIP 25
READ ZARR13.DAT Y
LET YMEAN = PYTHON MEAN Y
Privacy
Policy/Security Notice
Disclaimer |
FOIA
NIST is an agency of the U.S.
Commerce Department.
Date created: 02/27/2019
Last updated: 02/27/2019
Please email comments on this WWW page to
alan.heckert@nist.gov.
|
|