aboutsummaryrefslogtreecommitdiff
path: root/noao/imred/vtel/decodeheader.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/imred/vtel/decodeheader.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/imred/vtel/decodeheader.x')
-rw-r--r--noao/imred/vtel/decodeheader.x67
1 files changed, 67 insertions, 0 deletions
diff --git a/noao/imred/vtel/decodeheader.x b/noao/imred/vtel/decodeheader.x
new file mode 100644
index 00000000..5d54753d
--- /dev/null
+++ b/noao/imred/vtel/decodeheader.x
@@ -0,0 +1,67 @@
+include <mach.h>
+include "vt.h"
+
+# DECODEHEADER -- Unpack date and time, and, if 'verbose' flag is set,
+# display some information to the user.
+
+procedure decodeheader (hbuf, hs, verbose)
+
+pointer hbuf # header data input buffer pointer (short, SZ_VTHDR)
+pointer hs # header data structure
+bool verbose # verbose flag
+
+int hour, minute, second
+int bitupk()
+
+begin
+ # Unpack date, time. The constants below are explained in the
+ # description of the image header and how it is packed. If any
+ # changes are made the following code will have to be rewritten.
+
+ # Month. The month and day are stored in the first header word.
+ VT_HMONTH[hs] = (bitupk (int(Mems[hbuf]), 13, 4)) * 10 +
+ bitupk (int(Mems[hbuf]), 9, 4)
+
+ # Day.
+ VT_HDAY[hs] = (bitupk (int(Mems[hbuf]), 5, 4)) * 10 +
+ bitupk (int(Mems[hbuf]), 1, 4)
+
+ # Year. The year is stored in the second header word.
+ VT_HYEAR[hs] = (bitupk (int(Mems[hbuf+1]), 13, 4)) * 10 +
+ bitupk (int(Mems[hbuf+1]), 9, 4)
+
+ # Time (seconds since midnight). Stored in the third and forth words.
+ VT_HTIME[hs] = (bitupk (int(Mems[hbuf+2]), 1, 2)) * 2**15 +
+ bitupk (int(Mems[hbuf+3]), 1, 15)
+
+ # Store other header parameters. Stored one per word.
+ VT_HWVLNGTH[hs] = Mems[hbuf+4] # Wavelength (angstroms)
+ VT_HOBSTYPE[hs] = Mems[hbuf+5] # Observation type (0,1,2,3,or 4)
+ VT_HAVINTENS[hs] = Mems[hbuf+6] # Average intensity
+ VT_HNUMCOLS[hs] = Mems[hbuf+7] # Number of columns
+ VT_HINTGPIX[hs] = Mems[hbuf+8] # Integrations per pixel
+ VT_HREPTIME[hs] = Mems[hbuf+9] # Repitition time
+
+ # Calculate the time in hours, minutes, and seconds instead of
+ # seconds since midnight.
+
+ hour = int(VT_HTIME[hs]/3600)
+ minute = int((VT_HTIME[hs] - hour * 3600)/60)
+ second = VT_HTIME[hs] - hour * 3600 - minute * 60
+
+ # If verbose, print out some header info on one line no <CR>.
+ if (verbose) {
+ call printf ("%02d/%02d/%02d %02d:%02d:%02d")
+ call pargi (VT_HMONTH[hs])
+ call pargi (VT_HDAY[hs])
+ call pargi (VT_HYEAR[hs])
+ call pargi (hour)
+ call pargi (minute)
+ call pargi (second)
+ call printf (" wvlngth %d obstype %d numcols %d")
+ call pargi (VT_HWVLNGTH[hs])
+ call pargi (VT_HOBSTYPE[hs])
+ call pargi (VT_HNUMCOLS[hs])
+ call flush (STDOUT)
+ }
+end