<!-- 
RSS generated by JIRA (8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b) at Sat Feb 10 15:56:32 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-689] Vector version of DetectorMap.findPoint fails</title>
                <link>https://pfspipe.ipmu.jp/jira/browse/PIPE2D-689</link>
                <project id="10002" key="PIPE2D">DRP 2-D Pipeline</project>
                    <description>&lt;p&gt;Using the weekly,&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-python&quot;&gt;
dataId = &lt;span class=&quot;code-object&quot;&gt;dict&lt;/span&gt;(visit=47, arm=&lt;span class=&quot;code-quote&quot;&gt;&quot;r&quot;&lt;/span&gt;, spectrograph=1)
pfsArm = butler.get(&lt;span class=&quot;code-quote&quot;&gt;&quot;pfsArm&quot;&lt;/span&gt;, dataId)
detMap = butler.get(&lt;span class=&quot;code-quote&quot;&gt;&quot;detectorMap&quot;&lt;/span&gt;, dataId)

detMap.findPoint(pfsArm.fiberId[0], pfsArm.wavelength[0][0])    &lt;span class=&quot;code-comment&quot;&gt;# succeeds
&lt;/span&gt;detMap.findPoint(pfsArm.fiberId[0], pfsArm.wavelength[0][0:2])  &lt;span class=&quot;code-comment&quot;&gt;# fails&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;generates the error:&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;
TypeError: findPoint(): incompatible function arguments. The following argument types are supported:
    1. (self: pfs.drp.stella.DetectorMap.DetectorMap, fiberId: &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;, wavelength: &lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;) -&amp;gt; lsst.geom.Point2D
    2. (self: pfs.drp.stella.DetectorMap.DetectorMap, fiberId: &lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;, wavelength: ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 1, 1&amp;gt;) -&amp;gt; ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 2, 1&amp;gt;
    3. (self: pfs.drp.stella.DetectorMap.DetectorMap, fiberId: ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;, 1, 1&amp;gt;, wavelength: ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 1, 1&amp;gt;) -&amp;gt; ndarray::Array&amp;lt;&lt;span class=&quot;code-object&quot;&gt;float&lt;/span&gt;, 2, 1&amp;gt;

Invoked with: &amp;lt;pfs.drp.stella.SplinedDetectorMap.SplinedDetectorMap object at 0x2b3b8add2928&amp;gt;, 2, array([620.33496, 620.4214 ], dtype=float32)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
        <key id="15120">PIPE2D-689</key>
            <summary>Vector version of DetectorMap.findPoint fails</summary>
                <type id="10001" iconUrl="https://pfspipe.ipmu.jp/jira/secure/viewavatar?size=xsmall&amp;avatarId=10515&amp;avatarType=issuetype">Story</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="price">price</assignee>
                                    <reporter username="rhl">rhl</reporter>
                        <labels>
                    </labels>
                <created>Mon, 21 Dec 2020 17:50:49 +0000</created>
                <updated>Mon, 7 Mar 2022 23:22:50 +0000</updated>
                            <resolved>Mon, 1 Feb 2021 19:09:00 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>1</watches>
                                                                <comments>
                            <comment id="18199" author="price" created="Mon, 21 Dec 2020 18:18:30 +0000"  >&lt;p&gt;I think this is working as expected.&lt;/p&gt;

&lt;p&gt;The solution is:&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;
&amp;gt;&amp;gt;&amp;gt; detMap.findPoint(&lt;span class=&quot;code-object&quot;&gt;int&lt;/span&gt;(pfsArm.fiberId[0]), pfsArm.wavelength[0][0:2].astype(np.float32))
array([[          nan,           nan],
       [4.0264922e+03, 1.0000000e+00]], dtype=float32)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There were two problems:&lt;br/&gt;
