def _parseStar(self, _star, lc): """Transform kplr Star object into package Star object""" star = Star() more = {} ident = {} data_dict = _star.__dict__ for key, value in data_dict.items(): if key in list(self.STAR_MORE_MAP.keys()): more[self.STAR_MORE_MAP[key]] = value elif key in list(self.IDENTIFIER.keys()): ident[self.IDENTIFIER[key]] = {} ident[self.IDENTIFIER[key]]["identifier"] = value ident[self.IDENTIFIER[key]]["name"] = "kic_" + value ra = data_dict.get(self.RA_IDENT) dec = data_dict.get(self.DEC_IDENT) star.name = "KIC_" + data_dict.get(self.NAME, "") if lc: star.lightCurve, _ = self._getLightCurve(_star, lim=1) star.coo = (ra, dec) star.ident = ident star.more = more return star
def _createStarFromFITS(self, fits): DB_NAME_END = "_name" DB_IDENT_SEP = "_id_" prim_hdu = fits[0].header ra = prim_hdu.get(self.FITS_RA) dec = prim_hdu.get(self.FITS_DEC) ra_unit = prim_hdu.get(self.FITS_RA_UNIT) dec_unit = prim_hdu.get(self.FITS_DEC_UNIT) star = Star(name=prim_hdu.get(self.FITS_NAME), coo=(ra, dec, (ra_unit, dec_unit)), starClass=prim_hdu.get(self.FITS_CLASS)) ident = {} more = {} for db_name_key in list(prim_hdu.keys()): if db_name_key.endswith(DB_NAME_END): db_name = db_name_key[:-len(DB_NAME_END)] ident[db_name] = {} ident[db_name]["name"] = prim_hdu[db_name_key] elif DB_IDENT_SEP in db_name_key: db_name, ident_key = db_name_key.split(DB_IDENT_SEP) if not ident[db_name].get("db_ident"): ident[db_name]["db_ident"] = {} ident[db_name]["db_ident"][ident_key] = prim_hdu[db_name_key] elif db_name_key not in [ "SIMPLE", "BITPIX", "NAXIS", "EXTEND", self.FITS_RA, self.FITS_DEC, self.FITS_RA_UNIT, self.FITS_DEC_UNIT, self.FITS_NAME, self.FITS_CLASS ]: more[db_name_key.lower()] = prim_hdu[db_name_key] star.ident = ident star.more = more for lc_hdu in fits[1:]: star.putLightCurve(self._createLcFromFits(lc_hdu)) fits.close() return star