Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5bc86e8
adding a metadetect ingestion stage
empEvil Nov 6, 2025
c59725c
added options to just provide a parquet file
empEvil Nov 6, 2025
ecf9d85
updated to DP2 schema
empEvil Feb 20, 2026
41befad
more updates
empEvil Feb 27, 2026
da3e2a1
Merge branch 'master' into MetaDetect_ingest
empEvil Mar 16, 2026
78d6545
fixed up for dp1
empEvil Mar 17, 2026
f75c150
re-enabling mfrac
empEvil Mar 17, 2026
090d92d
Merge branch 'master' into MetaDetect_ingest
empEvil Mar 20, 2026
d406834
changing to mags
empEvil Mar 20, 2026
d9b1e74
Merge branch 'master' into MetaDetect_ingest
empEvil Apr 14, 2026
796ba55
just a few lint errors
empEvil Apr 14, 2026
d19c94d
Merge branch 'master' into MetaDetect_ingest
empEvil May 5, 2026
0ba3e52
added missing original T
empEvil May 5, 2026
35d5ebe
updated naming
empEvil May 5, 2026
d08bb91
fixing smaller details
empEvil May 18, 2026
a485fda
further updates
empEvil May 18, 2026
6ab7c89
Rename MetaDetect.py to metaDetect.py
empEvil May 18, 2026
0f94175
changing 00 to ns in datatypes
empEvil May 18, 2026
de41d62
missed a 00
empEvil May 19, 2026
7b3f25e
change 00 to ns in random_forest
empEvil May 19, 2026
3fe6149
removed weight from source selector
empEvil May 19, 2026
28e3735
removed weight from source selector
empEvil May 19, 2026
0914b42
Merge branch 'MetaDetect_ingest' of https://github.com/LSSTDESC/TXPip…
empEvil May 19, 2026
0cf4a5d
adding a weight column with 1s
empEvil May 19, 2026
b134bfd
readding weights
empEvil May 19, 2026
04a9e5e
changing 00 to ns
empEvil May 19, 2026
633fbfc
psf diagnostics fixed
empEvil May 19, 2026
c41df07
updating diagnostics to ns
empEvil May 19, 2026
b54aa01
missed 00s in calibration
empEvil May 19, 2026
1462173
removing shear_prefix
empEvil May 19, 2026
6a7e660
undoing removal of shear prefix
empEvil May 19, 2026
fd593cb
update on the weighting
empEvil May 20, 2026
91f90e5
updating shear_tomo_cols
empEvil May 22, 2026
0b6f19e
commenting out a qual_cut, to be deleted
empEvil May 22, 2026
60a0d1f
addding bin to list
empEvil May 22, 2026
00682d9
trying to fix issue with plots
empEvil May 22, 2026
0204935
trying to fix mean shear for metadetect
empEvil May 22, 2026
1b34c34
fixing typo
empEvil May 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion txpipe/binning/random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def apply_classifier(classifier, features, bands, shear_catalog_type, shear_data
prefixes = ["", "", "", "", ""]
suffixes = ["", "_1p", "_2p", "_1m", "_2m"]
elif shear_catalog_type == "metadetect":
prefixes = ["00/", "1p/", "2p/", "1m/", "2m/"]
prefixes = ["ns/", "1p/", "2p/", "1m/", "2m/"]
suffixes = ["", "", "", "", ""]
else:
prefixes = [""]
Expand Down
6 changes: 3 additions & 3 deletions txpipe/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def run(self):

# cat_cols is everything we are reading in
if cat_type == "metadetect":
cat_cols = cat_cols + [f"00/{c}" for c in extra_cols + mag_cols_in]
mag_cols_in = [f"00/{c}" for c in mag_cols_in]
renames.update({f"00/{c}": c for c in extra_cols})
cat_cols = cat_cols + [f"ns/{c}" for c in extra_cols + mag_cols_in]
mag_cols_in = [f"ns/{c}" for c in mag_cols_in]
renames.update({f"ns/{c}": c for c in extra_cols})
else:
cat_cols = cat_cols + extra_cols + mag_cols_in

Expand Down
14 changes: 7 additions & 7 deletions txpipe/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,29 @@ def catalog_type(self):

def get_size(self):
if self.catalog_type == "metadetect":
return self.file["shear/00/ra"].size
return self.file["shear/ns/ra"].size
else:
return self.file["shear/ra"].size

def get_primary_catalog_group(self):
if self.catalog_type == "metadetect":
return "shear/00"
return "shear/ns"
else:
return "shear"

def get_true_redshift_column(self):
if self.catalog_type == "metadetect":
return "00/redshift_true"
return "ns/redshift_true"
else:
return "redshift_true"

def get_primary_catalog_names(self, true_shear=False):
if true_shear:
if self.catalog_type == "metadetect":
shear_cols = ["00/true_g1", "00/true_g2", "00/ra", "00/dec", "00/weight"]
shear_cols = ["ns/true_g1", "ns/true_g2", "ns/ra", "ns/dec", "ns/weight"]
rename = {c: c[3:] for c in shear_cols}
rename["00/true_g1"] = "g1"
rename["00/true_g2"] = "g2"
rename["ns/true_g1"] = "g1"
rename["ns/true_g2"] = "g2"
else:
rename = {"true_g1": "g1", "true_g2": "g2"}
rename = {}
Expand All @@ -106,7 +106,7 @@ def get_primary_catalog_names(self, true_shear=False):
shear_cols = ["g1", "g2", "c1", "c2", "ra", "dec", "weight"]
rename = {}
elif self.catalog_type == "metadetect":
shear_cols = ["00/g1", "00/g2", "00/ra", "00/dec", "00/weight"]
shear_cols = ["ns/g1", "ns/g2", "ns/ra", "ns/dec", "ns/weight"]
rename = {c: c[3:] for c in shear_cols}
else:
shear_cols = ["g1", "g2", "ra", "dec", "weight"]
Expand Down
33 changes: 19 additions & 14 deletions txpipe/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ def run(self):
"m",
] + [f"mag_{b}" for b in self.config["bands"]]

