Exemplo n.º 1
0
def create_sample_frame(import_file: str):
    """Import a file with pycompwa and convert it to a `~pandas.DataFrame`."""
    events = pwa.read_ascii_data(import_file)
    frame = convert.events_to_pandas(
        events=events, model=f"{SCRIPT_DIR}/files/kinematics_three.xml"
    )
    return frame
Exemplo n.º 2
0
def import_events(weights: bool = False):
    """Import the data sample as `~.EventCollection`."""
    if weights:
        import_file = f'{SCRIPT_DIR}/files/ascii_weights.dat'
    else:
        import_file = f'{SCRIPT_DIR}/files/ascii_noweights.dat'
    return pwa.read_ascii_data(import_file)
Exemplo n.º 3
0
def _read_ascii_with_header(filename, particles=None):
    """Import ASCII file **with** header."""
    event_collection = pwa.read_ascii_data(filename)
    frame = convert.events_to_pandas(event_collection)
    particles_in_frame = frame.pwa.particles
    if isinstance(particles, list) \
            and len(particles_in_frame) != len(particles):
        raise exception.DataException(
            f'The number of particles in argument particles ({particles}) '
            'does not have the same number of particles as inferred from '
            f'the ASCII header of file ({particles_in_frame})')
    return frame