Index: /trunk/Ohana/src/libautocode/def/image.d
===================================================================
--- /trunk/Ohana/src/libautocode/def/image.d	(revision 4019)
+++ /trunk/Ohana/src/libautocode/def/image.d	(revision 4020)
@@ -6,56 +6,58 @@
 # elements of the image structure
 
-TYPE  coords,               COORDS,               Coords         astrometric data
-FIELD tzero,                TZERO,                e_time         readout time (row 0)
-FIELD nstar,                NSTAR,                unsigned int   number of stars on image 
-FIELD secz,                 SECZ,                 short int      airmass,                   milliairmass
-FIELD NX,                   NX,                   short int      image width
-FIELD NY,                   NY,                   short int      image height
-FIELD apmifit,              APMIFIT,              short int      aperture correction,       millimag
-FIELD dapmifit,             DAPMIFIT,             short int      apmifit error,             millimag 
-FIELD source,               SOURCE,               short int      identifier for CCD
-FIELD Mcal,                 MCAL,                 short int      millimag
-FIELD dMcal,                DMCAL,                short int      millimag
-FIELD Xm,                   XM,                   short int      10*log(image chi-square) 
-FIELD name,                 NAME,                 char[32]       name of original image 
-FIELD detection_limit,      DETECTION_LIMIT,      unsigned char  detection limit,           10*mag
-FIELD saturation_limit,     SATURATION_LIMIT,     unsigned char  saturation limit,          10*mag
-FIELD cerror,               CERROR,               unsigned char  astrometric error,         50*arcsec
-FIELD fwhm_x                FWHM_X                unsigned char  PSF x width,               25*arcsec
-FIELD fwhm_y,               FWHM_Y,               unsigned char  PSF y width,               25*arcsec
-FIELD trate,                TRATE,                unsigned char  scan rate,                 100 usec/pixel 
-FIELD exptime,              EXPTIME,              float          exposure time,             seconds
-FIELD code,                 CODE,                 char           image quality flag
-FIELD ccdnum,               CCDNUM,               unsigned char  CCD ID number
-FIELD dummy,                DUMMY,                char[20]       unused
-FIELD order,                ORDER,                short int      Mrel 2D polynomical order 
-FIELD Mx,                   MX,                   short int      Mrel polyterm
-FIELD My,                   MY,                   short int      Mrel polyterm
-FIELD Mxx                   MXX                   short int      Mrel polyterm
-FIELD Mxy                   MXY                   short int      Mrel polyterm
-FIELD Myy,                  MYY,                  short int      Mrel polyterm
-FIELD Mxxx                  MXXX                  short int      Mrel polyterm
-FIELD Mxxy                  MXXY                  short int      Mrel polyterm
-FIELD Mxyy                  MXYY                  short int      Mrel polyterm
-FIELD Myyy,                 MYYY,                 short int      Mrel polyterm
-FIELD Mxxxx                 MXXXX                 short int      Mrel polyterm
-FIELD Mxxxy                 MXXXY                 short int      Mrel polyterm
-FIELD Mxxyy                 MXXYY                 short int      Mrel polyterm
-FIELD Mxyyy                 MXYYY                 short int      Mrel polyterm
-FIELD Myyyy,                MYYYY,                short int      Mrel polyterm
+SUBSTRUCT coords,           COORDS,               Coords,        astrometric data
+SUBFIELD  crval1,           CRVAL1,               double,   	 coordinate at reference pixel
+SUBFIELD  crval2,           CRVAL2,               double,  	 coordinate at reference pixel
+SUBFIELD  crpix1,           CRPIX1,               float,   	 coordinate of reference pixel
+SUBFIELD  crpix2,           CRPIX2,               float,   	 coordinate of reference pixel
+SUBFIELD  cdelt1,           CDELT1,               float,   	 degrees per pixel
+SUBFIELD  cdelt2,           CDELT2,               float,    	 degrees per pixel
+SUBFIELD  pc1_1,            PC1_1,                float,    	 rotation matrix
+SUBFIELD  pc1_2,            PC1_2,                float,    	 rotation matrix
+SUBFIELD  pc2_1,            PC2_1,                float,    	 rotation matrix
+SUBFIELD  pc2_2,            PC2_2,                float,    	 rotation matrix
+SUBFIELD  polyterms[7][2],  POLYTERMS[7][2],      float,    	 higher order warping terms
+SUBFIELD  ctype[15],        CTYPE[15],            char,     	 coordinate type
+SUBFIELD  Npolyterms,       NPOLYTERMS,           char,     	 order of polynomial
 
