<!-- 
RSS generated by JIRA (8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b) at Sat Feb 10 15:49:40 JST 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>PFS-JIRA</title>
    <link>https://pfspipe.ipmu.jp/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.3.4</version>
        <build-number>803005</build-number>
        <build-date>13-09-2019</build-date>
    </build-info>


<item>
            <title>[PIPE2D-218] Discuss FiberTrace&apos;s architecture</title>
                <link>https://pfspipe.ipmu.jp/jira/browse/PIPE2D-218</link>
                <project id="10002" key="PIPE2D">DRP 2-D Pipeline</project>
                    <description>&lt;p&gt;Having just been debugging some issues with &lt;tt&gt;FiberTrace&lt;/tt&gt; I got the impression that it could be made significantly simpler and more robust.&lt;/p&gt;

&lt;p&gt;We should discuss this.&lt;/p&gt;</description>
                <environment></environment>
        <key id="11695">PIPE2D-218</key>
            <summary>Discuss FiberTrace&apos;s architecture</summary>
                <type id="3" iconUrl="https://pfspipe.ipmu.jp/jira/secure/viewavatar?size=xsmall&amp;avatarId=10518&amp;avatarType=issuetype">Task</type>
                                            <priority id="10000" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/priorities/medium.svg">Normal</priority>
                        <status id="10002" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/statuses/generic.png" description="The issue is resolved, reviewed, and merged">Done</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="rhl">rhl</assignee>
                                    <reporter username="rhl">rhl</reporter>
                        <labels>
                    </labels>
                <created>Wed, 12 Jul 2017 17:18:33 +0000</created>
                <updated>Thu, 17 Aug 2017 20:00:45 +0000</updated>
                            <resolved>Fri, 4 Aug 2017 19:26:18 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>2</watches>
                                                                <comments>
                            <comment id="12436" author="rhl" created="Wed, 26 Jul 2017 15:19:58 +0000"  >&lt;p&gt;Some of the comments about unused code will be fixed on &lt;a href=&quot;https://pfspipe.ipmu.jp/jira/browse/PIPE2D-207&quot; title=&quot;Run coverage tools and remove *all* unused code&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PIPE2D-207&quot;&gt;&lt;del&gt;PIPE2D-207&lt;/del&gt;&lt;/a&gt; (or, in one case, &lt;a href=&quot;https://pfspipe.ipmu.jp/jira/browse/PIPE2D-221&quot; title=&quot;Remove obsolete makeNormFlatFiberTrace from FiberTraces.cc&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PIPE2D-221&quot;&gt;&lt;del&gt;PIPE2D-221&lt;/del&gt;&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Here&apos;s a first dump of my thoughts.&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
The FiberTrace &lt;span class=&quot;code-keyword&quot;&gt;class &lt;/span&gt;describes the profiles and positions of spectra on a detector.

Creating a FiberTraceSet is done as follows:

    ftffc = drpStella.FiberTraceFunctionFindingControl()     &lt;span class=&quot;code-comment&quot;&gt;// terrible name!
&lt;/span&gt;    quartzImage = butler.get(&lt;span class=&quot;code-quote&quot;&gt;&quot;calexp&quot;&lt;/span&gt;, dataId).getMaskedImage()

    fiberTraceSet = drpStella.findAndTraceApertures(quartzImage, ftffc)

    fiberTraceSet.sortTracesByXCenter()

    &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; i in range(fiberTraceSet.size()):
        fiberTraceSet.getFiberTrace(i).setITrace(i)

    fiberTraceSet.setFiberTraceProfileFittingControl(fiberTraceProfileFittingControl)

    &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; doAll:
        inFiberTraceSet.calcProfileAllTraces()
    &lt;span class=&quot;code-keyword&quot;&gt;else&lt;/span&gt;:
        &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; i in inTraceNumbers:
	    inFiberTraceSet.getFiberTrace(i).calcProfile()

