Created
March 8, 2018 18:04
-
-
Save tekknolagi/03f10b1137917baad3c0e261e9a5e973 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import math | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import tufte | |
from collections import namedtuple | |
SNPoint = namedtuple('SNPoint', ['sn_name', 'z_cmb', 'mu_mag', 'err_mu', | |
'sample', 'flag']) | |
def import_data(fname): | |
with open(fname, 'r') as f: | |
lines = f.readlines() | |
def fmt_line(line): | |
return (line[0], float(line[1]), float(line[2]), float(line[3]), | |
int(line[4]), line[5]) | |
# Ignore comments | |
return [SNPoint(*fmt_line(x.split())) for x in lines if x[0] != '#'] | |
if __name__ == '__main__': | |
print import_data('datafile.txt')[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment