diff --git a/SAGA/hosts/build.py b/SAGA/hosts/build.py index 9f867db..2b75ad3 100644 --- a/SAGA/hosts/build.py +++ b/SAGA/hosts/build.py @@ -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 diff --git a/SAGA/hosts/cuts.py b/SAGA/hosts/cuts.py index f2c2138..a9b84cc 100644 --- a/SAGA/hosts/cuts.py +++ b/SAGA/hosts/cuts.py @@ -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 diff --git a/SAGA/hosts/host_catalog.py b/SAGA/hosts/host_catalog.py index 4ca22fe..b28b37e 100644 --- a/SAGA/hosts/host_catalog.py +++ b/SAGA/hosts/host_catalog.py @@ -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 @@ -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 @@ -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(), @@ -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) diff --git a/setup.py b/setup.py index efc32d6..9508f86 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,5 @@ "fast3tree>=0.3.1", "healpy>=1.11", ], - extras_require={ - 'full': ['ipython', 'scikit-learn'], - }, + extras_require={"full": ["ipython", "scikit-learn"],}, )