AnaCal ingestion#446
Conversation
mr-superonion
left a comment
There was a problem hiding this comment.
Thanks for the preparing the PR, here is my comment
| The indicies of the objects selected from this chunk of data | ||
| """ | ||
| data = _DataWrapper(data, "") | ||
| select = self.selector(data, *args, **kwargs) |
There was a problem hiding this comment.
i think the select also need a shear response calculation like what is done in self.get_submask()
There was a problem hiding this comment.
Not quite sure what you mean
There was a problem hiding this comment.
@mr-superonion The select function is passed to the code that does the shear calibration. The DataWrapper objects pass in different subsets of data - if the select function asks for data["s2n"], for example, then DataWrapper will give it different columns depending on the second argument used when creating it.
There was a problem hiding this comment.
thanks for the explanation
- i am implementing it here (e112dea#r3592442390) to create
s2n_1p,s2n_1m,s2n_2p,s2n_2m - then the data wrapper is used here (e112dea#r3592459804) to create different shifted version
| config: examples/Anacal_test/config.yml | ||
|
|
||
| inputs: | ||
| anacal_catalog: /pscratch/sd/x/xiangchl/data/DP1/catalogs/anacal_catalog_a360.fits |
There was a problem hiding this comment.
Should the example do the butler version?
| except Exception as e: | ||
| raise RuntimeError(error_msg) from e | ||
|
|
||
| if self.config["select_field"]: |
There was a problem hiding this comment.
Will we have anacal for DP2? If so we might code that applies there?
There was a problem hiding this comment.
Not sure what you mean? The plan is to generate an Anacal catalog for DP2
There was a problem hiding this comment.
I just meant that all the fields are DP1 fields so it might not be that useful here.
There was a problem hiding this comment.
ahh okay, I also added the option of just providing tracts
2. correct for the typo in calibration_calibrators.py, det_respponse_e1 3. in conversion.py f was not defined, changed to flux
|
It seems that i do not have permission to modify the pr here; therefore i opened a pr to correct for some bugs/typo in this pr: |
Two equivalent bookkeeping conventions give an unbiased shear:
(A) <e> = Σ(wsel·e) / N
R = Σ(de/dg·wsel + dw/dg·e) / N
→ R_sel normalized by count.
(B) <e> = Σ(wsel·e) / N / <wsel>
R = Σ(de/dg·wsel + dw/dg·e) / N / <wsel>
→ R_sel normalized by sum(wsel).
The rest of the code — R_shape, R_weight, and every mean-e
computation — uses convention (B), so R_sel must match with a
sum_weights denominator, not count.
Also: nanojansky_err_to_mag_ab returns NaN for flux <= 0 via
np.divide(where=flux>0) instead of producing negative sigma_mag
and RuntimeWarnings.
anacal ingest bug correction
|
@mr-superonion I've added you to the team that gives you permissions for future things. |
as a second stage after ingest, with a matching config.yml block:
delta_gamma: 0.01, mask_threshold: 40, s2n_cut: 5.0, T_cut: 0.1,
5-bin source_zbin_edges, input_pz: true.
2. Ingested photo-z point estimates. TXIngestAnacal now reads
zmode_{0,1p,1m,2p,2m} from the merged catalog and exposes them on the
shear catalog as mean_z, mean_z_{1p,1m,2p,2m} — baseline for
tomographic binning, the four variants for the R_sel bin-migration
term.
3. Built ±γ variants of every quantity the selector cuts on. In
TXSourceSelectorAnaCal.apply_simple_redshift_cut, injected
s2n_{1p,1m,2p,2m} = s2n ± δγ · ds2n_dg{1,2}, and analogous variants
of m00, m20 (from dm00_dg, dm20_dg) and zbin (from mean_z_*). All
four cut quantities now respond to shear via a single uniform
injection step.
4. Unified the calculator's cut logic under _DataWrapper. Deleted the
ad-hoc get_submask size-cut machinery in AnaCalCalculator.add_data.
The selector now applies mask + s2n + size + zbin in one place; the
calculator just runs the same selector on five wrappers (baseline +
_1p/_1m/_2p/_2m), and the wrapper's suffix-lookup routes the shifted
columns automatically. AnaCalCalculator.__init__ dropped its
mask_threshold argument as a consequence.
5. Consistent response formulae. Rewrote R_shape, R_weight, R_sel_{1,2}
in the calculator so all three share the same code shape: Σ(w · X) /
sum_weights for R_shape and R_weight, and [Σ(w·e)|sel_+ −
Σ(w·e)|sel_−] / (2 δγ · sum_weights) for R_sel. R_shape switched from
a ParallelMean to a plain scalar sum for parity; det_response_*
renamed to weight_response_* to match the "R_weight" label; a small
_reduce helper replaced 30 lines of MPI reduce boilerplate.
6. Promoted the size threshold to config. The AnaCal size cut,
previously hard-coded as (m00 + m20) / m00 > 0.1, is now > T_cut —
driven by the base selector's T_cut config option that was previously
unused for AnaCal. TXSourceSelectorAnaCal.config_options gives it a
default of 0.1 alongside a new s2n_cut default of 5.0, so a minimal
yaml block still runs; both can be overridden in the yaml for
tighter/looser cuts.
mr-superonion
left a comment
There was a problem hiding this comment.
I made a few update to include the selection bias correction for s2n and add selection stage into the example. I will check over the dp1 data to see whether i can get consistent result to the hsc code.
| pz_data["s2n_1m"] = s2n - dg * shear_data["ds2n_dg1"] | ||
| pz_data["s2n_2p"] = s2n + dg * shear_data["ds2n_dg2"] | ||
| pz_data["s2n_2m"] = s2n - dg * shear_data["ds2n_dg2"] | ||
|
|
There was a problem hiding this comment.
here is the code to create shifted columns for s2n.
| shear_cols += ["mean_z"] | ||
| # Baseline photo-z + the four shifted variants used to derive | ||
| # zbin_{1p,1m,2p,2m} for the selection-response calculation. | ||
| shear_cols += ["mean_z", "mean_z_1p", "mean_z_1m", "mean_z_2p", "mean_z_2m"] |
There was a problem hiding this comment.
Here we need columns for the shifted redshifts to get the selection bias due to the binning.
| data_1p = _DataWrapper(data, "_1p") | ||
| data_1m = _DataWrapper(data, "_1m") | ||
| data_2p = _DataWrapper(data, "_2p") | ||
| data_2m = _DataWrapper(data, "_2m") |
There was a problem hiding this comment.
data wrapper is used here to get different shifted version of the catalog
| The indicies of the objects selected from this chunk of data | ||
| """ | ||
| data = _DataWrapper(data, "") | ||
| select = self.selector(data, *args, **kwargs) |
There was a problem hiding this comment.
thanks for the explanation
- i am implementing it here (e112dea#r3592442390) to create
s2n_1p,s2n_1m,s2n_2p,s2n_2m - then the data wrapper is used here (e112dea#r3592459804) to create different shifted version
| # (zmode_{1p,1m,2p,2m}) in xlens' photoZPipe (currently ±0.01 in | ||
| # DISTORTIONS). | ||
| delta_gamma: 0.01 | ||
|
|
There was a problem hiding this comment.
i add the selection stage in the example.
There was a problem hiding this comment.
But we don't want to run them at the same time. Sadly from how things are set up on NERSC, we want to run the ingestion stage in one environment and then the rest of the pipeline should be run in a dedicated environment for TXPipe. But we want to be able to run the Selection stage later, where we might be able to use different photo-z's for example
|
@mr-superonion Thank you for the additions, I however do not think we should move away from parallel mean if we can avoid it! I am a little confused about what has been moved from the calibration stage to the source-selection, and why? |
This is a pull request for ingesting the DP2 version of AnaCal. currently it is ingesting a DP1 version of the catalog