astrodatadownloader: use SECTOR for TESS and TTABLEID for Kepler/K2 as extra information
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from astroquery.mast import Observations
|
||||
from astropy import table
|
||||
from astropy.io import fits
|
||||
import numpy as np
|
||||
from enum import Enum
|
||||
from copy import deepcopy
|
||||
@@ -26,25 +27,22 @@ def parse_manifest(manifest):
|
||||
exts = []
|
||||
for i,f in enumerate(manifest['Local Path']):
|
||||
file_parts = np.array(np.unique(f.split(sep = '-')))
|
||||
sectors = list( map ( lambda x: x[0:2] == 's0', file_parts))
|
||||
if(len(file_parts[sectors]) > 0):
|
||||
s1 = file_parts[sectors][0]
|
||||
try:
|
||||
s2 = file_parts[sectors][1]
|
||||
except:
|
||||
s2 = s1
|
||||
if(s1 == s2):
|
||||
sector_range.append("%s" % s1)
|
||||
else:
|
||||
sector_range.append("%s-%s" % (s1,s2))
|
||||
else:
|
||||
try:
|
||||
with fits.open(f, mode="readonly") as hdu:
|
||||
if("SECTOR" in hdu[0].header):
|
||||
sector_range.append(f"{hdu[0].header['SECTOR']}")
|
||||
elif("TTABLEID" in hdu[0].header):
|
||||
sector_range.append(f"{hdu[0].header['TTABLEID']}")
|
||||
hdu.close()
|
||||
except:
|
||||
sector_range.append("-")
|
||||
|
||||
path_parts = np.array(f.split(sep = '/'))
|
||||
filenames.append(path_parts[-1])
|
||||
exts.append(path_parts[-1][-8:])
|
||||
|
||||
results.add_column(table.Column(name = "filename", data = filenames))
|
||||
results.add_column(table.Column(name = "sectors", data = sector_range))
|
||||
results.add_column(table.Column(name = "sector", data = sector_range))
|
||||
results.add_column(table.Column(name = "fileType", data = exts))
|
||||
results.add_column(table.Column(name = "index", data = np.arange(0,len(manifest))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user