Loading src/lsst_inaf_agile/util.py +24 −3 Original line number Diff line number Diff line Loading @@ -113,12 +113,18 @@ def get_volume( area_deg2: float Sky area in square degrees. H0: float Present day Hubble parameter in km/s/Mpc Present day Hubble parameter in km/s/Mpc. Use H0=100 (i.e. h=1) to return the comoving volume in (Mpc/h)^3 Om0: float Present day dimensionless matter density parameter. Tcmb0: float Present day CMB temperature in Kelvin. Returns ------- comoving_volume: float The comoving volume (Mpc3) corresponding to the input arguments. Examples -------- >>> # Following values only illustrate the usage. Loading Loading @@ -188,7 +194,7 @@ def get_chisq_nu(y, y_model, sigma): return np.ma.true_divide(np.ma.sum(diff[is_good] ** 2), is_good.sum() - 1) def get_key_function(bins, x, values, nmin=30, *args, **kwargs): def get_key_function(bins, x, values=None, nmin=30, *args, **kwargs): """ Return the "key" function i.e. number of objects at interval in 'key'. Loading Loading @@ -279,9 +285,19 @@ def egg_band_to_index(egg: dict, band: str) -> int: band: str Name of the band e.g. 'lsst-r'. Returns ------- idx: int Index of the band in the EGG catalog. Raises ------ ValueError If EGG does not contain the band. Examples -------- >>> # Generate a mock EGG catalog >>> # Generate a mock EGG catalog -- note the shape [1, 3] >>> egg = {"BANDS": [["lsst-r", "lsst-g", "lsst-i"]]} >>> egg_band_to_index(egg, "lsst-r") 0 Loading @@ -289,6 +305,11 @@ def egg_band_to_index(egg: dict, band: str) -> int: 1 >>> egg_band_to_index(egg, "lsst-i") 2 >>> egg_band_to_index(egg, "non-existing-band") Traceback (most recent call last): ... ValueError: 'non-existing-band' is not in list """ bands = [b.strip() for b in egg["BANDS"][0]] return bands.index(band) Loading tests/lsst_inaf_agile/test_catalog_combined.py +1 −4 Original line number Diff line number Diff line Loading @@ -188,12 +188,9 @@ class TestCatalogCombined(TestCase): def test_band_flux_equals_egg(self): egg = self.catalog_combined.catalog_galaxy.egg bands = egg["BANDS"][0] # loop through all LSST bands for band in "ugrizy": idx = 0 while bands[idx].strip() != f"lsst-{band}": idx += 1 idx = util.egg_band_to_index(egg, f"lsst-{band}") # loop through both galaxy components for comp in "BULGE", "DISK": flux1 = egg[f"FLUX_{comp}"][0, :, idx] Loading Loading
src/lsst_inaf_agile/util.py +24 −3 Original line number Diff line number Diff line Loading @@ -113,12 +113,18 @@ def get_volume( area_deg2: float Sky area in square degrees. H0: float Present day Hubble parameter in km/s/Mpc Present day Hubble parameter in km/s/Mpc. Use H0=100 (i.e. h=1) to return the comoving volume in (Mpc/h)^3 Om0: float Present day dimensionless matter density parameter. Tcmb0: float Present day CMB temperature in Kelvin. Returns ------- comoving_volume: float The comoving volume (Mpc3) corresponding to the input arguments. Examples -------- >>> # Following values only illustrate the usage. Loading Loading @@ -188,7 +194,7 @@ def get_chisq_nu(y, y_model, sigma): return np.ma.true_divide(np.ma.sum(diff[is_good] ** 2), is_good.sum() - 1) def get_key_function(bins, x, values, nmin=30, *args, **kwargs): def get_key_function(bins, x, values=None, nmin=30, *args, **kwargs): """ Return the "key" function i.e. number of objects at interval in 'key'. Loading Loading @@ -279,9 +285,19 @@ def egg_band_to_index(egg: dict, band: str) -> int: band: str Name of the band e.g. 'lsst-r'. Returns ------- idx: int Index of the band in the EGG catalog. Raises ------ ValueError If EGG does not contain the band. Examples -------- >>> # Generate a mock EGG catalog >>> # Generate a mock EGG catalog -- note the shape [1, 3] >>> egg = {"BANDS": [["lsst-r", "lsst-g", "lsst-i"]]} >>> egg_band_to_index(egg, "lsst-r") 0 Loading @@ -289,6 +305,11 @@ def egg_band_to_index(egg: dict, band: str) -> int: 1 >>> egg_band_to_index(egg, "lsst-i") 2 >>> egg_band_to_index(egg, "non-existing-band") Traceback (most recent call last): ... ValueError: 'non-existing-band' is not in list """ bands = [b.strip() for b in egg["BANDS"][0]] return bands.index(band) Loading
tests/lsst_inaf_agile/test_catalog_combined.py +1 −4 Original line number Diff line number Diff line Loading @@ -188,12 +188,9 @@ class TestCatalogCombined(TestCase): def test_band_flux_equals_egg(self): egg = self.catalog_combined.catalog_galaxy.egg bands = egg["BANDS"][0] # loop through all LSST bands for band in "ugrizy": idx = 0 while bands[idx].strip() != f"lsst-{band}": idx += 1 idx = util.egg_band_to_index(egg, f"lsst-{band}") # loop through both galaxy components for comp in "BULGE", "DISK": flux1 = egg[f"FLUX_{comp}"][0, :, idx] Loading