Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-14041

skymap.baseSkyMap.findTract assumes {{tractinfo}} objects are sortable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: To Do
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: skymap
    • Labels:
      None

      Description

      skymap.baseSkyMap.findTract assumes that tract info is sortable:

          def findTract(self, coord):
              """Find the tract whose center is nearest the specified coord.
       
              @param[in] coord: ICRS sky coordinate (lsst.afw.geom.SpherePoint)
              @return TractInfo of tract whose center is nearest the specified coord
       
              @warning:
              - if tracts do not cover the whole sky then the returned tract may not include the coord
       
              @note
              - This routine will be more efficient if coord is ICRS.
              - If coord is equidistant between multiple sky tract centers then one is arbitrarily chosen.
              - The default implementation is not very efficient; subclasses may wish to override.
              """
              distTractInfoList = []
              for tractInfo in self:
                  angSep = coord.separation(tractInfo.getCtrCoord()).asDegrees()
                  distTractInfoList.append((angSep, tractInfo))
              distTractInfoList.sort()
              return distTractInfoList[0][1]
      

      The distTractInfoList.sort is sorting a list of tuples (angSep, tractInfo). That only works if each are sortable. But tractInfo doesn't have to be sortable. It might just return a repr of the object.

      The goal appears to be to sort just on angSep. In that case, perhaps something like the following code would be more suitable:

              distTractInfoList.sort(key=lambda x: x[0])
      

      https://github.com/lsst/skymap/blob/master/python/lsst/skymap/baseSkyMap.py#L128

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            wmwood-vasey Michael Wood-Vasey [X] (Inactive)
            Watchers:
            Michael Wood-Vasey [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Jenkins Builds

                No builds found.