Extracting a spectrum then consists of:

   # Read a model of the mapping from pixels to traces
   xCenters, wavelengths, traceIds = readWavelengthFile(wLenFile)

   # assign trace number to fiberTraceSet based on model
   drpStella.assignITrace(fiberTraceSet, traceIds, xCenters)
   #
   spectrumSet = drpStella.SpectrumSet()

   scienceImage = butler.get(&lt;span class=&quot;code-quote&quot;&gt;&quot;calexp&quot;&lt;/span&gt;, dataId).getMaskedImage()

   &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; i in traceIds:
      fiberTrace = fiberTraceSet.getFiberTrace(i)

      # Set pixels in FiberTrace from scienceImage
      fiberTrace.createTrace(scienceImage)
      
      # Extract spectrum from profile
      spectrum = fiberTrace.extractFromProfile()
      spectrumSet.addSpectrum(spectrum)

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

I&apos;d expect &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; to look like:

    xCenters, wavelengths, fiberIds = readWavelengthFile(wLenFile)   # we&apos;d actually read the DetectorMap
    detectorMap = DetectorMap(xCenters, wavelengths, fiberIds, ...)

    quartzImage = butler.get(&lt;span class=&quot;code-quote&quot;&gt;&quot;calexp&quot;&lt;/span&gt;, dataId).getMaskedImage()

    ftffc = drpStella.FiberTraceFunctionFindingControl()
    ftpfc = fiberTraceProfileFittingControl

    fiberTraceSet = drpStella.findAndTraceApertures(quartzImage, detectorMap, ftffc, ftpfc)

which would now have profiles set.  Extracting a spectrum would then consist of:

    scienceImage = butler.get(&lt;span class=&quot;code-quote&quot;&gt;&quot;calexp&quot;&lt;/span&gt;, dataId).getMaskedImage()
    spectrumSet = drpStella.extractSpectrumSet(scienceImage, fiberTraceSet)

Note in particular that we &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; not set the &lt;span class=&quot;code-quote&quot;&gt;&quot;trace&quot;&lt;/span&gt; images in the FiberTrace; in fact, I don&apos;t think that
we need them at all.  We &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; need code to &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; a MaskedImage of the Profile (in the CCD coordinate system,
with XY0 set and mask bits to indicate the trace).

The FiberTrace does, of course, need to know all about its profile but I think that the current code is more
complex than is really necessary.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

A FiberTrace has a number of data members:
    std::vector&amp;lt;PTR(std::vector&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;&amp;gt;)&amp;gt; _overSampledProfileFitXPerSwath;
    std::vector&amp;lt;PTR(std::vector&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;&amp;gt;)&amp;gt; _overSampledProfileFitYPerSwath;
    std::vector&amp;lt;PTR(std::vector&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;&amp;gt;)&amp;gt; _profileFittingInputXPerSwath;
    std::vector&amp;lt;PTR(std::vector&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;&amp;gt;)&amp;gt; _profileFittingInputYPerSwath;
    std::vector&amp;lt;PTR(std::vector&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;&amp;gt;)&amp;gt; _profileFittingInputXMeanPerSwath;
    std::vector&amp;lt;PTR(std::vector&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;&amp;gt;)&amp;gt; _profileFittingInputYMeanPerSwath;
What are these?  2-D arrays?  why are they vectors of vectors, and what &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; they all mean?
    
    PTR(lsst::afw::image::MaskedImage&amp;lt;ImageT, MaskT, VarianceT&amp;gt;) _trace;
Why &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; we need &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; in the data structure?
    
    PTR(lsst::afw::image::Image&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;&amp;gt;) _profile;
Why is &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; an image, not a MaskedImage?

    ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 2, 1&amp;gt; _xCentersMeas;
What are these?  Do they need to be in the class?
    ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 1, 1&amp;gt; _xCenters;
In what sense are these not measured?

    std::size_t _iTrace;
Is &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; a fiberId?

    bool _isTraceSet;
    bool _isProfileSet;
    bool _isFiberTraceProfileFittingControlSet;
