Uploaded image for project: 'DRP 2-D Pipeline'
  1. DRP 2-D Pipeline
  2. PIPE2D-782

Spectra extracted from data used to construct fiberTraces are not flat

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done (View Workflow)
    • Priority: Normal
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Sprint:
      2DDRP-2021 A3

      Description

      If I run the code in constructFiberProfilesTask.py to make new fiberProfiles from a single exposure and then use them to extract the spectra from the same data they should be identically 1.0, but they are not (see ). The code was actually unpacked into this stand-alone fragment from a notebook, but I think it's doing the same thing as the combine method (remove the %matplotlib notebook to run as a python script).

      import os
      import numpy as np
      
      import matplotlib.pyplot as plt
      %matplotlib notebook
      
      import lsst.daf.persistence as dafPersist
      
      # ---------------------------------
      
      base, rerun = "/projects/HSC/PFS/Subaru", os.path.join("rhl", "sunss")
      
      dataDir = os.path.join(base, "rerun", rerun)
      calibRoot = os.path.join(base, "CALIB-SuNSS")
      butler = dafPersist.Butler(dataDir, calibRoot=calibRoot)
      
      # ---------------------------------
      
      import pfs.drp.stella.buildFiberProfiles 
      
      BuildFiberProfilesTask = pfs.drp.stella.buildFiberProfiles.BuildFiberProfilesTask
      
      config = BuildFiberProfilesTask.ConfigClass()
      config.doBlindFind = False
      buildFiberProfilesTask = BuildFiberProfilesTask(config)
      
      # ---------------------------------
      
      dataId = dict(visit=46243, spectrograph=1, arm='r')   # domeflat
      
      exp = butler.get("calexp", dataId)
      detMap = butler.get("detectorMap", dataId)
      pfsConfig = butler.get("pfsConfig", dataId)
      
      results = buildFiberProfilesTask.run(exp, detMap, pfsConfig)
      profiles, centers = results.profiles, results.centers
      
      traces = profiles.makeFiberTracesFromDetectorMap(detMap)
      
      spectra0 = traces.extractSpectra(exp.maskedImage)
      
      for i, ss in enumerate(spectra0):
          profiles[ss.fiberId].norm = ss.flux
      
      traces = profiles.makeFiberTracesFromDetectorMap(detMap)
      
      spectra = traces.extractSpectra(exp.maskedImage)
      
      # ---------------------------------
      
      fig = 1; plt.close(fig); fig = plt.figure(fig)
      
      for ss in spectra:
          if 4 < ss.fiberId < 140:
              plt.plot(ss.flux/np.median(ss.flux), alpha=0.5)
      
      plt.ylim(1 + 0.01*np.array([-1, 1]))
      plt.xlabel("pixel")
      plt.ylabel("Extracted flux")
      plt.title(f"{'%(visit)d %(arm)s%(spectrograph)d' % dataId}");
      

        Attachments

        1. extract_three_slits.png
          extract_three_slits.png
          165 kB
        2. pipe2d-782.png
          pipe2d-782.png
          19 kB
        3. pipe2d-782-fixed.png
          pipe2d-782-fixed.png
          19 kB
        4. quartz_spectra.png
          quartz_spectra.png
          259 kB
        5. three_slits.png
          three_slits.png
          124 kB

          Activity

            People

            • Assignee:
              price price
              Reporter:
              rhl rhl
              Reviewers:
              hassan
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: