Changeset 17945
- Timestamp:
- Jun 5, 2008, 12:25:32 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/ipp_mops_translate.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/ipp_mops_translate.pl
r17549 r17945 13 13 use constant EXTNAME => 'MOPS_TRANSIENT_DETECTIONS'; # Extension name for output table 14 14 use constant POSITION_ERROR => 0.2 / 3600; # Error in positions, degrees 15 use constant ZERO_POINT => 25; # Magnitude zero point16 use constant MAG_ERROR => 0.1; # Error in magnitudes15 use constant ZERO_POINT => 25; # Magnitude zero point 16 use constant MAG_ERROR => 0.1; # Error in magnitudes 17 17 use constant OBSERVATORY_CODE => 566; # IAU Observatory Code 18 use constant FAKE_LIMITING_MAG => 23.0; # Fake limiting magnitude to report18 use constant FAKE_LIMITING_MAG => 23.0; # Fake limiting magnitude to report 19 19 use constant FAKE_DETECTION_EFFICIENCY => 0.0; # Fake detection efficiency to report 20 20 21 my ( $input, # Name of input file with IPP photometry22 $extname, # Name of extension containing photometry23 $skycell, # Skycell file with WCS24 $output, # Name of output file25 $save_temps, # Save temporary files?21 my ( $input, # Name of input file with IPP photometry 22 $extname, # Name of extension containing photometry 23 $skycell, # Skycell file with WCS 24 $output, # Name of output file 25 $save_temps, # Save temporary files? 26 26 ); 27 27 28 28 GetOptions( 29 'input=s' => \$input,30 'extname=s' => \$extname,31 'skycell=s' => \$skycell,32 'output=s' => \$output,33 'save-temps' => \$save_temps,29 'input=s' => \$input, 30 'extname=s' => \$extname, 31 'skycell=s' => \$skycell, 32 'output=s' => \$output, 33 'save-temps' => \$save_temps, 34 34 ) or pod2usage( 2 ); 35 35 … … 37 37 pod2usage( -msg => "Required options: --input --extname --skycell --output", 38 38 -exitval => 3) 39 unless defined $input 39 unless defined $input 40 40 and defined $extname 41 41 and defined $skycell … … 44 44 # Specification of columns to write 45 45 my $columns = [ { name => 'RA_DEG', type => 'D' }, # Right ascension 46 { name => 'DEC_DEG', type => 'D' }, # Declination47 { name => 'RA_SIG', type => 'D' }, # Error in right ascension48 { name => 'DEC_SIG', type => 'D' }, # Error in declination49 { name => 'FLUX', type => 'D' }, # Flux50 { name => 'FLUX_SIG', type => 'D' }, # Error in flux51 { name => 'ANG', type => 'D' }, # Angle52 { name => 'ANG_SIG', type => 'D' }, # Error in angle53 { name => 'LEN', type => 'D' }, # Length54 { name => 'LEN_SIG', type => 'D' }, # Error in length55 ];46 { name => 'DEC_DEG', type => 'D' }, # Declination 47 { name => 'RA_SIG', type => 'D' }, # Error in right ascension 48 { name => 'DEC_SIG', type => 'D' }, # Error in declination 49 { name => 'FLUX', type => 'D' }, # Flux 50 { name => 'FLUX_SIG', type => 'D' }, # Error in flux 51 { name => 'ANG', type => 'D' }, # Angle 52 { name => 'ANG_SIG', type => 'D' }, # Error in angle 53 { name => 'LEN', type => 'D' }, # Length 54 { name => 'LEN_SIG', type => 'D' }, # Error in length 55 ]; 56 56 57 57 # Header translation table … … 66 66 'FPA.AZ' => { name => 'TEL_AZ', type => TDOUBLE, comment => 'Telescope azimuth' }, 67 67 'MJD-OBS' => { name => 'MJD-OBS', type => TDOUBLE, comment => 'Time of exposure' }, 68 };68 }; 69 69 70 70 … … 103 103 check_fitsio($status); 104 104 $inFits->movnam_hdu(BINARY_TBL, $extname, 0, $status) and check_fitsio($status); 105 my $numRows; # Number of rows in table105 my $numRows; # Number of rows in table 106 106 $inFits->get_num_rows($numRows, $status) and check_fitsio($status); 107 107 108 my ($xCol, $yCol, $magCol); # Column numbers for x and y108 my ($xCol, $yCol, $magCol); # Column numbers for x and y 109 109 $inFits->get_colnum(0, 'X_PSF', $xCol, $status) and check_fitsio($status); 110 110 $inFits->get_colnum(0, 'Y_PSF', $yCol, $status) and check_fitsio($status); 111 111 $inFits->get_colnum(0, 'PSF_INST_MAG', $magCol, $status) and check_fitsio($status); 112 112 113 my ($xType, $yType, $magType); # Column types113 my ($xType, $yType, $magType); # Column types 114 114 $inFits->get_coltype($xCol, $xType, undef, undef, $status) and check_fitsio($status); 115 115 $inFits->get_coltype($yCol, $yType, undef, undef, $status) and check_fitsio($status); 116 116 $inFits->get_coltype($magCol, $magType, undef, undef, $status) and check_fitsio($status); 117 117 118 my ($x, $y, $mag); # Sources arrays118 my ($x, $y, $mag); # Sources arrays 119 119 $inFits->read_col($xType, $xCol, 1, 1, $numRows, 0, $x, undef, $status) and check_fitsio($status); 120 120 $inFits->read_col($yType, $yCol, 1, 1, $numRows, 0, $y, undef, $status) and check_fitsio($status); … … 124 124 125 125 # Parse the list of columns 126 my @colNames; # Names of columns127 my @colTypes; # Types of columns128 my %colData; # Data for each column126 my @colNames; # Names of columns 127 my @colTypes; # Types of columns 128 my %colData; # Data for each column 129 129 foreach my $colSpec ( @$columns) { 130 130 push @colNames, $colSpec->{name}; … … 156 156 check_fitsio( $status ); 157 157 158 # Write the PHU keywords 158 # Write the table 159 $outFits->create_tbl( BINARY_TBL(), $numRows, scalar @colNames, \@colNames, \@colTypes, undef, EXTNAME, 160 $status ); 161 check_fitsio( $status ); 162 163 # Write the header keywords 159 164 $outFits->create_img( 16, 0, undef, $status ); 160 165 check_fitsio( $status ); … … 162 167 my $value = $inHeader->{$keyword}; # Header keyword value 163 168 unless (defined $value) { 164 print "Can't find header keyword $keyword\n";165 next;169 print "Can't find header keyword $keyword\n"; 170 next; 166 171 } 167 172 $value =~ s/\'//g; … … 196 201 $outFits->write_key( TINT, 'DE10', FAKE_DETECTION_EFFICIENCY, 'Detection efficiency (FAKE)', $status ); 197 202 198 # Write the table 199 $outFits->create_tbl( BINARY_TBL(), $numRows, scalar @colNames, \@colNames, \@colTypes, undef, EXTNAME, 200 $status ); 201 check_fitsio( $status ); 203 # Write the data 202 204 for (my $i = 0; $i < scalar @colNames; $i++) { 203 205 my $colName = $colNames[$i];# Column name … … 215 217 sub check_fitsio 216 218 { 217 my $status = shift; # Status of FITSIO calls219 my $status = shift; # Status of FITSIO calls 218 220 219 221 if ($status != 0) { 220 my $msg;# Message to output221 Astro::FITS::CFITSIO::fits_get_errstatus( $status , $msg );222 die "CFITSIO error: $msg\n";222 my $msg; # Message to output 223 Astro::FITS::CFITSIO::fits_get_errstatus( $status , $msg ); 224 die "CFITSIO error: $msg\n"; 223 225 } 224 226 } … … 227 229 sub pixels_to_sky 228 230 { 229 my ($x, $y) = @_; # Coordinates231 my ($x, $y) = @_; # Coordinates 230 232 231 233 # Pixel coordinate relative to reference … … 242 244 my $phi = atan2($eta,$xi) + pi/2; 243 245 my $theta = atan(180 / pi / sqrt($xi**2 + $eta**2)); 244 246 245 247 # Coordinates on celestial sphere 246 248 my $ra = $crval1 + atan2(cos($theta) * sin($phi), 247 sin($theta) * cos($crval2) + cos($theta) * sin($crval2) * cos($phi));249 sin($theta) * cos($crval2) + cos($theta) * sin($crval2) * cos($phi)); 248 250 my $dec = asin(sin($theta) * sin($crval2) - cos($theta) * cos($crval2) * cos($phi)); 249 251 250 252 return (rad2deg($ra), rad2deg($dec)); 251 253 }
Note:
See TracChangeset
for help on using the changeset viewer.
