summaryrefslogtreecommitdiffstats
path: root/ast/ast_tester/testnormmap.f
blob: 2c57ee67e3b0463456563e148694f6875a5d5822 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
      program testnormmap
      implicit none
      include 'SAE_PAR'
      include 'AST_PAR'
      include 'PRM_PAR'

      integer status, m, m2, m3, f, perm(3)
      double precision at(3), bt(3)

      call ast_begin( status )


      status = sai__ok

      f = ast_cmpframe( ast_specframe( ' ', status ),
     :                  ast_skyframe( ' ', status ), ' ', status )

      perm( 1 )  = 3
      perm( 2 )  = 1
      perm( 3 )  = 2
      call ast_permaxes( f, perm, status )
      m = ast_normmap( f, ' ', status )

      if( ast_geti( m, 'nin', status ) .ne. 3 ) call stopit( 1, status )
      if( ast_geti( m, 'nout', status ) .ne. 3 ) call stopit( 2, status)

      if( .not. ast_getl( m, 'TranForward', status ) ) call stopit( 3,
     :                                                        status )
      if( .not. ast_getl( m, 'TranInverse', status ) ) call stopit( 4,
     :                                                        status )


      m2 = ast_copy( m, status )
      call ast_invert( m2, status )
      m3 = ast_simplify( ast_cmpmap( m, m2, .true., ' ', status ),
     :                   status )
      if( .not. ast_isaunitmap( m3, status ) ) call stopit( 5, status )


      at( 1 ) = 2.0D0
      at( 2 ) = 3.0D4
      at( 3 ) = 1.0D0

      call ast_trann( m, 1, 3, 1, at, 1, 3, 1, bt, status )

      if( abs( bt(1)-1.14159265D0) .gt. 1.0D-6 ) then
         write(*,*) bt(1)-1.14159265D0
         call stopit(6,status)
      end if
      if( bt(2) .ne. 3.0D4 ) call stopit(7,status)
      if( abs( bt(3)-4.14159265D0) .gt. 1.0D-6 ) call stopit(8,status)




* Test adjacent identical NormMaps are simplified to a single NormMap.
      m2 = ast_cmpmap( ast_cmpmap( m, ast_copy( m, status ), .true.,
     :                             ' ', status ),
     :                 ast_cmpmap( m, ast_copy( m, status ), .true.,
     :                             ' ', status ), .true., ' ', status )
      m3 = ast_simplify( m2, status )
      if( .not. ast_isanormmap( m3, status ) ) call stopit( 9, status )

* Test NormMap that encapsulate a basic Frame are simplified to a UnitMap.
      m = ast_normmap( ast_frame(2, ' ', status ), ' ', status )
      m2 = ast_simplify( m, status )
      if( .not. ast_isaunitmap( m2, status ) ) call stopit( 10, status )





      call ast_end( status )

      call ast_flushmemory( 1 )

      if( status .eq. sai__ok ) then
         write(*,*) 'All NormMap tests passed'
      else
         write(*,*) 'NormMap tests failed'
      end if

      end


      subroutine stopit( i, status )
      implicit none
      include 'SAE_PAR'
      integer i, status
      if( status .eq. sai__ok ) then
         write( *,* ) 'Error ',i
         status = sai__error
      end if
      end