Skip to content

Eac/shear table ids - #22

Merged
eacharles merged 9 commits into
mainfrom
eac/shear-table-ids
Oct 1, 2026
Merged

eacharles merged 9 commits into
mainfrom
eac/shear-table-ids

Conversation

@eacharles

Copy link
Copy Markdown
Contributor

No description provided.

Introduce ObjectShearTable (object_id + cluster_id + shear stats) and
ClusterShearTable (cluster_id + shear stats) as subclasses of ShearTable.
ShearTable.buildObjectShearStats and buildClusterShearStats now return the
appropriate subclass with ids correctly populated.  Both classes are exported
from the package.

Generated with AI

Co-Authored-By: SLAC AI
…sterTable

Both functions now accept an optional parquet file path:
- buildJoinedObjectTable: object_shear=<path> joins ObjectShearTable on
  object_id; cluster_id is dropped before joining to avoid duplication
- buildJoinedClusterTable: cluster_shear=<path> joins ClusterShearTable on
  cluster_id

Also adds Path to imports and two new unit tests covering the new parameters.

Generated with AI

Co-Authored-By: SLAC AI
computeColumnStats(df, col_prefix, catalog_ids) collects all columns named
{col_prefix}_{cat_id} that exist in df and returns a DataFrame with
{col_prefix}_mean, {col_prefix}_std (ddof=1), and {col_prefix}_n, ignoring
NaN values (missing matches) row-wise.  Catalog IDs whose column is absent
are silently skipped.  Exported from the package.

Generated with AI

Co-Authored-By: SLAC AI
reduceJoinedTable(df, catalog_ids, keep_cols, drop_cols, stats_cols) applies
three operations in sequence:
  1. Column selection: keep_cols if provided, else all minus drop_cols
  2. Per-catalog column removal: strips {prefix}_{cat_id} for each stats prefix
  3. Stats aggregation: appends {prefix}_mean/_std/_n via computeColumnStats

Generated with AI

Co-Authored-By: SLAC AI
Previously only {prefix}_{cat_id} variants were removed. Now any column
whose name exactly matches a prefix in stats_cols is dropped too, so a
bare "flux" column (e.g. from an object_shear join) is replaced along
with "flux_0", "flux_1", … by the aggregated flux_mean/std/n columns.

Generated with AI

Co-Authored-By: SLAC AI
Returns only {prefix}_mean and {prefix}_std. Updated docstring, empty-cols
fallback, and all affected tests.

Generated with AI

Co-Authored-By: SLAC AI
Instead of calling nanmean/nanstd over all rows and letting numpy warn on
degenerate slices, pre-compute the per-row non-NaN count (n) and only call
each function on rows where it is well-defined (n>=1 for mean, n>=2 for
std). Rows with insufficient data remain NaN without any warning.

Generated with AI

Co-Authored-By: SLAC AI
n_sib_objects: number of objects in the parent cluster (len(cluster.objects))
n_sib_srcs: total sources across all objects in the parent cluster
            (sum of o.n_src for o in cluster.objects)

Generated with AI

Co-Authored-By: SLAC AI
@eacharles
eacharles merged commit a0d9c23 into main Oct 1, 2026
4 checks passed
@eacharles
eacharles deleted the eac/shear-table-ids branch October 1, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant