Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yymao committed Nov 11, 2019
1 parent 84efd39 commit 16684f9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion SAGA/hosts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def calc_needed_quantities(d):
d["modz_nsa"],
)
d["DIST"] = m2d(d["DISTMOD"])
d["Z_COSMO"] = d2z(d)
d["Z_COSMO"] = d2z(d["DIST"])

d["kcorrection"] = calc_kcor(
"Ks2", d["Z_COSMO"].data, "H2 - Ks2", d["H_tc"].data - d["K_tc"].data
Expand Down
2 changes: 2 additions & 0 deletions SAGA/hosts/cuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

has_image = Query("HAS_IMAGE > 0")
has_better_image = Query("HAS_IMAGE > 1")

potential_hosts = Query("HOST_SCORE > 0")
good_hosts = Query("HOST_SCORE >= 3")
preferred_hosts = Query("HOST_SCORE >= 4")
good = good_hosts & has_image
Expand Down
27 changes: 20 additions & 7 deletions SAGA/hosts/host_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def _master_table(self):
"Cannot load master list; attempt to build from scratch..."
)
self._master_table_ = self.build_master_list()
self._master_index_ = None
return self._master_table_

@property
Expand All @@ -105,9 +106,8 @@ def _host_table(self):
logging.warning(
"Cannot load host list; attempt to load master list..."
)
self._host_table_ = Query("HOST_SCORE > 0").filter(
self._master_table
)
self._host_table_ = cuts.potential_hosts.filter(self._master_table)
self._host_index_ = None
return self._host_table_

@staticmethod
Expand Down Expand Up @@ -334,14 +334,16 @@ def load_single_near_ra_dec(self, ra, dec, sep=3600, use_master=None):
)
return cat[0]

def build_master_list(self, overwrite=False):
def build_master_list(self, overwrite=False, overwrite_host_list=False):
if self._version == 1:
raise NotImplementedError("cannot build v1 master list!")

if self._database["master_list"].remote.isfile() and not overwrite:
raise ValueError(
"master list already exist and overwrite is not set to True"
)

d = build_master_list(
self._master_table_ = build_master_list(
hyperleda=self._database["hyperleda_kt12"].read(),
edd_2mrs=self._database["edd_2mrs_slim"].read(),
edd_kim17=self._database["edd_kim17_slim"].read(),
Expand All @@ -355,8 +357,19 @@ def build_master_list(self, overwrite=False):
if k.startswith("footprint_")
},
)
self._database["master_list"].write(d, overwrite=True)
return d
self._master_index_ = None

self._host_table_ = cuts.potential_hosts.filter(self._master_table_)
self._host_index_ = None

self._database["master_list"].write(self._master_table_, overwrite=True)

if self._database["hosts"].local is not None and (
overwrite_host_list or not self._database["hosts"].local.isfile()
):
self._database["hosts"].local.write(self._host_table_, overwrite=True)

return self._master_table_

def load_master_list(self, hosts=None, add_coord=True):
return self.load(hosts, add_coord, use_master=True)
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,5 @@
"fast3tree>=0.3.1",
"healpy>=1.11",
],
extras_require={
'full': ['ipython', 'scikit-learn'],
},
extras_require={"full": ["ipython", "scikit-learn"],},
)

0 comments on commit 16684f9

Please sign in to comment.