-TYPE  Coords
-FIELD crval1                CRVAL1                double   
-FIELD crval2                CRVAL2                double   
-FIELD crpix1                CRPIX1                float    
-FIELD crpix2                CRPIX2                float    
-FIELD cdelt1                CDELT1                float    
-FIELD cdelt2                CDELT2                float    
-FIELD pc1_1                 PC1_1                 float    
-FIELD pc1_2                 PC1_2                 float    
-FIELD pc2_1                 PC2_1                 float    
-FIELD pc2_2                 PC2_2                 float    
-FIELD polyterms[7][2]       POLYTERMS[7][2]       float    
-FIELD ctype[15]             CTYPE[15]             char     
-FIELD Npolyterms            NPOLYTERMS            char     
-END
+FIELD 	  tzero,            TZERO,                e_time,         readout time (row 0)
+FIELD 	  nstar,            NSTAR,                unsigned int,   number of stars on image
+FIELD 	  secz,             SECZ,                 short int,      airmass,                   milliairmass
+FIELD 	  NX,               NX,                   short int,      image width
+FIELD 	  NY,               NY,                   short int,      image height
+FIELD 	  apmifit,          APMIFIT,              short int,      aperture correction,       millimag
+FIELD 	  dapmifit,         DAPMIFIT,             short int,      apmifit error,             millimag
+FIELD 	  source,           SOURCE,               short int,      identifier for CCD,
+FIELD 	  Mcal,             MCAL,                 short int,      calibration mag,           millimag
+FIELD 	  dMcal,            DMCAL,                short int,      error on Mcal,             millimag
+FIELD 	  Xm,               XM,                   short int,      image chisq,               10*log(value)
+FIELD 	  name,             NAME,                 char[32],       name of original image 
+FIELD 	  detection_limit,  DETECTION_LIMIT,      unsigned char,  detection limit,           10*mag
+FIELD 	  saturation_limit, SATURATION_LIMIT,     unsigned char,  saturation limit,          10*mag
+FIELD 	  cerror,           CERROR,               unsigned char,  astrometric error,         50*arcsec
+FIELD 	  fwhm_x,           FWHM_X,               unsigned char,  PSF x width,               25*arcsec
+FIELD 	  fwhm_y,           FWHM_Y,               unsigned char,  PSF y width,               25*arcsec
+FIELD 	  trate,            TRATE,                unsigned char,  scan rate,                 100 usec/pixel
+FIELD 	  exptime,          EXPTIME,              float,          exposure time,             seconds
+FIELD 	  code,             CODE,                 char,           image quality flag
+FIELD 	  ccdnum,           CCDNUM,               unsigned char,  CCD ID number
+FIELD 	  dummy,            DUMMY,                char[20],       unused
+FIELD 	  order,            ORDER,                short int,      Mrel 2D polynomical order 
+FIELD 	  Mx,               MX,                   short int,      Mrel polyterm
+FIELD 	  My,               MY,                   short int,      Mrel polyterm
+FIELD 	  Mxx,              MXX,                  short int,      Mrel polyterm
+FIELD 	  Mxy,              MXY,                  short int,      Mrel polyterm
+FIELD 	  Myy,              MYY,                  short int,      Mrel polyterm
+FIELD 	  Mxxx,             MXXX,                 short int,      Mrel polyterm
+FIELD 	  Mxxy,             MXXY,                 short int,      Mrel polyterm
+FIELD 	  Mxyy,             MXYY,                 short int,      Mrel polyterm
+FIELD 	  Myyy,             MYYY,                 short int,      Mrel polyterm
+FIELD 	  Mxxxx,            MXXXX,                short int,      Mrel polyterm
+FIELD 	  Mxxxy,            MXXXY,                short int,      Mrel polyterm
+FIELD 	  Mxxyy,            MXXYY,                short int,      Mrel polyterm
+FIELD 	  Mxyyy,            MXYYY,                short int,      Mrel polyterm
+FIELD 	  Myyyy,            MYYYY,                short int,      Mrel polyterm
+
+
+
+
Index: /trunk/Ohana/src/libautocode/generate
===================================================================
--- /trunk/Ohana/src/libautocode/generate	(revision 4019)
+++ /trunk/Ohana/src/libautocode/generate	(revision 4020)
@@ -1,4 +1,6 @@
 #!/usr/bin/env perl
 
