def load_ztf_data( phot_path='/media/biswajit/drive/Kilonova_datasets/ZTF_20190512/ZTF_MSIP_MODEL64/ZTF_MSIP_NONIaMODEL0-0001_PHOT.FITS', drop_separators=True): df_header, df_phot = read_fits(phot_path) df_header = Table.from_pandas(df_header) df_phot = Table.from_pandas(df_phot) df_phot['FLT'][df_phot['FLT'] == b'g '] = 'g' df_phot['FLT'][df_phot['FLT'] == b'r '] = 'r' data_ob = Data(df_metadata=df_header, df_data=df_phot, object_id_col_name='SNID', time_col_name='MJD', target_col_name='SNTYPE', band_col_name='FLT', flux_col_name='FLUXCAL', flux_err_col_name='FLUXCALERR', band_map={ 'g': 'g', 'r': 'r' }, bands=['g', 'r']) if drop_separators: data_ob.df_data = data_ob.df_data[ data_ob.df_data[data_ob.time_col_name] != -777] return data_ob
def create_alert_data_obj(data, bands): band_map = {} for item in bands: band_map[item] = item data_ob = Data(df_metadata=data, df_data=data, object_id_col_name='SNID', time_col_name='MJD', band_col_name='FLT', flux_col_name='FLUXCAL', flux_err_col_name='FLUXCALERR', band_map=band_map, bands=bands) return data_ob
def load_ztf_test_data( head_path='/media/biswajit/drive/Kilonova_datasets/ZTF_20190512/test_HEAD.FITS', phot_path='/media/biswajit/drive/Kilonova_datasets/ZTF_20190512/test_PHOT.FITS' ): df_header = Table.read(head_path, format='fits') df_phot = Table.read(phot_path, format='fits') data_ob = Data(df_metadata=df_header, df_data=df_phot, object_id_col_name='SNID', time_col_name='MJD', target_col_name='SNTYPE', band_col_name='FLT', flux_col_name='FLUXCAL', flux_err_col_name='FLUXCALERR', band_map={ 'g': 'g', 'r': 'r' }) return data_ob
def load_RESSPECT_data( phot_df_file_path="/media/biswajit/drive/Kilonova_datasets/RESSPECT" "/RESSPECT_PERFECT_LIGHTCURVE.csv", meta_df_file_path="/media/biswajit/drive/Kilonova_datasets/RESSPECT/RESSPECT_PERFECT_HEAD.csv" ): df_meta_data = Table.read(meta_df_file_path, delimiter=",") df_data = Table.read(phot_df_file_path) data_ob = Data(df_metadata=df_meta_data, df_data=df_data, object_id_col_name='SNID', time_col_name='MJD', band_col_name='FLT', flux_col_name='FLUXCAL', flux_err_col_name='FLUXCALERR', band_map={ 'u': 'u', 'g': 'g', 'r': 'r', 'i': 'i', 'z': 'z', 'Y': 'y' }) return data_ob
def load_PLAsTiCC_data( phot_df_file_path="/media/biswajit/drive/Kilonova_datasets/PLAsTiCC_data/training_set.csv", meta_df_file_path="/media/biswajit/drive/Kilonova_datasets/PLAsTiCC_data/training_set_metadata.csv" ): df_meta_data = Table.read(meta_df_file_path, delimiter=",") df_data = Table.read(phot_df_file_path) data_ob = Data(df_metadata=df_meta_data, df_data=df_data, object_id_col_name='object_id', time_col_name='mjd', band_col_name='passband', flux_col_name='flux', flux_err_col_name='flux_err', target_col_name='target', band_map={ 0: 'u', 1: 'g', 2: 'r', 3: 'i', 4: 'z', 5: 'y' }) return data_ob
time[stamp.timestamp.hour][stamp.sender] += 1 return time def day_of_week(self): man, woman = config.config['MAN'], config.config['WOMAN'] weekday = OrderedDict([('Monday',{man:0, woman:0}), ('Tuesday',{man:0, woman:0}), ('Wednesday',{man:0, woman:0}), ('Thursday',{man:0, woman:0}), ('Friday',{man:0, woman:0}), ('Saturday',{man:0, woman:0}), ('Sunday',{man:0, woman:0})]) for index, stamp in self.df.iterrows(): weekday[stamp.timestamp.day_name()][stamp.sender] += 1 return weekday def messages_per_month(self): man, woman = config.config['MAN'], config.config['WOMAN'] month = OrderedDict([("January",{man:0, woman:0}),("February",{man:0, woman:0}),("March",{man:0, woman:0}), ("April",{man:0, woman:0}),("May",{man:0, woman:0}),("June",{man:0, woman:0}),("July",{man:0, woman:0}), ("August",{man:0, woman:0}),("September",{man:0, woman:0}),("October",{man:0, woman:0}), ("November",{man:0, woman:0}), ("December",{man:0, woman:0})]) for index, stamp in self.df.iterrows(): month[stamp.timestamp.month_name()][stamp.sender] += 1 return month if __name__ == '__main__': data = Data(config.config['FILE_NAME']) df = data.parse_file() analysed_data = Analyse(df) print(analysed_data.words_from_each()) # print(analysed_data.messages_from_each()) # print(analysed_data.average_character_length())