def coffset_from_geometry_file(fnam):
    """Extracts detector distance information from a geometry file.

    Extracts detector distance offset information from a CrystFEL-style geometry file.

    Args:

        fnam (str): geometry filename.

    Returns:

        coffset (float): the detector distance offset
    """

    f = open(fnam, 'r')
    f_lines = f.readlines()
    f.close()

    coffset = 0.0

    for line in f_lines:
        if line.startswith('coffset'):
            coffset = float(line.split('=')[1].split(';')[0])

    return coffset