This will go once the profile extraction is part of the trace generation

    PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; FiberTraceFunction) _fiberTraceFunction;
This isn&lt;span class=&quot;code-quote&quot;&gt;&apos;t a function, it&apos;&lt;/span&gt;s a set of parameters.  What &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; the coefficients mean -- there seems to
be only one per trace.
    PTR(FiberTraceProfileFittingControl) _fiberTraceProfileFittingControl;
There seems to be lots of old code in here.  What&lt;span class=&quot;code-quote&quot;&gt;&apos;s the telluric code doing -- we&apos;&lt;/span&gt;ll never turn it on.  If it simplifies the code we should delete all references to Piskunov.

And methods:
    &lt;span class=&quot;code-comment&quot;&gt;// ctors/dtors
&lt;/span&gt;    explicit FiberTrace(std::size_t width = 0, std::size_t height = 0, std::size_t iTrace = 0);
Do we need a &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt; ctor?
    explicit FiberTrace(PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; MaskedImageT) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; maskedImage,
                        PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; FiberTraceFunction) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceFunction, 
                        std::size_t iTrace=0);
    FiberTrace(FiberTrace&amp;lt;ImageT, MaskT, VarianceT&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTrace);
    FiberTrace(FiberTrace&amp;lt;ImageT, MaskT, VarianceT&amp;gt; &amp;amp; fiberTrace, bool &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; deep);
&lt;span class=&quot;code-comment&quot;&gt;// why two, not a &lt;span class=&quot;code-keyword&quot;&gt;default&lt;/span&gt; argument (here or in the pybind11 bindings)?
&lt;/span&gt;&lt;span class=&quot;code-comment&quot;&gt;// &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; we ever need to copy FiberTraces?
&lt;/span&gt;
    virtual ~FiberTrace() {}

    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    &lt;span class=&quot;code-comment&quot;&gt;// getters and setters
&lt;/span&gt;    &lt;span class=&quot;code-comment&quot;&gt;// &lt;span class=&quot;code-quote&quot;&gt;&quot;trace&quot;&lt;/span&gt;
&lt;/span&gt;    PTR(MaskedImageT) getTrace();
    &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; MaskedImageT) getTrace() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
    void setTrace(PTR(MaskedImageT) &amp;amp; trace);
    void createTrace(PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; MaskedImageT) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; maskedImage);
I think all of these can go.

    &lt;span class=&quot;code-comment&quot;&gt;// &lt;span class=&quot;code-quote&quot;&gt;&quot;profile&quot;&lt;/span&gt;
&lt;/span&gt;    PTR(lsst::afw::image::Image&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;&amp;gt;) getProfile() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
This needs to be in CCD coordinates, not internal &lt;span class=&quot;code-quote&quot;&gt;&quot;sliced&quot;&lt;/span&gt; images.
    void setProfile( PTR(lsst::afw::image::Image&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;&amp;gt;) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; profile);
When &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; we &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;?
    
    &lt;span class=&quot;code-comment&quot;&gt;// ID number of &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; trace (_iTrace) to &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; number
&lt;/span&gt;    void setITrace(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; std::size_t iTrace);
Shouldn&apos;t be needed
    std::size_t getITrace() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
ITrace -&amp;gt; FiberId

    &lt;span class=&quot;code-comment&quot;&gt;// dimensions of &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; FiberTrace
&lt;/span&gt;    std::size_t getWidth() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
    std::size_t getHeight() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
What are these used &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt;?

    &lt;span class=&quot;code-comment&quot;&gt;// Check &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; things are set
&lt;/span&gt;    bool isTraceSet() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
    bool isProfileSet() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
    bool isFiberTraceProfileFittingControlSet() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
All of these must always be set in the construction step.

    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    &lt;span class=&quot;code-comment&quot;&gt;// Extract the spectrum of &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; fiber trace using the _profile
