XMM-Newton SAS Home Page
XMM-Newton Science Analysis System


ssclib (ssclib-4.36.1) [xmmsas_20230412_1735-21.0.0]


Return the indices (i,j) for the input axes (x,y) of an array

The inverse function of getAxesFromIndices (See Section 2.4.1).

  interface getIndicesFromAxes
    function getIndicesFromAxesDouble(axes, iLbound, iUbound, lEdge, uEdge) result(indices)
      real(double), intent(in) :: axes(:)
      integer,      intent(in) :: iLbound(size(axes)), iUbound(size(axes))
      real(double), intent(in)           :: lEdge(size(axes))
      real(double), intent(in), optional :: uEdge(size(axes))
      real(double) :: indices(size(axes))	! result
    end function getIndicesFromAxesDouble

    function getIndicesFromAxesSingle(axes, iLbound, iUbound, lEdge, uEdge) result(indices)
      real(single), intent(in) :: axes(:)
      integer,      intent(in) :: iLbound(size(axes)), iUbound(size(axes))
      real(single), intent(in)           :: lEdge(size(axes))
      real(single), intent(in), optional :: uEdge(size(axes))
      real(single) :: indices(size(axes))	! result
    function getIndicesFromAxesSingle

    function getIndicesFromAxesEdgesDouble(axes, aryEdgesInfo) result(indices)
      real(double), intent(in) :: axes(:)
      type(AryEdgesInfoT), intent(in) :: aryEdgesInfo
      real(double) :: indices(size(axes))	! result
    end function getIndicesFromAxesEdgesDouble

    function getIndicesFromAxesEdgesSingle(axes, aryEdgesInfo) result(indices)
      real(single), intent(in) :: axes(:)
      type(AryEdgesInfoT), intent(in) :: aryEdgesInfo
      real(single) :: indices(size(axes))	! result
    end function getIndicesFromAxesEdgesSingle
  end interface

Indices, though the returned values here may be Real, mean the index for the given array, therefore for an array

  ary(int(returned_i), int(returned_j))
will give something significant in the Fortran code. Axes are arbitrary and give the frame, which may mean something physical.

If uEdge is not given, it is assumed that the width of axes is the same as the size of the array (= abs(iUbound-iLbound) for each axis).

The following is a few examples.

Case 1
The indices for the axes (x,y)=(3.0, 3.0) in the array (1:5, 1:5) with the edge (0.5:5.5, 0.5:5.5) is (3, 3).
Case 2
The indices for the axes (x,y)=(5.0, 5.0) in the array (1:5, 1:5) with the edge (2.5:7.5, 2.5:7.5) is (3, 3).
Case 3
The indices for the axes (x,y)=(5.0, 5.0) in the array (1:5, 1:5) with the edge (0.0:10, 0.0:10) is (3,3).
Case 4
The indices for the axes (x,y)=(-5, -5) in the array (1:5, 1:5) with the edge (-10:0.0, -10:0.0) is (3, 3).
Case 5
The indices for the axes (x,y)=(5.0, 5.0) in the array (3:7, 3:7) with the edge (0.0:10, 0.0:10) is (5, 5).

XMM-Newton SOC -- 2023-04-16