Index: trunk/ippScripts/scripts/register_exp.pl
===================================================================
--- trunk/ippScripts/scripts/register_exp.pl	(revision 14080)
+++ trunk/ippScripts/scripts/register_exp.pl	(revision 14115)
@@ -59,25 +59,26 @@
    [   
        #          PPSTATS KEYWORD         STATISTIC          CHIPTOOL FLAG
-       { name => "exp_name",       type => "constant",   flag => "-exp_name" }, # File level
-       { name => "telescope",      type => "constant",   flag => "-telescope" }, # File level
-       { name => "camera",         type => "constant",   flag => "-inst" }, # File level
-       { name => "filelevel",      type => "constant",   flag => "-filelevel" }, # File level
-       { name => "object",         type => "constant",   flag => "-object" },
-       { name => "exp_type",       type => "constant",   flag => "-exp_type" }, # File level
-       { name => "filter",         type => "constant",   flag => "-filter" }, # File level
-       { name => "dateobs",        type => "constant",   flag => "-dateobs" }, # File level
-       { name => "ccd_temp",	   type => "mean", 	 flag => "-ccd_temp" }, # CCD temperature
-       { name => "exp_time",	   type => "mean", 	 flag => "-exp_time" }, # Exposure time
-       { name => "sat_pixel_frac", type => "mean", 	 flag => "-sat_pixel_frac" }, # Fraction of saturated pixels
-       { name => "airmass",	   type => "mean", 	 flag => "-airmass" }, # Airmass
-       { name => "ra",		   type => "mean", 	 flag => "-ra" }, # Right ascension
-       { name => "decl",	   type => "mean", 	 flag => "-decl" }, # Declination
-       { name => "posang",	   type => "mean", 	 flag => "-posang" }, # Position angle
-       { name => "alt",		   type => "mean", 	 flag => "-alt" }, # Altitude
-       { name => "az",		   type => "mean", 	 flag => "-az" }, # Azimuth
-       { name => "bg",		   type => "mean", 	 flag => "-bg" }, # Azimuth
-       { name => "bg",		   type => "stdev", 	 flag => "-bg_mean_stdev" }, # Azimuth
-       { name => "bg_stdev",	   type => "rms", 	 flag => "-bg_stdev" }, # Azimuth
+       { name => "exp_name",       type => "constant",   flag => "-exp_name",       dtype => "string" }, # File level
+       { name => "telescope",      type => "constant",   flag => "-telescope",      dtype => "string" }, # File level
+       { name => "camera",         type => "constant",   flag => "-inst",           dtype => "string" }, # File level
+       { name => "filelevel",      type => "constant",   flag => "-filelevel",      dtype => "string" }, # File level
+       { name => "object",         type => "constant",   flag => "-object",         dtype => "string" },
+       { name => "exp_type",       type => "constant",   flag => "-exp_type",       dtype => "string" }, # File level
+       { name => "filter",         type => "constant",   flag => "-filter",         dtype => "string" }, # File level
+       { name => "dateobs",        type => "constant",   flag => "-dateobs",        dtype => "string" }, # File level
+       { name => "ccd_temp",       type => "mean",       flag => "-ccd_temp",       dtype => "float"  }, # CCD temperature
+       { name => "exp_time",       type => "mean",       flag => "-exp_time",       dtype => "float"  }, # Exposure time
+       { name => "sat_pixel_frac", type => "mean",       flag => "-sat_pixel_frac", dtype => "float"  }, # Fraction of saturated pixels
+       { name => "airmass",        type => "mean",       flag => "-airmass",        dtype => "float"  }, # Airmass
+       { name => "ra",             type => "mean",       flag => "-ra",             dtype => "float"  }, # Right ascension
+       { name => "decl",           type => "mean",       flag => "-decl",           dtype => "float"  }, # Declination
+       { name => "posang",         type => "mean",       flag => "-posang",         dtype => "float"  }, # Position angle
+       { name => "alt",            type => "mean",       flag => "-alt",            dtype => "float"  }, # Altitude
+       { name => "az",             type => "mean",       flag => "-az",             dtype => "float"  }, # Azimuth
+       { name => "bg",             type => "mean",       flag => "-bg",             dtype => "float"  }, # background
+       { name => "bg",             type => "stdev",      flag => "-bg_mean_stdev",  dtype => "float"  }, # Azimuth
+       { name => "bg_stdev",       type => "rms",        flag => "-bg_stdev",       dtype => "float"  }, # Azimuth
        ];
+my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
 
 # Look for commands we need
@@ -117,5 +118,4 @@
 
     # extract the stats from the metadata
-    my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
     unless ($stats->parse($metadata)) {
         &my_die ("Unable to find all values", $exp_id, $PS_EXIT_CONFIG_ERROR);
@@ -124,9 +124,9 @@
 
 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_type
-if (uc(&STATS_value_for_flag ($STATS, "-telescope")) eq "NAN") { &my_die ("telescope not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
-if (uc(&STATS_value_for_flag ($STATS, "-inst"))      eq "NAN") { &my_die ("inst      not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
-if (uc(&STATS_value_for_flag ($STATS, "-filelevel")) eq "NAN") { &my_die ("filelevel not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
-if (uc(&STATS_value_for_flag ($STATS, "-exp_type"))  eq "NAN") { &my_die ("exp_type  not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
-if (uc(&STATS_value_for_flag ($STATS, "-exp_name"))  eq "NAN") { &my_die ("exp_name  not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
+if (uc($stats->value_for_flag ("-telescope")) eq "NULL") { &my_die ("telescope not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
+if (uc($stats->value_for_flag ("-inst"))      eq "NULL") { &my_die ("inst      not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
+if (uc($stats->value_for_flag ("-filelevel")) eq "NULL") { &my_die ("filelevel not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
+if (uc($stats->value_for_flag ("-exp_type"))  eq "NULL") { &my_die ("exp_type  not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
+if (uc($stats->value_for_flag ("-exp_name"))  eq "NULL") { &my_die ("exp_name  not found", $exp_id, $PS_EXIT_CONFIG_ERROR); }
 
 my $command = "$regtool -addprocessedexp";
@@ -134,13 +134,7 @@
 $command .= " -exp_tag $exp_tag";
 $command .= " -dbname $dbname" if defined $dbname;
+$command .= $stats->cmdflags();
 
-# add in the elements from the selected stats above
-foreach my $entry (@$STATS) {
-    my $value = $entry->{value};
-    my $flag = $entry->{flag};
-    $command .= " $flag '$value'";
-}
-
-my $exp_type = &STATS_value_for_flag ($STATS, "-exp_type");
+my $exp_type = $stats->value_for_flag ("-exp_type");
 
 # Add the detrend flag, if needed
@@ -196,17 +190,4 @@
 }
 
-sub STATS_value_for_flag 
-{
-    my $STATS = shift;
-    my $flag  = shift;
-
-    foreach my $entry (@$STATS) {
-	if ($flag eq $entry->{flag}) {
-	    return $entry->{value};
-	}
-    }
-    return 'NAN';
-}
-
 END {
     my $exit = $?;
