def get_lightcurve_dataset_from_stingray_Lightcurve(lcurve, header=None, header_comments=None, hduname='RATE', column=CONFIG.TIME_COLUMN): from astropy.io.fits import Header dataset = get_hdu_type_dataset("LIGHTCURVE", [column, hduname], hduname) hdu_table = dataset.tables[hduname] if header is None: if not hasattr(lcurve, 'header'): logging.warn("Light curve has no header") lcurve.header = Header() header = Header.fromstring(lcurve.header) header = dict() for header_column in header: header[header_column] = str(header[header_column]) header_comments[header_column] = \ str(header.comments[header_column]) hdu_table.set_header_info(header, header_comments) hdu_table.columns[column].add_values(lcurve.time) hdu_table.columns[hduname].add_values(lcurve.counts, lcurve.counts_err) dataset.tables["GTI"] = \ DsHelper.get_gti_table_from_stingray_gti(lcurve.gti) return dataset
def get_lightcurve_dataset_from_stingray_Lightcurve(lcurve, header=None, header_comments=None, hduname='RATE', column=CONFIG.TIME_COLUMN): from astropy.io.fits import Header dataset = get_hdu_type_dataset("LIGHTCURVE", [column, hduname], hduname) hdu_table = dataset.tables[hduname] if header is None: if not hasattr(lcurve, 'header'): logging.warn("Light curve has no header") lcurve.header = Header() header = Header.fromstring(lcurve.header) header = dict() for header_column in header: header[header_column] = str(header[header_column]) header_comments[header_column] = \ str(header.comments[header_column]) hdu_table.set_header_info(header, header_comments) hdu_table.columns[column].add_values(lcurve.time) hdu_table.columns[hduname].add_values(lcurve.counts, lcurve.counts_err) dataset.tables["GTI"] = \ DsHelper.get_gti_table_from_stingray_gti(lcurve.gti) return dataset
def get_eventlist_dataset_from_stingray_Eventlist(evlist, header=None, header_comments=None, hduname='EVENTS', column=CONFIG.TIME_COLUMN): from astropy.io.fits import Header evt_columns = [column, "PI"] if hasattr(evlist, 'energy'): evt_columns = [column, "PI", "E"] dataset = get_hdu_type_dataset("EVENTS", evt_columns, hduname) hdu_table = dataset.tables[hduname] if header is None: if not hasattr(evlist, 'header'): logging.warn("Event list has no header") evlist.header = Header() header = Header.fromstring(evlist.header) header = dict() for header_column in header: header[header_column] = str(header[header_column]) header_comments[header_column] = \ str(header.comments[header_column]) hdu_table.set_header_info(header, header_comments) hdu_table.columns[column].add_values(evlist.time) if hasattr(evlist, 'energy'): if evlist.energy is not None and len(evlist.energy) == len( evlist.time): hdu_table.columns['E'].add_values(evlist.energy) else: logging.warn( "Event list energies differs from event counts, setted all energies as 0" ) hdu_table.columns['E'].add_values(np.zeros_like(evlist.time)) if hasattr(evlist, 'pi') and evlist.pi is not None and len( evlist.pi) == len(evlist.time): hdu_table.columns['PI'].add_values(evlist.pi) else: logging.warn("Event list has no PI values, using np.zeros_like") hdu_table.columns['PI'].add_values(np.zeros_like(evlist.time)) dataset.tables["GTI"] = \ DsHelper.get_gti_table_from_stingray_gti(evlist.gti) return dataset
def get_lightcurve_dataset_from_stingray_lcurve(lcurve, header, header_comments, hduname='RATE', column=CONFIG.TIME_COLUMN): lc_columns = [column, hduname] dataset = get_hdu_type_dataset("LIGHTCURVE", lc_columns, hduname) hdu_table = dataset.tables[hduname] hdu_table.set_header_info(header, header_comments) hdu_table.columns[lc_columns[0]].add_values(lcurve["time"]) hdu_table.columns[lc_columns[1]].add_values(lcurve["counts"], lcurve["counts_err"]) dataset.tables["GTI"] = \ DsHelper.get_gti_table_from_stingray_gti(lcurve["gti"]) return dataset
def get_eventlist_dataset_from_stingray_Eventlist(evlist, header=None, header_comments=None, hduname='EVENTS', column=CONFIG.TIME_COLUMN): from astropy.io.fits import Header evt_columns = [column, "PI"] if hasattr(evlist, 'energy'): evt_columns = [column, "PI", "E"] dataset = get_hdu_type_dataset("EVENTS", evt_columns, hduname) hdu_table = dataset.tables[hduname] if header is None: if not hasattr(evlist, 'header'): logging.warn("Event list has no header") evlist.header = Header() header = Header.fromstring(evlist.header) header = dict() for header_column in header: header[header_column] = str(header[header_column]) header_comments[header_column] = \ str(header.comments[header_column]) hdu_table.set_header_info(header, header_comments) hdu_table.columns[column].add_values(evlist.time) if hasattr(evlist, 'energy'): if evlist.energy is not None and len(evlist.energy) == len(evlist.time): hdu_table.columns['E'].add_values(evlist.energy) else: logging.warn("Event list energies differs from event counts, setted all energies as 0") hdu_table.columns['E'].add_values(np.zeros_like(evlist.time)) if hasattr(evlist, 'pi') and evlist.pi is not None and len(evlist.pi) == len(evlist.time): hdu_table.columns['PI'].add_values(evlist.pi) else: logging.warn("Event list has no PI values, using np.zeros_like") hdu_table.columns['PI'].add_values(np.zeros_like(evlist.time)) dataset.tables["GTI"] = \ DsHelper.get_gti_table_from_stingray_gti(evlist.gti) return dataset
def get_lightcurve_dataset_from_stingray_lcurve(lcurve, header, header_comments, hduname='RATE', column=CONFIG.TIME_COLUMN): lc_columns = [column, hduname] dataset = get_hdu_type_dataset("LIGHTCURVE", lc_columns, hduname) hdu_table = dataset.tables[hduname] hdu_table.set_header_info(header, header_comments) hdu_table.columns[lc_columns[0]].add_values(lcurve["time"]) hdu_table.columns[lc_columns[1]].add_values(lcurve["counts"], lcurve["counts_err"]) dataset.tables["GTI"] = \ DsHelper.get_gti_table_from_stingray_gti(lcurve["gti"]) return dataset
def get_lightcurve_dataset_from_stingray_lcurve(lcurve, header, header_comments, hduname='RATE', column='TIME'): lc_columns = [column, hduname, "ERROR"] dataset = get_hdu_type_dataset("LIGHTCURVE", lc_columns, hduname) hdu_table = dataset.tables[hduname] hdu_table.set_header_info(header, header_comments) hdu_table.columns[lc_columns[0]].add_values(lcurve["time"]) hdu_table.columns[lc_columns[1]].add_values(lcurve["lc"]) hdu_table.columns[lc_columns[2]].add_values(lcurve["elc"]) dataset.tables["GTI"] = DsHelper.get_gti_table_from_stingray_gti( lcurve["GTI"]) return dataset
def get_eventlist_dataset_from_stingray_Eventlist(evlist, header=None, header_comments=None, hduname='EVENTS', column='TIME'): from astropy.io.fits import Header lc_columns = [column, "PI", "ENERGY"] dataset = get_hdu_type_dataset("EVENTS", lc_columns, hduname) hdu_table = dataset.tables[hduname] if header is None: if not hasattr(evlist, 'header'): logging.warn("Event list has no header") evlist.header = Header() header = Header.fromstring(evlist.header) header = dict() for header_column in header: header[header_column] = str(header[header_column]) header_comments[header_column] = \ str(header.comments[header_column]) hdu_table.set_header_info(header, header_comments) hdu_table.columns[lc_columns[0]].add_values(evlist.time) if hasattr(evlist, 'energy'): hdu_table.columns['ENERGY'].add_values(evlist.energy) else: hdu_table.columns['ENERGY'].add_values(np.zeros_like(evlist.time)) if hasattr(evlist, 'pi'): hdu_table.columns['PI'].add_values(evlist.pi) else: hdu_table.columns['ENERGY'].add_values(np.zeros_like(evlist.time)) dataset.tables["GTI"] = \ DsHelper.get_gti_table_from_stingray_gti(evlist.gti) return dataset
def get_gti_dataset_from_stingray_gti(st_gtis): dataset = get_empty_dataset("GTI_DS") gti_table = DsHelper.get_gti_table_from_stingray_gti(st_gtis) dataset.tables["GTI"] = gti_table return dataset
def get_gti_dataset_from_stingray_gti(st_gtis): dataset = get_empty_dataset("GTI_DS") gti_table = DsHelper.get_gti_table_from_stingray_gti(st_gtis) dataset.tables["GTI"] = gti_table return dataset