forked from Starlink/perl-Starlink-Autoastrom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Autoastrom.pm
2522 lines (1934 loc) · 76 KB
/
Autoastrom.pm
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package Starlink::Autoastrom;
=head1 NAME
Starlink::Autoastrom - Perform automated astrometric corrections on
an astronomical frame.
=head1 SYNOPSIS
use Starlink::Autoastrom;
my $auto = new Starlink::Autoastrom( ndf => $ndf );
$auto->solve;
=head1 DESCRIPTION
This module performs automated astrometric corrections on an astronomical
frame. It is essentially a wrapper around L<Starlink::Astrom> with bits
added on to allow one to pass an NDF and have its astrometry corrected.
=cut
use strict;
use Carp;
use Data::Dumper;
use File::Temp qw/ tempdir /;
# We need a wack of other modules.
#
# That's right, a WACK.
use Starlink::AST;
use Starlink::Astrom;
use Starlink::Extractor;
use Astro::Coords;
use Astro::Correlate;
use Astro::Catalog;
use Astro::Catalog::Query::SkyCat;
use Astro::Flux;
use Astro::Fluxes;
use Astro::FITS::HdrTrans qw/ translate_from_FITS /;
use Astro::FITS::Header;
use Astro::FITS::Header::NDF;
use Astro::WaveBand;
use Time::HiRes qw/ time /;
use NDF '1.52';
use constant DAS2R => 4.8481368110953599358991410235794797595635330237270e-6;
use vars qw/ $VERSION $DEBUG /;
$VERSION = '0.01';
$DEBUG = 0;
=head1 METHODS
=head2 Constructor
=over 4
=item B<new>
$auto = new Starlink::Autoastrom( ndf => $ndf );
The constructor returns an C<Starlink::Autoastrom> object.
=cut
sub new {
my $proto = shift;
my $class = ref( $proto ) || $proto;
# Retrieve the arguments.
my %args = @_;
# Create the object.
my $auto = {};
bless( $auto, $class );
# Configure the object.
$auto->_configure( \%args );
# Set up default options.
$auto->aperture( 5.0 ) if ( ! defined( $auto->aperture ) );
$auto->autocrowded( 0 ) if ( ! defined( $auto->autocrowded ) );
$auto->catalogue( 'USNO@ESO' ) if( ! defined( $auto->catalogue ) );
$auto->crowded( 0 ) if ( ! defined( $auto->crowded ) );
$auto->crowded_threshold( 250 ) if ( ! defined( $auto->crowded_threshold ) );
$auto->defects( 'warn' ) if ( ! defined( $auto->defects ) );
$auto->detection_threshold( 5.0 ) if ( ! defined( $auto->detection_threshold ) );
$auto->insert( 1 ) if ( ! defined( $auto->insert ) );
$auto->keeptemps( 0 ) if ( ! defined( $auto->keeptemps ) );
$auto->match( 'FINDOFF' ) if ( ! defined( $auto->match ) );
$auto->maxfit( 9 ) if ( ! defined( $auto->maxfit ) );
$auto->maxobj_query( 500 ) if ( ! defined( $auto->maxobj_query ) );
$auto->maxobj_image( 500 ) if ( ! defined( $auto->maxobj_image ) );
$auto->maxobj_corr( 500 ) if ( ! defined( $auto->maxobj_corr ) );
$auto->messages( 1 ) if ( ! defined( $auto->messages ) );
$auto->obsdata( 'source=USER:AST:FITS,angle=0,scale=1,invert=0' ) if ( ! defined( $auto->obsdata ) );
$auto->starlink_output( 1 ) if ( ! defined( $auto->starlink_output ) );
$auto->temp( tempdir( CLEANUP => ( ! $auto->keeptemps ) ) ) if ( ! defined( $auto->temp ) );
$auto->timeout( 180 ) if ( ! defined( $auto->timeout ) );
$auto->verbose( 1 ) if ( ! defined( $auto->verbose ) );
# Return.
return $auto;
}
=back
=head2 Accessor Methods
=over 4
=item B<aperture>
Aperture size to use for aperture photometry.
my $aperture = $auto->aperture;
$auto->aperture( 10.0 );
The value is the aperture diameters in pixels. Defaults to 5.0.
=cut
sub aperture {
my $self = shift;
if( @_ ) {
my $aperture = shift;
$self->{APERTURE} = $aperture;
}
return $self->{APERTURE};
}
=item B<autocrowded>
Whether or not to automatically detect whether or not the frame is a crowded field, and then act accordingly.
my $autocrowded = $auto->autocrowded;
$auto->autocrowded( 1 );
If set to true, then the automated astrometry step will automatically
detect whether or not the field is considered crowded. If the number
of objects extracted from the central 25% of the frame is greater than
the value returned by the crowded_threshold() accessor, then the field
is considered to be crowded, in which case only the central region of
the image will be used.
If the crowded() accessor is set to 1, then that will override any
value that this accessor is set to. If the crowded() accessor is set
to false, then the value of this accessor takes priority.
The value defaults to 0, or false.
=cut
sub autocrowded {
my $self = shift;
if( @_ ) {
my $autocrowded = shift;
$self->{AUTOCROWDED} = $autocrowded;
}
return $self->{AUTOCROWDED};
}
=item B<bestfitlog>
Retrieve or set the filename to write information about the best fit
to.
my $bestfitlog = $auto->bestfitlog;
$auto->bestfitlog( 'bestfit.log' );
Will write the file to the current working directory. If undefined,
which is the default, no log will be written.
=cut
sub bestfitlog {
my $self = shift;
if( @_ ) {
my $bestfitlog = shift;
$self->{BESTFITLOG} = $bestfitlog;
}
return $self->{BESTFITLOG};
}
=item B<catalogue>
Retrieve or set the SkyCat name of the online catalogue to use
for queries.
my $skycat = $auto->catalogue;
$auto->catalogue( 'usno@eso' );
Take care to avoid string interpolation with the @ sign. Returns a
string. Defaults to 'USNO@ESO'. The string is upper-cased when stored
and returned.
For a list of available SkyCat catalogue names, see
http://archive.eso.org/skycat/
This method supports multiple SkyCat names separated by commas:
$auto->catalogue( 'usno@eso,2mass@ukirt' );
If more than one SkyCat name has been supplied, the first will be
tried. If that fails or returns zero objects, then the second will be
returned, and so on until the list of names has been exhausted.
=cut
sub catalogue {
my $self = shift;
if( @_ ) {
my $catalogue = uc( shift );
$self->{CATALOGUE} = $catalogue;
}
return $self->{CATALOGUE};
}
=item B<ccdcatalogue>
Retrieve or set a pre-existing catalogue of objects in the CCD frame.
my $ccdcatalogue = $auto->ccdcatalogue;
$auto->ccdcatalogue( 'm31.cat' );
The format is that as produced as output by SExtractor when the
CATALOG_TYPE parameter is set to ASCII_HEAD. The catalogue must
have all of the fields NUMBER, FLUX_ISO, X_IMAGE, Y_IMAGE, A_IMAGE,
B_IMAGE, X2_IMAGE, Y2_IMAGE, ERRX2_IMAGE, ERRY2_IMAGE, and ISOAREA_IMAGE,
of which X2_IMAGE, Y2_IMAGE, A_IMAGE, B_IMAGE, ERRX2_IMAGE, and
ERRY2_IMAGE are not generated by default.
This parameter defaults to undef, which means a catalogue will be
formed by running SExtractor on the input frame instead of relying
on the pre-existing catalogue.
=cut
sub ccdcatalogue {
my $self = shift;
if( @_ ) {
my $ccdcatalogue = shift;
$self->{CCDCATALOGUE} = $ccdcatalogue;
}
return $self->{CCDCATALOGUE};
}
=item B<crowded>
Whether or not the autoastrom is being run on a crowded field. This is
primarily used for speed considerations, as a smaller region of the
frame will be used to detect objects in.
=cut
sub crowded {
my $self = shift;
if( @_ ) {
my $crowded = shift;
$self->{CROWDED} = $crowded;
}
return $self->{CROWDED};
}
=item B<crowded_threshold>
The lower limit of extracted objects before which a field is
considered crowded.
my $thresh = $auto->crowded_threshold;
$auto->crowded_threshold( 500 );
See the C<autocrowded> method for more information.
Defaults to 250.
=cut
sub crowded_threshold {
my $self = shift;
if( @_ ) {
my $thresh = shift;
$self->{CROWDED_THRESHOLD} = $thresh;
}
return $self->{CROWDED_THRESHOLD};
}
=item B<defects>
Retrieve or set the keyword that dictates how defects in the
CCD catalogue are treated.
my $defects = $auto->defects;
$auto->defects( 'remove' );
This method can take one of four possible keywords:
=over 4
=item ignore - Completely ignore defects.
=item warn - Warn about possible defects, but do nothing further.
=item remove - Remove any suspected defects from the catalogue of
CCD objects.
=item badness - Provide the threshold for defect removal and warnings.
Any objects with a badness greater than the value specified here are
noted or removed.
=back
The badness heuristic works by assigning a 'badness' to each object
detected. Objects with a position variance smaller than one pixel
and whose flux density is significantly higher than the average
are given high scores.
The default behaviour is to warn about possible defects (i.e. the
default keyword is 'warn'), and the default badness level is 1.
To set the badness level, set this keyword to 'badness=2' if, for example,
you wanted the badness threshold to be 2.
=cut
sub defects {
my $self = shift;
if( @_ ) {
my $defects = shift;
if( $defects !~ /^(ignore|warn|remove|badness)/i ) {
$defects = 'warn';
} else {
$defects = lc( $defects );
}
$self->{DEFECTS} = $defects;
}
return $self->{DEFECTS};
}
=item B<detected_catalogue>
Retrieve or set a filename that will take the set of objects detected
by the detection step. The file is formatted in Cluster format
with 13 columns:
=over 4
=item * a zero
=item * the object ID number
=item * the RA and Dec in space-separated format
=item * the x and y positions of the source on the CCD
=item * an instrumental magnitude
=item * the error in the instrumental magnitude
=item * extraction flags
=back
my $detected_catalogue = $auto->detected_catalogue;
$auto->detected_catalogue( 'detect.cat' );
Defaults to undef, meaning that no such file will be written. If defined,
it will write the catalogue in the current working directory.
=cut
sub detected_catalogue {
my $self = shift;
if( @_ ) {
my $detected_catalogue = shift;
$self->{DETECTED_CATALOGUE} = $detected_catalogue;
}
return $self->{DETECTED_CATALOGUE};
}
=item B<detection_threshold>
The detection threshold above which objects will be detected. This is
equivalent to the DETECT_THRESH parameter to SExtractor.
my $detection_threshold = $auto->detection_threshold;
$auto->detection_threshold( 2.5 );
Setting a lower detection will slow down automated astrometry. The
default is 5.0.
=cut
sub detection_threshold {
my $self = shift;
if( @_ ) {
my $thresh = shift;
$self->{DETECTION_THRESHOLD} = $thresh;
}
return $self->{DETECTION_THRESHOLD};
}
=item B<err_output>
Define a callback that will take text for error output.
$auto->err_output( sub { print "Autoastrom error: " . shift; } );
If no callback is defined, then text will be output to STDERR by the
printerr_me() method.
=cut
sub err_output {
my $self = shift;
if( @_ ) {
$self->{ERR_OUTPUT} = shift;
}
return $self->{ERR_OUTPUT};
}
=item B<filter>
=cut
sub filter {
my $self = shift;
if( @_ ) {
my $filter = shift;
$self->{FILTER} = $filter;
}
return $self->{FILTER};
}
=item B<insert>
Whether or not to insert the final astrometric fit into the input NDF
as an AST WCS component. If false, the insertion is not done.
my $insert = $auto->insert;
$auto->insert( 1 );
The default is true.
=cut
sub insert {
my $self = shift;
if( @_ ) {
my $insert = shift;
$self->{INSERT} = $insert;
}
return $self->{INSERT};
}
=item B<iterrms_abs>
Retrieve or set the absolute RMS level to reach in determining the solution during the iterative process.
my $iterrms_abs = $auto->iterrms_abs;
$auto->iterrms_abs( 0.25 );
Values are in arcseconds. If undefined, which is the default, then iterations will continue until the number of iterations reaches the value stored in the maxiter() accessor.
=cut
sub iterrms_abs {
my $self = shift;
if( @_ ) {
my $iterrms_abs = shift;
$self->{ITERRMS_ABS} = $iterrms_abs;
}
return $self->{ITERRMS_ABS};
}
=item B<iterrms_diff>
Retrieve or set the difference in RMS between iterations to reach in determining the solution during the iterative process.
my $iterrms_diff = $auto->iterrms_diff;
$auto->iterrms_diff( 0.001 );
Values are in arcseconds. If undefined, which is the default, then iterations will continue until the number of iterations reaches the value stored in the maxiter() accessor.
=cut
sub iterrms_diff {
my $self = shift;
if( @_ ) {
my $iterrms_diff = shift;
$self->{ITERRMS_DIFF} = $iterrms_diff;
}
return $self->{ITERRMS_DIFF};
}
=item B<keepfits>
Whether or not to keep the final astrometric fit as a FITS-WCS file.
my $keepfits = $auto->keepfits;
$auto->keepfits('wcs.fits');
If this parameter is undefined (which is the default), then no FITS-WCS
file will be kept. If it is defined, then the FITS-WCS file will have
the name given as this value. Using the above example, the FITS-WCS
file will be saved as 'wcs.fits' in the current working directory.
=cut
sub keepfits {
my $self = shift;
if( @_ ) {
my $keepfits = shift;
$self->{KEEPFITS} = $keepfits;
}
return $self->{KEEPFITS};
}
=item B<keeptemps>
Whether or not to keep temporary files after processing is completed.
my $keeptemps = $auto->keeptemps;
$auto->keeptemps( 1 );
Temporary files are created in a temporary directory that is reported
during execution. The location of this temporary directory can be
controlled using the C<temp> method.
This parameter defaults to false, so all temporary files are deleted
after processing.
=cut
sub keeptemps {
my $self = shift;
if( @_ ) {
my $keeptemps = shift;
$self->{KEEPTEMPS} = $keeptemps;
}
return $self->{KEEPTEMPS};
}
=item B<match>
The matching algorithm to be used.
my $match = $auto->match;
$auto->match( 'FINDOFF' );
Currently, the only available matching algorithm is the Starlink
FINDOFF application, part of CCDPACK. FINDOFF has certain limitations
(i.e. it's slow, it doesn't work if you have unequal X and Y scales),
but works if your data get around these limitations.
=cut
sub match {
my $self = shift;
if( @_ ) {
my $match = shift;
$self->{MATCH} = $match;
}
return $self->{MATCH};
}
=item B<matchcatalogue>
Retrieve or set a filename that will take the set of positions matched
by the matching process. The file is formatted like a SExtractor output
file with five columns: the object number, RA and Dec of the source on
the sky, and x and y positions of the source on the CCD.
my $matchcatalogue = $auto->matchcatalogue;
$auto->matchcatalogue( 'match.cat' );
Defaults to undef, meaning that no such file will be written. If defined,
it will write the catalogue in the current working directory.
=cut
sub matchcatalogue {
my $self = shift;
if( @_ ) {
my $matchcatalogue = shift;
$self->{MATCHCATALOGUE} = $matchcatalogue;
}
return $self->{MATCHCATALOGUE};
}
=item B<maxfit>
Retrieve or set the maximum number of fit parameters to use to obtain
the astrometric fit.
my $maxfit = $auto->maxfit;
$auto->maxfit( 7 );
Allowed values are 4, 6, 7, 8, and 9, and the default is 9.
=cut
sub maxfit {
my $self = shift;
if( @_ ) {
my $maxfit = shift;
if( $maxfit != 4 &&
$maxfit != 6 &&
$maxfit != 7 &&
$maxfit != 8 &&
$maxfit != 9 ) {
$maxfit = 9;
}
$self->{MAXFIT} = $maxfit;
}
return $self->{MAXFIT};
}
=item B<maxiter>
Retrieve or set the maximum number of iterations to perform.
my $maxiter = $auto->maxiter;
$auto->maxiter( 20 );
Defaults to 10. There is an upper limit of 100, and a lower limit of 1.
=cut
sub maxiter {
my $self = shift;
if( @_ ) {
my $maxiter = shift;
$self->{MAXITER} = $maxiter;
}
if( ! defined( $self->{MAXITER} ) ) {
$self->{MAXITER} = 10;
}
if( $self->{MAXITER} > 100 ) {
$self->{MAXITER} = 100;
} elsif ( $self->{MAXITER} < 1 ) {
$self->{MAXITER} = 1;
}
return $self->{MAXITER};
}
=item B<maxobj_corr>
Retrieve or set the maximum number of objects to use for correlation.
my $maxobj_corr = $auto->maxobj_corr;
$auto->maxobj_corr( 50 );
Defaults to 500. Useful for speeding up processing by setting to a
lower number, or possibly obtaining better matches with larger numbers
of objects. This puts limits on both the query catalogue and the image
catalogue when used as input to the correlation routine.
=cut
sub maxobj_corr {
my $self = shift;
if( @_ ) {
my $max_obj_corr = shift;
$self->{MAXOBJ_CORR} = $max_obj_corr;
}
return $self->{MAXOBJ_CORR};
}
=item B<maxobj_image>
Retrieve or set the maximum number of objects to use from the image.
my $maxobj_image = $self->maxobj_image;
$self->maxobj_image( 1000 );
Defaults to 500. Useful for speeding up processing time in
densely-populated fields.
If this limit is smaller than the number of objects detected in the
image, then the filtering will be done radially from the image centre,
i.e. it will use those objects nearer the centre.
=cut
sub maxobj_image {
my $self = shift;
if( @_ ) {
my $max_obj_image = shift;
$self->{MAXOBJ_IMAGE} = $max_obj_image;
}
return $self->{MAXOBJ_IMAGE};
}
=item B<maxobj_query>
Retrieve or set the maximum number of objects to retrieve from the
catalogue server.
my $max_obj_query = $auto->maxobj_query;
$auto->maxobj_query( 1000 );
Defaults to 500.
=cut
sub maxobj_query {
my $self = shift;
if( @_ ) {
my $max_obj_query = shift;
$self->{MAXOBJ_QUERY} = $max_obj_query;
}
return $self->{MAXOBJ_QUERY};
}
=item B<messages>
Whether or not to display messages from the Starlink applications.
my $messages = $auto->messages;
$auto->messages( 0 );
Defaults to true (1).
=cut
sub messages {
my $self = shift;
if( @_ ) {
my $messages = shift;
$self->{MESSAGES} = $messages;
}
return $self->{MESSAGES};
}
=item B<ndf>
Retrieve or set the NDF that will have its astrometry solved.
my $ndf = $auto->ndf;
$auto->ndf( $ndf );
Returns a string.
=cut
sub ndf {
my $self = shift;
if( @_ ) {
my $ndf = shift;
$self->{NDF} = $ndf;
}
return $self->{NDF};
}
=item B<obsdata>
Retrieve or set a source for the observation data, including WCS
information.
my $obsdata = $auto->obsdata;
$auto->obsdata( $obsdata );
This method returns or takes a hash reference containing the following
keys:
=over 4
=item source - A colon-separated list of sources of WCS information.
The values may be 'AST', indicating that the information should come
from the AST WCS component of the WCS, 'FITS', indicating that it
should come from any FITS extension in the NDF, or 'USER', indicating
that values given by this method are to be used. The default is
'USER:AST:FITS', so that any WCS information given by this method
has precedence. The values are not case-sensitive. If no WCS information
can be obtained, an error will be thrown.
=item ra - Right ascension of the centre of the pixel grid, given in
colon-separated HMS or decimal hours. This is stored internally
as an C<Astro::Coords::Angle::Hour> object, and if the obsdata()
method is called then the value for this key will also be an
C<Astro::Coords::Angle::Hour> object.
=item dec - Declination of the centre of the pixel grid, given in colon-
separated DMS or decimal degrees. This is stored internally as an
C<Astro::Coords::Angle> object, and if the obsdata() method is called then
the value for this key will also be an C<Astro::Coords::Angle> object.
=item angle - Position angle of the pixel grid. This is the rotation
in degrees counter-clockwise of the declination axis with respect to
the y-axis of the data array. Defaults to 0.
=item scale - Plate scale in arcseconds per pixel. Defaults to 1.
=item invert - If true, the axes are inverted. Defaults to 0.
=back
There are additional observation data keywords that can be defined.
These are used to refine higher-order astrometric fits.
=over 4
=item time - An observation time, given as a Julian epoch (in the
format r), a local sideral time (in the format i:i), or UT (in the
format i:i:i:i:r specifying four-digit year, month, day, hours,
and minutes).
=item obs - An observation station, given either as one of the
SLALIB observatory codes, or in the format i:r:i:r[:r] specifying
longitude, latitude, and optional height. Longitudes are east longitudes,
so west longitudes may be given as minus degrees or longitudes
greater than 180.
=item met - Temperature and pressure at the telescope, in degrees
Kelvin and millibars. The defaults are 278K and a pressure computed
from the observatory height. Format r[:r].
=item col - The effective colour of the observations, as a wavelength
in nanometres. The default is 500nm.
=back
In the format specifications for the above four keywords, r represents
a real, i represents an integer, and optional entries are in [...].
When returned as a hash reference, the keys have been converted to upper-case.
For example, to retrieve the value for the 'source', you would do:
$source = $auto->obsdata->{'SOURCE'};
=cut
sub obsdata {
my $self = shift;
if( @_ ) {
my $obsdata_input = shift;
my @obsdata = split( ',', $obsdata_input );
foreach my $thing ( @obsdata ) {
( my $key, my $value ) = split( '=', $thing );
$key = uc( $key );
# Perform format checking on the value.
if( $key eq 'SOURCE' ) {
my @values = split( ':', $value );
my @valid = map { uc($_) } grep { /^(ast|fits|user)$/i } @values;
$value = join ':', @valid;
}
if( $key eq 'RA' ) {
# Convert to Astro::Coords::Angle::Hour object.
if( $value =~ /^\d+:\d+:[\d\.]+$/ ) {
$value = new Astro::Coords::Angle::Hour( $value, units => 'sex' );
} elsif( $value =~ /^[\d\.]+$/ ) {
$value = new Astro::Coords::Angle::Hour( $value, units => 'hour' );
} else {
$self->printstd( "--E Could not parse $value to form Right Ascension from obsdata information.\n" )
if $self->starlink_output;
croak "Could not parse $value to form Right Ascension from obsdata information";
}
}
if( $key eq 'DEC' ) {
# Convert to Astro::Coords::Angle object.
if( $value =~ /^[+\-]?\d+:\d+:[\d\.]+$/ ) {
$value = new Astro::Coords::Angle( $value, units => 'sex' );
} elsif( $value =~ /^-?[\d\.]+$/ ) {
$value = new Astro::Coords::Angle( $value, units => 'deg' );
} else {
$self->printstd( "--E Could not parse $value to form Declination from obsdata information.\n" )
if $self->starlink_output;
croak "Could not parse $value to form Declination from obsdata information";
}
}
if( $key eq 'ANGLE' ) {
if( $value !~ /^-?\d+(\.\d*)?$/ ) {
$self->printstd( "--W Cannot parse position angle of $value from obsdata information. Setting position angle to 0 degrees.\n" )
if $self->starlink_output;
carp "Cannot parse position angle of $value from obsdata information. Setting position angle to 0 degrees";
$value = 0;
}
}
if( $key eq 'SCALE' ) {
if( $value !~ /^\d+(\.\d*)?$/ ) {
$self->printstd( "--W Cannot parse plate scale of $value from obsdata information. Setting plate scale to 1 arcsec/pixel.\n" )
if $self->starlink_output;
carp "Cannot parse plate scale of $value from obsdata information. Setting plate scale to 1 arcsec/pixel";
$value = 1;
}
}
if( $key eq 'INVERT' ) {
if( ( $value != 1 ) && ( $value != 0 ) ) {
$self->printstd( "--W Value of invert from obsdata information must be 0 or 1, not $value. Setting invert to 0.\n" )
if $self->starlink_output;
carp "Value of invert from obsdata information must be 0 or 1, not $value. Setting invert to 0";
$value = 0;
}
}
if( $key eq 'TIME' ) {
if( $value !~ /^\d+(\.\d+)?$/ &&
$value !~ /^\d+:\d+$/ &&
$value !~ /^\d+:\d+:\d+:\d+:\d+(\.\d*)?$/ ) {
$self->printstd( "--E Could not parse time of $value from obsdata information.\n" )
if $self->starlink_output;
croak "Could not parse time of $value from obsdata information";
}
$value =~ s/:/ /g;
}
if( $key eq 'OBS' ) {
if( $value !~ /^([\w\.])+$/ &&
$value !~ /^-?\d+:\d+(\.\d*)?:\d+:\d+(\.\d*)?(:\d+(\.\d*)?)?$/ ) {
# And who says Perl is line noise? :-)
$self->printstd( "--E Could not parse observatory code of $value from obsdata information.\n" )
if $self->starlink_output;
croak "Could not parse observatory code of $value from obsdata information";
}
}
if( $key eq 'MET' ) {
if( $value !~ /^\d+(\.\d*)?(:\d+(\.\d*)?)?$/ ) {
$self->printstd( "--E Could not parse meteorological information of $value from obsdata information.\n" )
if $self->starlink_output;
croak "Could not parse meteorological information of $value from obsdata information";
}
}
if( $key eq 'COL' ) {
if( $value !~ /^\d+(\.\d*)?$/ ) {
$self->printstd( "--E Could not parse effective colour of $value from obsdata information.\n" )
if $self->starlink_output;
croak "Could not parse effective colour of $value from obsdata information";
}
}
$self->{OBSDATA}->{$key} = $value;
}
}
# Make sure defaults are set up.
$self->{OBSDATA}->{ANGLE} = 0 unless defined( $self->{OBSDATA}->{ANGLE} );
$self->{OBSDATA}->{SCALE} = 1 unless defined( $self->{OBSDATA}->{SCALE} );
$self->{OBSDATA}->{INVERT} = 0 unless defined( $self->{OBSDATA}->{INVERT} );
$self->{OBSDATA}->{SOURCE} = 'USER:AST:FITS' unless defined( $self->{OBSDATA}->{SOURCE} );
return $self->{OBSDATA};
}
=item B<positional_error>
The error, in pixels, of the positions in the two catalogues.
$auto->error( 4 );
This parameter is used in the cross-correlation. Setting an
appropriate positional error may result in more accurate fits.
If this parameter is not defined, then the default value will be set
according to the appropriate cross-correlation routine (see
C<Astro::Correlate> and its correlation methods for more information).
=cut
sub positional_error {
my $self = shift;
if( @_ ) {
my $pos_error = shift;
$self->{POSITIONAL_ERROR} = $pos_error;
}
return $self->{POSITIONAL_ERROR};
}
=item B<rawcatalogue>
Retrieve the catalogue of detected objects before astrometry
correction.
$raw = $auto->rawcatalogue;
This method returns an C<Astro::Catalog> object.
=cut
sub rawcatalogue {
my $self = shift;