| 1 | package Astro::Catalog::IO::Astrom; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Astro::Catalog::IO::Astrom - Starlink Astrom catalog I/O for Astro::Catalog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | $lines = Astro::Catalog::IO::Astrom->_write_catalog($catalog); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | This class provides a write method for catalogs to be used as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | import to Starlink Astrom. The method is not public and should, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | in general, only be called from the C<Astro::Catalog> C<write_catalog> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use warnings::register; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use Astro::Catalog; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use Astro::Catalog::Item; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use Astro::Coords; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use base qw/Astro::Catalog::IO::ASCII/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | our $VERSION = '4.38'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | our $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | =begin __PRIVATE_METHODS__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | =head1 PRIVATE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | These methods are usually called automatically from the C<Astro::Catalog> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | constructor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | =item B<_read_catalog> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | Not currently implemented for Astro::Catalog::IO::Astrom. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub _read_catalog { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_catalog: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | croak "Not yet implemented."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | =item B<_write_catalog> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | Writes the catalog object to a file in a format that Starlink ASTROM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | can understand. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | $lines = Astro::Catalog::IO::Astrom->_write_catalog($catalog); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | where $catalog is an C<Astro::Catalog> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | ▶ | sub _write_catalog { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_catalog: called CC=12 SCAR=28.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | croak ('Usage: _write_catalog($catalog)') unless scalar(@_) >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | my $catalog = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # Get the number of stars, since if we have fewer than N we cannot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # do a fit without the field centre. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | my $nstars = $catalog->sizeof(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | unless (defined $catalog->get_coords) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | croak "Need catalog field centre to do astrometry correction"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # Set up some variables for output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | my @output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | my $output_line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # Write the approximate field centre. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | my $ra_cen = $catalog->get_coords->ra(format => 's'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | my $dec_cen = $catalog->get_coords->dec(format => 's'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # Strip out colons or dms/hms and replace them with spaces. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | $ra_cen =~ s/[:dhms]/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | $dec_cen =~ s/[:dhms]/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # Get the epoch of observation. This can be obtained from the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # first star, so just pop it off, read the epoch, and pop it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # back on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | my $epoch_star = $catalog->popstar; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | my $wcs = $epoch_star->wcs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | $catalog->pushstar($epoch_star); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | my $epoch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | if (defined($wcs)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $epoch = $wcs->GetC("Epoch"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | unless (defined $epoch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $epoch = "2000.0"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | $epoch = "2000.0"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | push @output, "~ GENE 0.0"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | push @output, "~ $ra_cen $dec_cen J2000 $epoch"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # For each star, write the RA, Dec, epoch, X and Y coordinates. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | foreach my $star ($catalog->stars) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | ▶ | next if (! defined($star->ra) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $star->ra and defined $star->dec and defined $star->x and defined $star->y
defined $star->ra and defined $star->dec and defined $star->x
defined $star->ra and defined $star->dec
MC/DC0%0/4
defined $star->ra and defined $star->dec and defined $star->x and defined $star->y
defined $star->ra
defined $star->dec
defined $star->x
defined $star->y
Truth table20%1/5
A and B and C and D
A= defined $star->raB= defined $star->decC= defined $star->xD= defined $star->y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ! defined($star->dec) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ! defined($star->x) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ! defined($star->y)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | my $coords = $star->coords; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | my $ra = $coords->ra(format => 's'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 4 | my $dec = $coords->dec(format => 's'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # Strip out colons or dms/hms and replace them with spaces. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 4 | $ra =~ s/[:dhms]/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | $dec =~ s/[:dhms]/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # Get the star's epoch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | my $star_epoch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | ▶ | if (defined $star->wcs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $star_epoch = $star->wcs->GetC("Epoch"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | unless (defined $star_epoch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $star_epoch = "2000.0"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | $star_epoch = "2000.0"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 4 | $output_line = "$ra $dec J2000 $star_epoch"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 4 | push @output, $output_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | my $x = $star->x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 4 | my $y = $star->y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 4 | $output_line = "$x $y"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 4 | push @output, $output_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | push @output, "END"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | return \@output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||