&lt;/span&gt;    PTR(SpectrumT) extractFromProfile();
No;  &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; is a free function that takes an image and a fiber trace.
    
    &lt;span class=&quot;code-comment&quot;&gt;// Simple Sum Extraction of &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; fiber trace
&lt;/span&gt;    PTR(SpectrumT) extractSum();
No; &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; should be an option to the free function.

    &lt;span class=&quot;code-comment&quot;&gt;// FiberTraceFunction (&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;)
&lt;/span&gt;    &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; FiberTraceFunction) getFiberTraceFunction() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
    void setFiberTraceFunction(PTR(FiberTraceFunction &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;) fiberTraceFunction);
Why &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; you need these?  Maybe the getter

    &lt;span class=&quot;code-comment&quot;&gt;// Return FiberTraceProfileFittingControl
&lt;/span&gt;    PTR(FiberTraceProfileFittingControl) getFiberTraceProfileFittingControl() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
I&apos;m not sure you need the getter
    void setFiberTraceProfileFittingControl(PTR(FiberTraceProfileFittingControl) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp;);
    void setFiberTraceProfileFittingControl(PTR(FiberTraceProfileFittingControl &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp;);
Why &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; you need both of these?
    
    &lt;span class=&quot;code-comment&quot;&gt;// fitted x-centers of the fiber trace
&lt;/span&gt;    &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; ndarray::Array&amp;lt; &lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 1, 1 &amp;gt; getXCenters() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
OK
    void setXCenters( ndarray::Array&amp;lt; &lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 1, 1 &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; xCenters );
Why &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; you need &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;?

    &lt;span class=&quot;code-comment&quot;&gt;// Return the measured x-centers of the fiber trace
&lt;/span&gt;    ndarray::Array&amp;lt; &lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 2, 1 &amp;gt; getXCentersMeas() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
    void setXCentersMeas( ndarray::Array&amp;lt; &lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 2, 1 &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; );
How is &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; different from getXCenters?

    &lt;span class=&quot;code-comment&quot;&gt;// Return an image containing the reconstructed 2D spectrum of the FiberTrace
&lt;/span&gt;    &lt;span class=&quot;code-comment&quot;&gt;// @param spectrum : 1D spectrum to reconstruct the 2D image from
&lt;/span&gt;    PTR(Image) getReconstructed2DSpectrum(SpectrumT &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; spectrum) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
Should be a MaskedImage, I think.  In CCD coords, of course.

    &lt;span class=&quot;code-comment&quot;&gt;// Return an image containing the reconstructed background of the FiberTrace
&lt;/span&gt;    &lt;span class=&quot;code-comment&quot;&gt;// @param backgroundSpectrum : 1D spectrum to reconstruct the 2D image from
&lt;/span&gt;    PTR(Image) getReconstructedBackground(SpectrumT &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; backgroundSpectrum) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
Why &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; you need &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; too?

    &lt;span class=&quot;code-comment&quot;&gt;// Return an image containing the reconstructed 2D spectrum + background of the FiberTrace
&lt;/span&gt;    &lt;span class=&quot;code-comment&quot;&gt;// @param spectrum : 1D spectrum to use &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the 2D reconstruction
&lt;/span&gt;    &lt;span class=&quot;code-comment&quot;&gt;// @param background : 1D background spectrum to use &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the 2D reconstruction
&lt;/span&gt;    PTR(Image) getReconstructed2DSpectrum(SpectrumT &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; spectrum,
                                          SpectrumT &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; background) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
Why &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; you need &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; too?
    
    /**
     * @brief Calculate the spatial profile &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the FiberTrace
     * Normally &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; would be a Flat FiberTrace, but in principle, &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; the spectrum
     * shows some kind of continuum, the spatial profile can still be calculated
     */
    void calcProfile();
What does &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt;?

    /**
     * @brief Helper function &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; calcProfile, calculates profile &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; a swath
     * A swath is approximately FiberTraceProfileFittingControl.swathWidth &lt;span class=&quot;code-object&quot;&gt;long&lt;/span&gt;
     * Each swath is overlapping the previous swath &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; half of the swath width
     * spectrum:
     * |-----------------------------------------------------------------
     * swaths:
     * |---------------|--------------|--------------|--------------|----
     *         |---------------|--------------|--------------|-----------
     * @param imageSwath : array containing the CCD image of the FiberTrace swath
     * @param maskSwath : array containing the mask of the FiberTrace swath
     * @param varianceSwath : array containing the variance of the FiberTrace swath
     * @param xCentersSwath : 1D array containing the x center positions &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the swath
     * @param iSwath : number of swath
     */
    ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 2, 1&amp;gt; calcProfileSwath(ndarray::Array&amp;lt;ImageT &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;, 2, 1&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; imageSwath,
                                                 ndarray::Array&amp;lt;MaskT &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;, 2, 1&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; maskSwath,
                                                 ndarray::Array&amp;lt;VarianceT &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;, 2, 1&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; varianceSwath,
                                                 ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;, 1, 1&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; xCentersSwath,
                                                 std::size_t &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; iSwath);
Why is &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; part of the &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;interface&lt;/span&gt;?  Those image swaths should be invisible to the user.

    /**
     * @brief Calculate boundaries &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the swaths used &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; profile calculation
     * @param swathWidth_In : Approximate width &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the swaths, will be adjusted
     * to fill the length of the FiberTrace with equally sized swaths
     * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; 2D array containing the pixel numbers &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; the start and the end
     * of each swath
     */
    ndarray::Array&amp;lt;std::size_t, 2, 1&amp;gt; calcSwathBoundY(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; std::size_t swathWidth_In) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
Ditto

    &lt;span class=&quot;code-comment&quot;&gt;// Return the coefficients of the trace function of the xCenters
&lt;/span&gt;    ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 1, 1&amp;gt; getTraceCoefficients() &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;;
Why &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; we need these?  I can see a function that returns the model

    &lt;span class=&quot;code-comment&quot;&gt;// Return a smart pointer to &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; FiberTrace
&lt;/span&gt;    PTR(FiberTrace) getPointer();
Why &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; we need &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;?

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  template&amp;lt;typename ImageT, typename VarianceT=lsst::afw::image::VariancePixel&amp;gt;
  FindCenterPositionsOneTraceResult findCenterPositionsOneTrace(
	PTR(lsst::afw::image::Image&amp;lt;ImageT&amp;gt;) &amp;amp; ccdImage,
        PTR(lsst::afw::image::Image&amp;lt;VarianceT&amp;gt;) &amp;amp; ccdImageVariance,
        PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; FiberTraceFunctionFindingControl) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceFunctionFindingControl);

