fileHandlers

This module contains a few convience classes written to make working with the data types of the PWA project easier and making writing files of that data easier as well.

bampReader

pythonPWA.fileHandlers.bampReader.readBamp(filename)

This is a general bamp reading function.

Args:

filename (string): Path to bamp file to be read.

Returns:

List of numpy.complexes representing the complex amplitudes of the wave represented by the file.

gampReader

class pythonPWA.fileHandlers.gampReader.gampReader(gampFile=None)

This class is a convience class used to ease the reading (and eventually writing) of gamp files.

__init__(gampFile=None)

Default gampReader constructor.

Kwargs:

gampFile (file): Must be an open file handle, gamp file to be read.

parseParticle(line)

This function takes in a space delimited line representing a particle, and instantiates a new instance of the gampParticle class from it then returns it.

Args:

line (string): A single line representing a gamp particle.

Returns:

A gampParticle, of type pythonPWA.dataTypes.gampParticle, instantiated from the argument.

readGamp()

This function parses a whole gamp file and returns a list of all gamp events.

Returns:

List of all gampEvents contained within self.gampFile.

getWavesGen

pythonPWA.fileHandlers.getWavesGen.getwaves(totalpath)

This function finds and reads in all bamp files in the provided directory and returns a list of all waves of type pwawave.wave after populating the needed data members of each member.

Args:

totalPath (string): Directory to scan for *.bamp files.

Returns:

List of type pythonPWA.dataTypes.wave sorted by the ‘filename’ data member to ensure preserved ordering.

gampTranslator

class pythonPWA.fileHandlers.gampTranslator.gampTranslator(gampFile=None)

This class is a convience class used to convert a gamp .txt file into a 3 demensional numpy ndarray saved in numpy’s .npy file format

__init__(gampFile=None)

Default gampReader constructor.

Kwargs:

gampFile (file): Must be an open file handle, gamp file to be read.

readFile()

This function parses a whole gamp file and returns the 3 demensional array. The first demension is the event number. The second is the line number in that event (0 is the number of particles, >0 is a particle). The third is the index within an individual particle.

translate(saveFile)

This function will run the readFile function and then save the array to the specified file name.

Args:

saveFile (string): The file name the user wants the file named(will end in .npy).

Returns:

The 3D numpy array of gamp events

writeEvent(dataSlice)

This function takes a slice of the events array ([n,:,:]) and returns the pythonPWA gampEvent object of that slice.

Args:

dataSlice (numpy ndarray): The 2 densional array of a single event fron the events 3D array.

Returns:

gampEvent

writeFile(outFile, data)

This function will convert the 3 demensional array of gamp data back into a text file of those events.

Args:

outFile (string): The file name the user wants the file named(will end in .txt).

data (numpy ndarray): The 3D that will be converted.

Table Of Contents