+$VERBOSE = 0;
+if ($ARGV[0] eq "-v") { $VERBOSE = 1; shift @ARGV; }
 if (@ARGV != 3) { die "generate (schema) (template) (output)\n"; }
 
@@ -40,7 +42,7 @@
 
 	# not a simple key/value entry
-	if ($key eq "FIELD") {
+ 	if (($key eq "FIELD") || ($key eq "SUBSTRUCT") || ($key eq "SUBFIELD")) {
 	    ($element, $field, $format, $comment, $unit) = split (/,\s+/, $value, 5);
-#	    print "$element : $field : $format : $comment : $unit\n";
+	    if ($VERBOSE) { printf "%-20s %-20s %-15s %-35s %-10s\n", $element, $field, $format, $comment, $unit; }
 	    push @element, $element;
 	    push @field,   $field;
@@ -48,4 +50,5 @@
 	    push @comment, $comment;
 	    push @unit,    $unit;
+	    push @mode,    $key;
 	}
     }
@@ -89,4 +92,8 @@
 
     for ($i = 0; $i < @field; $i++) {
+	# skip SUBSTRUCT type of entries:
+	if ($mode[$i] eq "SUBSTRUCT") { next; }
+
+	# need to handle all structures like: float poly[5][4]
 	# add [\d\.] to match ascii-type formats
 	($type, $length) = $format[$i] =~ m|^(\w+)\[(\d+)\]|;
@@ -122,4 +129,7 @@
 
     for ($i = 0; $i < @field; $i++) {
+	# skip SUBSTRUCT type of entries:
+	if ($mode[$i] eq "SUBSTRUCT") { next; }
+
 	($type, $length) = $format[$i] =~ m|^(\w+)\[([\d\.]+)\]|;
 	if (!$type && !$length) { die "format must be specified for ASCII table"; }
@@ -147,4 +157,7 @@
     print FILE "typedef struct {\n";
     for ($i = 0; $i < @element; $i++) {
+	# skip SUBFIELD entries
+	if ($mode[$i] eq "SUBFIELD") { next; }
+
 	($type, $length) = $format[$i] =~ m|^(\w+)\[([\d\.]+)\]|;
 	if (!$type && !$length) { $type = $format[$i]; }
@@ -169,4 +182,7 @@
     $N = 0;
     for ($i = 0; $i < @field; $i++) {
+	# skip SUBSTRUCT type of entries:
+	if ($mode[$i] eq "SUBSTRUCT") { next; }
+
 	($type, $length) = $format[$i] =~ m|^(\w+)\[([\d\.]+)\]|;
 	if (!$type && !$length) { $type = $format[$i]; }
@@ -219,4 +235,6 @@
     $Nbytes = 0;
     for ($i = 0; $i < @field; $i++) {
+	# skip SUBSTRUCT type of entries:
+	if ($mode[$i] eq "SUBSTRUCT") { next; }
 
 	# add [\d\.] to match ascii-type formats
@@ -250,4 +268,7 @@
     $Nbytes = 0;
     for ($i = 0; $i < @field; $i++) {
+	# skip SUBSTRUCT type of entries:
+	if ($mode[$i] eq "SUBSTRUCT") { next; }
+
 	($length) = $format[$i] =~ m|^\w+\[([\d\.]+)\]|;
 	if ($length == 0) { die "ASCII table format requires field size"; }
