\(\renewcommand\AA{\unicode{x212B}}\)

FixGSASInstrumentFile v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Fix format error in an GSAS instrument file.

See Also

LoadGSASInstrumentFile

Properties

Name

Direction

Type

Default

Description

InputFilename

Input

string

Mandatory

Name of the GSAS instrument parameter file to get fixed for format. Allowed extensions: [‘.prm’, ‘.iparm’]

OutputFilename

Input

string

Mandatory

Name of the output GSAS instrument parameter file to have format fixed. Allowed extensions: [‘.prm’, ‘.iparm’]

Description

GSAS instrument is required to have exact 80 characters each line. FixGSASInstrument will check the input GSAS instrument file whether each line of it will have 80 characters. If any line contains fewer than 80 characters, this algorithm will fill the line with space to 80 characters.

Usage

Example - correct a GSAS instrument file to 80 characters per line:

# Create filename (puts it in home directory to guarantee it exists)
import os
savefile = os.path.expanduser("~/fixed.iparm")

# Run the algorithm
FixGSASInstrumentFile(InputFilename="PG3HR60_FmPython.iparm", OutputFilename=savefile)

# Load new file and check each line
wfile = open(savefile, "r")
lines = wfile.readlines()
wfile.close()
numlinefewer80b = 0
for line in lines:
  if len(line) > 0:
    line = line.split("\n")[0]
    if len(line) != 80:
      numlinefewer80b += 1

# Print out result
print("Corrected File: Number of lines that are not equal to 80 characters =  {}".format(numlinefewer80b))

Output:

Corrected File: Number of lines that are not equal to 80 characters =  0

Categories: AlgorithmIndex | Diffraction\DataHandling

Source

C++ header: FixGSASInstrumentFile.h

C++ source: FixGSASInstrumentFile.cpp