File: palObs.c

package info (click to toggle)
starlink-pal 0.9.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,808 kB
  • sloc: ansic: 6,689; makefile: 128; sh: 81
file content (932 lines) | stat: -rw-r--r-- 25,678 bytes parent folder | download
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
/*
*+
*  Name:
*     palObs

*  Purpose:
*     Parameters of selected ground-based observing stations

*  Language:
*     Starlink ANSI C

*  Type of Module:
*     Library routine

*  Invocation:
*     int palObs( size_t n, const char * c,
*                 char * ident, size_t identlen,
*                 char * name, size_t namelen,
*                 double * w, double * p, double * h );

*  Arguments:
*     n = size_t (Given)
*         Number specifying the observing station. If 0
*         the identifier in "c" is used to determine the
*         observing station to use.
*     c = const char * (Given)
*         Identifier specifying the observing station for
*         which the parameters should be returned. Only used
*         if n is 0. Can be NULL for n>0. Case insensitive.
*     ident = char * (Returned)
*         Identifier of the observing station selected. Will be
*         identical to "c" if n==0. Unchanged if "n" or "c"
*         do not match an observing station. Should be at least
*         11 characters (including the trailing nul).
*     identlen = size_t (Given)
*         Size of the buffer "ident" including trailing nul.
*     name = char * (Returned)
*         Full name of the specified observing station. Contains "?"
*         if "n" or "c" did not correspond to a valid station. Should
*         be at least 41 characters (including the trailing nul).
*     w = double * (Returned)
*         Longitude (radians, West +ve). Unchanged if observing
*         station could not be identified.
*     p = double * (Returned)
*         Geodetic latitude (radians, North +ve). Unchanged if observing
*         station could not be identified.
*     h = double * (Returned)
*         Height above sea level (metres). Unchanged if observing
*         station could not be identified.

*  Returned Value:
*     palObs = int
*         0 if an observing station was returned. -1 if no match was
*         found.

*  Description:
*     Station numbers, identifiers, names and other details are
*     subject to change and should not be hardwired into
*     application programs.
*
*     All characters in "c" up to the first space are
*     checked;  thus an abbreviated ID will return the parameters
*     for the first station in the list which matches the
*     abbreviation supplied, and no station in the list will ever
*     contain embedded spaces. "c" must not have leading spaces.
*
*     IMPORTANT -- BEWARE OF THE LONGITUDE SIGN CONVENTION.  The
*     longitude returned by palOBS (and SLA_OBS) is west-positive in accordance
*     with astronomical usage.  However, this sign convention is
*     left-handed and is the opposite of the one used by geographers;
*     elsewhere in PAL the preferable east-positive convention is
*     used.  In particular, note that for use in palAop, palAoppa
*     and palOap the sign of the longitude must be reversed.
*
*     Users are urged to inform the author of any improvements
*     they would like to see made.  For example:
*
*         typographical corrections
*         more accurate parameters
*         better station identifiers or names
*         additional stations


*  Authors:
*     PTW: Patrick T. Wallace
*     TIMJ: Tim Jenness (JAC, Hawaii)
*     {enter_new_authors_here}

*  Notes:
*     - Differs from the SLA interface in that the output short name
*       is not the same variable as the input short name. This simplifies
*       consting. Additionally the size of the output buffers are now
*       specified in the API and a status integer is returned.

*  History:
*     2012-03-06 (TIMJ):
*        Initial version containing entries from SLA/F as of 15 March 2002
*        with a 2008 tweak to the JCMT GPS position.
*        Adapted with permission from the Fortran SLALIB library.
*     2014-04-08 (TIMJ):
*        Add APEX and NANTEN2
*     {enter_further_changes_here}

*  Copyright:
*     Copyright (C) 2002 Rutherford Appleton Laboratory
*     Copyright (C) 2012 Science and Technology Facilities Council.
*     Copyright (C) 2014 Cornell University.
*     All Rights Reserved.

*  Licence:
*     This program is free software; you can redistribute it and/or
*     modify it under the terms of the GNU General Public License as
*     published by the Free Software Foundation; either version 3 of
*     the License, or (at your option) any later version.
*
*     This program is distributed in the hope that it will be
*     useful, but WITHOUT ANY WARRANTY; without even the implied
*     warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
*     PURPOSE. See the GNU General Public License for more details.
*
*     You should have received a copy of the GNU General Public License
*     along with this program; if not, write to the Free Software
*     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
*     MA 02110-1301, USA.

*  Bugs:
*     {note_any_bugs_here}
*-
*/

