-
Notifications
You must be signed in to change notification settings - Fork 59
/
gsdac_putFits.c
1139 lines (831 loc) · 37.5 KB
/
gsdac_putFits.c
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
/*
*+
* Name:
* gsdac_putFits.c
* Purpose:
* Retrieve values from the GSD headers to fill the FITS headers
* in the ACSIS file.
* Language:
* Starlink ANSI C
* Type of Module:
* Subroutine
* Invocation:
* gsdac_putFits ( const gsdVars *gsdVars, const int subBandNum,
* const int nSubsys, const int obsNum,
* const int utDate, const int nSteps,
* const char *backend, const int recepsUsed,
* char *recepNames[], const char *samMode,
* const char *obsType, const dateVars *dateVars,
* const mapVars *mapVars, const double *lineFreqs,
* const double *IFFreqs, const gsdWCS *wcs,
* AstFitsChan *fitschan, int *status )
* Arguments:
* gsdVars = const gsdVars* (Given)
* GSD file access parameters.
* subBandNum = const int (Given)
* Subband number.
* nSubsys = const int (Given)
* Number of subsystems.
* obsNum = const int (Given)
* Observation number.
* utDate = const int (Given)
* UT observation date.
* nSteps = const int (Given)
* Number of time steps in observation.
* backend = const char* (Given)
* Name of the backend.
* recepsUsed = const int (Given)
* Number of receptors actually used.
* recepnames = char*[] (Given)
* Names of receptors.
* samMode = const char* (Given)
* Sample mode.
* obsType = const char* (Given)
* Observation type.
* dateVars = const dateVars* (Given)
* Date and time variables.
* mapVars = const mapVars* (Given)
* Map/Chop/Scan variables.
* lineFreqs = const double* (Given)
* Frequencies for line transitions for each subband.
* IFFreqs = const double* (Given)
* IFs for each subband.
* wcs = const *gsdWCS (Given)
* pointing and time values
* fitschan = AstFitsChan* (Given and Returned)
* FITS headers.
* status = int* (Given and Returned)
* Pointer to global status.
* Description:
* This routine fills the AstFitsChan with the values retrieved
* from the GSD headers.
* Authors:
* J.Balfour (UBC)
* Tim Jenness (JAC)
* V.Tilanus (JAC)
* MJC: Malcolm J. Currie (JAC)
* {enter_new_authors_here}
* History :
* 2008-02-04 (JB):
* Original.
* 2008-02-14 (JB):
* Use gsdVars struct to store headers/arrays.
* 2008-02-19 (JB):
* Pass in gsdWCS struct instead of JCMTState.
* 2008-02-21 (JB):
* Fix integration time calculation.
* 2008-02-28 (JB):
* Replace subsysNum with subBandNum.
* 2008-02-28 (JB):
* Move getDateVars and getMapVars to wrtData.
* 2008-03-04 (JB):
* Use number of scans actually completed.
* 2008-03-06 (JB):
* Save calculation of am, az, el start/end till after
* all spectra completed.
* 2008-03-07 (JB):
* Use IFFreq of 4.0, and set refChan as offset channel.
* 2008-03-19 (JB):
* Removed unused variables.
* 2008-03-24 (JB):
* Calculate intTime and nMix.
* 2008-03-28 (JB):
* Find molecule and transition using LUT.
* 2008-03-31 (JB):
* Call smf_get_moltrans to get transition info.
* 2008-04-02 (JB):
* Fixed typo in OBSIDSS.
* 2008-04-03 (JB):
* Fix pressure and steptime.
* 2008-04-11 (JB):
* Remove wcs argument (not needed).
* 2008-04-11 (JB):
* Add NCHNSUBS FITS header.
* 2008-04-14 (JB):
* Add a few missing FITS headers.
* 2008-04-16 (JB):
* Calculate OBSGEO values from -OBS values.
* 2008-04-18 (JB):
* For special configs use centreFreq for moltrans.
* 2008-04-22 (JB):
* Add BUNIT header for compatability with specwrite.
* 2008-04-23 (JB):
* Use frequencies from matchFreqs for refchan/IF.
* 2008-04-25 (JB):
* INSTAP_X = INSTAP_Y = 0.0.
* 2008-04-30 (JB):
* Correct FFT_WIN and BEDEFAC.
* 2008-06-24 (TIMJ):
* Fix compiler warnings.
* 2008-12-02 (DSB):
* Use astSetFitsU to set undefined values.
* 2009-07-08 (TIMJ):
* Use astSetFitsCM instead of astSetFitsCN
* 2010-07-01 (VT):
* Use ACSIS oberving mode.
* Fix (mainly) JOS FITS headers
* 2010-07-22 (VT):
* Added SPECID FITS header.
* 2012-01-26 (TIMJ):
* Reinstate WCS arg for BASE position
* 2013 May 25 (MJC):
* Select different data-reduction recipes for pointings, planets,
* and galaxies.
* 2013 May 28 (MJC):
* Add additional continuum-recipe objects.
* 2013 June 7 (MJC):
* Add focus recipe.
* 2013-07-28 (TIMJ):
* Use frontend translation routine to get real instrument name.
* Do not assume that "RXB" always has 2 receptors.
* 2013-07-30 (TIMJ):
* Trap bad seeing and tau values so that they can be correctly
* stored as undef FITS headers.
* Copyright:
* Copyright (C) 2008-2013 Science and Technology Facilities Council.
* 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:
*-
*/
/* Standard includes */
#include <string.h>
#include <strings.h>
#include <ctype.h>
/* Starlink includes */
#include "sae_par.h"
#include "mers.h"
#include "cnf.h"
/* SMURF includes */
#include "smurf_par.h"
#include "libsmf/smf.h"
#include "gsdac.h"
#include "gsdac_standard_sources.h"
#define FUNC_NAME "gsdac_putFits"
void gsdac_putFits ( const gsdVars *gsdVars, const int subBandNum,
const int nSubsys, const int obsNum,
const int utDate, const int nSteps,
const char *backend, const int recepsUsed,
char *recepNames[], const char *samMode,
const char *obsType, const dateVars *dateVars,
const mapVars *mapVars, const double *lineFreqs,
const double *IFFreqs, const gsdWCS *wcs,
AstFitsChan *fitschan, int *status )
{
/* Local variables */
char bwMode[SZFITSTR]; /* ACSIS total bandwidth setup */
char curChar; /* character pointer */
int day; /* days for time conversion. */
char doppler[SZFITSTR]; /* doppler velocity definition */
double etal; /* telescope efficiency */
int hour; /* hours for time conversion. */
int i; /* loop counter */
float IFchanSp; /* TOPO IF channel spacing (Hz) */
char instrume[SZFITSTR]; /* front-end receiver */
double intTime; /* total time spent integrating (s) */
int josMult; /* times around the jiggle (i.e. 1) */
int josMin; /* minimum step time psw */
int min; /* minutes for time conversion. */
const char *molecule; /* target molecular species */
int month; /* months for time conversion. */
int nMix; /* number of mixers */
double nRefStep; /* number of nod sets repeated */
char object[SZFITSTR]; /* object of interest */
char object2[SZFITSTR]; /* object of interest (second half of name) */
double obsgeo[3]; /* cartesian coordinates of telescope */
char obsIDSS[SZFITSTR]; /* unique observation number + subsystem
number in format
INSTR_NNNNN_YYYYMMDDTHHMMSS_N */
char obsSB[SZFITSTR]; /* observed sideband */
int parse; /* flag for incorrect date string. */
char recipe[25]; /* ORAC-DR recipe name */
char recptors[SZFITSTR]; /* active FE receptor IDs for this obs */
double refChan; /* reference IF channel no. */
int seeingok; /* True if the seeing measurement is okay */
char seeDatSt[SZFITSTR]; /* time of seeingSt in format
YYYY-MM-DDTHH:MM:SS */
char sSysObs[SZFITSTR]; /* spectral ref. frame during observation */
int standard; /* true for spectral line standards */
int startIdx; /* index in pattern at start of observation */
int stBetRef; /* max number of steps between refs */
int stBetRef_defined; /* Use the stBetRef value? */
double stepTime; /* RTS step time */
char subBands[SZFITSTR]; /* ACSIS sub-band set-up */
int tauok; /* True if the tau measurement is okay */
char tauDatSt[SZFITSTR]; /* time of tau225St observation in
format YYYY-MM-DDTHH:MM:SS */
const char *transiti; /* target transition for molecule */
int year; /* year for time conversion. */
/* Check inherited status */
if ( *status != SAI__OK ) return;
/* Get the cartesian coordinates of the telescope's location. */
smf_terr( gsdVars->telLatitude * DD2R, gsdVars->telHeight * 1000.0,
-gsdVars->telLongitude * DD2R, obsgeo );
/* Get the telescope efficiency and convert from percentage to decimal */
etal = gsdVars->etal / 100.0;
/* Obs Id, Date, Pointing Info */
/* Truncate the object names and concatenate. */
cnfImprt ( gsdVars->object1, 16, object );
if ( strncmp ( gsdVars->object2, " ", 1 ) != 0 ) {
cnfImprt ( gsdVars->object2, 16, object2 );
strcat ( object, ", " );
strcat ( object, object2 );
}
/* Determine if this is a spectral line standard. */
/* Loop through the array of standards and see if the object matches
one of them. */
standard = 0;
i = 0;
while ( strcmp ( standards[i], "" ) != 0 ) {
if ( strcmp ( object, standards[i] ) == 0 ) {
standard = 1;
}
i++;
}
/* Copy the obsID into the obsIDSS and add the subsystem number. */
sprintf ( obsIDSS, "%s_%i", dateVars->obsID,
subBandNum % nSubsys + 1 );
/* Integration time related. */
/* Get the sum of the integration times. This is either the
sum of the elements of the intTimes table for grids, or
the scan time times the number of scans for rasters. */
if ( gsdVars->obsContinuous ) {
intTime = gsdVars->scanTime * gsdVars->nScan;
} else {
intTime = gsdVars->nCycle * gsdVars->cycleTime;
}
/* ACSIS Specific. */
/* Get the molecule and transition. */
smf_get_moltrans ( lineFreqs[subBandNum] * 1000.0, &molecule, &transiti,
status );
/* Get the bandwidth setup. */
/***** NOTE: may be different for rxb widebands *****/
sprintf ( bwMode, "%iMHzx%i", (int)(gsdVars->bandwidths[subBandNum]),
gsdVars->BEChans[subBandNum] );
/***** NOTE: Possibly undef? *****/
strcpy ( subBands, bwMode );
/* Get the reference channel (offset from channel which contains
IFFreq). */
refChan = ( (double)( gsdVars->BEChans[subBandNum] ) / 2.0 ) +
( ( IFFreqs[subBandNum] - gsdVars->totIFs[subBandNum] ) /
( fabs(gsdVars->freqRes[subBandNum]) / 1000.0 ) );
IFchanSp = gsdVars->freqRes[subBandNum] * 1000000.0;
strcpy( recipe, "REDUCE_SCIENCE" );
/* Is this a pointing? */
if ( strncasecmp( gsdVars->backend, "DAS", 3 ) == 0 &&
strncasecmp( gsdVars->obsType, "FIVEPOINT", 9 ) == 0 )
strcpy( recipe, "REDUCE_POINTING" );
else if ( strncasecmp( gsdVars->obsType, "focus", 5 ) == 0 )
strcpy( recipe, "REDUCE_FOCUS" );
/* Solar-system objects have a different default recipe. */
else if ( strncasecmp( gsdVars->object1, "SUN", 3 ) == 0 ||
strncasecmp( gsdVars->object1, "MERCURY", 7 ) == 0 ||
strncasecmp( gsdVars->object1, "VENUS", 5 ) == 0 ||
strncasecmp( gsdVars->object1, "MOON", 4 ) == 0 ||
strncasecmp( gsdVars->object1, "MARS", 4 ) == 0 ||
strncasecmp( gsdVars->object1, "JUPITER", 7 ) == 0 ||
strncasecmp( gsdVars->object1, "SATURN", 6 ) == 0 ||
strncasecmp( gsdVars->object1, "TITAN", 5 ) == 0 ||
strncasecmp( gsdVars->object1, "URANUS", 6 ) == 0 ||
strncasecmp( gsdVars->object1, "NEPTUNE", 7 ) == 0 ||
strncasecmp( gsdVars->object1, "PLUTO", 5 ) == 0 )
strcpy( recipe, "REDUCE_SCIENCE_CONTINUUM" );
/* Try to catch most galaxies but exclude regions of the Galaxy. */
else if ( gsdVars->velocity > 120 )
strcpy( recipe, "REDUCE_SCIENCE_BROADLINE" );
else if ( strncmp( mapVars->swMode, "freq", 4 ) == 0 )
strcpy( recipe, "REDUCE_SCIENCE_FSW" );
/* FE Specific. */
/* We need to take the opportunity to correct the frontend name.
In many cases, especially in B-band, the instrument names are
incorrect. */
gsdac_getRealInstrumentName( gsdVars, instrume, sizeof(instrume), status );
/* Get the number of mixers, 2 for RXB3 & RXW, 1 for others.
but note that RXB3I has 1. We know that instrume is nul-terminated.
Both RXWC and RXWD have two mixers so just check first 3 characters.
*/
if ( strcmp ( "RXB3", instrume ) == 0 ||
strncmp ( "RXW", instrume, 3 ) == 0 ) {
nMix = 2;
} else {
nMix = 1;
}
/* Get the observed sideband (-ve value = LSB, +ve value = USB ). */
if ( gsdVars->sbSigns[subBandNum] > 0 ) strcpy ( obsSB, "USB" );
else strcpy ( obsSB, "LSB" );
/* Get the names of the receptors. */
strcpy ( recptors, recepNames[0] );
for ( i = 1; i < recepsUsed; i++ ) {
strcat ( recptors, " " );
strcat ( recptors, recepNames[i] );
}
/* Truncate the doppler velocity definition and set
to lowercase. */
cnfImprt ( gsdVars->velDefn, 16, doppler );
i = 0;
curChar = doppler[i];
while ( curChar != '\0' ) {
doppler[i] = tolower(curChar);
i++;
curChar = doppler[i];
}
/***** NOTE : Possibly comes from VEL_REF (c12vref). */
strcpy ( sSysObs, "TOPOCENT" );
/* Environmental data. */
/* The GSD magic value for bad seeing and tau seems to be VAL__BADR */
tauDatSt[0] = '\0'; /* make sure it is initialised */
if (gsdVars->tau225 == VAL__BADR) {
tauok = 0;
} else {
tauok = 1;
/* Convert dates from YYMMDDHHMMSS to
YYYY-MM-DDTHH:MM:SS. */
parse = sscanf ( gsdVars->tauTime, "%02d%02d%02d%02d%02d", &year,
&month, &day, &hour, &min );
if ( parse == 0 || parse == EOF ) {
msgOutf ( FUNC_NAME, "Couldn't convert CSO tau time of '%s', continuing anyway.",
status, gsdVars->tauTime );
} else {
/* Inelegant method to get YYYY from YY. */
if ( year > 70 ) year = year + 1900;
else year = year + 2000;
sprintf ( tauDatSt, "%04d-%02d-%02dT%02d:%02d:00",
year, month, day, hour, min );
}
}
/* The GSD magic value for bad seeing and tau seems to be VAL__BADR */
seeDatSt[0] = '\0'; /* Make sure it is initialised */
if (gsdVars->seeing == VAL__BADR) {
seeingok = 0;
} else {
seeingok = 1;
/* Convert dates from YYMMDDHHMMSS to
YYYY-MM-DDTHH:MM:SS. */
parse = sscanf ( gsdVars->seeTime, "%02d%02d%02d%02d%02d", &year,
&month, &day, &hour, &min );
if ( parse == 0 || parse == EOF ) {
msgOutiff(MSG__VERB," ",
"Couldn't convert seeing time of '%s', continuing anyway.", status,
gsdVars->seeTime );
} else {
/* Kludge to get YYYY from YY. */
if ( year > 70 ) year = year + 1900;
else year = year + 2000;
sprintf ( seeDatSt, "%04d-%02d-%02dT%02d:%02d:00",
year, month, day, hour, min );
}
}
/* JOS parameters */
/* STEPTIME is SCAN_TIME divided by the number of points in a scan
for rasters. For PSW spectra it is SCAN_TIME/2 and for BSW
it is SCAN_TIME/4 -- because acsis expects a minimum unit
of ABBA for the nod --*/
if ( strcmp ( samMode, "scan" ) == 0 ) {
if ( strncmp ( gsdVars->obsDirection, "HORIZONTAL", 10 ) == 0 ) {
stepTime = gsdVars->scanTime / gsdVars->nMapPtsX;
} else {
stepTime = gsdVars->scanTime / gsdVars->nMapPtsY;
}
josMin = 1;
josMult = 0;
} else if ( strcmp ( mapVars->swMode, "chop" ) == 0 ) {
stepTime = gsdVars->scanTime / 4.0;
josMin = 0;
josMult = 1;
} else {
stepTime = gsdVars->scanTime / 2.0;
josMin = stepTime;
josMult = 0;
}
/* Get the length of time in the reference, and the number
of steps between references. set up defaults first to avoid compiler
warnings. */
nRefStep = 1;
stBetRef = 1;
if ( gsdVars->obsContinuous ) {
/* For rasters, determine the number of time scanning
each point in one row from the total time for
the row / number of points in the row. The length
of time in the reference is then sqrt (number of
points in the row) * (time per point). */
nRefStep = sqrt ( (double)(gsdVars->nScanPts) ) *
( (double)(gsdVars->scanTime) / (double)(gsdVars->nScanPts) );
stBetRef = gsdVars->nScanPts;
}
/* Set a flag indicating if the stBetRef value is defined. */
stBetRef_defined = ( strcmp ( mapVars->swMode, "chop" ) != 0 );
/* Get the starting index into the pattern. */
gsdac_getStartIdx ( gsdVars, samMode, &startIdx, status );
/************************************/
/* WRITE OUT FITS HEADERS */
/************************************/
astSetFitsS ( fitschan, "TELESCOP", gsdVars->telName,
"Name of Telescope", 0 );
astSetFitsS ( fitschan, "ORIGIN", "Joint Astronomy Centre, Hilo",
"Origin of file", 0 );
astSetFitsF ( fitschan, "ALT-OBS", gsdVars->telHeight * 1000.0,
"[m] Height of observation above sea level", 0 );
astSetFitsF ( fitschan, "LAT-OBS", gsdVars->telLatitude,
"[deg] Latitude of Observatory", 0 );
astSetFitsF ( fitschan, "LONG-OBS", -(gsdVars->telLongitude),
"[deg] East longitude of Observatory", 0 );
astSetFitsF ( fitschan, "OBSGEO-X", obsgeo[0],
"[m]", 0 );
astSetFitsF ( fitschan, "OBSGEO-Y", obsgeo[1],
"[m]", 0 );
astSetFitsF ( fitschan, "OBSGEO-Z", obsgeo[2],
"[m]", 0 );
astSetFitsF ( fitschan, "ETAL", etal,
"Telescope efficiency", 0 );
/* OMP and ORAC-DR Specific */
astSetFitsCM ( fitschan,
"---- OMP and ORAC-DR Specific ----", 0 );
astSetFitsS ( fitschan, "PROJECT", gsdVars->project,
"PATT number", 0 );
/***** NOTE: possibly REDUCE_POINTING for spectral 5 points *****/
astSetFitsS ( fitschan, "RECIPE", recipe, "ORAC-DR recipe", 0 );
astSetFitsU ( fitschan, "DRGROUP", "Data Reduction group ID", 0 );
astSetFitsU ( fitschan, "MSBID", "ID of minimum schedulable block", 0 );
astSetFitsU ( fitschan, "MSBTID", "Transaction ID of MSB", 0 );
astSetFitsU ( fitschan, "SURVEY", "Survey Name", 0 );
astSetFitsU ( fitschan, "RMTAGENT", "name of Remote Agent", 0 );
astSetFitsU ( fitschan, "AGENTID", "Unique identifier for remote agent", 0 );
/* Obs Id, Date, Pointing Info */
astSetFitsCM ( fitschan,
"---- Obs Id, Date, pointing Info ----", 0 );
astSetFitsS ( fitschan, "OBJECT", object,
"Object of interest", 0 );
astSetFitsL ( fitschan, "STANDARD", standard,
"True if the spectral line is a standard", 0 );
astSetFitsI ( fitschan, "OBSNUM", obsNum,
"Observation number", 0 );
astSetFitsI ( fitschan, "NSUBSCAN", 1,
"Sub-scan number", 0 );
astSetFitsL ( fitschan, "OBSEND", 1,
"True if the file is the last in current observation", 0 );
astSetFitsI ( fitschan, "UTDATE", utDate,
"UT Date as integer in yyyymmdd format", 0 );
astSetFitsS ( fitschan, "DATE-OBS", dateVars->dateObs,
"UTC Datetime of start of observation", 0 );
astSetFitsS ( fitschan, "DATE-END", dateVars->dateEnd,
"UTC Datetime of end of observation", 0 );
astSetFitsF ( fitschan, "DUT1", gsdVars->obsUT1C,
"[d] UT1-UTC correction", 0 );
astSetFitsS ( fitschan, "OBSID", dateVars->obsID,
"Unique observation identifier", 0 );
astSetFitsS ( fitschan, "OBSIDSS", obsIDSS,
"Unique observation + subsystem ID", 0 );
/***** NOTE: possibly same as REFRECEP *****/
astSetFitsU ( fitschan, "INSTAP", "Receptor at tracking centre (if any)", 0 );
astSetFitsF ( fitschan, "INSTAP_X", 0.0,
"[arcsec] Aperture X off. rel. to instr centre", 0 );
astSetFitsF ( fitschan, "INSTAP_Y", 0.0,
"[arcsec] Aperture Y off. rel. to instr centre", 0 );
/* The following 6 cards are just placeholders and will be
updated later. */
astSetFitsU ( fitschan, "AMSTART", "Airmass at start of observation", 0 );
astSetFitsU ( fitschan, "AMEND", "Airmass at end of observation", 0 );
astSetFitsU ( fitschan, "AZSTART", "[deg] Azimuth at start of observation", 0 );
astSetFitsU ( fitschan, "AZEND", "[deg] Azimuth at end of observation", 0 );
astSetFitsU ( fitschan, "ELSTART", "[deg] Elevation at start of observation", 0 );
astSetFitsU ( fitschan, "ELEND", "[deg] Elevation at end of observation", 0 );
/* Base position in tracking coordinates */
astSetFitsS( fitschan, "TRACKSYS", gsdac_code2tcssys(gsdVars->centreCode, status),
"TCS tracking coordinate system", 0 );
astSetFitsF ( fitschan, "BASEC1", wcs->baseTr1 * AST__DR2D,
"[deg] TCS BASE position (longitude) in TRACKSYS", 0 );
astSetFitsF ( fitschan, "BASEC2", wcs->baseTr2 * AST__DR2D,
"[deg] TCS BASE position (latitude) in TRACKSYS", 0 );
astSetFitsS ( fitschan, "HSTSTART", dateVars->HSTstart,
"HST at start of observation", 0 );
astSetFitsS ( fitschan, "HSTEND", dateVars->HSTend,
"HST at end of observation", 0 );
astSetFitsS ( fitschan, "LSTSTART", dateVars->LSTstart,
"LST at start of observation", 0 );
astSetFitsS ( fitschan, "LSTEND", dateVars->LSTend,
"LST at end of observation", 0 );
/* Integration time related. */
astSetFitsCM ( fitschan,
"---- Integration time related ----", 0 );
astSetFitsF ( fitschan, "INT_TIME", intTime,
"Time spent integrating, entire", 0 );
/* DAS Specific */
astSetFitsCM ( fitschan,
"---- DAS Specific ----", 0 );
astSetFitsI ( fitschan, "SPECID", gsdVars->BESubsys[subBandNum],
"Spectrum ID for this subband", 0 );
/* ACSIS Specific. */
astSetFitsCM ( fitschan,
"---- ACSIS Specific ----", 0 );
astSetFitsS ( fitschan, "BACKEND", backend,
"Name of the backend", 0 );
astSetFitsS ( fitschan, "MOLECULE", molecule,
"Target molecular species", 0 );
astSetFitsS ( fitschan, "TRANSITI", transiti,
"Target transition for MOLECULE", 0 );
astSetFitsU ( fitschan, "DRRECIPE", "ACSIS-DR recipe name", 0 );
astSetFitsS ( fitschan, "BWMODE", bwMode,
"Bandwidth setup", 0 );
astSetFitsI ( fitschan, "SUBSYSNR", ( subBandNum % nSubsys ) + 1,
"Sub-system number", 0 );
astSetFitsS ( fitschan, "SUBBANDS", bwMode,
"Sub-band setup", 0 );
astSetFitsI ( fitschan, "NSUBBAND", 1,
"Number of subbands", 0 );
astSetFitsF ( fitschan, "SUBREFP1", refChan,
"Reference channel for subband1", 0 );
astSetFitsU ( fitschan, "SUBREFP2", "Reference channel for subband2", 0 );
astSetFitsI ( fitschan, "NCHNSUBS", gsdVars->BEChans[subBandNum],
"Number of subbands", 0 );
astSetFitsF ( fitschan, "REFCHAN", refChan,
"Reference IF channel No.", 0 );
astSetFitsF ( fitschan, "IFCHANSP", IFchanSp,
"[Hz] TOPO IF channel spacing (signed)", 0 );
astSetFitsS ( fitschan, "FFT_WIN", "truncate",
"Type of window used for FFT", 0 );
if ( strncmp ( gsdVars->backend, "DAS", 3 ) == 0 ) {
astSetFitsF ( fitschan, "BEDEGFAC", 1.15,
"Backend degradation factor", 0 );
} else if ( strncmp ( gsdVars->backend, "AOSC", 4 ) == 0 ) {
astSetFitsF ( fitschan, "BEDEGFAC", 1.0,
"Backend degradation factor", 0 );
} else {
astSetFitsU ( fitschan, "BEDEGFAC", "Backend degradation factor", 0 );
}
astSetFitsU ( fitschan, "MSROOT", "Root name of raw measurement sets", 0 );
/* FE Specific. */
astSetFitsCM ( fitschan,
"---- FE Specific ----", 0 );
astSetFitsS ( fitschan, "INSTRUME", instrume,
"Front-end receiver", 0 );
astSetFitsS ( fitschan, "SB_MODE", gsdVars->sbMode,
"Sideband mode", 0 );
astSetFitsF ( fitschan, "IFFREQ", IFFreqs[subBandNum],
"[GHz] IF Frequency", 0 );
astSetFitsI ( fitschan, "N_MIX", nMix,
"No. of mixers", 0 );
astSetFitsS ( fitschan, "OBS_SB", obsSB,
"The observed sideband", 0 );
astSetFitsF ( fitschan, "LOFREQS", gsdVars->LOFreqs[subBandNum],
"[GHz] LO Frequency at start of obs", 0 );
astSetFitsF ( fitschan, "LOFREQE", gsdVars->LOFreqs[subBandNum],
"[GHz] LO Frequency at end of obs", 0 );
astSetFitsS ( fitschan, "RECPTORS", recptors,
"Active FE receptor IDs for this obs", 0 );
astSetFitsS ( fitschan, "REFRECEP", recepNames[0],
"Receptor with unit sensitivity", 0 );
if ( strcmp ( samMode, "grid" ) == 0 ) {
astSetFitsU ( fitschan, "MEDTSYS", "[K] Median of the T-sys across all receptors", 0 );
} else {
astSetFitsF ( fitschan, "MEDTSYS",
gsdVars->sourceSysTemps[subBandNum],
"[K] Median of the T-sys across all receptors", 0 );
}
astSetFitsS ( fitschan, "TEMPSCAL", "TA*",
"Temperature scale in use", 0 );
astSetFitsS ( fitschan, "DOPPLER", doppler,
"Doppler velocity definition", 0 );
astSetFitsS ( fitschan, "SSYSOBS", sSysObs,
"Spectral ref. frame during observation", 0 );
/* Environmental data. */
astSetFitsCM ( fitschan,
"---- Environmental Data ----", 0 );
astSetFitsF ( fitschan, "ATSTART", gsdVars->tamb,
"[degC] Air temp at start of observation", 0 );
astSetFitsF ( fitschan, "ATEND", gsdVars->tamb,
"[degC] Air temp at end of observation", 0 );
astSetFitsF ( fitschan, "HUMSTART",gsdVars->hamb ,
"Rel Humidity at observation start", 0 );
astSetFitsF ( fitschan, "HUMEND", gsdVars->hamb,
"Rel Humidity observation end", 0 );
astSetFitsF ( fitschan, "BPSTART", gsdVars->pamb,
"[mbar] Pressure at observation start", 0 );
astSetFitsF ( fitschan, "BPEND", gsdVars->pamb,
"[mbar] Pressure at observation end", 0 );
astSetFitsU ( fitschan, "WNDSPDST", "[km/h] Wind Speed at obs start", 0 );
astSetFitsU ( fitschan, "WNDSPDEN", "[km/h] Wind Speed at obs end", 0 );
astSetFitsU ( fitschan, "WNDDIRST", "[deg] Wind direction, azimuth at obs start", 0 );
astSetFitsU ( fitschan, "WNDDIREN", "[deg] Wind direction, azimuth at obs end", 0 );
if (tauok) {
astSetFitsF ( fitschan, "TAU225ST", gsdVars->tau225,
"Tau at 225 GHz from CSO at start", 0 );
astSetFitsF ( fitschan, "TAU225EN", gsdVars->tau225,
"Tau at 225 GHz from CSO at end", 0 );
} else {
astSetFitsU ( fitschan, "TAU225ST",
"Tau at 225 GHz from CSO at start", 0 );
astSetFitsU ( fitschan, "TAU225EN",
"Tau at 225 GHz from CSO at end", 0 );
}
if (tauok && tauDatSt[0]) {
astSetFitsS ( fitschan, "TAUDATST", tauDatSt,
"Time of TAU225ST observation", 0 );
astSetFitsS ( fitschan, "TAUDATEN", tauDatSt,
"Time of TAU225EN observation", 0 );
} else {
astSetFitsU ( fitschan, "TAUDATST",
"Time of TAU225ST observation", 0 );
astSetFitsU ( fitschan, "TAUDATEN",
"Time of TAU225EN observation", 0 );
}
astSetFitsS ( fitschan, "TAUSRC", "CSO225GHZ",
"Source of the TAU225 value", 0 );
astSetFitsU ( fitschan, "WVMTAUST", "186GHz Tau from JCMT WVM at start", 0 );
astSetFitsU ( fitschan, "WVMTAUEN", "185GHz Tau from JCMT WVM at end", 0 );
astSetFitsU ( fitschan, "WVMDATST", "Time of WVMTAUST", 0 );
astSetFitsU ( fitschan, "WVMDATEN", "Time of WVMTAUEN", 0 );
if ( seeingok ) {
astSetFitsF ( fitschan, "SEEINGST", gsdVars->seeing,
"[arcsec] SAO atmospheric seeing (start)", 0 );
astSetFitsF ( fitschan, "SEEINGSEN", gsdVars->seeing,
"[arcsec] SAO atmospheric seeing (end)", 0 );
} else {
/* Use undefined header value if there was no measurement */
astSetFitsU ( fitschan, "SEEINGST",
"[arcsec] SAO atmospheric seeing (start)", 0 );
astSetFitsU ( fitschan, "SEEINGSEN",
"[arcsec] SAO atmospheric seeing (end)", 0 );
}
if (seeingok && seeDatSt[0] ) {
astSetFitsS ( fitschan, "SEEDATST", seeDatSt,
"Date/Time of SEEINGST", 0 );
astSetFitsS ( fitschan, "SEEDATEN", seeDatSt,
"Date/Time of SEEINGEN", 0 );
} else {
astSetFitsU ( fitschan, "SEEDATST",
"Date/Time of SEEINGST", 0 );
astSetFitsU ( fitschan, "SEEDATEN",
"Date/Time of SEEINGEN", 0 );
}
astSetFitsU ( fitschan, "FRLEGTST", "[degC] Mean Front leg temperature - Start", 0 );
astSetFitsU ( fitschan, "FRLEGTEN", "[degC] Mean Front leg temperature - End", 0 );
astSetFitsU ( fitschan, "BKLEGTST", "[degC] Mean Back leg temperature - Start", 0 );
astSetFitsU ( fitschan, "BKLEGTEN", "[degC] Mean Back leg temperature - End", 0 );
/* Switching and Map setup for the observation. */
astSetFitsCM ( fitschan,
"---- Switching and Map setup for the observationi ----", 0 );
astSetFitsS ( fitschan, "SAM_MODE", samMode,
"Sampling Mode", 0 );
astSetFitsS ( fitschan, "SW_MODE", mapVars->swMode,
"Switch Mode", 0 );
astSetFitsS ( fitschan, "SKYREFX", mapVars->skyRefX,
"X co-ord of Reference Position", 0 );
astSetFitsS ( fitschan, "SKYREFY", mapVars->skyRefY,
"Y co-ord of Reference Position", 0 );
astSetFitsS ( fitschan, "OBS_TYPE", obsType,
"Type of observation", 0 );
if ( strcmp ( samMode, "grid" ) == 0
&& strcmp ( mapVars->swMode, "chop" ) == 0 ) {
astSetFitsS ( fitschan, "CHOP_CRD", mapVars->chopCrd,
"Chopping co-ordinate system", 0 );
astSetFitsF ( fitschan, "CHOP_FRQ", gsdVars->chopFrequency,
"[Hz] Chop frequency", 0 );
astSetFitsF ( fitschan, "CHOP_PA", gsdVars->chopPA,
"[deg] Chop PA; 0=in lat, 90=in long", 0 );
astSetFitsF ( fitschan, "CHOP_THR", gsdVars->chopThrow,
"[arcsec] Chop throw", 0 );
} else {
astSetFitsU ( fitschan, "CHOP_CRD", "Chopping co-ordinate system", 0 );
astSetFitsU ( fitschan, "CHOP_FRQ", "[Hz] Chop frequency", 0 );
astSetFitsU ( fitschan, "CHOP_PA", "[deg] Chop PA; 0=in lat, 90=in long", 0 );
astSetFitsU ( fitschan, "CHOP_THR", "[arcsec] Chop throw", 0 );
}
astSetFitsU ( fitschan, "ROT_CRD", "Coordinate frame of image rotator", 0 );
astSetFitsU ( fitschan, "ROT_PA", "[[deg] Angle of image rotator", 0 );
astSetFitsU ( fitschan, "JIGL_CNT", "Number of offsets in jiggle pattern", 0 );
astSetFitsU ( fitschan, "JIGL_NAM", "File containing the jiggle offsets", 0 );
astSetFitsU ( fitschan, "JIG_PA", "[deg] Jiggle PA; 0=in lat, 90=in long", 0 );
astSetFitsU ( fitschan, "JIG_CRD", "Jiggling co-ordinate system", 0 );
astSetFitsU ( fitschan, "JIG_SCAL", "Scale size of jiggle pattern", 0 );
if ( strcmp ( samMode, "scan" ) == 0
&& strcmp ( mapVars->swMode, "pssw" ) == 0 ) {
astSetFitsF ( fitschan, "MAP_HGHT", mapVars->mapHght,
"[arcsec] Requested height of map", 0 );
astSetFitsF ( fitschan, "MAP_PA", mapVars->mapPA,
"[deg] Requested PA of map", 0 );
astSetFitsF ( fitschan, "MAP_WDTH", mapVars->mapWdth,
"[arcsec] Requested width of map", 0 );
astSetFitsS ( fitschan, "LOCL_CRD", mapVars->loclCrd,
"Local offset/map PA co-ordinate system", 0 );
astSetFitsF ( fitschan, "MAP_X", gsdVars->centreOffsetX,
"[arcsec] Requested map offset from telescope centre", 0 );
astSetFitsF ( fitschan, "MAP_Y", gsdVars->centreOffsetY,
"[arcsec] Requested map offset from telescope centre", 0 );
astSetFitsS ( fitschan, "SCAN_CRD", mapVars->scanCrd,
"Co-ordinate system for scan", 0 );
astSetFitsF ( fitschan, "SCAN_VEL", mapVars->scanVel,
"[arcsec/sec] Scan velocity along scan direction", 0 );
astSetFitsF ( fitschan, "SCAN_DY", mapVars->scanDy,
"[arcsec] Scan spacing perp. to scan", 0 );
astSetFitsS ( fitschan, "SCAN_PAT", mapVars->scanPat,
"Scan pattern name", 0 );
} else {
astSetFitsU ( fitschan, "MAP_HGHT", "[arcsec] Requested height of map", 0 );
astSetFitsU ( fitschan, "MAP_PA", "[deg] Requested PA of map", 0 );
astSetFitsU ( fitschan, "MAP_WDTH", "[arcsec] Requested width of map", 0 );
astSetFitsU ( fitschan, "LOCL_CRD", "Local offset/map PA co-ordinate system", 0 );
astSetFitsU ( fitschan, "MAP_X", "[arcsec] Requested map offset from telescope centre", 0 );
astSetFitsU ( fitschan, "MAP_Y", "[arcsec] Requested map offset from telescope centre", 0 );