def _loadDatFiles(self, star_paths, numberOfFiles): if not star_paths: return [] stars = [] counter = 1 # Load every light curve and put it into star object for singleFile in tqdm(star_paths[:numberOfFiles], desc="Loading dat files:"): if self.files_to_load and os.path.basename( singleFile) not in self.files_to_load: break lc = LightCurve(self._loadLcFromDat(singleFile)) # Check if light curve is not empty if (len(lc.mag) >= 1): db_ident = self.parseFileName(singleFile) if self.db_ident: ident = {self.db_ident: {"name": db_ident}} else: ident = {"file": {"name": db_ident}} star = Star(ident=ident) star.starClass = self.star_class star.putLightCurve(lc) stars.append(star) counter += 1 return stars
def _createStars(self, header, rows, lc_tmp): # [u'No', u'Field', u'StarID', u'RA', u'Decl', u'V', u'I', u'B'] # [u'No', u'Field', u'StarID', u'RA', u'Decl', u'I'] cols_map = self._parseHeader(header) stars = [] for row in rows: field = str(row[cols_map.get("field")]) starid = str(row[cols_map.get("starid")]) ra = float(row[cols_map.get("ra")]) dec = float(row[cols_map.get("dec")]) identifiers = {} identifiers["Macho"] = row[cols_map.get("macho_id")] identifiers["Asas"] = row[cols_map.get("asas_id")] identifiers["OgleII"] = row[cols_map.get("ogle_ii_id")] identifiers["GCVS"] = row[cols_map.get("gcvs_id")] name = str(row[cols_map.get("name")]) ident = {"OgleIII": {"name": name, "db_ident": {"field": field, "starid": starid}}} for ide, val in identifiers.iteritems(): if val != u"\xa0": ident[ide] = {"name": str(val)} query_ide = self._parseDbNames(ide, val) if query_ide: ident[ide]["db_ident"] = query_ide more = {} for col in self.MORE: if cols_map.get(col) and cols_map.get(col): val = row[cols_map.get(col)] if val != u"\xa0": try: val = float(val) except: val = str(val) more[col] = val coo = (ra * 15, dec, "deg") st = Star(ident, name, coo, more) st.starClass = str(row[cols_map.get("type")]) if lc_tmp: lc = self._getLc(name) if lc and len(lc) != 0: st.putLightCurve(np.array(lc), meta=self.LC_META) stars.append(st) return stars