#if HAVE_CONFIG_H
#  include <config.h>
#endif

#ifdef HAVE_BSD_STRING_H
#include <bsd/string.h>
#endif

#include <string.h>

/* We prefer to use the starutil package. */
#if HAVE_STAR_UTIL_H
#include "star/util.h"
#else
/* This version is just a straight copy without putting ellipsis on the end. */
static void star__strellcpy( char * dest, const char * src, size_t size ) {
# if HAVE_STRLCPY
  strlcpy( dest, src, size );
# else
  strncpy( dest, src, size );
  dest[size-1] = '\0';
# endif
}

#define star_strellcpy(dest, src, size) star__strellcpy(dest, src, size)
#endif

#if HAVE__STRICMP || defined(_WIN32) || defined(_WIN64)
#define strcasecmp _stricmp
#endif

#include "pal.h"
#include "palmac.h"

/* Helper macros to convert degrees to radians in longitude and latitude */
#define WEST(ID,IAM,AS) PAL__DAS2R*((60.0*(60.0*(double)ID+(double)IAM))+(double)AS)
#define NORTH(ID,IAM,AS) WEST(ID,IAM,AS)
#define EAST(ID,IAM,AS) -1.0*WEST(ID,IAM,AS)
#define SOUTH(ID,IAM,AS) -1.0*WEST(ID,IAM,AS)

struct telData {
  double w;
  double p;
  double h;
  char shortname[11];
  char longname[41];
};


