File: ast.t

package info (click to toggle)
libastro-fits-header-perl 3.01-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 356 kB
  • ctags: 81
  • sloc: perl: 2,265; makefile: 21
file content (124 lines) | stat: -rw-r--r-- 5,148 bytes parent folder | download | duplicates (6)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!perl
# Testing AST dependancies

use strict;

use Test::More;
BEGIN { 
 eval "use Starlink::AST;";
 if ($@) {
   plan skip_all => "Starlink::AST not available.";
   exit;
 } else {
   plan tests => 51;
 }
}

# load modules
require_ok( "Astro::FITS::Header" );
require_ok( "Astro::FITS::Header::AST" );
require_ok( "Astro::FITS::Header::Item" );


# T E S T   H A R N E S S --------------------------------------------------

# GET_WCS() in ASTRO::FITS::HEADER
# --------------------------------

# read header from DATA block
my @raw = <DATA>;
chomp(@raw);

# build header array
my $header = new Astro::FITS::Header( Cards => \@raw );

# test the header
for my $i (0 .. $#raw) {
  my $card = $header->item($i);
  ok( "$card", $raw[$i]);  
}

# grab the WCS
my $wcsinfo = $header->get_wcs();
isa_ok( $wcsinfo, "Starlink::AST::FrameSet" );

# Mappings
# --------

# define some arrays (and references) to hold out inital coordinates
my ( @x, @y );
my $xpixel = \@x;
my $ypixel = \@y;

# FORWARD MAPPING
$x[0] = 0;
$y[0] = 0;;
$x[1] = 114;
$y[1] = 128;

my ( $xworld, $yworld) = $wcsinfo->Tran2( $xpixel, $ypixel, 1 );
is( $$xworld[0], 4.5, "Forward mapping of lower bound X co-ordinate" ); 
is( $$yworld[0], -0.5, "Forward mapping of lower bound Y co-ordinate" );
is( $$xworld[1], 118.5, "Forward mapping of upper bound X co-ordinate" ); 
is( $$yworld[1], 127.5, "Forward mapping of upper bound Y co-ordinate" );

# REVERSE MAPPING
$x[0] = 4.5;
$y[0] = -0.5;
$x[1] = 118.5;
$y[1] = 127.5;
($xworld, $yworld) = $wcsinfo->Tran2( $xpixel, $ypixel, 0 );
is( $$xworld[0], 0, "Reverse mapping of lower bound X co-ordinate" ); 
is( $$yworld[0], 0, "Reverse mapping of lower bound Y co-ordinate" );
is( $$xworld[1], 114, "Reverse mapping of upper bound X co-ordinate" ); 
is( $$yworld[1], 128, "Reverse mapping of upper bound Y co-ordinate" );

# new ASTRO::FITS::HEADER::AST()
# ------------------------------

my $ast_header = new Astro::FITS::Header::AST( FrameSet => $wcsinfo );

# test the header
is( $ast_header->sizeof(), 9, "Size of returned header" );

exit;

__DATA__
SIMPLE  =                    T / file does conform to FITS standard             
BITPIX  =                  -32 / number of bits per data pixel                  
NAXIS   =                    2 / number of data axes                            
NAXIS1  =                  114 / length of data axis 1                          
NAXIS2  =                  128 / length of data axis 2                          
CRPIX1  =                 57.0 / Reference pixel on axis 1                      
CRPIX2  =                 64.0 / Reference pixel on axis 2                      
CRVAL1  =                 61.5 / Value at ref. pixel on axis 1                  
CRVAL2  =                 63.5 / Value at ref. pixel on axis 2                  
CTYPE1  = 'CCD_REG1'           / Quantity represented by axis 1                 
CTYPE2  = 'CCD_REG2'           / Quantity represented by axis 2                 
CD1_1   =                  1.0 / Transformation matrix element                  
CD2_2   =                  1.0 / Transformation matrix element                  
EXTEND  =                    T / FITS dataset may contain extensions            
COMMENT   FITS (Flexible Image Transport System) format is defined in 'Astronomy
COMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H 
LBOUND1 =                    6 / Pixel origin along axis 1                      
LBOUND2 =                    1 / Pixel origin along axis 2                      
OBJECT  = 'Output from TRANNDF'/ Title of the dataset                           
DATE    = '2004-02-22T22:02:27'/ file creation date (YYYY-MM-DDThh:mm:ss UT)    
ORIGIN  = 'Starlink Project, U.K.'/ Origin of this FITS file                    
BSCALE  =                  1.0 / True_value = BSCALE * FITS_value + BZERO       
BZERO   =                  0.0 / True_value = BSCALE * FITS_value + BZERO       
HDUCLAS1= 'NDF     '           / Starlink NDF (hierarchical n-dim format)       
HDUCLAS2= 'DATA    '           / Array component subclass                       
CCDXIMSI=                  114                                                  
CCDXIMST=                    6                                                  
CCDXSIZE=                  128                                                  
CCDYIMSI=                  128                                                  
CCDYIMST=                    1                                                  
CCDYSIZE=                  128                                                  
GAIN    =                    1                                                  
READNOIS=                 10.0                                                  
PFMFNAME= 'B                 '                                                  
OBSTYPE = 'TARGET            '                                                  
TELESCOP= 'CCDPACK SPECIAL   '                                                  
ISEQ    =                    1                                                  
END