def beta_fits_overall(input_file, output_file): """Get data, do beta fits on data, write all back to a file. Args: input_file: Filename to get data from output_file: Filename to write data and fits to. """ data = jmutils.get_csv_dict(input_file) meta = np.array([[float(p['BTS_Lower']), float(p['BTS_Avg']), float(p['BTS_Upper'])] for p in data]) fits = np.apply_along_axis(lambda m: beta_fitting_python(m, True), 1, meta) combined = combine_fits(data, fits) jmutils.write_csv_dict(output_file, combined, [])
def split_ifp(input_dir, output_dir, ifp_fname): """Split ifp file into individual date files - this is overall func that calls other ones. Args: input_dir: dir containing the ifp file to be split. ifp_prefix: ifp filename (must be a .csv) to split up w/o the .csv. output_dir: dir to write split up files in. """ ifp_file = os.path.join(input_dir, ifp_fname) data = jmutils.get_csv_dict(ifp_file) add_pythondate(data) aggregation_dates = all_aggregation_dates(data) split, dates = split_by_dates(data, aggregation_dates) #use dates for filenames later. newest = [only_retain_newest(s) for s in split] omit_writting = ['python_date'] for d, to_write in zip(dates, newest): ifp_prefix = ifp_fname.partition('.')[0] ifp_date = os.path.join(output_dir, ifp_prefix + '_date_' + d + ".csv") jmutils.write_csv_dict(ifp_date, to_write, omit_writting)