SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

PYTHON MEAN

Name:
    PYTHON MEAN (LET)
Type:
    Let Subcommand
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:

    1. 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.

    2. 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.

    3. The values for the variable for which the mean is to be computed are written to the file "dpst1f.dat" in the current directory.

    4. 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.

    5. 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:
    If Python is not in your search path, you can use the command

      SET PYTHON PATH <path>

    to specify the directory where the Python executable is located. For example

      SET PYTHON PATH /usr/local/bin
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:
    None
Synonyms:
    None
Related Commands:
    MEAN = Compute the mean of a variable.
    SYSTEM = Execute an operating system command.
Applications:
    Data Analysis
Implementation Date:
    2019/03
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.gov.