Skip to content

Commit 8fd4b1d

Browse files
committed
finalizing build + SGA
1 parent 59b3225 commit 8fd4b1d

File tree

9 files changed

+275
-118
lines changed

9 files changed

+275
-118
lines changed

SAGA/database/saga_database.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ def __init__(self, shared_dir=None, local_dir=None):
229229
FitsTable(os.path.join(self._local_dir, "external_catalogs", "nsa", "nsa_v0_1_2.fits")),
230230
use_local_first=True,
231231
),
232+
"sga_v3.0": DataObject(
233+
FitsTable(
234+
"https://portal.nersc.gov/cfs/cosmo/data/legacysurvey/dr9/largegalaxies/SGA-parent-v3.0.fits"
235+
),
236+
FitsTable(os.path.join(self._local_dir, "external_catalogs", "sga", "SGA-parent-v3.0.fits")),
237+
use_local_first=True,
238+
),
232239
"spectra_gama_dr2": DataObject(
233240
FitsTable("http://www.gama-survey.org/dr2/data/cat/SpecCat/v08/SpecObj.fits"),
234241
FitsTable(

SAGA/objects/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ def find_satellites(base, version=1):
784784
fill_values_by_query(base, clean_obj & C.sat_rcut & C.sat_vcut, {"SATS": 1})
785785

786786
# removed objects
787-
removed_obj = is_galaxy & C.has_spec & (~is_clean)
787+
removed_obj = C.has_spec & ~(is_clean & is_galaxy)
788788
fill_values_by_query(base, removed_obj & C.is_high_z, {"SATS": 90})
789789
fill_values_by_query(base, removed_obj & C.is_low_z, {"SATS": 92})
790790
fill_values_by_query(base, removed_obj & C.is_very_low_z, {"SATS": 94})

SAGA/objects/build2.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ def match_spectra_to_base_and_merge_duplicates(specs, base, debug=None, matching
622622
possible_match["ba"] if "ba" in possible_match.colnames else None,
623623
possible_match["phi"] if "phi" in possible_match.colnames else None,
624624
)
625+
possible_match["SPEC_Z"] = specs["SPEC_Z"][spec_idx_this]
625626

626627
# using following criteria one by one to find matching photo obj, stop when found
627628
for q, sorter in matching_order:
@@ -820,10 +821,11 @@ def remove_shreds_near_spec_obj(base, nsa=None, shreds_recover=None):
820821
has_nsa = Query("OBJ_NSAID > -1")
821822
has_sga = QueryMaker.equal("REF_CAT", "L3")
822823
has_spec_z = Query(
823-
"SPEC_Z > 0",
824+
"SPEC_Z >= 0.002",
824825
"ZQUALITY >= 3",
825826
"is_galaxy",
826827
"radius > abs(radius_err) * 2.0",
828+
"radius > 0",
827829
)
828830

829831
if "REF_CAT" in base.colnames:
@@ -887,7 +889,7 @@ def remove_shreds_near_spec_obj(base, nsa=None, shreds_recover=None):
887889

888890
elif obj_this["REMOVE"] == 0: # any other good, non-NSA objects
889891

890-
radius = obj_this["radius"]
892+
radius = obj_this["radius"] * 0.9
891893

892894
# HOT FIX for NGC7162A (330.148221, -43.140536) in pgc67817 (base v2)
893895
if obj_this["OBJID"] == 219806824:
@@ -919,33 +921,31 @@ def remove_shreds_near_spec_obj(base, nsa=None, shreds_recover=None):
919921
nearby_obj["_idx"] = np.flatnonzero(nearby_obj_mask)
920922
del nearby_obj_mask
921923

922-
remove_basic_conditions = Query("is_galaxy", "r_mag > 14")
924+
is_brighter = Query("r_mag < {}".format(obj_this["r_mag"]))
925+
is_fainter = ~is_brighter
926+
remove_basic_conditions = Query("is_galaxy", is_fainter, "r_mag > 14")
927+
923928
if "REF_CAT" in base.colnames:
924-
remove_basic_conditions &= ~has_sga
925929
remove_basic_conditions |= has_nsa
930+
remove_basic_conditions &= QueryMaker.equal("REF_CAT", "")
926931
elif "OBJ_NSAID" in base.colnames:
927932
remove_basic_conditions &= ~has_nsa
928933

929-
close_spec_z = Query(
930-
remove_basic_conditions,
931-
"ZQUALITY >= 0",
932-
(
933-
lambda z: np.fabs(z - obj_this["SPEC_Z"]) < 200.0 / SPEED_OF_LIGHT,
934-
"SPEC_Z",
935-
),
936-
)
934+
if shreds_recover is not None:
935+
remove_basic_conditions &= QueryMaker.in1d("OBJID", shreds_recover, invert=True)
936+
937+
z_limit = v2z([300, 250, 200, 150][np.searchsorted([14, 16, 20], obj_this["r_mag"])])
938+
close_spec_z = Query("ZQUALITY > -1", (lambda z: np.abs(z - obj_this["SPEC_Z"]) < z_limit, "SPEC_Z"))
937939
good_close_spec_z = Query(close_spec_z, "ZQUALITY >= 3")
938-
is_fainter = Query((lambda r: (r >= obj_this["r_mag"]) | (~np.isfinite(r)), "r_mag"))
939-
to_remove = close_spec_z | Query(remove_basic_conditions, is_fainter, "ZQUALITY < 2")
940+
no_spec_z = Query("ZQUALITY < 2")
940941

941-
if shreds_recover is not None:
942-
to_remove = to_remove & QueryMaker.in1d("OBJID", shreds_recover, invert=True)
942+
to_remove = Query(remove_basic_conditions, close_spec_z | no_spec_z)
943943

944944
if not to_remove.mask(nearby_obj).any(): # Nothing to remove, carry on
945945
continue
946946

947947
new_remove_count = Query(to_remove, "REMOVE == 0").count(nearby_obj)
948-
if new_remove_count > 25 and remove_flag == 29:
948+
if new_remove_count > 25 and "NSA" not in obj_this["SPEC_REPEAT"] and "SGA" not in obj_this["SPEC_REPEAT"]:
949949
logging.warning(
950950
'{} photo obj newly removed within ~{:.3f}" of {} spec obj {} ({}, {})'.format(
951951
new_remove_count,
@@ -957,7 +957,10 @@ def remove_shreds_near_spec_obj(base, nsa=None, shreds_recover=None):
957957
)
958958
)
959959

960-
base["REMOVE"][to_remove.filter(nearby_obj, "_idx")] += 1 << remove_flag
960+
base["REMOVE"][to_remove.filter(nearby_obj, "_idx")] |= 1 << remove_flag
961+
962+
close_spec_z = close_spec_z & remove_basic_conditions
963+
good_close_spec_z = good_close_spec_z & remove_basic_conditions
961964

962965
if not close_spec_z.mask(nearby_obj).any():
963966
continue

0 commit comments

Comments
 (0)