diff --git a/README.md b/README.md index a074383c..5cc9db87 100644 --- a/README.md +++ b/README.md @@ -85,22 +85,17 @@ Determines the quality of the fiber extraction. | `extQaImage` | `instrument, visit, arm, spectrograph` | Residual, and chi comparisons of the postISRCCD profile and fiberProfiles are plotted for some fibers with bad extraction quality. | | `extQaImage_pickle` | `instrument, visit, arm, spectrograph` | Statistics of the residual analysis. | -#### `fluxCalQa` +#### `fiberNormsQa` -> NOTE: This is not fully updated for `gen3`. In particular the `dimensions` in the output table will change. - -Determines the quality of the flux calibration. +Plot the fiber normalization for the given detector and visit. ##### Options -- `fluxCalQa:filterSet`: The filter set to use for the flux calibration. Default is `ps1`. -- `fluxCalQa:includeFakeJ`: Include the fake J band in the flux calibration. Default is `False`. -- `fluxCalQa:diffFilter`: The filter to use for the differential flux calibration. Default is `g_ps1`. +- `fiberNormsQa:plotLower`: Lower bound for plot (standard deviations from median), default 2.5. +- `fiberNormsQa:plotUpper`: Upper bound for plot (standard deviations from median), default 2.5. ##### Outputs -| DataSet Type | Dimensions | Description | -|------------------------|--------------|----------------------------------------------------------------------------------------------| -| `fluxCalMagDiffPlot` | `instrument` | Plot of the difference between the standard star magnitudes and the instrumental magnitudes. | -| `fluxCalColorDiffPlot` | `instrument` | Plot of the difference between the instrumental magnitudes and a given filter. | -| `fluxCalStats` | `instrument` | Statistics of the flux calibration analysis. | +| DataSet Type | Dimensions | Description | +|------------------|--------------------------|-----------------------------------------------| +| `fiberNormsPlot` | `instrument, visit, arm` | Plot of the fiber normalizations for a visit. | diff --git a/pipelines/drpQA.yaml b/pipelines/drpQA.yaml index 503b4810..a812ffb6 100644 --- a/pipelines/drpQA.yaml +++ b/pipelines/drpQA.yaml @@ -6,3 +6,5 @@ tasks: class: pfs.drp.qa.dmCombinedResiduals.DetectorMapCombinedResidualsTask extractionQa: class: pfs.drp.qa.extractionQa.ExtractionQaTask + fiberNormsQa: + class: pfs.drp.qa.fiberNormsQa.FiberNormQaTask diff --git a/python/pfs/drp/qa/fiberNormsQa.py b/python/pfs/drp/qa/fiberNormsQa.py new file mode 100644 index 00000000..da7707b3 --- /dev/null +++ b/python/pfs/drp/qa/fiberNormsQa.py @@ -0,0 +1,79 @@ +from lsst.pex.config import Field +from lsst.pipe.base import ( + PipelineTask, + PipelineTaskConfig, + PipelineTaskConnections, + Struct, +) +from lsst.pipe.base.connectionTypes import ( + Input as InputConnection, + Output as OutputConnection, + PrerequisiteInput as PrerequisiteConnection, +) +from pfs.drp.stella import PfsConfig, PfsFiberNorms + + +class FiberNormQaConnections( + PipelineTaskConnections, + dimensions=("instrument", "visit", "arm"), +): + """Connections for fiberNormQaTask""" + + pfsConfig = PrerequisiteConnection( + name="pfsConfig", + doc="Top-end configuration", + storageClass="PfsConfig", + dimensions=("instrument", "visit"), + ) + fiberNorms = InputConnection( + name="fiberNorms", + doc="Measured fiber normalisations", + storageClass="PfsFiberNorms", + dimensions=("instrument", "visit", "arm"), + ) + fiberNormsPlot = OutputConnection( + name="fiberNormsPlot", + doc="FiberNorms QA plot", + storageClass="Plot", + dimensions=("instrument", "visit", "arm"), + ) + + +class FiberNormQaConfig(PipelineTaskConfig, pipelineConnections=FiberNormQaConnections): + """Configuration for fiberNormQaTask""" + + plotLower = Field(dtype=float, default=2.5, doc="Lower bound for plot (standard deviations from median)") + plotUpper = Field(dtype=float, default=2.5, doc="Upper bound for plot (standard deviations from median)") + + +class FiberNormQaTask(PipelineTask): + """Task for QA of fiberNorms""" + + ConfigClass = FiberNormQaConfig + _DefaultName = "fiberNormsQa" + + def run(self, fiberNorms: PfsFiberNorms, pfsConfig: PfsConfig) -> Struct: + """QA of fiberNorms. + + Parameters + ---------- + fiberNorms : `PfsFiberNorms` + Measured fiber normalisations. + pfsConfig : `PfsConfig` + Top-end configuration. + + Returns + ------- + outputs : `Struct` + QA outputs. + """ + self.log.info(f"Plotting fiber norms QA for {fiberNorms.identity}") + + upper_bounds = self.config.plotUpper + lower_bounds = self.config.plotLower + fig, axes = fiberNorms.plot(pfsConfig, lower=lower_bounds, upper=upper_bounds) + visitList = fiberNorms.identity.visit0 + arm = fiberNorms.identity.arm + axes.set_title(f"Fiber normalization for {arm=}\nvisits: {visitList}") + + return Struct(fiberNormsPlot=fig)