def read_hdf5(hdf5_file):
"""
Reads the hdf5 file into a dataframe. Assumes a very specific format!
Parameters:
===========
- hdf5_file: string
The full path to the hdf5 file.
Returns
========
A pandas DataFrame containing summary information
"""
logging.info('Reading HDF5 file {}'.format(hdf5_file))
hdf5_int = HDF5_Interface(hdf5_file)
df = hdf5_int.to_df()
# Get the contrast. Split by group and then merge to limit the amount of calculation needed
logging.info('Estimating the V-band contrast ratio for each trial')
test_vsini = df.vsini.unique()[0]
temp = df.loc[(df.rv == 0) & (df.vsini == test_vsini)].drop_duplicates(subset=['star', 'temperature'])
temp['contrast'] = temp.apply(lambda r: get_contrast(r, band='V'), axis=1)
logging.info('Estimating the luminosity ratio for each trial')
temp['lum_ratio'] = temp.apply(get_luminosity_ratio, axis=1)
logging.info('Re-merging dataframe')
df = pd.merge(df, temp[['star', 'temperature', 'contrast', 'lum_ratio']], on=['star', 'temperature'], how='left')
df['logL'] = np.log10(df.lum_ratio)
return df
评论列表
文章目录