Skip to content

Introduction

The Python library files are in:

/utilities/process_io_lib/

Library for IN.DAT Files

./utilities/process.io.in_dat.py

A set of Python classes to read, modify and write an IN.DAT file.

class InDat

Class InDat for handling IN.DAT data. It handles

  • Reading IN.DAT files
  • Writing IN.DAT files
  • Storing information in dictionary for use in other codes
  • Alterations to IN.DAT

To open a PROCESS input file and store the information in a Python class use:

    i = InDat(filename="IN.DAT")

To get values of input file entries from the object

    i.data["ixc"].value
    i.number_of_constraints
    i.number_of_itvars
    i.data["fimp"].value
    i.data["ipfloc"].value

To add/remove constraints, iteration variables

    i.remove_constraint_equation(2)
    i.add_constraint_equation("3")
    i.add_constraint_equation(2)
    i.add_iteration_variable(103)
    i.add_iteration_variable("2")
    i.remove_iteration_variable(2)
    i.remove_iteration_variable("3")
    # Add bound will change the bound value if it already exists
    i.add_bound(103, "upper", 5.0)
    i.remove_bound(2, "upper")

To change the value or add/remove a regular input

# Add parameter will change the parameter value if it already exists
i.add_parameter("blnktthdsd", 0.5)
i.add_parameter("iavail", 1)
i.remove_parameter("blnkithsddd")
i.remove_parameter("blnkith")
i.add_parameter("sweep", [3.0, 3.0])

To write the modified IN.DAT to file

i.write_in_dat()
i.write_in_dat(output_filename="new_IN.DAT")

Library for MFILE.DAT Files

./utilities/process.io.mfile.py

A set of Python classes to read and extract data from the MFILE.DAT.

class MFile

To open an MFILE.DAT as a Python object:

m = MFile(filename="MFILE.DAT")

As a PROCESS run may contain a scan, access to the MFILE data is determined by scan number. To find the number of scans use

m.data["rmajor"].get_number_of_scans()

To get an individual scan for a variable use

m.data["rmajor"].get_scan(2)

If the file contains no scan, but a single data point then one can use the above with the argument of -1 like below

m.data["rmajor"].get_scan(-1)

To get all of the scans as a list (if there is a single point it returns list length of 1) use

m.data["rmajor"].get_scans()