int palObs( size_t n, const char * c,
            char * ident, size_t identlen,
            char * name, size_t namelen,
            double * w, double * p, double * h ) {
  const struct telData telData[] = {
    /* AAT (Observer's Guide)                                            AAT */
    {
      EAST(149,3,57.91),
      SOUTH(31,16,37.34),
      1164E0,
      "AAT",
      "Anglo-Australian 3.9m Telescope"
    },
    /* WHT (Gemini, April 1987)                                       LPO4.2 */
    {
      WEST(17,52,53.9),
      NORTH(28,45,38.1),
      2332E0,
      "LPO4.2",
      "William Herschel 4.2m Telescope"
    },
    /* INT (Gemini, April 1987)                                       LPO2.5 */
    {
      WEST(17,52,39.5),
      NORTH(28,45,43.2),
      2336E0,
      "LPO2.5",
      "Isaac Newton 2.5m Telescope"
    },
    /* JKT (Gemini, April 1987)                                         LPO1 */
    {
      WEST(17,52,41.2),
      NORTH(28,45,39.9),
      2364E0,
      "LPO1",
      "Jacobus Kapteyn 1m Telescope"
    },
    /* Lick 120" (S.L.Allen, private communication, 2002)            LICK120 */
    {
      WEST(121,38,13.689),
      NORTH(37,20,34.931),
      1286E0,
      "LICK120",
      "Lick 120 inch"
    },
    /* MMT 6.5m conversion (MMT Observatory website)                     MMT */
    {
      WEST(110,53,4.4),
      NORTH(31,41,19.6),
      2608E0,
      "MMT",
      "MMT 6.5m, Mt Hopkins"
    },
    /* Victoria B.C. 1.85m (1984 Almanac)                              DAO72 */
    {
      WEST(123,25,1.18),
      NORTH(48,31,11.9),
      238E0,
      "DAO72",
      "DAO Victoria BC 1.85 metre"
    },
    /* Las Campanas (1983 Almanac)                                    DUPONT */
    {
      WEST(70,42,9.),
      SOUTH(29,0,11.),
      2280E0,
      "DUPONT",
      "Du Pont 2.5m Telescope, Las Campanas"
    },
    /* Mt Hopkins 1.5m (1983 Almanac)                               MTHOP1.5 */
    {
      WEST(110,52,39.00),
      NORTH(31,40,51.4),
      2344E0,
      "MTHOP1.5",
      "Mt Hopkins 1.5 metre"
    },
    /* Mt Stromlo 74" (1983 Almanac)                               STROMLO74 */
    {
      EAST(149,0,27.59),
      SOUTH(35,19,14.3),
      767E0,
      "STROMLO74",
      "Mount Stromlo 74 inch"
    },
    /* ANU 2.3m, SSO (Gary Hovey)                                     ANU2.3 */
    {
      EAST(149,3,40.3),
      SOUTH(31,16,24.1),
      1149E0,
      "ANU2.3",
      "Siding Spring 2.3 metre"
    },
    /* Greenbank 140' (1983 Almanac)                                 GBVA140 */
    {
      WEST(79,50,9.61),
      NORTH(38,26,15.4),
      881E0,
      "GBVA140",
      "Greenbank 140 foot"
    },
    /* Cerro Tololo 4m (1982 Almanac)                               TOLOLO4M */
    {
      WEST(70,48,53.6),
      SOUTH(30,9,57.8),
      2235E0,
      "TOLOLO4M",
      "Cerro Tololo 4 metre"
    },
    /* Cerro Tololo 1.5m (1982 Almanac)                           TOLOLO1.5M */
    {
      WEST(70,48,54.5),
      SOUTH(30,9,56.3),
      2225E0,
      "TOLOLO1.5M",
      "Cerro Tololo 1.5 metre"
    },
    /* Tidbinbilla 64m (1982 Almanac)                              TIDBINBLA */
    {
      EAST(148,58,48.20),
      SOUTH(35,24,14.3),
      670E0,
      "TIDBINBLA",
      "Tidbinbilla 64 metre"
    },
    /* Bloemfontein 1.52m (1981 Almanac)                              BLOEMF */
    {
      EAST(26,24,18.),
      SOUTH(29,2,18.),
      1387E0,
      "BLOEMF",
      "Bloemfontein 1.52 metre"
    },
    /* Bosque Alegre 1.54m (1981 Almanac)                         BOSQALEGRE */
    {
      WEST(64,32,48.0),
      SOUTH(31,35,53.),
      1250E0,
      "BOSQALEGRE",
      "Bosque Alegre 1.54 metre"
    },
    /* USNO 61" astrographic reflector, Flagstaff (1981 Almanac)   FLAGSTF61 */
    {
      WEST(111,44,23.6),
      NORTH(35,11,2.5),
      2316E0,
      "FLAGSTF61",
      "USNO 61 inch astrograph, Flagstaff"
    },
    /* Lowell 72" (1981 Almanac)                                    LOWELL72 */
    {
      WEST(111,32,9.3),
      NORTH(35,5,48.6),
      2198E0,
      "LOWELL72",
      "Perkins 72 inch, Lowell"
    },
    /* Harvard 1.55m (1981 Almanac)                                  HARVARD */
    {
      WEST(71,33,29.32),
      NORTH(42,30,19.0),
      185E0,
      "HARVARD",
      "Harvard College Observatory 1.55m"
    },
    /* Okayama 1.88m (1981 Almanac)                                  OKAYAMA */
    {
      EAST(133,35,47.29),
      NORTH(34,34,26.1),
      372E0,
      "OKAYAMA",
      "Okayama 1.88 metre"
    },
    /* Kitt Peak Mayall 4m (1981 Almanac)                            KPNO158 */
    {
      WEST(111,35,57.61),
      NORTH(31,57,50.3),
      2120E0,
      "KPNO158",
      "Kitt Peak 158 inch"
    },
    /* Kitt Peak 90 inch (1981 Almanac)                               KPNO90 */
    {
      WEST(111,35,58.24),
      NORTH(31,57,46.9),
      2071E0,
      "KPNO90",
      "Kitt Peak 90 inch"
    },
    /* Kitt Peak 84 inch (1981 Almanac)                               KPNO84 */
    {
      WEST(111,35,51.56),
      NORTH(31,57,29.2),
      2096E0,
      "KPNO84",
      "Kitt Peak 84 inch"
    },
    /* Kitt Peak 36 foot (1981 Almanac)                             KPNO36FT */
    {
      WEST(111,36,51.12),
      NORTH(31,57,12.1),
      1939E0,
      "KPNO36FT",
      "Kitt Peak 36 foot"
    },
    /* Kottamia 74" (1981 Almanac)                                  KOTTAMIA */
    {
      EAST(31,49,30.),
      NORTH(29,55,54.),
      476E0,
      "KOTTAMIA",
      "Kottamia 74 inch"
    },
    /* La Silla 3.6m (1981 Almanac)                                   ESO3.6 */
    {
      WEST(70,43,36.),
      SOUTH(29,15,36.),
      2428E0,
      "ESO3.6",
      "ESO 3.6 metre"
    },
    /* Mauna Kea 88 inch                                            MAUNAK88 */
    /* (IfA website, Richard Wainscoat) */
    {
      WEST(155,28,9.96),
      NORTH(19,49,22.77),
      4213.6E0,
      "MAUNAK88",
      "Mauna Kea 88 inch"
    },
    /* UKIRT (IfA website, Richard Wainscoat)                          UKIRT */
    {
      WEST(155,28,13.18),
      NORTH(19,49,20.75),
      4198.5E0,
      "UKIRT",
      "UK Infra Red Telescope"
    },
    /* Quebec 1.6m (1981 Almanac)                                  QUEBEC1.6 */
    {
      WEST(71,9,9.7),
      NORTH(45,27,20.6),
      1114E0,
      "QUEBEC1.6",
      "Quebec 1.6 metre"
    },
    /* Mt Ekar 1.82m (1981 Almanac)                                   MTEKAR */
    {
      EAST(11,34,15.),
      NORTH(45,50,48.),
      1365E0,
      "MTEKAR",
      "Mt Ekar 1.82 metre"
    },
    /* Mt Lemmon 60" (1981 Almanac)                               MTLEMMON60 */
    {
      WEST(110,42,16.9),
      NORTH(32,26,33.9),
      2790E0,
      "MTLEMMON60",
      "Mt Lemmon 60 inch"
    },
    /* Mt Locke 2.7m (1981 Almanac)                               MCDONLD2.7 */
    {
      WEST(104,1,17.60),
      NORTH(30,40,17.7),
      2075E0,
      "MCDONLD2.7",
      "McDonald 2.7 metre"
    },
    /* Mt Locke 2.1m (1981 Almanac)                               MCDONLD2.1 */
    {
      WEST(104,1,20.10),
      NORTH(30,40,17.7),
      2075E0,
      "MCDONLD2.1",
      "McDonald 2.1 metre"
    },
    /* Palomar 200" (1981 Almanac)                                PALOMAR200 */
    {
      WEST(116,51,50.),
      NORTH(33,21,22.),
      1706E0,
      "PALOMAR200",
      "Palomar 200 inch"
    },
    /* Palomar 60" (1981 Almanac)                                  PALOMAR60 */
    {
      WEST(116,51,31.),
      NORTH(33,20,56.),
      1706E0,
      "PALOMAR60",
      "Palomar 60 inch"
    },
    /* David Dunlap 74" (1981 Almanac)                              DUNLAP74 */
    {
      WEST(79,25,20.),
      NORTH(43,51,46.),
      244E0,
      "DUNLAP74",
      "David Dunlap 74 inch"
    },
    /* Haute Provence 1.93m (1981 Almanac)                         HPROV1.93 */
    {
      EAST(5,42,46.75),
      NORTH(43,55,53.3),
      665E0,
      "HPROV1.93",
      "Haute Provence 1.93 metre"
    },
    /* Haute Provence 1.52m (1981 Almanac)                         HPROV1.52 */
    {
      EAST(5,42,43.82),
      NORTH(43,56,0.2),
      667E0,
      "HPROV1.52",
      "Haute Provence 1.52 metre"
    },
    /* San Pedro Martir 83" (1981 Almanac)                           SANPM83 */
    {
      WEST(115,27,47.),
      NORTH(31,2,38.),
      2830E0,
      "SANPM83",
      "San Pedro Martir 83 inch"
    },
    /* Sutherland 74" (1981 Almanac)                                  SAAO74 */
    {
      EAST(20,48,44.3),
      SOUTH(32,22,43.4),
      1771E0,
      "SAAO74",
      "Sutherland 74 inch"
    },
    /* Tautenburg 2m (1981 Almanac)                                  TAUTNBG */
    {
      EAST(11,42,45.),
      NORTH(50,58,51.),
      331E0,
      "TAUTNBG",
      "Tautenburg 2 metre"
    },
    /* Catalina 61" (1981 Almanac)                                CATALINA61 */
    {
      WEST(110,43,55.1),
      NORTH(32,25,0.7),
      2510E0,
      "CATALINA61",
      "Catalina 61 inch"
    },
    /* Steward 90" (1981 Almanac)                                  STEWARD90 */
    {
      WEST(111,35,58.24),
      NORTH(31,57,46.9),
      2071E0,
      "STEWARD90",
      "Steward 90 inch"
    },
    /* Russian 6m (1981 Almanac)                                       USSR6 */
    {
      EAST(41,26,30.0),
      NORTH(43,39,12.),
      2100E0,
      "USSR6",
      "USSR 6 metre"
    },
    /* Arecibo 1000' (1981 Almanac)                                  ARECIBO */
    {
      WEST(66,45,11.1),
      NORTH(18,20,36.6),
      496E0,
      "ARECIBO",
      "Arecibo 1000 foot"
    },
    /* Cambridge 5km (1981 Almanac)                                  CAMB5KM */
    {
      EAST(0,2,37.23),
      NORTH(52,10,12.2),
      17E0,
      "CAMB5KM",
      "Cambridge 5km"
    },
    /* Cambridge 1 mile (1981 Almanac)                             CAMB1MILE */
    {
      EAST(0,2,21.64),
      NORTH(52,9,47.3),
      17E0,
      "CAMB1MILE",
      "Cambridge 1 mile"
    },
    /* Bonn 100m (1981 Almanac)                                   EFFELSBERG */
    {
      EAST(6,53,1.5),
      NORTH(50,31,28.6),
      366E0,
      "EFFELSBERG",
      "Effelsberg 100 metre"
    },
    /* Greenbank 300' (1981 Almanac)                        GBVA300 (R.I.P.) */
    {
      WEST(79,50,56.36),
      NORTH(38,25,46.3),
      894E0,
      "(R.I.P.)",
      "Greenbank 300 foot"
    },
    /* Jodrell Bank Mk 1 (1981 Almanac)                             JODRELL1 */
    {
      WEST(2,18,25.),
      NORTH(53,14,10.5),
      78E0,
      "JODRELL1",
      "Jodrell Bank 250 foot"
    },
    /* Australia Telescope Parkes Observatory                         PARKES */
    /* (Peter te Lintel Hekkert) */
    {
      EAST(148,15,44.3591),
      SOUTH(32,59,59.8657),
      391.79E0,
      "PARKES",
      "Parkes 64 metre"
    },
    /* VLA (1981 Almanac)                                                VLA */
    {
      WEST(107,37,3.82),
      NORTH(34,4,43.5),
      2124E0,
      "VLA",
      "Very Large Array"
    },
    /* Sugar Grove 150' (1981 Almanac)                            SUGARGROVE */
    {
      WEST(79,16,23.),
      NORTH(38,31,14.),
      705E0,
      "SUGARGROVE",
      "Sugar Grove 150 foot"
    },
    /* Russian 600' (1981 Almanac)                                   USSR600 */
    {
      EAST(41,35,25.5),
      NORTH(43,49,32.),
      973E0,
      "USSR600",
      "USSR 600 foot"
    },
    /* Nobeyama 45 metre mm dish (based on 1981 Almanac entry)      NOBEYAMA */
    {
      EAST(138,29,12.),
      NORTH(35,56,19.),
      1350E0,
      "NOBEYAMA",
      "Nobeyama 45 metre"
    },
    /* James Clerk Maxwell 15 metre mm telescope, Mauna Kea             JCMT */
    /* From GPS measurements on 11Apr2007 for eSMA setup (R. Tilanus) */
    {
      WEST(155,28,37.30),
      NORTH(19,49,22.22),
      4124.75E0,
      "JCMT",
      "JCMT 15 metre"
    },
    /* ESO 3.5 metre NTT, La Silla (K.Wirenstrand)                    ESONTT */
    {
      WEST(70,43,7.),
      SOUTH(29,15,30.),
      2377E0,
      "ESONTT",
      "ESO 3.5 metre NTT"
    },
    /* St Andrews University Observatory (1982 Almanac)           ST.ANDREWS */
    {
      WEST(2,48,52.5),
      NORTH(56,20,12.),
      30E0,
      "ST.ANDREWS",
      "St Andrews"
    },
    /* Apache Point 3.5 metre (R.Owen)                                APO3.5 */
    {
      WEST(105,49,11.56),
      NORTH(32,46,48.96),
      2809E0,
      "APO3.5",
      "Apache Point 3.5m"
    },
    /* W.M.Keck Observatory, Telescope 1                               KECK1 */
    /* (William Lupton) */
    {
      WEST(155,28,28.99),
      NORTH(19,49,33.41),
      4160E0,
      "KECK1",
      "Keck 10m Telescope #1"
    },
    /* Tautenberg Schmidt (1983 Almanac)                            TAUTSCHM */
    {
      EAST(11,42,45.0),
      NORTH(50,58,51.0),
      331E0,
      "TAUTSCHM",
      "Tautenberg 1.34 metre Schmidt"
    },
    /* Palomar Schmidt (1981 Almanac)                              PALOMAR48 */
    {
      WEST(116,51,32.0),
      NORTH(33,21,26.0),
      1706E0,
      "PALOMAR48",
      "Palomar 48-inch Schmidt"
    },
    /* UK Schmidt, Siding Spring (1983 Almanac)                         UKST */
    {
      EAST(149,4,12.8),
      SOUTH(31,16,27.8),
      1145E0,
      "UKST",
      "UK 1.2 metre Schmidt, Siding Spring"
    },
    /* Kiso Schmidt, Japan (1981 Almanac)                               KISO */
    {
      EAST(137,37,42.2),
      NORTH(35,47,38.7),
      1130E0,
      "KISO",
      "Kiso 1.05 metre Schmidt, Japan"
    },
    /* ESO Schmidt, La Silla (1981 Almanac)                          ESOSCHM */
    {
      WEST(70,43,46.5),
      SOUTH(29,15,25.8),
      2347E0,
      "ESOSCHM",
      "ESO 1 metre Schmidt, La Silla"
    },
    /* Australia Telescope Compact Array                                ATCA */
    /* (WGS84 coordinates of Station 35, Mark Calabretta) */
    {
      EAST(149,33,0.500),
      SOUTH(30,18,46.385),
      236.9E0,
      "ATCA",
      "Australia Telescope Compact Array"
    },
    /* Australia Telescope Mopra Observatory                           MOPRA */
    /* (Peter te Lintel Hekkert) */
    {
      EAST(149,5,58.732),
      SOUTH(31,16,4.451),
      850E0,
      "MOPRA",
      "ATNF Mopra Observatory"
    },
    /* Subaru telescope, Mauna Kea                                     SUBARU */
    /* (IfA website, Richard Wainscoat) */
    {
      WEST(155,28,33.67),
      NORTH(19,49,31.81),
      4163E0,
      "SUBARU",
      "Subaru 8m telescope"
    },
    /* Canada-France-Hawaii Telescope, Mauna Kea                         CFHT */
    /* (IfA website, Richard Wainscoat) */
    {
      WEST(155,28,7.95),
      NORTH(19,49,30.91),
      4204.1E0,
      "CFHT",
      "Canada-France-Hawaii 3.6m Telescope"
    },
    /* W.M.Keck Observatory, Telescope 2                                KECK2 */
    /* (William Lupton) */
    {
      WEST(155,28,27.24),
      NORTH(19,49,35.62),
      4159.6E0,
      "KECK2",
      "Keck 10m Telescope #2"
    },
    /* Gemini North, Mauna Kea                                        GEMININ */
    /* (IfA website, Richard Wainscoat) */
    {
      WEST(155,28,8.57),
      NORTH(19,49,25.69),
      4213.4E0,
      "GEMININ",
      "Gemini North 8-m telescope"
    },
    /* Five College Radio Astronomy Observatory                        FCRAO */
    /* (Tim Jenness) */
    {
      WEST(72,20,42.0),
      NORTH(42,23,30.0),
      314E0,
      "FCRAO",
      "Five College Radio Astronomy Obs"
    },
    /* NASA Infra Red Telescope Facility                                IRTF */
    /* (IfA website, Richard Wainscoat) */
    {
      WEST(155,28,19.20),
      NORTH(19,49,34.39),
      4168.1E0,
      "IRTF",
      "NASA IR Telescope Facility, Mauna Kea"
    },
    /* Caltech Submillimeter Observatory                                 CSO */
    /* (IfA website, Richard Wainscoat; height estimated) */
    {
      WEST(155,28,31.79),
      NORTH(19,49,20.78),
      4080E0,
      "CSO",
      "Caltech Sub-mm Observatory, Mauna Kea"
    },
    /* ESO VLT, UT1                                                       VLT1 */
    /* (ESO website, VLT Whitebook Chapter 2) */
    {
      WEST(70,24,11.642),
      SOUTH(24,37,33.117),
      2635.43,
      "VLT1",
      "ESO VLT, Paranal, Chile: UT1"
    },
    /* ESO VLT, UT2                                                       VLT2 */
    /* (ESO website, VLT Whitebook Chapter 2) */
    {
      WEST(70,24,10.855),
      SOUTH(24,37,31.465),
      2635.43,
      "VLT2",
      "ESO VLT, Paranal, Chile: UT2"
    },
    /* ESO VLT, UT3                                                       VLT3 */
    /* (ESO website, VLT Whitebook Chapter 2) */
    {
      WEST(70,24,9.896),
      SOUTH(24,37,30.300),
      2635.43,
      "VLT3",
      "ESO VLT, Paranal, Chile: UT3"
    },
    /* ESO VLT, UT4                                                       VLT4 */
    /* (ESO website, VLT Whitebook Chapter 2) */
    {
      WEST(70,24,8.000),
      SOUTH(24,37,31.000),
      2635.43,
      "VLT4",
      "ESO VLT, Paranal, Chile: UT4"
    },
    /* Gemini South, Cerro Pachon                                     GEMINIS */
    /* (GPS readings by Patrick Wallace) */
    {
      WEST(70,44,11.5),
      SOUTH(30,14,26.7),
      2738E0,
      "GEMINIS",
      "Gemini South 8-m telescope"
    },
    /* Cologne Observatory for Submillimeter Astronomy (KOSMA)        KOSMA3M */
    /* (Holger Jakob) */
    {
      EAST(7,47,3.48),
      NORTH(45,58,59.772),
      3141E0,
      "KOSMA3M",
      "KOSMA 3m telescope, Gornergrat"
    },
    /* Magellan 1, 6.5m telescope at Las Campanas, Chile            MAGELLAN1 */
    /* (Skip Schaller) */
    {
      WEST(70,41,31.9),
      SOUTH(29,0,51.7),
      2408E0,
      "MAGELLAN1",
      "Magellan 1, 6.5m, Las Campanas"
    },
    /* Magellan 2, 6.5m telescope at Las Campanas, Chile            MAGELLAN2 */
    /* (Skip Schaller) */
    {
      WEST(70,41,33.5),
      SOUTH(29,0,50.3),
      2408E0,
      "MAGELLAN2",
      "Magellan 2, 6.5m, Las Campanas"
    },
    /* APEX - Atacama Pathfinder EXperiment, Llano de Chajnantor    APEX */
    /* (APEX web site) */
    {
      WEST(67,45,33.0),
      SOUTH(23,0,20.8),
      5105E0,
      "APEX",
      "APEX 12m telescope, Llano de Chajnantor"
    },
    /* NANTEN2 Submillimeter Observatory, 4m telescope Atacame desert NANTEN2 */
    /* (NANTEN2 web site) */
    {
      WEST(67,42,8.0),
      SOUTH(22,57,47.0),
      4865E0,
      "NANTEN2",
      "NANTEN2 4m telescope, Pampa la Bola"
    }
  };

  int retval = -1;    /* Return status. 0 if found. -1 if no match */

  /* Work out the number of telescopes */
  const size_t NTEL = sizeof(telData) / sizeof(struct telData);

  /* Prefill the return buffer in a pessimistic manner */
  star_strellcpy( name, "?", namelen );

  if (n > 0) {
    if (n <= NTEL) {
      /* Index into telData with correction for zero-based indexing */
      struct telData thistel;
      thistel = telData[n-1];
      *w = thistel.w;
      *p = thistel.p;
      *h = thistel.h;
      star_strellcpy( ident, thistel.shortname, identlen );
      star_strellcpy( name, thistel.longname, namelen );
      retval = 0;
    }

  } else {
    /* Searching */
    size_t i;
    for (i=0; i<NTEL; i++) {
      struct telData thistel = telData[i];
      if (strcasecmp( c, thistel.shortname) == 0) {
        /* a match */
        *w = thistel.w;
        *p = thistel.p;
        *h = thistel.h;
        star_strellcpy( ident, thistel.shortname, identlen );
        star_strellcpy( name, thistel.longname, namelen );
        retval = 0;
        break;
      }
    }

  }

  return retval;

}