Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PREOPS-4949: Add stackers useful for schedview (Teff and dayobs related) #399

Merged
merged 8 commits into from
Mar 29, 2024

Conversation

ehneilsen
Copy link
Collaborator

I'll do the addition of the plotters we discussed as a separate PR.

@rhiannonlynne rhiannonlynne changed the title tickets/PREOPS-4949: Add stackers useful for schedview PREOPS-4949: Add stackers useful for schedview (Teff and dayobs related) Mar 29, 2024
@rhiannonlynne
Copy link
Member

I realized I had a concern that if there were two bundles with TeffStacker but one "normed" and one not, that they might run at the same time and have a conflict about the t_eff column. However, apparently we built MAF better than that and it does the right thing (runs them separately, rewrites the t_eff values, and comes up with the correct answers. Yay!

import rubin_sim.maf as maf

opsdb = '/Users/lynnej/opsim/baseline_v3.4_10yrs.db'

teff_stacker = maf.TeffStacker()
teff_stacker2 = maf.TeffStacker(normed=True)

bundle = maf.MetricBundle(maf.SumMetric(col='t_eff'), maf.UniSlicer(), '', stacker_list=[teff_stacker])
bundle2 = maf.MetricBundle(maf.MeanMetric(col='t_eff'), maf.UniSlicer(), '', stacker_list=[teff_stacker2])

g = maf.MetricBundleGroup({'teff': bundle, 'teff_normed': bundle2}, opsdb, verbose=True)
g.run_all()

bundle.metric_values, bundle2.metric_values

produces

(masked_array(data=[44791395.476532385],
              mask=[False],
        fill_value=-666.0),
 masked_array(data=[0.6969573084883421],
              mask=[False],
        fill_value=-666.0))

as expected.

values from the previous TeffMetric for the same run:
All sky all bands 0.70 (normed) 44791395.48 (total).

@@ -0,0 +1,145 @@
__all__ = ["TEFF_FIDUCIAL_DEPTH", "TEFF_FIDUCIAL_EXPTIME", "TeffStacker"]
Copy link
Member

Choose a reason for hiding this comment

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

You might as well export "compute_teff" as well, though maybe? (especially if exporting the fiducial values).
In theory, you could use the compute_teff with a pandas data frame using apply, although it may be better overall (i.e. from schedview) to just use the
maf.get_sim_data() method, pointing to the visit database in question, and add the stackers you want.

@@ -106,9 +106,12 @@ def glanceBatch(
bundle_list.append(bundle)

# Total effective exposure time
metric = metrics.TeffMetric(m5_col=colmap["fiveSigmaDepth"], filter_col=colmap["filter"], normed=True)
metric = metrics.MeanMetric(col="t_eff")
Copy link
Member

Choose a reason for hiding this comment

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

Ooh, right -- when using Normed stackers, the sum becomes a MeanMetric.

@ehneilsen ehneilsen merged commit 8f02edc into main Mar 29, 2024
6 of 9 checks passed
@ehneilsen ehneilsen deleted the tickets/PREOPS-4949 branch March 29, 2024 21:58
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.

2 participants