should be in anon namespace

  
  ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 1, 1&amp;gt; calculateXCenters(PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; ::pfs::drp::stella::FiberTraceFunction) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceFunctionIn,
                                                 std::size_t &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; ccdHeightIn = 0,
                                                 std::size_t &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; ccdWidthIn = 0);
  ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 1, 1&amp;gt; calculateXCenters(PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; ::pfs::drp::stella::FiberTraceFunction) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceFunctionIn,
                                                 ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 1, 1&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; yIn,
                                                 std::size_t &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; ccdHeightIn = 0,
                                                 std::size_t &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; ccdWidthIn = 0);
Why &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; we need both in the &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; API?  And why not a member function?

  template&amp;lt; typename ImageT, typename MaskT=lsst::afw::image::MaskPixel,
            typename VarianceT=lsst::afw::image::VariancePixel &amp;gt;
  PTR(FiberTrace&amp;lt; ImageT, MaskT, VarianceT &amp;gt;) makeNormFlatFiberTrace(
	PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; lsst::afw::image::MaskedImage&amp;lt; ImageT, MaskT, VarianceT &amp;gt;) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; maskedImage,
        PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; ::pfs::drp::stella::FiberTraceFunction) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceFunctionWide,
        PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; ::pfs::drp::stella::FiberTraceFunctionControl) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceFunctionControlNarrow,
        PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; ::pfs::drp::stella::FiberTraceProfileFittingControl) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceProfileFittingControl,
        ImageT minSNR = 100.,
        std::size_t iTrace = 0);
