Changeset 17622
- Timestamp:
- May 9, 2008, 3:28:25 PM (18 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 2 edited
-
ipp_serial_inject_mosaic.pl (modified) (5 diffs)
-
ipp_simulation_data.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/ipp_serial_inject_mosaic.pl
r15283 r17622 23 23 use Pod::Usage qw( pod2usage ); 24 24 25 my ($camera, # Camera used 26 $telescope, # Telescope used 27 $dbname, # Database name 28 $workdir, # Working directory 29 $path, # Path to data 25 my ($camera, # Camera used 26 $telescope, # Telescope used 27 $tess_id, # Tessellation identifier 28 $dbname, # Database name 29 $workdir, # Working directory 30 $path, # Path to data 30 31 ); 31 32 GetOptions( 32 'camera|c=s' => \$camera, 33 'telescope|t=s' => \$telescope, 34 'workdir=s' => \$workdir, 35 'path=s' => \$path, 36 'dbname=s' => \$dbname, 33 'camera|c=s' => \$camera, 34 'telescope|t=s' => \$telescope, 35 'workdir=s' => \$workdir, 36 'tess_id=s' => \$tess_id, 37 'path=s' => \$path, 38 'dbname=s' => \$dbname, 37 39 ) or pod2usage( 2 ); 38 40 39 41 pod2usage( 40 -msg => "Required options: --camera --telescope --workdir --path --dbname",41 -exitval => 3,42 ) unless defined $camera42 -msg => "Required options: --camera --telescope --workdir --path --dbname", 43 -exitval => 3, 44 ) unless defined $camera 43 45 and defined $telescope 44 46 and defined $workdir … … 57 59 58 60 # Inject new data into the database 59 my @classes; # Names of the classes60 my @files; # What to add to the filename for each class61 my @classes; # Names of the classes 62 my @files; # What to add to the filename for each class 61 63 my $imfiles; 62 my $add_dir; # Add directory name to get file name?64 my $add_dir; # Add directory name to get file name? 63 65 if ($camera eq "MEGACAM") { 64 66 for (my $i = 0; $i < 36; $i++) { 65 push @classes, sprintf("ccd%02d", $i);66 push @files, sprintf(".ccd%02d", $i);67 push @classes, sprintf("ccd%02d", $i); 68 push @files, sprintf(".ccd%02d", $i); 67 69 } 68 70 } elsif ($camera eq "MCSHORT") { … … 74 76 } elsif ($camera eq "TC3") { 75 77 @classes = ( 'CCID58-1-06b2', 'CCID45-1-14A', 'CCID45-1-11A', 'CCID45-1-22A', 76 'CCID45-1-04C', 'CCID45-1-13A', 'CCID45-1-05A', 'CCID45-1-19A' );78 'CCID45-1-04C', 'CCID45-1-13A', 'CCID45-1-05A', 'CCID45-1-19A' ); 77 79 @files = ( '00', '01', '10', '11', '20', '21', '30', '31' ); 78 80 $add_dir = 1; … … 85 87 } elsif ($camera eq "GPC1") { 86 88 for (my $i = 0; $i < 8; $i++) { 87 for (my $j = 0; $j < 8; $j++) {88 if (($i == 0 or $i == 7) and ($j == 0 or $j == 7)) {89 # Excluding corner chips90 next;91 }92 push @classes, "XY$i$j";93 push @files, "$i$j";94 }89 for (my $j = 0; $j < 8; $j++) { 90 if (($i == 0 or $i == 7) and ($j == 0 or $j == 7)) { 91 # Excluding corner chips 92 next; 93 } 94 push @classes, "XY$i$j"; 95 push @files, "$i$j"; 96 } 95 97 } 96 98 $add_dir = 1; … … 100 102 101 103 foreach my $exp_name ( @ARGV ) { 102 my $command = "$pxinject -newExp -tmp_exp_name $exp_name -tmp_inst $camera -tmp_telescope $telescope -workdir $workdir "; # Command to run104 my $command = "$pxinject -newExp -tmp_exp_name $exp_name -tmp_inst $camera -tmp_telescope $telescope -workdir $workdir -tess_id $tess_id"; # Command to run 103 105 $command .= " -dbname $dbname" if defined $dbname; 104 106 105 107 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 106 run( command => $command, verbose => 1 );108 run( command => $command, verbose => 1 ); 107 109 die "Unable to inject $exp_name: $error_code\n" if not $success; 108 110 109 111 my @line = split(/\s+/, $$stdout_buf[0]); # The output line, containing the exposure tag 110 my $exp_id = $line[2]; # The exposure tag112 my $exp_id = $line[2]; # The exposure tag 111 113 for (my $i = 0; $i < scalar @classes; $i++) { 112 my $class_id = $classes[$i];113 my $file_id = $files[$i];114 my $filename = $exp_name . $file_id . '.fits';115 $filename = caturi( $exp_name, $filename ) if defined $add_dir;116 $filename = caturi( $path, $filename );114 my $class_id = $classes[$i]; 115 my $file_id = $files[$i]; 116 my $filename = $exp_name . $file_id . '.fits'; 117 $filename = caturi( $exp_name, $filename ) if defined $add_dir; 118 $filename = caturi( $path, $filename ); 117 119 118 die "Unable to find file $filename" unless -f $ipprc->file_resolve( $filename );120 die "Unable to find file $filename" unless -f $ipprc->file_resolve( $filename ); 119 121 120 $filename = $ipprc->convert_filename_relative( $filename );121 my $command = "$pxinject -newImfile -exp_id $exp_id -tmp_class_id $class_id -uri $filename"; # Command to run122 $command .= " -dbname $dbname" if defined ($dbname);122 $filename = $ipprc->convert_filename_relative( $filename ); 123 my $command = "$pxinject -newImfile -exp_id $exp_id -tmp_class_id $class_id -uri $filename"; # Command to run 124 $command .= " -dbname $dbname" if defined ($dbname); 123 125 124 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =125 run( command => $command, verbose => 1 );126 die "Unable to inject $exp_name $class_id: $error_code\n" if not $success;126 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 127 run( command => $command, verbose => 1 ); 128 die "Unable to inject $exp_name $class_id: $error_code\n" if not $success; 127 129 } 128 130 129 131 if (scalar @classes == 0) { 130 my $filename = $exp_name . '.fits';131 $filename = caturi( $exp_name, $filename ) if defined $add_dir;132 $filename = caturi( $path, $filename );132 my $filename = $exp_name . '.fits'; 133 $filename = caturi( $exp_name, $filename ) if defined $add_dir; 134 $filename = caturi( $path, $filename ); 133 135 134 die "Unable to find file $filename" unless -f $ipprc->file_resolve( $filename );136 die "Unable to find file $filename" unless -f $ipprc->file_resolve( $filename ); 135 137 136 $filename = $ipprc->convert_filename_relative( $filename );137 my $command = "$pxinject -newImfile -exp_id $exp_id -tmp_class_id fpa -uri $filename"; # Command to run138 $command .= " -dbname $dbname" if defined ($dbname);139 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =140 run( command => $command, verbose => 1 );141 die "Unable to inject $exp_name imfile: $error_code\n" if not $success;138 $filename = $ipprc->convert_filename_relative( $filename ); 139 my $command = "$pxinject -newImfile -exp_id $exp_id -tmp_class_id fpa -uri $filename"; # Command to run 140 $command .= " -dbname $dbname" if defined ($dbname); 141 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 142 run( command => $command, verbose => 1 ); 143 die "Unable to inject $exp_name imfile: $error_code\n" if not $success; 142 144 } 143 145 144 146 # Update the exposure to run 145 147 { 146 my $command = "$pxinject -updatenewExp -exp_id $exp_id -state run"; # Command to run147 $command .= " -dbname $dbname" if defined ($dbname);148 my $command = "$pxinject -updatenewExp -exp_id $exp_id -state run"; # Command to run 149 $command .= " -dbname $dbname" if defined ($dbname); 148 150 149 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =150 run( command => $command, verbose => 1 );151 die "Unable to activate $exp_name: $error_code\n" if not $success;151 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 152 run( command => $command, verbose => 1 ); 153 die "Unable to activate $exp_name: $error_code\n" if not $success; 152 154 } 153 155 -
trunk/ippScripts/scripts/ipp_simulation_data.pl
r16489 r17622 13 13 use Pod::Usage qw( pod2usage ); 14 14 use PS::IPP::Config qw( 15 $PS_EXIT_SUCCESS16 $PS_EXIT_UNKNOWN_ERROR17 $PS_EXIT_SYS_ERROR18 $PS_EXIT_CONFIG_ERROR19 $PS_EXIT_PROG_ERROR20 $PS_EXIT_DATA_ERROR21 $PS_EXIT_TIMEOUT_ERROR22 caturi23 );15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 caturi 23 ); 24 24 25 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration 26 26 27 my ($name, # Base name for output images 28 $camera, # Name of camera to use 29 $telescope, # Telescope name 30 $dbname, # Database name 31 $path, # Path to data 32 $workdir, # Working directory for data 33 $no_cal, # Don't produce calibration files 34 $no_update # Don't update the database 27 my ($name, # Base name for output images 28 $camera, # Name of camera to use 29 $telescope, # Telescope name 30 $tess_id, # Tessellation identifier 31 $dbname, # Database name 32 $path, # Path to data 33 $workdir, # Working directory for data 34 $no_cal, # Don't produce calibration files 35 $no_update # Don't update the database 35 36 ); 36 37 37 38 GetOptions( 38 'name=s' => \$name, 39 'camera=s' => \$camera, 40 'telescope=s' => \$telescope, 41 'dbname=s' => \$dbname, 42 'path=s' => \$path, 43 'workdir=s' => \$workdir, 44 'no-cal' => \$no_cal, 45 'no-update' => \$no_update, 46 ) or pod2usage( 2 ); 39 'name=s' => \$name, 40 'camera=s' => \$camera, 41 'telescope=s' => \$telescope, 42 'tess_id=s' => \$tess_id, 43 'dbname=s' => \$dbname, 44 'path=s' => \$path, 45 'workdir=s' => \$workdir, 46 'no-cal' => \$no_cal, 47 'no-update' => \$no_update, 48 ) or pod2usage( 2 ); 47 49 48 50 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 50 52 pod2usage( 51 53 -msg => "Required options: --name --path --camera --telescope --dbname", 52 -exitval => 3,53 ) unless54 -exitval => 3, 55 ) unless 54 56 defined $name and 55 57 defined $path and … … 67 69 or (warn "Can't find ipp_serial_inject_mosaic.pl" and $missing_tools = 1); 68 70 69 if ($missing_tools) { 71 if ($missing_tools) { 70 72 warn ("Can't find required tools"); 71 exit($PS_EXIT_CONFIG_ERROR); 73 exit($PS_EXIT_CONFIG_ERROR); 72 74 } 73 75 … … 76 78 # Dark exposure times 77 79 use constant DARK => [ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 78 300, 300, 300, 300, 300, 300, 300, 300, 300, 300 ];80 300, 300, 300, 300, 300, 300, 300, 300, 300, 300 ]; 79 81 # Flat-field image characteristics 80 82 use constant FLAT => [ 81 {82 filter => 'r',83 exptime => [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.5, 1, 2, 5, 10, 20, 20, 20, 20, 20 ],84 },85 {86 filter => 'i',87 exptime => [ 20, 20, 20, 20, 20 ],88 }89 ];83 { 84 filter => 'r', 85 exptime => [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.5, 1, 2, 5, 10, 20, 20, 20, 20, 20 ], 86 }, 87 { 88 filter => 'i', 89 exptime => [ 20, 20, 20, 20, 20 ], 90 } 91 ]; 90 92 # Object image characteristics 91 93 use constant OBJECT => [ 92 {93 filter => 'r',94 exptime => [ 5, 10, 10, 10, 10, 10, 240 ],95 seeing => [ 0.8, 0.4, 0.6, 0.8, 1.2, 1.5, 0.7 ],96 ra => 150.119167,97 dec => 2.205833,98 pa => 0,99 zp => 25.15,100 sky => 20.86,101 dither => 40,102 },103 {104 filter => 'i',105 exptime => [ 5, 30, 30, 30, 30, 30, 240 ],106 seeing => [ 0.8, 0.4, 0.6, 0.8, 1.2, 1.5, 0.7 ],107 ra => 150.119167,108 dec => 2.205833,109 pa => 0,110 zp => 25.00,111 sky => 20.15,112 dither => 40,113 },114 ];115 use constant SCALE => 0.2; # Plate scale94 { 95 filter => 'r', 96 exptime => [ 5, 10, 10, 10, 10, 10, 240 ], 97 seeing => [ 0.8, 0.4, 0.6, 0.8, 1.2, 1.5, 0.7 ], 98 ra => 150.119167, 99 dec => 2.205833, 100 pa => 0, 101 zp => 25.15, 102 sky => 20.86, 103 dither => 40, 104 }, 105 { 106 filter => 'i', 107 exptime => [ 5, 30, 30, 30, 30, 30, 240 ], 108 seeing => [ 0.8, 0.4, 0.6, 0.8, 1.2, 1.5, 0.7 ], 109 ra => 150.119167, 110 dec => 2.205833, 111 pa => 0, 112 zp => 25.00, 113 sky => 20.15, 114 dither => 40, 115 }, 116 ]; 117 use constant SCALE => 0.2; # Plate scale 116 118 117 119 ############################################################################################################# … … 120 122 121 123 my $counter = 0; 124 my $tessellation = (defined $tess_id) ? "--tess_id $tess_id" : ""; # Additional switch for tessellation 122 125 123 126 # Generate bias images 124 127 for (my $i = 0; $i < BIAS; $i++) { 125 my $basename; # Output base filename128 my $basename; # Output base filename 126 129 ( $basename, $counter ) = filename( $name, $counter ); 127 130 my $filename = caturi( $path, $basename ); 128 131 unless ($no_cal) { 129 run( command => "$ppSim -camera $camera -type BIAS $filename",130 verbose => 1 ) or die "Unable to run ppSim";131 unless ($no_update) {132 run( command => "$inject --camera $camera --telescope $telescope --path $path " .133 "--workdir $workdir --dbname $dbname $basename",134 verbose => 1 ) or die "Unable to inject file.";135 }132 run( command => "$ppSim -camera $camera -type BIAS $filename", 133 verbose => 1 ) or die "Unable to run ppSim"; 134 unless ($no_update) { 135 run( command => "$inject --camera $camera --telescope $telescope --path $path " . 136 "$tessellation --workdir $workdir --dbname $dbname $basename", 137 verbose => 1 ) or die "Unable to inject file."; 138 } 136 139 } 137 140 } … … 139 142 # Generate dark images 140 143 foreach my $exptime ( @{DARK()} ) { 141 my $basename; # Output base filename144 my $basename; # Output base filename 142 145 ( $basename, $counter ) = filename( $name, $counter ); 143 146 my $filename = caturi( $path, $basename ); 144 147 unless ($no_cal) { 145 run ( command => "$ppSim -camera $camera -type DARK -exptime $exptime $filename",146 verbose => 1 ) or die "Unable to run ppSim";147 unless ($no_update) {148 run( command => "$inject --camera $camera --telescope $telescope --path $path " .149 "--workdir $workdir --dbname $dbname $basename",150 verbose => 1 ) or die "Unable to inject file.";151 }148 run ( command => "$ppSim -camera $camera -type DARK -exptime $exptime $filename", 149 verbose => 1 ) or die "Unable to run ppSim"; 150 unless ($no_update) { 151 run( command => "$inject --camera $camera --telescope $telescope --path $path " . 152 "$tessellation --workdir $workdir --dbname $dbname $basename", 153 verbose => 1 ) or die "Unable to inject file."; 154 } 152 155 } 153 156 } … … 157 160 my $filter = $set->{filter}; # Name of filter 158 161 foreach my $exptime ( @{$set->{exptime}} ) { 159 my $basename;# Output base filename160 ( $basename, $counter ) = filename( $name, $counter );161 my $filename = caturi( $path, $basename );162 unless ($no_cal) {163 run( command => "$ppSim -camera $camera -type FLAT -filter $filter -exptime $exptime $filename",164 verbose => 1 ) or die "Unable to run ppSim";165 unless ($no_update) {166 run( command => "$inject --camera $camera --telescope $telescope --path $path " .167 "--workdir $workdir --dbname $dbname $basename",168 verbose => 1 ) or die "Unable to inject file.";169 }170 }162 my $basename; # Output base filename 163 ( $basename, $counter ) = filename( $name, $counter ); 164 my $filename = caturi( $path, $basename ); 165 unless ($no_cal) { 166 run( command => "$ppSim -camera $camera -type FLAT -filter $filter -exptime $exptime $filename", 167 verbose => 1 ) or die "Unable to run ppSim"; 168 unless ($no_update) { 169 run( command => "$inject --camera $camera --telescope $telescope --path $path " . 170 "$tessellation --workdir $workdir --dbname $dbname $basename", 171 verbose => 1 ) or die "Unable to inject file."; 172 } 173 } 171 174 } 172 175 } … … 175 178 foreach my $set ( @{OBJECT()} ) { 176 179 my $filter = $set->{filter}; # Name of filter 177 my $ra0 = $set->{ra}; # Base Right Ascension (deg)178 my $dec0 = $set->{dec}; # Base Declination (deg)179 my $pa = $set->{pa}; # Position angle (deg)180 my $zp = $set->{zp}; # Zero point181 my $scale = SCALE(); # Plate scale (arcsec/pix)182 my $sky = 10**( -0.4 * ( $set->{sky} - $zp ) ) * $scale**2; # Sky background (counts/s)183 my $dither = $set->{dither} / 3600; # Dither size (deg)180 my $ra0 = $set->{ra}; # Base Right Ascension (deg) 181 my $dec0 = $set->{dec}; # Base Declination (deg) 182 my $pa = $set->{pa}; # Position angle (deg) 183 my $zp = $set->{zp}; # Zero point 184 my $scale = SCALE(); # Plate scale (arcsec/pix) 185 my $sky = 10**( -0.4 * ( $set->{sky} - $zp ) ) * $scale**2; # Sky background (counts/s) 186 my $dither = $set->{dither} / 3600; # Dither size (deg) 184 187 185 188 for (my $i = 0; $i < scalar @{$set->{exptime}}; $i++) { 186 my $exptime = ${$set->{exptime}}[$i]; # Exposure time187 my $seeing = ${$set->{seeing}}[$i]; # Seeing (pix)188 my $ra = $ra0 + (2*rand() - 1) * $dither * cos(deg2rad($dec0)); # RA with dither189 my $dec = $dec0 + (2*rand() - 1) * $dither; # Dec with dither190 191 my $basename;# Output base filename192 ( $basename, $counter ) = filename( $name, $counter );193 my $filename = caturi( $path, $basename );194 run( command => "$ppSim -camera $camera -type OBJECT -filter $filter -exptime $exptime " .195 "-skyrate $sky -ra $ra -dec $dec -pa $pa -scale $scale -zp $zp -seeing $seeing $filename",196 verbose => 1 ) or die "Unable to run ppSim";197 unless ($no_update) {198 run( command => "$inject --camera $camera --telescope $telescope --path $path " .199 "--workdir $workdir --dbname $dbname $basename",200 verbose => 1 ) or die "Unable to inject file.";201 }189 my $exptime = ${$set->{exptime}}[$i]; # Exposure time 190 my $seeing = ${$set->{seeing}}[$i]; # Seeing (pix) 191 my $ra = $ra0 + (2*rand() - 1) * $dither * cos(deg2rad($dec0)); # RA with dither 192 my $dec = $dec0 + (2*rand() - 1) * $dither; # Dec with dither 193 194 my $basename; # Output base filename 195 ( $basename, $counter ) = filename( $name, $counter ); 196 my $filename = caturi( $path, $basename ); 197 run( command => "$ppSim -camera $camera -type OBJECT -filter $filter -exptime $exptime " . 198 "-skyrate $sky -ra $ra -dec $dec -pa $pa -scale $scale -zp $zp -seeing $seeing $filename", 199 verbose => 1 ) or die "Unable to run ppSim"; 200 unless ($no_update) { 201 run( command => "$inject --camera $camera --telescope $telescope --path $path " . 202 "$tessellation --workdir $workdir --dbname $dbname $basename", 203 verbose => 1 ) or die "Unable to inject file."; 204 } 202 205 } 203 206 } … … 210 213 sub filename 211 214 { 212 my $base = shift; # Base name213 my $num = shift; # Number214 my $workdir = shift; # Working directory215 my $base = shift; # Base name 216 my $num = shift; # Number 217 my $workdir = shift; # Working directory 215 218 my $name = sprintf("$base%04d", $num); 216 219 $num++;
Note:
See TracChangeset
for help on using the changeset viewer.