1. &lt;tt&gt;pfsArm.fiberId&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&lt;/tt&gt; is an &lt;tt&gt;np.uint64&lt;/tt&gt;, which isn&apos;t recognised as an `int`.&lt;br/&gt;
2. &lt;tt&gt;pfsArm.wavelength&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;0:2&amp;#93;&lt;/span&gt;.dtype&lt;/tt&gt; is &lt;tt&gt;dtype(&apos;&amp;gt;f4&apos;)&lt;/tt&gt;, which isn&apos;t recognised as &lt;tt&gt;np.float32&lt;/tt&gt;.&lt;/p&gt;</comment>
                            <comment id="18200" author="rhl" created="Mon, 21 Dec 2020 19:05:29 +0000"  >&lt;p&gt;I&apos;m reopening this. &#160;If you can&apos;t pass the arrays in a &lt;tt&gt;PfsArm&lt;/tt&gt;&#160;to a &lt;tt&gt;DetectorMap&lt;/tt&gt;&#160;then something in the API needs to be fixed.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="18202" author="rhl" created="Wed, 23 Dec 2020 15:00:07 +0000"  >&lt;p&gt;And I don&apos;t think that the cast to &lt;tt&gt;int&lt;/tt&gt; is necessary.&lt;/p&gt;</comment>
                            <comment id="18304" author="price" created="Mon, 4 Jan 2021 19:30:33 +0000"  >&lt;p&gt;OK, then I think we need to do a couple of things:&lt;/p&gt;

&lt;p&gt;1. Convert arrays on read (byte swap, cast) in datamodel.&lt;br/&gt;
2. Ensure all pybind APIs in drp&amp;#95;stella use consistent types.&lt;/p&gt;

&lt;p&gt;An alternative would be to add more pybind overloads for &lt;tt&gt;float&lt;/tt&gt; and &lt;tt&gt;double&lt;/tt&gt; arrays, but that doesn&apos;t catch byte-swapping, and I&apos;m concerned that the number of combinations might make maintenance difficult. I guess it might be possible to add automatic translations between &lt;tt&gt;float&lt;/tt&gt; and &lt;tt&gt;double&lt;/tt&gt; arrays in the pybind layer, but that goes against the ndarray package&apos;s philosophy of only doing explicit conversions (because of the potential for silent memory and CPU inefficiency).&lt;/p&gt;

&lt;p&gt;I propose to use &lt;tt&gt;double&lt;/tt&gt; for all arrays (pixel position, flux, wavelength and associated errors) instead of single-precision &lt;tt&gt;float&lt;/tt&gt;. &lt;tt&gt;float&lt;/tt&gt; would give us ~6 decimal digits of precision, and I&apos;m afraid that that&apos;s getting a little tight for wavelengths (dispersion is 0.04 nm/pixel for &lt;tt&gt;m&lt;/tt&gt;, I believe our centroids are good to around a 1/100 of a pixel, so we need a precision of 0.04/100 = 4e-4; precision of {float}} for values between between 2^9 and 2^10 is 2^(9-23) ~ 6e-5, which is getting a bit close for comfort). We could mix and match by using &lt;tt&gt;double&lt;/tt&gt; for wavelengths and &lt;tt&gt;float&lt;/tt&gt; for fluxes, but I think a desire for consistency and the fact that arrays default to &lt;tt&gt;double&lt;/tt&gt; in numpy encourages us to always use &lt;tt&gt;double&lt;/tt&gt; for arrays.&lt;/p&gt;</comment>
                            <comment id="18410" author="price" created="Fri, 29 Jan 2021 15:59:34 +0000"  >&lt;p&gt;Implemented the above. &lt;tt&gt;detMap.findPoint(pfsArm.fiberId&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;, pfsArm.wavelength&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;0:2&amp;#93;&lt;/span&gt;)&lt;/tt&gt; now works out-of-the-box.&lt;/p&gt;</comment>
                            <comment id="18425" author="price" created="Mon, 1 Feb 2021 19:09:00 +0000"  >&lt;p&gt;Merged to master.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10003">
                    <name>Relates</name>
                                            <outwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="22672">DAMD-130</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|02qps3:1y</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10100" key="com.atlassian.jira.plugin.system.customfieldtypes:userpicker">
                        <customfieldname>Reviewers</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>hassan</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10005" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="93">2DDRP-2021 A</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10002" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                        </customfields>
    </item>
</channel>
</rss>