shear_tomo_cols = ["bin"]
if self.config["shear_catalog_type"] == "metadetect":
shear_tomo_cols = ["bin_ns", "bin_1p", "bin_1m", "bin_2p", "bin_2m"]
else:
shear_tomo_cols = ["bin"]

if self.config["shear_catalog_type"] == "metacal":
more_iters = ["shear_tomography_catalog", "response", ["R_gamma"]]
Expand Down Expand Up @@ -292,7 +295,7 @@ def plot_psf_shear(self):
delta_gamma = self.config["delta_gamma"]

psf_g_edges = self.get_bin_edges("psf_g1")
shear_prefix = "00/" if self.config["shear_catalog_type"] == "metadetect" else ""
shear_prefix = "ns/" if self.config["shear_catalog_type"] == "metadetect" else ""

p1 = MeanShearInBins(
f"{shear_prefix}psf_g1",
Expand Down Expand Up @@ -391,7 +394,7 @@ def plot_psf_size_shear(self):
delta_gamma = self.config["delta_gamma"]

psf_T_edges = self.get_bin_edges("psf_T_mean")
shear_prefix = "00/" if self.config["shear_catalog_type"] == "metadetect" else ""
shear_prefix = "ns/" if self.config["shear_catalog_type"] == "metadetect" else ""

binnedShear = MeanShearInBins(
f"{shear_prefix}psf_T_mean",
Expand Down Expand Up @@ -451,7 +454,7 @@ def plot_snr_shear(self):

# Parameters of the binning in SNR
shear_catalog_type = self.config["shear_catalog_type"]
shear_prefix = "00/" if shear_catalog_type == "metadetect" else ""
shear_prefix = "ns/" if shear_catalog_type == "metadetect" else ""
delta_gamma = self.config["delta_gamma"]

snr_edges = self.get_bin_edges("s2n")
Expand Down Expand Up @@ -516,7 +519,7 @@ def plot_size_shear(self):
from scipy import stats

shear_catalog_type = self.config["shear_catalog_type"]
shear_prefix = "00/" if shear_catalog_type == "metadetect" else ""
shear_prefix = "ns/" if shear_catalog_type == "metadetect" else ""
delta_gamma = self.config["delta_gamma"]

T_edges = self.get_bin_edges("T")
Expand Down Expand Up @@ -580,7 +583,7 @@ def plot_mag_shear(self):
from scipy import stats

shear_catalog_type = self.config["shear_catalog_type"]
shear_prefix = "00/" if shear_catalog_type == "metadetect" else ""
shear_prefix = "ns/" if shear_catalog_type == "metadetect" else ""
delta_gamma = self.config["delta_gamma"]
nbins = self.config["nbins"]

Expand Down Expand Up @@ -712,16 +715,16 @@ def plot_g_histogram(self):
if data is None:
break

qual_cut = data["bin"] != -1
#qual_cut = data["bin"] != -1

if cat_type == "metacal":
g1 = data["g1"]
g2 = data["g2"]
w = data["weight"]
elif cat_type == "metadetect":
g1 = data["00/g1"]
g2 = data["00/g2"]
w = data["00/weight"]
g1 = data["ns/g1"]
g2 = data["ns/g2"]
w = data["ns/weight"]
elif cat_type == "lensfit":
dec = data["dec"]
g1 = data["g1"]
Expand Down Expand Up @@ -790,7 +793,8 @@ def plot_snr_histogram(self):

delta_gamma = self.config["delta_gamma"]
shear_catalog_type = self.config["shear_catalog_type"]
shear_prefix = "00/" if shear_catalog_type == "metadetect" else ""
shear_prefix = "ns/" if shear_catalog_type == "metadetect" else ""
bin_type = "bin_ns" if self.config["shear_catalog_type"] == "metadetect" else "bin"
bins = 10
edges = np.logspace(1, 3, bins + 1)
mids = 0.5 * (edges[1:] + edges[:-1])
Expand All @@ -802,7 +806,7 @@ def plot_snr_histogram(self):
if data is None:
break

qual_cut = data["bin"] != -1
qual_cut = data[bin_type] != -1

b1 = np.digitize(data[f"{shear_prefix}s2n"][qual_cut], edges) - 1

Expand Down Expand Up @@ -979,7 +983,8 @@ def plot_mag_histograms(self):
mid = 0.5 * (edges[1:] + edges[:-1])
width = edges[1] - edges[0]
bands = self.config["bands"]
shear_prefix = "00/" if self.config["shear_catalog_type"] == "metadetect" else ""
shear_prefix = "ns/" if self.config["shear_catalog_type"] == "metadetect" else ""
bin_type = "bin_ns" if self.config["shear_catalog_type"] == "metadetect" else "bin"
nband = len(bands)
full_hists = [np.zeros(size, dtype=int) for b in bands]
source_hists = [np.zeros(size, dtype=int) for b in bands]
Expand All @@ -998,7 +1003,7 @@ def plot_mag_histograms(self):
count = w.sum()
h1[i] += count

w &= data["bin"] >= 0
w &= data[bin_type] >= 0
count = w.sum()
h2[i] += count

Expand Down
1 change: 1 addition & 0 deletions txpipe/ingest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
)
from .dp1 import TXIngestDataPreview1
from .stage3 import TXIngestDESY3Gold
from .metaDetect import TXIngestRubinMetaDetect
52 changes: 52 additions & 0 deletions txpipe/ingest/lsst.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,55 @@ def process_shear_data(data):
output["psf_g2"] = psf_g2

return output


def process_metadetect_data(data):
output = {}
for variant in ["ns", "1p", "1m", "2p", "2m"]:
var_data = data[data["metaStep"] == variant]
var_data = sanitize(var_data)

var_output = {
"ra": var_data["ra"],
"dec": var_data["dec"],
"id": var_data["shearObjectId"],
"object_mask_fraction": var_data["mfrac"],
#"n_epoch": var_data["nEpochCell"],
"g1": var_data["gauss_g1"],
"g2": var_data["gauss_g2"],
"g1_err": var_data["gauss_g1_g1_Cov"],
"g2_err": var_data["gauss_g2_g2_Cov"],
"g_cross": var_data["gauss_g1_g2_Cov"],
"T": var_data["gauss_T"],
"s2n": var_data["gauss_snr"],
"T_err": var_data["gauss_TErr"],
"psf_g1_original": var_data["psfOriginal_e1"],
"psf_g2_original": var_data["psfOriginal_e2"],
"psf_T_mean_original": var_data["psfOriginal_T"],
"psf_g1": var_data["gauss_psfReconvolved_g1"],
"psf_g2": var_data["gauss_psfReconvolved_g1"],
"psf_T_mean": var_data["gauss_psfReconvolved_T"],
"flags": var_data["gauss_shape_flags"], # TO BE ADDRESSED!
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the comment more?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I wasn't sure if that was the only flag we needed, or if we need to add a bunch of the flags instead.

"weight": 1 / (0.5 * (var_data["gauss_g1_g1_Cov"] + var_data["gauss_g2_g2_Cov"])),
}
for band in "gri": # For DP2, we only expect 4 bands
f = var_data[f"{band}_pgaussFlux"]
f_err = var_data[f"{band}_pgaussFluxErr"]
var_output[f"mag_{band}"] = nanojansky_to_mag_ab(f)
var_output[f"mag_err_{band}"] = nanojansky_err_to_mag_ab(f, f_err)
output[f"{variant}"] = var_output

return output

def sanitize(data):
"""
Convert unicode arrays into types that h5py can save
"""
# convert unicode to strings
if data.dtype.kind == "U":
data = data.astype("S")
# convert dates to integers
elif data.dtype.kind == "M":
data = data.astype(int)

return data
Loading
Loading