HdrTrans/JCMT_GSD_DB.pm

filter: Statementstmt 73.9% 105 / 142 Branchbran 31.8% 21 / 66 Conditioncond 20.4% 19 / 93 MC/DCmcdc 2.2% 1 / 44 Subroutinesub 100% 17 / 17 Podpod 100% 9 / 9 totaltotal 46.3% 172 / 371 CC 66 SCAR 61.5
CC
66
Cov
48%
to_EXPOSURE_TIME
908.8
to_BANDWIDTH_MODE
15.2
to_SYSTEM_VELOCITY
6.7
CRAP 468.5
« HdrTrans/ISAAC.pm ↑ Summary HdrTrans/LCOSBIG_1m0.pm »
1 package Astro::FITS::HdrTrans::JCMT_GSD_DB;
2  
3 =head1 NAME
4  
5 Astro::FITS::HdrTrans::JCMT_GSD_DB - JCMT GSD Database header translations
6  
7 =head1 DESCRIPTION
8  
9 Converts information contained in JCMT heterodyne database headers
10 to and from generic headers. See Astro::FITS::HdrTrans for a list of
11 generic headers.
12  
13 =cut
14  
15 10 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 10 ▶use Time::Piece;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # Inherit from Base
23 10 ▶use base qw/ Astro::FITS::HdrTrans::Base /;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 10 our $VERSION = "1.66";
26  
27 # for a constant mapping, there is no FITS header, just a generic
28 # header that is constant
29 10 my %CONST_MAP = (
30 INST_DHS => 'HET_GSD',
31 COORDINATE_UNITS => 'decimal',
32 EQUINOX => 'current',
33 TELESCOPE => 'JCMT',
34 );
35  
36 # NULL mappings used to override base class implementations
37 10 my @NULL_MAP = ();
38  
39 # unit mapping implies that the value propogates directly
40 # to the output with only a keyword name change
41  
42 10 my %UNIT_MAP = (
43 AMBIENT_TEMPERATURE => "TAMB",
44 APERTURE => "APERTURE",
45 AZIMUTH_START => "AZ",
46 BACKEND => "BACKEND",
47 BACKEND_SECTIONS => "NORSECT",
48 CHOP_FREQUENCY => "CHOPFREQ",
49 CHOP_THROW => "CHOPTHRW",
50 COORDINATE_SYSTEM => "COORDCD",
51 # COORDINATE_TYPE => "C4LSC",
52 CYCLE_LENGTH => "CYCLLEN",
53 # DEC_BASE => "",
54 ELEVATION_START => "EL",
55 FILENAME => "GSDFILE",
56 FILTER => "FILTER",
57 FREQUENCY_RESOLUTION => "FREQRES",
58 FRONTEND => "FRONTEND",
59 HUMIDITY => "HUMIDITY",
60 NUMBER_OF_CYCLES => "NOCYCLES",
61 NUMBER_OF_SUBSCANS => "NOSCANS",
62 OBJECT => "OBJECT",
63 OBSERVATION_MODE => "OBSMODE",
64 OBSERVATION_NUMBER => "SCAN",
65 PROJECT => "PROJID",
66 # RA_BASE => "C4RADATE",
67 RECEIVER_TEMPERATURE => "TRX",
68 ROTATION => "YPOSANG",
69 REST_FREQUENCY => "RESTFRQ1",
70 SEEING => "PHA",
71 SWITCH_MODE => "SWMODE",
72 SYSTEM_TEMPERATURE => "STSYS",
73 TAU => "TAU",
74 USER_AZ_CORRECTION => "UXPNT",
75 USER_EL_CORRECTION => "UYPNT",
76 VELOCITY => "VELOCITY",
77 VELOCITY_REFERENCE_FRAME => "VREF",
78 VELOCITY_TYPE => "VDEF",
79 X_BASE => "XREF",
80 Y_BASE => "YREF",
81 X_DIM => "NOXPTS",
82 Y_DIM => "NOYPTS",
83 X_REQUESTED => "XSOURCE",
84 Y_REQUESTED => "YSOURCE",
85 X_SCALE => "DELTAX",
86 Y_SCALE => "DELTAY",
87 );
88  
89 # Create the translation methods
90 10 __PACKAGE__->_generate_lookup_methods( \%CONST_MAP, \%UNIT_MAP, \@NULL_MAP );
91  
92 =head1 METHODS
93  
94 =over 4
95  
96 =item B<can_translate>
97  
98 Returns true if the supplied headers can be handled by this class.
99  
100 $cando = $class->can_translate( \%hdrs );
101  
102 For this class, the method will return true if the "GSDFILE" header
103 exists and the "SCA#" header exist.
104  
105 =cut
106  
107 20 ▶sub can_translate {
Subroutine can_translate: called CC=3 SCAR=11.0
Pod documented
108 20 my $self = shift;
109 20 my $headers = shift;
110  
111 20 ▶ if (exists $headers->{GSDFILE} && exists $headers->{"SCA#"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $headers->{"GSDFILE"} and exists $headers->{"SCA#"}) 1 19 20
Condition66%2/3
exists $headers->{"GSDFILE"} and exists $headers->{"SCA#"}
!ll&&!rl&&r
1901
MC/DC50%1/2
exists $headers->{"GSDFILE"} and exists $headers->{"SCA#"}
exists $headers->{"GSDFILE"} exists $headers->{"SCA#"}
Truth table66%2/3
A and B
A= exists $headers->{"GSDFILE"}B= exists $headers->{"SCA#"}
ABresult
0X0
100
111
112 1 return 1;
113 }
114 19 return 0;
115 }
116  
117 =back
118  
119 =head1 COMPLEX CONVERSIONS
120  
121 These methods are more complicated than a simple mapping. We have to
122 provide both from- and to-FITS conversions All these routines are
123 methods and the to_ routines all take a reference to a hash and return
124 the translated value (a many-to-one mapping) The from_ methods take a
125 reference to a generic hash and return a translated hash (sometimes
126 these are many-to-many)
127  
128 =over 4
129  
130 =item B<to_INSTRUMENT>
131  
132 Sets the C<INSTRUMENT> generic header. For RxA3i, sets the value
133 to RXA3. For RxB, sets the value to RXB3.
134  
135 =cut
136  
137 1 ▶sub to_INSTRUMENT {
Subroutine to_INSTRUMENT: called CC=4 SCAR=14.6
Pod documented
138 1 my $self = shift;
139 1 my $FITS_headers = shift;
140 1 my $return;
141  
142 1 ▶ if ( exists( $FITS_headers->{'FRONTEND'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"FRONTEND"}) 1 0 1
143 1 $return = $FITS_headers->{'FRONTEND'};
144 1 ▶ if ( $return =~ /^rxa3/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($return =~ /^rxa3/i) { } 0 1 1
elsif ($return =~ /^rxb/i) { } 1 0 1
145 0 $return = "RXA3";
146 } elsif ( $return =~ /^rxb/i ) {
147 1 $return = "RXB3";
148 }
149 }
150 1 return $return;
151 }
152  
153 =item B<to_OBSERVATION_ID>
154  
155 Calculate a unique Observation ID.
156  
157 =cut
158  
159 # Note this routine is generic for JCMT heterodyne instrumentation.
160 # Would be completely generic if BACKEND was not used in preference to instrument.
161  
162 1 ▶sub to_OBSERVATION_ID {
Subroutine to_OBSERVATION_ID: called CC=1 SCAR=0.0
Pod documented
163 1 my $self = shift;
164 1 my $FITS_headers = shift;
165 1 my $backend = lc( $self->to_BACKEND( $FITS_headers ) );
166 1 my $obsnum = $self->to_OBSERVATION_NUMBER( $FITS_headers );
167 1 my $dateobs = $self->to_UTSTART( $FITS_headers );
168 1 my $datetime = $dateobs->datetime;
169 1 $datetime =~ s/-//g;
170 1 $datetime =~ s/://g;
171  
172 1 my $obsid = join('_', $backend, $obsnum, $datetime);
173 1 return $obsid;
174 }
175  
176 =item B<to_UTDATE>
177  
178 Translates the C<DATE_OBS> or C<LONGDATEOBS> header into a
179 YYYYMMDD integer.
180  
181 =cut
182  
183 1 ▶sub to_UTDATE {
Subroutine to_UTDATE: called CC=1 SCAR=0.0
Pod documented
184 1 my $self = shift;
185 1 my $FITS_headers = shift;
186 1 my $date = _mysql_convert_date( _date_header( $FITS_headers ), 1);
187 1 return $date->strftime('%Y%m%d');
188 }
189  
190 =item B<to_UTSTART>
191  
192 Translates the DB date header into a C<Time::Piece> object.
193  
194 =cut
195  
196 2 ▶sub to_UTSTART {
Subroutine to_UTSTART: called CC=1 SCAR=0.0
Pod documented
197 2 my $self = shift;
198 2 my $FITS_headers = shift;
199 2 return _mysql_convert_date( _date_header( $FITS_headers ));
200 }
201  
202 =item B<to_UTEND>
203  
204 Translates the database date header into a C<Time::Piece> object and adds
205 on the exposure time.
206  
207 =cut
208  
209 1 ▶sub to_UTEND {
Subroutine to_UTEND: called CC=2 SCAR=7.0
Pod documented
210 1 my $self = shift;
211 1 my $FITS_headers = shift;
212  
213 1 my $return = _mysql_convert_date( _date_header( $FITS_headers ) );
214 1 ▶ return undef unless defined $return;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $return 0 1 1
215 1 my $expt = $self->to_EXPOSURE_TIME( $FITS_headers );
216  
217 1 $return += $expt;
218 1 return $return;
219 }
220  
221 =item B<to_BANDWIDTH_MODE>
222  
223 Uses the NORSECT (number of backend sections), NOFCHAN (number of
224 frontend output channels) and NOBCHAN (number of channels) to form a
225 string that is of the format 250MHzx2048. To obtain this, the
226 bandwidth (250MHz in this example) is calculated as 125MHz * NORSECT /
227 NOFCHAN. The number of channels is taken directly and not manipulated
228 in any way.
229  
230 If appropriate, the bandwidth may be given in GHz.
231  
232 =cut
233  
234 1 ▶sub to_BANDWIDTH_MODE {
Subroutine to_BANDWIDTH_MODE: called CC=8 SCAR=27.2
Pod documented
235 1 my $self = shift;
236 1 my $FITS_headers = shift;
237  
238 1 my $return;
239  
240 1 ▶ if ( exists( $FITS_headers->{'NORSECT'} ) && defined( $FITS_headers->{'NORSECT'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"NORSECT"} and defined $FITS_headers->{"NORSECT"} and exists $FITS_headers->{"NOFCHAN"} and defined $FITS_headers->{"NOFCHAN"} and exists $FITS_headers->{"NOBCHAN"} and defined $FITS_headers->{"NOBCHAN"}) 1 0 1
Condition33%5/15
exists $FITS_headers->{"NORSECT"} and defined $FITS_headers->{"NORSECT"} and exists $FITS_headers->{"NOFCHAN"} and defined $FITS_headers->{"NOFCHAN"} and exists $FITS_headers->{"NOBCHAN"} and defined $FITS_headers->{"NOBCHAN"}
!ll&&!rl&&r
001
exists $FITS_headers->{"NORSECT"} and defined $FITS_headers->{"NORSECT"} and exists $FITS_headers->{"NOFCHAN"} and defined $FITS_headers->{"NOFCHAN"} and exists $FITS_headers->{"NOBCHAN"}
!ll&&!rl&&r
001
exists $FITS_headers->{"NORSECT"} and defined $FITS_headers->{"NORSECT"} and exists $FITS_headers->{"NOFCHAN"} and defined $FITS_headers->{"NOFCHAN"}
!ll&&!rl&&r
001
exists $FITS_headers->{"NORSECT"} and defined $FITS_headers->{"NORSECT"} and exists $FITS_headers->{"NOFCHAN"}
!ll&&!rl&&r
001
exists $FITS_headers->{"NORSECT"} and defined $FITS_headers->{"NORSECT"}
!ll&&!rl&&r
001
MC/DC0%0/6
exists $FITS_headers->{"NORSECT"} and defined $FITS_headers->{"NORSECT"} and exists $FITS_headers->{"NOFCHAN"} and defined $FITS_headers->{"NOFCHAN"} and exists $FITS_headers->{"NOBCHAN"} and defined $FITS_headers->{"NOBCHAN"}
exists $FITS_headers->{"NORSECT"} defined $FITS_headers->{"NORSECT"} exists $FITS_headers->{"NOFCHAN"} defined $FITS_headers->{"NOFCHAN"} exists $FITS_headers->{"NOBCHAN"} defined $FITS_headers->{"NOBCHAN"}
Truth table14%1/7
A and B and C and D and E and F
A= exists $FITS_headers->{"NORSECT"}B= defined $FITS_headers->{"NORSECT"}C= exists $FITS_headers->{"NOFCHAN"}D= defined $FITS_headers->{"NOFCHAN"}E= exists $FITS_headers->{"NOBCHAN"}F= defined $FITS_headers->{"NOBCHAN"}
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
241 exists( $FITS_headers->{'NOFCHAN'} ) && defined( $FITS_headers->{'NOFCHAN'} ) &&
242 exists( $FITS_headers->{'NOBCHAN'} ) && defined( $FITS_headers->{'NOBCHAN'} ) ) {
243  
244 1 my $bandwidth = 125 * $FITS_headers->{'NORSECT'} / $FITS_headers->{'NOFCHAN'};
245  
246 1 ▶ if ( $bandwidth >= 1000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bandwidth >= 1000) { } 0 1 1
247 0 $bandwidth /= 1000;
248 0 $return = sprintf( "%dGHzx%d", $bandwidth, $FITS_headers->{'NOBCHAN'} );
249 } else {
250 1 $return = sprintf( "%dMHzx%d", $bandwidth, $FITS_headers->{'NOBCHAN'} );
251 }
252 }
253  
254 1 return $return;
255  
256 }
257  
258  
259 =item B<to_EXPOSURE_TIME>
260  
261 =cut
262  
263 2 ▶sub to_EXPOSURE_TIME {
Subroutine to_EXPOSURE_TIME: called CC=42 SCAR=68.1
Pod documented
264 2 my $self = shift;
265 2 my $FITS_headers = shift;
266 2 my $expt = 0;
267  
268 2 ▶ if ( exists( $FITS_headers->{'OBSMODE'} ) && defined( $FITS_headers->{'OBSMODE'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"OBSMODE"} and defined $FITS_headers->{"OBSMODE"}) 2 0 2
Condition33%1/3
exists $FITS_headers->{"OBSMODE"} and defined $FITS_headers->{"OBSMODE"}
!ll&&!rl&&r
002
MC/DC0%0/2
exists $FITS_headers->{"OBSMODE"} and defined $FITS_headers->{"OBSMODE"}
exists $FITS_headers->{"OBSMODE"} defined $FITS_headers->{"OBSMODE"}
Truth table33%1/3
A and B
A= exists $FITS_headers->{"OBSMODE"}B= defined $FITS_headers->{"OBSMODE"}
ABresult
0X0
100
111
269  
270 2 my $obsmode = uc( $FITS_headers->{'OBSMODE'} );
271  
272 2 ▶ if ( $obsmode eq 'RASTER' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($obsmode eq 'RASTER') { } 0 2 2
elsif ($obsmode eq 'PATTERN' or $obsmode eq 'GRID') { } 0 2 2
273  
274 0 ▶ if ( exists( $FITS_headers->{'NSCAN'} ) && defined( $FITS_headers->{'NSCAN'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"} and exists $FITS_headers->{"NOCYCPTS"} and defined $FITS_headers->{"NOCYCPTS"}) 0 0 0
Condition0%0/15
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"} and exists $FITS_headers->{"NOCYCPTS"} and defined $FITS_headers->{"NOCYCPTS"}
!ll&&!rl&&r
000
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"} and exists $FITS_headers->{"NOCYCPTS"}
!ll&&!rl&&r
000
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"}
!ll&&!rl&&r
000
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"CYCLLEN"}
!ll&&!rl&&r
000
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"}
!ll&&!rl&&r
000
MC/DC0%0/6
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"} and exists $FITS_headers->{"NOCYCPTS"} and defined $FITS_headers->{"NOCYCPTS"}
exists $FITS_headers->{"NSCAN"} defined $FITS_headers->{"NSCAN"} exists $FITS_headers->{"CYCLLEN"} defined $FITS_headers->{"CYCLLEN"} exists $FITS_headers->{"NOCYCPTS"} defined $FITS_headers->{"NOCYCPTS"}
Truth table0%0/7
A and B and C and D and E and F
A= exists $FITS_headers->{"NSCAN"}B= defined $FITS_headers->{"NSCAN"}C= exists $FITS_headers->{"CYCLLEN"}D= defined $FITS_headers->{"CYCLLEN"}E= exists $FITS_headers->{"NOCYCPTS"}F= defined $FITS_headers->{"NOCYCPTS"}
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
275 exists( $FITS_headers->{'CYCLLEN'} ) && defined( $FITS_headers->{'CYCLLEN'} ) &&
276 exists( $FITS_headers->{'NOCYCPTS'} ) && defined( $FITS_headers->{'NOCYCPTS'} ) ) {
277  
278 0 my $nscan = $FITS_headers->{'NSCAN'};
279 0 my $cycllen = $FITS_headers->{'CYCLLEN'};
280 0 my $nocycpts = $FITS_headers->{'NOCYCPTS'};
281  
282 # raster.
283 0 $expt = 15 + $nscan * $cycllen * ( 1 + 1 / sqrt( $nocycpts ) ) * 1.4;
284 }
285 ▶ } elsif ( $obsmode eq 'PATTERN' or $obsmode eq 'GRID' ) {
Condition33%1/3
$obsmode eq "PATTERN" or $obsmode eq "GRID"
l!l&&r!l&&!r
002
MC/DC0%0/2
$obsmode eq "PATTERN" or $obsmode eq "GRID"
$obsmode eq "PATTERN" $obsmode eq "GRID"
Truth table33%1/3
A or B
A= $obsmode eq "PATTERN"B= $obsmode eq "GRID"
ABresult
1X1
011
000
286  
287 0 my $swmode = '';
288  
289 0 ▶ if ( exists( $FITS_headers->{'SWMODE'} ) && defined( $FITS_headers->{'SWMODE'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'SWMODE'} and defined $FITS_headers->{'SWMODE'}) { } 0 0 0
Condition0%0/3
exists $FITS_headers->{"SWMODE"} and defined $FITS_headers->{"SWMODE"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $FITS_headers->{"SWMODE"} and defined $FITS_headers->{"SWMODE"}
exists $FITS_headers->{"SWMODE"} defined $FITS_headers->{"SWMODE"}
Truth table0%0/3
A and B
A= exists $FITS_headers->{"SWMODE"}B= defined $FITS_headers->{"SWMODE"}
ABresult
0X0
100
111
290 0 $swmode = $FITS_headers->{'SWMODE'};
291 } else {
292 0 $swmode = 'BEAMSWITCH';
293 }
294  
295 0 ▶ if ( exists( $FITS_headers->{'NSCAN'} ) && defined( $FITS_headers->{'NSCAN'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"}) 0 0 0
Condition0%0/15
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"}
!ll&&!rl&&r
000
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"} and exists $FITS_headers->{"CYCLLEN"}
!ll&&!rl&&r
000
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"}
!ll&&!rl&&r
000
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"}
!ll&&!rl&&r
000
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"}
!ll&&!rl&&r
000
MC/DC0%0/6
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"}
exists $FITS_headers->{"NSCAN"} defined $FITS_headers->{"NSCAN"} exists $FITS_headers->{"NCYCLE"} defined $FITS_headers->{"NCYCLE"} exists $FITS_headers->{"CYCLLEN"} defined $FITS_headers->{"CYCLLEN"}
Truth table0%0/7
A and B and C and D and E and F
A= exists $FITS_headers->{"NSCAN"}B= defined $FITS_headers->{"NSCAN"}C= exists $FITS_headers->{"NCYCLE"}D= defined $FITS_headers->{"NCYCLE"}E= exists $FITS_headers->{"CYCLLEN"}F= defined $FITS_headers->{"CYCLLEN"}
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
296 exists( $FITS_headers->{'NCYCLE'} ) && defined( $FITS_headers->{'NCYCLE'} ) &&
297 exists( $FITS_headers->{'CYCLLEN'} ) && defined( $FITS_headers->{'CYCLLEN'} ) ) {
298  
299 0 my $nscan = $FITS_headers->{'NSCAN'};
300 0 my $ncycle = $FITS_headers->{'NCYCLE'};
301 0 my $cycllen = $FITS_headers->{'CYCLLEN'};
302  
303 0 ▶ if ( $swmode eq 'POSITION_SWITCH' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($swmode eq 'POSITION_SWITCH') { } 0 0 0
elsif ($swmode eq 'BEAMSWITCH') { } 0 0 0
elsif ($swmode eq 'CHOPPING') { } 0 0 0
304  
305 # position switch pattern/grid.
306 0 $expt = 6 + $nscan * $ncycle * $cycllen * 1.35;
307  
308 } elsif ( $swmode eq 'BEAMSWITCH' ) {
309  
310 # beam switch pattern/grid.
311 0 $expt = 6 + $nscan * $ncycle * $cycllen * 1.35;
312  
313 } elsif ( $swmode eq 'CHOPPING' ) {
314 0 ▶ if ( exists( $FITS_headers->{'FRONTEND'} ) && defined( $FITS_headers->{'FRONTEND'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"FRONTEND"} and defined $FITS_headers->{"FRONTEND"}) 0 0 0
Condition0%0/3
exists $FITS_headers->{"FRONTEND"} and defined $FITS_headers->{"FRONTEND"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $FITS_headers->{"FRONTEND"} and defined $FITS_headers->{"FRONTEND"}
exists $FITS_headers->{"FRONTEND"} defined $FITS_headers->{"FRONTEND"}
Truth table0%0/3
A and B
A= exists $FITS_headers->{"FRONTEND"}B= defined $FITS_headers->{"FRONTEND"}
ABresult
0X0
100
111
315 0 my $frontend = uc( $FITS_headers->{'FRONTEND'} );
316 0 ▶ if ( $frontend eq 'RXA3I' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($frontend eq 'RXA3I') { } 0 0 0
elsif ($frontend eq 'RXB') { } 0 0 0
317  
318 # fast frequency switch pattern/grid, receiver A.
319 0 $expt = 15 + $nscan * $ncycle * $cycllen * 1.20;
320  
321 } elsif ( $frontend eq 'RXB' ) {
322  
323 # slow frequency switch pattern/grid, receiver B.
324 0 $expt = 18 + $nscan * $ncycle * $cycllen * 1.60;
325  
326 }
327 }
328 }
329 }
330 } else {
331  
332 2 my $swmode;
333 2 ▶ if ( exists( $FITS_headers->{'SWMODE'} ) && defined( $FITS_headers->{'SWMODE'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{'SWMODE'} and defined $FITS_headers->{'SWMODE'}) { } 2 0 2
Condition33%1/3
exists $FITS_headers->{"SWMODE"} and defined $FITS_headers->{"SWMODE"}
!ll&&!rl&&r
002
MC/DC0%0/2
exists $FITS_headers->{"SWMODE"} and defined $FITS_headers->{"SWMODE"}
exists $FITS_headers->{"SWMODE"} defined $FITS_headers->{"SWMODE"}
Truth table33%1/3
A and B
A= exists $FITS_headers->{"SWMODE"}B= defined $FITS_headers->{"SWMODE"}
ABresult
0X0
100
111
334 2 $swmode = uc( $FITS_headers->{'SWMODE'} );
335 } else {
336 0 $swmode = 'BEAMSWITCH';
337 }
338  
339 2 ▶ if ( exists( $FITS_headers->{'NSCAN'} ) && defined( $FITS_headers->{'NSCAN'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"}) 2 0 2
Condition33%5/15
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"}
!ll&&!rl&&r
002
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"} and exists $FITS_headers->{"CYCLLEN"}
!ll&&!rl&&r
002
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"}
!ll&&!rl&&r
002
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"}
!ll&&!rl&&r
002
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"}
!ll&&!rl&&r
002
MC/DC0%0/6
exists $FITS_headers->{"NSCAN"} and defined $FITS_headers->{"NSCAN"} and exists $FITS_headers->{"NCYCLE"} and defined $FITS_headers->{"NCYCLE"} and exists $FITS_headers->{"CYCLLEN"} and defined $FITS_headers->{"CYCLLEN"}
exists $FITS_headers->{"NSCAN"} defined $FITS_headers->{"NSCAN"} exists $FITS_headers->{"NCYCLE"} defined $FITS_headers->{"NCYCLE"} exists $FITS_headers->{"CYCLLEN"} defined $FITS_headers->{"CYCLLEN"}
Truth table14%1/7
A and B and C and D and E and F
A= exists $FITS_headers->{"NSCAN"}B= defined $FITS_headers->{"NSCAN"}C= exists $FITS_headers->{"NCYCLE"}D= defined $FITS_headers->{"NCYCLE"}E= exists $FITS_headers->{"CYCLLEN"}F= defined $FITS_headers->{"CYCLLEN"}
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
340 exists( $FITS_headers->{'NCYCLE'} ) && defined( $FITS_headers->{'NCYCLE'} ) &&
341 exists( $FITS_headers->{'CYCLLEN'} ) && defined( $FITS_headers->{'CYCLLEN'} ) ) {
342  
343 2 my $nscan = $FITS_headers->{'NSCAN'};
344 2 my $ncycle = $FITS_headers->{'NCYCLE'};
345 2 my $cycllen = $FITS_headers->{'CYCLLEN'};
346  
347 2 ▶ if ( $swmode eq 'POSITION_SWITCH' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($swmode eq 'POSITION_SWITCH') { } 0 2 2
elsif ($swmode eq 'BEAMSWITCH') { } 2 0 2
elsif ($swmode eq 'CHOPPING') { } 0 0 0
348  
349 # position switch sample.
350 0 $expt = 4.8 + $nscan * $ncycle * $cycllen * 1.10;
351  
352 } elsif ( $swmode eq 'BEAMSWITCH' ) {
353  
354 # beam switch sample.
355 2 $expt = 4.8 + $nscan * $ncycle * $cycllen * 1.25;
356  
357 } elsif ( $swmode eq 'CHOPPING' ) {
358 0 ▶ if ( exists( $FITS_headers->{'FRONTEND'} ) && defined( $FITS_headers->{'FRONTEND'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"FRONTEND"} and defined $FITS_headers->{"FRONTEND"}) 0 0 0
Condition0%0/3
exists $FITS_headers->{"FRONTEND"} and defined $FITS_headers->{"FRONTEND"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $FITS_headers->{"FRONTEND"} and defined $FITS_headers->{"FRONTEND"}
exists $FITS_headers->{"FRONTEND"} defined $FITS_headers->{"FRONTEND"}
Truth table0%0/3
A and B
A= exists $FITS_headers->{"FRONTEND"}B= defined $FITS_headers->{"FRONTEND"}
ABresult
0X0
100
111
359 0 my $frontend = uc( $FITS_headers->{'FRONTEND'} );
360 0 ▶ if ( $frontend eq 'RXA3I' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($frontend eq 'RXA3I') { } 0 0 0
elsif ($frontend eq 'RXB') { } 0 0 0
361  
362 # fast frequency switch sample, receiver A.
363 0 $expt = 3 + $nscan * $ncycle * $cycllen * 1.10;
364  
365 } elsif ( $frontend eq 'RXB' ) {
366  
367 # slow frequency switch sample, receiver B.
368 0 $expt = 3 + $nscan * $ncycle * $cycllen * 1.40;
369 }
370 }
371 }
372 }
373 }
374 }
375  
376 2 return $expt;
377 }
378  
379 =item B<to_SYSTEM_VELOCITY>
380  
381 Translate the C<VREF> and C<C12VDEF> headers into one combined header.
382  
383 =cut
384  
385 1 ▶sub to_SYSTEM_VELOCITY {
Subroutine to_SYSTEM_VELOCITY: called CC=5 SCAR=19.1
Pod documented
386 1 my $self = shift;
387 1 my $FITS_headers = shift;
388 1 my $return;
389 1 ▶ if ( exists( $FITS_headers->{'VREF'} ) && defined( $FITS_headers->{'VREF'} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{"VREF"} and defined $FITS_headers->{"VREF"} and exists $FITS_headers->{"VDEF"} and defined $FITS_headers->{"VDEF"}) 1 0 1
Condition33%3/9
exists $FITS_headers->{"VREF"} and defined $FITS_headers->{"VREF"} and exists $FITS_headers->{"VDEF"} and defined $FITS_headers->{"VDEF"}
!ll&&!rl&&r
001
exists $FITS_headers->{"VREF"} and defined $FITS_headers->{"VREF"} and exists $FITS_headers->{"VDEF"}
!ll&&!rl&&r
001
exists $FITS_headers->{"VREF"} and defined $FITS_headers->{"VREF"}
!ll&&!rl&&r
001
MC/DC0%0/4
exists $FITS_headers->{"VREF"} and defined $FITS_headers->{"VREF"} and exists $FITS_headers->{"VDEF"} and defined $FITS_headers->{"VDEF"}
exists $FITS_headers->{"VREF"} defined $FITS_headers->{"VREF"} exists $FITS_headers->{"VDEF"} defined $FITS_headers->{"VDEF"}
Truth table20%1/5
A and B and C and D
A= exists $FITS_headers->{"VREF"}B= defined $FITS_headers->{"VREF"}C= exists $FITS_headers->{"VDEF"}D= defined $FITS_headers->{"VDEF"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
390 exists( $FITS_headers->{'VDEF'} ) && defined( $FITS_headers->{'VDEF'} ) ) {
391 1 $return = uc( substr( $FITS_headers->{'VDEF'}, 0, 3 ) . substr( $FITS_headers->{'VREF'}, 0, 3 ) );
392 }
393 1 return $return;
394 }
395  
396 =back
397  
398 =begin __PRIVATE
399  
400 =over 4
401  
402 =item B<_date_header>
403  
404 Works out which header corresponds to the date field in MySQL format and returns the value.
405  
406 $value = _date_header( $FITS_headers );
407  
408 Returns undef if none found.
409  
410 =cut
411  
412 4 ▶sub _date_header {
Subroutine _date_header: called CC=4 SCAR=16.1
413 4 my $FITS_headers = shift;
414 # For compatability with Sybase database, also accept LONGDATEOBS LONGDATE
415 4 for my $key (qw/ DATE_OBS LONGDATEOBS LONGDATE / ) {
416 4 ▶ if (exists $FITS_headers->{$key} && defined $FITS_headers->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $FITS_headers->{$key} and defined $FITS_headers->{$key}) 4 0 4
Condition33%1/3
exists $FITS_headers->{$key} and defined $FITS_headers->{$key}
!ll&&!rl&&r
004
MC/DC0%0/2
exists $FITS_headers->{$key} and defined $FITS_headers->{$key}
exists $FITS_headers->{$key} defined $FITS_headers->{$key}
Truth table33%1/3
A and B
A= exists $FITS_headers->{$key}B= defined $FITS_headers->{$key}
ABresult
0X0
100
111
417 4 return $FITS_headers->{$key};
418 }
419 }
420 0 return;
421 }
422  
423 =item B<_mysql_convert_date>
424  
425 Converts a MySQL date to Time::Piece object.
426  
427 $date = _mysql_convert_date( $string );
428  
429 Optional flag can be set to true to drop Hours, minutes and seconds from parse.
430  
431 $utday = _mysql_convert_date( $string, 1);
432  
433 Returns undef if no string is supplied.
434  
435 =cut
436  
437 4 ▶sub _mysql_convert_date {
Subroutine _mysql_convert_date: called CC=5 SCAR=18.4
438 4 my $date = shift;
439 4 my $drophms = shift;
440 4 ▶ return undef unless $date;
Branch: 1 branch
BranchTrueFalseTotal
unless $date 0 4 4
441  
442 # The UT header is in MySQL format, which is something like
443 # "2002-03-15 07:04:35".
444 #
445 # Also support the Sybase format, which is something like
446 # "Mar 15 2002 7:04:35:234AM ". We first need to remove the number
447 # of milliseconds, then the whitespace at the end, then use the
448 # "%b%t%d%t%Y%t%I:%M:%S%p" format.
449  
450 # General cleanup
451 4 $date =~ s/\s*$//;
452  
453 4 my $return;
454  
455 4 ▶ if ($date =~ /^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($date =~ /^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/) { } 4 0 4
456 4 ▶ if ($drophms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($drophms) { } 1 3 4
457 1 $date =~ s/\s*\d\d?:\d\d:\d\d$//;
458 1 $return = Time::Piece->strptime( $date,
459 "%Y-%m-%d" );
460 } else {
461 3 $return = Time::Piece->strptime( $date,
462 "%Y-%m-%d %T" );
463 }
464 } else {
465 0 $date =~ s/:\d\d\d//;
466  
467 0 ▶ if ($drophms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($drophms) { } 0 0 0
468 0 $date =~ s/\s*\d\d?:\d\d:\d\d[A|P]M$//;
469 0 $return = Time::Piece->strptime( $date,
470 "%b %e %Y" );
471 } else {
472 0 $return = Time::Piece->strptime( $date,
473 "%b %e %Y %l:%M:%S%p" );
474 }
475 }
476 4 return $return;
477 }
478  
479 =back
480  
481 =end __PRIVATE
482  
483 =head1 AUTHOR
484  
485 Brad Cavanagh E<lt>b.cavanagh@jach.hawaii.eduE<gt>,
486 Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt>
487  
488 =head1 COPYRIGHT
489  
490 Copyright (C) 2008 Science and Technology Facilities Council.
491 Copyright (C) 2003-2007 Particle Physics and Astronomy Research Council.
492 All Rights Reserved.
493  
494 This program is free software; you can redistribute it and/or modify it under
495 the terms of the GNU General Public License as published by the Free Software
496 Foundation; either version 2 of the License, or (at your option) any later
497 version.
498  
499 This program is distributed in the hope that it will be useful,but WITHOUT ANY
500 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
501 PARTICULAR PURPOSE. See the GNU General Public License for more details.
502  
503 You should have received a copy of the GNU General Public License along with
504 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
505 Place,Suite 330, Boston, MA 02111-1307, USA
506  
507 =cut
508  
509 10 1;
« HdrTrans/ISAAC.pm ↑ Summary HdrTrans/LCOSBIG_1m0.pm »