Changeset 20101 for trunk/ippScripts/scripts/register_exp.pl
- Timestamp:
- Oct 13, 2008, 11:36:56 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/register_exp.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/register_exp.pl
r19779 r20101 19 19 use IPC::Cmd 0.36 qw( can_run run ); 20 20 use PS::IPP::Metadata::Config; 21 use PS::IPP::Metadata::Stats;22 21 use PS::IPP::Config 1.01 qw( :standard ); 23 22 … … 51 50 my $DETREND_FLAG = "-end_stage reg"; # Flag to use to mark detrend exposure 52 51 53 # values to extract from output metadata and the stats to calculate54 my $STATS =55 [ # register imfile56 # label STATISTIC CHIPTOOL FLAG57 { name => "exp_name", type => "constant", flag => "-exp_name", dtype => "string" }, # File level58 { name => "telescope", type => "constant", flag => "-telescope", dtype => "string" }, # File level59 { name => "camera", type => "constant", flag => "-inst", dtype => "string" }, # File level60 { name => "filelevel", type => "constant", flag => "-filelevel", dtype => "string" }, # File level61 { name => "object", type => "constant", flag => "-object", dtype => "string" },62 { name => "exp_type", type => "constant", flag => "-exp_type", dtype => "string" }, # File level63 { name => "filter", type => "constant", flag => "-filter", dtype => "string" }, # File level64 { name => "comment", type => "constant", flag => "-comment", dtype => "string" }, # ObsComment65 { name => "dateobs", type => "constant", flag => "-dateobs", dtype => "string" }, # File level66 { name => "ccd_temp", type => "mean", flag => "-ccd_temp", dtype => "float" }, # CCD temperature67 { name => "exp_time", type => "mean", flag => "-exp_time", dtype => "float" }, # Exposure time68 { name => "sat_pixel_frac", type => "mean", flag => "-sat_pixel_frac", dtype => "float" }, # Fraction of saturated pixels69 { name => "airmass", type => "mean", flag => "-airmass", dtype => "float" }, # Airmass70 { name => "ra", type => "mean", flag => "-ra", dtype => "float" }, # Right ascension71 { name => "decl", type => "mean", flag => "-decl", dtype => "float" }, # Declination72 { name => "posang", type => "mean", flag => "-posang", dtype => "float" }, # Position angle73 { name => "alt", type => "mean", flag => "-alt", dtype => "float" }, # Altitude74 { name => "az", type => "mean", flag => "-az", dtype => "float" }, # Azimuth75 { name => "m1_x", type => "constant", flag => "-m1_x", dtype => "float" }, # M1X76 { name => "m1_y", type => "constant", flag => "-m1_y", dtype => "float" }, # M1Y77 { name => "m1_z", type => "constant", flag => "-m1_z", dtype => "float" }, # M1Z78 { name => "m1_tip", type => "constant", flag => "-m1_tip", dtype => "float" }, # M1TIP79 { name => "m1_tilt", type => "constant", flag => "-m1_tilt", dtype => "float" }, # M1TILT80 { name => "m2_x", type => "constant", flag => "-m2_x", dtype => "float" }, # M2X81 { name => "m2_y", type => "constant", flag => "-m2_y", dtype => "float" }, # M2Y82 { name => "m2_z", type => "constant", flag => "-m2_z", dtype => "float" }, # M2Z83 { name => "m2_tip", type => "constant", flag => "-m2_tip", dtype => "float" }, # M2TIP84 { name => "m2_tilt", type => "constant", flag => "-m2_tilt", dtype => "float" }, # M2TILT85 { name => "env_temperature", type => "constant", flag => "-env_temperature", dtype => "float" }, # external temp86 { name => "env_humidity", type => "constant", flag => "-env_humidity", dtype => "float" }, # external humidity87 { name => "env_wind_speed", type => "constant", flag => "-env_wind_speed", dtype => "float" }, # external wind speed88 { name => "env_wind_dir", type => "constant", flag => "-env_wind_dir", dtype => "float" }, # external wind direction89 90 { name => "teltemp_m1", type => "constant", flag => "-teltemp_m1", dtype => "float" }, # Primary mirror temps (C)91 { name => "teltemp_m1cell", type => "constant", flag => "-teltemp_m1cell", dtype => "float" }, # Primary mirror support temps (C)92 { name => "teltemp_m2", type => "constant", flag => "-teltemp_m2", dtype => "float" }, # Secondary mirror temps (C93 { name => "teltemp_spider", type => "constant", flag => "-teltemp_spider", dtype => "float" }, # Spider temperatures (C)94 { name => "teltemp_truss", type => "constant", flag => "-teltemp_truss", dtype => "float" }, # Mid truss temperatures (C95 { name => "teltemp_extra", type => "constant", flag => "-teltemp_extra", dtype => "float" }, # Miscellaneous temperatures (C)96 97 { name => "sun_angle", type => "constant", flag => "-sun_angle", dtype => "float" }, # Angle to sun98 { name => "sun_alt", type => "constant", flag => "-sun_alt", dtype => "float" }, # Altitude of sun99 { name => "moon_angle", type => "constant", flag => "-moon_angle", dtype => "float" }, # Angle to moon100 { name => "moon_alt", type => "constant", flag => "-moon_alt", dtype => "float" }, # Altitude of moon101 { name => "moon_phase", type => "constant", flag => "-moon_phase", dtype => "float" }, # Phase of moon102 103 { name => "pon_time", type => "mean", flag => "-pon_time", dtype => "float" }, # time since last power on104 { name => "bg", type => "mean", flag => "-bg", dtype => "float" }, # background105 { name => "bg", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" }, # Azimuth106 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" }, # Azimuth107 ];108 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser109 110 52 # Look for commands we need 111 53 my $missing_tools; … … 136 78 } 137 79 138 # Parse the output 139 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 140 my $metadata = $mdcParser->parse(join "", @$stdout_buf); 141 unless ($metadata) { 142 &my_die ("Unable to parse metadata config doc", $exp_id, $PS_EXIT_PROG_ERROR); 80 # since I can't figure out how to do input and output within PERL, I'm writing to a temp file 81 my ($statFile, $statName) = tempfile( "/tmp/$exp_id.register.XXXX", UNLINK => !$save_temps ); 82 print "saving stats to $statName\n"; 83 foreach my $line (@$stdout_buf) { 84 print $statFile $line; 85 } 86 close $statFile; 87 88 # parse the stats in the metadata file 89 $command = "$ppStatsFromMetadata $statName - REGISTER_EXP"; 90 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 91 run(command => $command, verbose => $verbose); 92 unless ($success) { 93 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 94 warn("Unable to perform ppStatsFromMetadata: $error_code\n"); 95 exit($error_code); 143 96 } 144 97 145 # extract the stats from the metadata 146 unless ($stats->parse($metadata)) { 147 &my_die ("Unable to find all values", $exp_id, $PS_EXIT_CONFIG_ERROR); 98 foreach my $line (@$stdout_buf) { 99 $cmdflags .= " $line"; 148 100 } 149 101 } 150 102 151 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_type 152 if (uc($stats->value_for_flag ("-telescope")) eq "NULL") { &my_die ("telescope not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 153 if (uc($stats->value_for_flag ("-inst")) eq "NULL") { &my_die ("inst not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 154 if (uc($stats->value_for_flag ("-filelevel")) eq "NULL") { &my_die ("filelevel not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 155 if (uc($stats->value_for_flag ("-exp_type")) eq "NULL") { &my_die ("exp_type not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 156 if (uc($stats->value_for_flag ("-exp_name")) eq "NULL") { &my_die ("exp_name not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 103 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_name, -exp_type 104 if (uc(&value_for_flag ($cmdflags, "-telescope")) eq "NULL") { &my_die ("telescope not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 105 if (uc(&value_for_flag ($cmdflags, "-inst")) eq "NULL") { &my_die ("inst not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 106 if (uc(&value_for_flag ($cmdflags, "-filelevel")) eq "NULL") { &my_die ("filelevel not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 107 if (uc(&value_for_flag ($cmdflags, "-exp_name")) eq "NULL") { &my_die ("exp_name not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 108 109 my $exp_type = &value_for_flag ("-exp_type"); 110 if (uc($exp_type) eq "NULL") { &my_die ("exp_type not found", $exp_id, $PS_EXIT_CONFIG_ERROR); } 157 111 158 112 my $command = "$regtool -addprocessedexp"; … … 161 115 $command .= " -hostname $host" if defined $host; 162 116 $command .= " -dbname $dbname" if defined $dbname; 163 $command .= $stats->cmdflags(); 164 165 my $exp_type = $stats->value_for_flag ("-exp_type"); 117 $command .= " $cmdflags"; 166 118 167 119 # Add the detrend flag, if needed … … 206 158 } 207 159 160 sub value_for_flag 161 { 162 my $cmdflags = shift; 163 my $flag = shift; 164 165 my $value = 0.0; 166 if ($cmdflags =~ m|$flag|) { 167 ($value) = $cmdflags =~ m|$flag\s+(\S+)|; 168 } 169 $value; 170 } 171 208 172 sub my_die 209 173 {
Note:
See TracChangeset
for help on using the changeset viewer.