Unused

  template&amp;lt; typename ImageT, typename MaskT, typename VarianceT, typename T, typename U, &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt; I &amp;gt;
  void assignITrace( FiberTraceSet&amp;lt; ImageT, MaskT, VarianceT &amp;gt; &amp;amp; fiberTraceSet,
                     ndarray::Array&amp;lt; T, 1, I &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; traceIds,
                     ndarray::Array&amp;lt; U, 1, I &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; xCenters );
Part of the construction (and supported by DetectorMap)

    void addFiberTraceToCcdArray( FiberTrace&amp;lt; ImageT, MaskT, VarianceT &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTrace,
                                  lsst::afw::image::Image&amp;lt; arrayT &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceRepresentation,
                                  ndarray::Array&amp;lt; ccdImageT, 2, dim &amp;gt; &amp;amp; ccdArray );
    void addFiberTraceToCcdImage( FiberTrace&amp;lt; ImageT, MaskT, VarianceT &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTrace,
                                  lsst::afw::image::Image&amp;lt; arrayT &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceRepresentation,
                                  lsst::afw::image::Image&amp;lt; ccdImageT &amp;gt; &amp;amp; ccdImage );
    void addArrayIntoArray( ndarray::Array&amp;lt; smallT, 2, I &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; smallArr,
                            ndarray::Array&amp;lt; std::size_t, 2, 1 &amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; xMinMax,
                            std::size_t &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; yMin,
                            ndarray::Array&amp;lt; bigT, 2, J &amp;gt; &amp;amp; bigArr );
We don&apos;t need these once we can &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; an image of the profile

    dataXY&amp;lt;CoordT&amp;gt; ccdToFiberTraceCoordinates(
        dataXY&amp;lt;CoordT&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; ccdCoordinates,
        pfs::drp::stella::FiberTrace&amp;lt;ImageT, MaskT, VarianceT&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTrace);
Unused

    dataXY&amp;lt;CoordT&amp;gt; fiberTraceCoordinatesRelativeTo(
        dataXY&amp;lt;CoordT&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTraceCoordinates,
        dataXY&amp;lt;CoordT&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; ccdCoordinatesCenter,
        pfs::drp::stella::FiberTrace&amp;lt;ImageT, MaskT, VarianceT&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTrace
    );
unused
}   

    template&amp;lt;typename T&amp;gt;
    &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; T* getRawPointer(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; PTR(&lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt; T) &amp;amp; ptr);
Fortunately unused.  This is a Very bad idea.

     /**
      * @brief mark FiberTrace pixels in Mask image
      * @param fiberTrace : FiberTrace to mark in maskedImage&apos;s Mask
      * @param mask : mask to mark the FiberTrace in
      * @param value : value to Or into the FiberTrace mask
      */
     template&amp;lt; typename ImageT, typename MaskT, typename VarianceT &amp;gt;
     void markFiberTraceInMask( PTR( FiberTrace&amp;lt; ImageT, MaskT, VarianceT &amp;gt; ) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; fiberTrace,
                                PTR( lsst::afw::image::Mask&amp;lt; MaskT &amp;gt; ) &lt;span class=&quot;code-keyword&quot;&gt;const&lt;/span&gt;&amp;amp; mask,
                                MaskT value = 1);
Superceded by getting the MaskedImage back.
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="12482" author="swinbank" created="Fri, 4 Aug 2017 19:26:09 +0000"  >&lt;p&gt;We discussed this 2017-07-28. Marking it as done.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10003">
                    <name>Relates</name>
                                            <outwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="11696">PIPE2D-219</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="11725">PIPE2D-235</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="11726">PIPE2D-236</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="11802">PIPE2D-240</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10500" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|031vid:xi07fhk0i4</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        </customfields>
    </item>
</channel>
</rss>