| 1 | package Astro::Catalog::IO::Cluster; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | Astro::Catalog::IO::Cluster - Input/Output in ARK Cluster format | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | $catalog = Astro::Catalog::IO::Cluster->_read_catalog(\@lines); | ||||||||||||||||||||||||||||
| 10 | $lines = Astro::Catalog::IO::Cluster->_write_catalog($catalog, %opts); | ||||||||||||||||||||||||||||
| 11 | Astro::Catalog::IO::Cluster->_default_file(); | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Performs ARK Cluster specific tasks for input/output of ARK Cluster format | ||||||||||||||||||||||||||||
| 16 | files. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use warnings::register; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 3 | ▶ | use Astro::Catalog; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 3 | ▶ | use Astro::Catalog::Item; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 3 | ▶ | use Astro::Coords; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 3 | ▶ | use Astro::FluxColor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 3 | ▶ | use Astro::Flux; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 3 | ▶ | use Astro::Fluxes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 3 | ▶ | use Number::Uncertainty; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 3 | ▶ | use base qw/Astro::Catalog::IO::ASCII/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 3 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 3 | our $VERSION = '4.38'; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =begin __PRIVATE_METHODS__ | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head1 Private methods | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | These methods are for internal use only and are called from the | ||||||||||||||||||||||||||||
| 47 | Astro::Catalog module. Its not expected that anyone would want to | ||||||||||||||||||||||||||||
| 48 | call them from utside that module. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =over 4 | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =item B<_read_cluster> | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | Parses a reference to an array containing an ARK Cluster format | ||||||||||||||||||||||||||||
| 55 | catalog, returns an Astro::Catalog object. | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | $catalog = Astro::Catalog::IO::Cluster->_read_catalog(\@lines); | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =cut | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 2 | ▶ | sub _read_catalog { | ||||||||||||||||||||||||||
|
Subroutine
_read_catalog: called CC=13 SCAR=27.7
| |||||||||||||||||||||||||||||
| 62 | 2 | ▶ | croak('Usage: _read_catalog(\@lines)') unless scalar(@_) >= 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 64 | 2 | my $arg = shift; | |||||||||||||||||||||||||||
| 65 | 2 | my @lines = @{$arg}; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # create am Astro::Catalog object; | ||||||||||||||||||||||||||||
| 68 | 2 | my $catalog = new Astro::Catalog(); | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | # loop through lines | ||||||||||||||||||||||||||||
| 71 | 2 | foreach my $i (3 .. $#lines) { | |||||||||||||||||||||||||||
| 72 | # remove leading spaces | ||||||||||||||||||||||||||||
| 73 | 4 | $lines[$i] =~ s/^\s+//; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | # split each line | ||||||||||||||||||||||||||||
| 76 | 4 | my @separated = split(/\s+/, $lines[$i]); | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # temporary star object | ||||||||||||||||||||||||||||
| 79 | 4 | my $star = new Astro::Catalog::Item(); | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | # field | ||||||||||||||||||||||||||||
| 82 | 4 | $star->field($separated[0]); | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | # id | ||||||||||||||||||||||||||||
| 85 | 4 | $star->id($separated[1]); | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | # ra | ||||||||||||||||||||||||||||
| 88 | 4 | my $objra = "$separated[2] $separated[3] $separated[4]"; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | # dec | ||||||||||||||||||||||||||||
| 91 | 4 | my $objdec = "$separated[5] $separated[6] $separated[7]"; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | # Assume J2000 and create an Astro::Coords object | ||||||||||||||||||||||||||||
| 94 | 4 | my $coords = new Astro::Coords( | |||||||||||||||||||||||||||
| 95 | type => 'J2000', | ||||||||||||||||||||||||||||
| 96 | units => 'sex', | ||||||||||||||||||||||||||||
| 97 | ra => $objra, | ||||||||||||||||||||||||||||
| 98 | dec => $objdec, | ||||||||||||||||||||||||||||
| 99 | name => $star->id()); | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # and push it into the Astro::Catalog::Item object | ||||||||||||||||||||||||||||
| 102 | 4 | $star->coords($coords); | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # x & y | ||||||||||||||||||||||||||||
| 105 | 4 | ▶ | if ($separated[8] ne '0.000') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | $star->x($separated[8]); | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | 4 | ▶ | if ($separated[9] ne '0.000') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 0 | $star->y($separated[9]); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | # number of magnitudes and colours | ||||||||||||||||||||||||||||
| 113 | 4 | $lines[1] =~ s/^\s+//; | |||||||||||||||||||||||||||
| 114 | 4 | my @colours = split(/\s+/, $lines[1]); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 4 | my @quality; | |||||||||||||||||||||||||||
| 117 | 4 | my (@colors, @fluxes); | |||||||||||||||||||||||||||
| 118 | 4 | foreach my $j (0 .. $#colours) { | |||||||||||||||||||||||||||
| 119 | # colours have minus signs | ||||||||||||||||||||||||||||
| 120 | 20 | ▶ | if (lc($colours[$j]) =~ "-") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | # build a colour object and push it into the @colors array | ||||||||||||||||||||||||||||
| 122 | 8 | my @filters = split "-", $colours[$j]; | |||||||||||||||||||||||||||
| 123 | 8 | my $color = new Astro::FluxColor( | |||||||||||||||||||||||||||
| 124 | upper => new Astro::WaveBand(Filter => $filters[0]), | ||||||||||||||||||||||||||||
| 125 | lower => new Astro::WaveBand(Filter => $filters[1]), | ||||||||||||||||||||||||||||
| 126 | quantity => new Number::Uncertainty( | ||||||||||||||||||||||||||||
| 127 | Value => $separated[3*$j+10], | ||||||||||||||||||||||||||||
| 128 | Error => $separated[3*$j+11])); | ||||||||||||||||||||||||||||
| 129 | 8 | push @colors, $color; | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | # quality flags | ||||||||||||||||||||||||||||
| 132 | 8 | $quality[$j] = $separated[3*$j+12]; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||||||||
| 135 | 12 | my $mag = new Astro::Flux( | |||||||||||||||||||||||||||
| 136 | new Number::Uncertainty( | ||||||||||||||||||||||||||||
| 137 | Value => $separated[3*$j+10], | ||||||||||||||||||||||||||||
| 138 | Error => $separated[3*$j+11]), | ||||||||||||||||||||||||||||
| 139 | 'mag', $colours[$j]); | ||||||||||||||||||||||||||||
| 140 | 12 | push @fluxes, $mag; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | # quality flags | ||||||||||||||||||||||||||||
| 143 | 12 | $quality[$j] = $separated[3*$j+12]; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | # increment counter | ||||||||||||||||||||||||||||
| 146 | 12 | $j = $j + 2; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 4 | $star->fluxes(new Astro::Fluxes(@fluxes, @colors)); | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | # set default "good" quality | ||||||||||||||||||||||||||||
| 153 | 4 | $star->quality(0); | |||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | # check and set quality flag | ||||||||||||||||||||||||||||
| 156 | 4 | foreach my $k (0 .. $#colours) { | |||||||||||||||||||||||||||
| 157 | # if quality not good then set bad flag | ||||||||||||||||||||||||||||
| 158 | 20 | ▶ | if (Scalar::Util::looks_like_number($quality[$k])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 20 | ▶ | if (defined $quality[$k] && $quality[$k] != 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $quality[$k] and $quality[$k] != 0
MC/DC0%0/2
defined $quality[$k] and $quality[$k] != 0
defined $quality[$k]
$quality[$k] != 0
Truth table33%1/3
A and B
A= defined $quality[$k]B= $quality[$k] != 0
| |||||||||||||||||||||||||||||
| 160 | 0 | $star->quality(1); | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | else { | ||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if (defined $quality[$k] && $quality[$k] ne "OO") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $quality[$k] and $quality[$k] ne "OO"
MC/DC0%0/2
defined $quality[$k] and $quality[$k] ne "OO"
defined $quality[$k]
$quality[$k] ne "OO"
Truth table0%0/3
A and B
A= defined $quality[$k]B= $quality[$k] ne "OO"
| |||||||||||||||||||||||||||||
| 165 | 0 | $star->quality(1); | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | # push it onto the stack | ||||||||||||||||||||||||||||
| 171 | 4 | $catalog->pushstar($star); | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 2 | $catalog->origin('IO::Cluster'); | |||||||||||||||||||||||||||
| 175 | 2 | return $catalog; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =item B<_write_catalog> | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | Will write the catalog object to an standard ARK Cluster format file | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | $lines = Astro::Catalog::IO::Cluster->_write_catalog($catalog, %opts); | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | where $catalog is an Astro::Catalog object and allowable options are | ||||||||||||||||||||||||||||
| 186 | currently C<Colours> and C<Mags>, e.g. | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | $lines = Astro::Catalog::IO::Cluster->_write_catalog( | ||||||||||||||||||||||||||||
| 189 | $catalog, Magnitudes => \@mags, Colours => \@colours ); | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | where magnitudes and colours passed in the array will be used in the catalog | ||||||||||||||||||||||||||||
| 192 | despite the presence of other | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | my @mags = ('R'); | ||||||||||||||||||||||||||||
| 195 | my @colour = ('B-R', 'B-V'); | ||||||||||||||||||||||||||||
| 196 | \@lines = Astro::Catalog::IO::Cluster->write_catalog( | ||||||||||||||||||||||||||||
| 197 | $catalog, Magnitudes => \@mags, Colours => \@colours); | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | will write a catalog with R, B-R and B-V. | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | =cut | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 2 | ▶ | sub _write_catalog { | ||||||||||||||||||||||||||
|
Subroutine
_write_catalog: called CC=31 SCAR=37.0
| |||||||||||||||||||||||||||||
| 204 | 2 | ▶ | croak('Usage: _write_catalog($catalog, [%opts])') unless scalar(@_) >= 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 206 | 2 | my $catalog = shift; | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | # real list of filters and colours in the catalog | ||||||||||||||||||||||||||||
| 209 | 2 | my @filters = $catalog->starbyindex(0)->what_filters(); | |||||||||||||||||||||||||||
| 210 | 2 | my @colours = $catalog->starbyindex(0)->what_colours(); | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | # number of stars in catalog | ||||||||||||||||||||||||||||
| 213 | 2 | my $number = $catalog->sizeof(); | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | # number of filters & colours | ||||||||||||||||||||||||||||
| 216 | 2 | my $num_mags = $catalog->starbyindex(0)->what_filters(); | |||||||||||||||||||||||||||
| 217 | 2 | my $num_cols = $catalog->starbyindex(0)->what_colours(); | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | # reference to the $self->{STARS} array in Astro::Catalog | ||||||||||||||||||||||||||||
| 220 | 2 | my $stars = $catalog->stars(); | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | # figure out what magnitudes and colours we're going to output | ||||||||||||||||||||||||||||
| 223 | 2 | my ($mags, $cols); | |||||||||||||||||||||||||||
| 224 | 2 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if (defined $args{colours}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 0 | $cols = $args{colours}; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if (defined $args{magnitudes}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | $mags = $args{magnitudes}; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | else { | ||||||||||||||||||||||||||||
| 235 | 2 | $mags = \@filters; | |||||||||||||||||||||||||||
| 236 | 2 | $cols = \@colours; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | # define varaibles for output filters and colours | ||||||||||||||||||||||||||||
| 240 | 2 | my (@out_mags, @out_cols); | |||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | # Filter the output magnitudes and colours for uniqueness. | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | # if we want fewer magnitudes than we have in the object | ||||||||||||||||||||||||||||
| 245 | # to be written to the cluster file | ||||||||||||||||||||||||||||
| 246 | 2 | my %seen_mag; | |||||||||||||||||||||||||||
| 247 | 2 | foreach my $m (0 .. $#{$mags}) { | |||||||||||||||||||||||||||
| 248 | 6 | ▶ | next if $seen_mag{$mags->[$m]} ++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 6 | foreach my $n (0 .. $num_mags-1) { | |||||||||||||||||||||||||||
| 250 | 12 | ▶ | if (${$mags}[$m] eq $filters[$n]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 6 | push @out_mags, ${$mags}[$m]; | |||||||||||||||||||||||||||
| 252 | 6 | last; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | # same for colours | ||||||||||||||||||||||||||||
| 258 | 2 | my %seen_col; | |||||||||||||||||||||||||||
| 259 | 2 | foreach my $k (0 .. $#{$cols}) { | |||||||||||||||||||||||||||
| 260 | 4 | ▶ | next if $seen_col{$cols->[$k]} ++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | 4 | foreach my $l (0 .. $num_cols-1) { | |||||||||||||||||||||||||||
| 262 | 6 | ▶ | if (${$cols}[$k] eq $colours[$l]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 4 | push @out_cols, ${$cols}[$k]; | |||||||||||||||||||||||||||
| 264 | 4 | last; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | # write header | ||||||||||||||||||||||||||||
| 270 | 2 | my @output; | |||||||||||||||||||||||||||
| 271 | my $output_line; | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | # check to see if we're outputing all the filters and colours | ||||||||||||||||||||||||||||
| 274 | 2 | my $total = scalar(@out_mags) + scalar(@out_cols); | |||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 2 | push @output, "$total colours were created"; | |||||||||||||||||||||||||||
| 277 | 2 | push @output, "@out_mags @out_cols"; | |||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | # wierd and odd | ||||||||||||||||||||||||||||
| 280 | 2 | ▶ | $output_line = "Origin: " . $catalog->origin() . " " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | if defined $catalog->origin(); | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 2 | ▶ | if (defined $catalog->get_ra() && defined $catalog->get_dec()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $catalog->get_ra and defined $catalog->get_dec
MC/DC50%1/2
defined $catalog->get_ra and defined $catalog->get_dec
defined $catalog->get_ra
defined $catalog->get_dec
Truth table66%2/3
A and B
A= defined $catalog->get_raB= defined $catalog->get_dec
| |||||||||||||||||||||||||||||
| 284 | 1 | $output_line = $output_line . | |||||||||||||||||||||||||||
| 285 | " Field Centre: RA " . $catalog->get_ra() . | ||||||||||||||||||||||||||||
| 286 | ", Dec " . $catalog->get_dec() . " "; | ||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 2 | ▶ | $output_line = $output_line . | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | " Catalogue Radius: " . $catalog->get_radius() . " arcmin" | ||||||||||||||||||||||||||||
| 291 | if defined $catalog->get_radius(); | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 2 | $output_line = $output_line; | |||||||||||||||||||||||||||
| 294 | 2 | push @output, $output_line; | |||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | # write body | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | # loop through all the stars in the catalog | ||||||||||||||||||||||||||||
| 299 | 2 | foreach my $star (0 .. $#$stars) { | |||||||||||||||||||||||||||
| 300 | 4 | $output_line = undef; | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | # field, number, ra, dec and x&y position | ||||||||||||||||||||||||||||
| 303 | 4 | my $field = ${$stars}[$star]->field; | |||||||||||||||||||||||||||
| 304 | 4 | ▶ | if (defined $field) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 4 | $output_line = $field . " "; | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | else { | ||||||||||||||||||||||||||||
| 308 | 0 | $output_line = "0 "; | |||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 4 | my $id = ${$stars}[$star]->id; | |||||||||||||||||||||||||||
| 312 | 4 | ▶ | if (defined $id && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $id and &Scalar::Util::looks_like_number($id)
MC/DC50%1/2
defined $id and &Scalar::Util::looks_like_number($id)
defined $id
&Scalar::Util::looks_like_number($id)
Truth table66%2/3
A and B
A= defined $idB= &Scalar::Util::looks_like_number($id)
| |||||||||||||||||||||||||||||
| 313 | Scalar::Util::looks_like_number($id)) { | ||||||||||||||||||||||||||||
| 314 | 2 | $output_line = $output_line . $id . " "; | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | else { | ||||||||||||||||||||||||||||
| 317 | 2 | $output_line = $output_line . $star . " "; | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | # fiddle with the dec, olv versions of the Fortran Cluster | ||||||||||||||||||||||||||||
| 321 | # parser don't like + signs for northern hemisphere dec's | ||||||||||||||||||||||||||||
| 322 | 4 | my $dec = ${$stars}[$star]->dec(); | |||||||||||||||||||||||||||
| 323 | 4 | $dec =~ s/\+//; | |||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 4 | $output_line = $output_line . ${$stars}[$star]->ra() . " "; | |||||||||||||||||||||||||||
| 326 | 4 | $output_line = $output_line . $dec . " "; | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 4 | my $x = ${$stars}[$star]->x; | |||||||||||||||||||||||||||
| 329 | 4 | my $y = ${$stars}[$star]->y; | |||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 4 | ▶ | if (defined $x && defined $y) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $x and defined $y
MC/DC0%0/2
defined $x and defined $y
defined $x
defined $y
Truth table33%1/3
A and B
A= defined $xB= defined $y
| |||||||||||||||||||||||||||||
| 332 | 0 | $output_line = $output_line . $x . " " . $y . " "; | |||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | else { | ||||||||||||||||||||||||||||
| 335 | 4 | $output_line = $output_line . "0.000 0.000 "; | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | # magnitudes | ||||||||||||||||||||||||||||
| 339 | 4 | foreach my $out_mag (@out_mags) { | |||||||||||||||||||||||||||
| 340 | # Grab each magnitude listed in the @out_mags array and append | ||||||||||||||||||||||||||||
| 341 | # it to the output line. | ||||||||||||||||||||||||||||
| 342 | 12 | my $out_mag_value = ${$stars}[$star]->get_magnitude($out_mag); | |||||||||||||||||||||||||||
| 343 | 12 | ▶ | if (defined $out_mag_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 344 | 12 | $output_line .= $out_mag_value . " "; | |||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | else { | ||||||||||||||||||||||||||||
| 347 | 0 | $output_line .= "0.000 "; | |||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | # And get the error, if it exists. | ||||||||||||||||||||||||||||
| 351 | 12 | my $out_mag_error = ${$stars}[$star]->get_errors($out_mag); | |||||||||||||||||||||||||||
| 352 | 12 | ▶ | if (defined $out_mag_error) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 353 | 12 | $output_line .= $out_mag_error . " "; | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | else { | ||||||||||||||||||||||||||||
| 356 | 0 | $output_line .= "0.000 "; | |||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | # And the quality. | ||||||||||||||||||||||||||||
| 360 | 12 | my $quality = ${$stars}[$star]->quality; | |||||||||||||||||||||||||||
| 361 | 12 | ▶ | if (defined $quality) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | 12 | $output_line .= $quality . " "; | |||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | else { | ||||||||||||||||||||||||||||
| 365 | 0 | $output_line .= "0 "; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | # Now for the colours. | ||||||||||||||||||||||||||||
| 370 | 4 | foreach my $out_col (@out_cols) { | |||||||||||||||||||||||||||
| 371 | # Grab each colour listed in the @out_cols array and append it | ||||||||||||||||||||||||||||
| 372 | # to the output line. | ||||||||||||||||||||||||||||
| 373 | 8 | my $out_col_value = ${$stars}[$star]->get_colour($out_col); | |||||||||||||||||||||||||||
| 374 | 8 | ▶ | if (defined $out_col_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | 8 | $output_line .= $out_col_value . " "; | |||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||
| 377 | else { | ||||||||||||||||||||||||||||
| 378 | 0 | $output_line .= "0.000 "; | |||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | # And get the error, if it exists. | ||||||||||||||||||||||||||||
| 382 | 8 | my $out_col_error = ${$stars}[$star]->get_colourerr($out_col); | |||||||||||||||||||||||||||
| 383 | 8 | ▶ | if (defined $out_col_error) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 384 | 8 | $output_line .= $out_col_error . " "; | |||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | else { | ||||||||||||||||||||||||||||
| 387 | 0 | $output_line .= "0.000 "; | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | # And the quality. | ||||||||||||||||||||||||||||
| 391 | 8 | my $quality = ${$stars}[$star]->quality; | |||||||||||||||||||||||||||
| 392 | 8 | ▶ | if (defined $quality) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | 8 | $output_line .= $quality . " "; | |||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||
| 395 | else { | ||||||||||||||||||||||||||||
| 396 | 0 | $output_line .= "0 "; | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | # next star | ||||||||||||||||||||||||||||
| 401 | 4 | $output_line = $output_line; | |||||||||||||||||||||||||||
| 402 | 4 | push (@output, $output_line ); | |||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | # clean up | ||||||||||||||||||||||||||||
| 407 | 2 | return \@output; | |||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | =item B<_default_file> | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | If Astro::Catalog is created with a Format but no Filename or other data | ||||||||||||||||||||||||||||
| 413 | source it checked this routine to see whether there is a default file | ||||||||||||||||||||||||||||
| 414 | that should be read. This is mainly for Astro::Catalo::IO::JCMT and the | ||||||||||||||||||||||||||||
| 415 | JAC, but might prive useful elsewhere. | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | =cut | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | ▶ | sub _default_file { | ||||||||||||||||||||||||||
|
Subroutine
_default_file: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 420 | # returns an empty list | ||||||||||||||||||||||||||||
| 421 | 0 | return; | |||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 3 | 1; | |||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | __END__ | ||||||||||||||||||||||||||||