IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 27, 2009, 4:06:36 PM (17 years ago)
Author:
bills
Message:

handle with compressed skycell files. adapt to change in header names
in .cmf format

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/ipp_mops_translate.pl

    r19732 r21195  
    1010use Math::Trig;
    1111use Data::Dumper;
     12use PS::IPP::Config 1.01 qw( :standard );
     13
     14my $ipprc = PS::IPP::Config->new();
    1215
    1316use constant EXTNAME => 'MOPS_TRANSIENT_DETECTIONS'; # Extension name for output table
     
    6972
    7073# Read the skycell header for the WCS
    71 my ($wcsheader, $status) = Astro::FITS::CFITSIO::fits_read_header( $skycell );
     74my $skycellResolved = $ipprc->file_resolve( $skycell );
     75my $status = 0;
     76my $skyfile_fits = Astro::FITS::CFITSIO::open_file( $skycellResolved, READONLY, $status );
     77    die("failed to open skycell file: $skycellResolved: $status") if $status;
     78
     79my $wcsheader;
     80($wcsheader, $status) = Astro::FITS::CFITSIO::fits_read_header( $skyfile_fits );
     81die("Unable to read skycell header: $status") if $status;
    7282
    7383# Get the useful header keywords
    74 my $naxis1 = $$wcsheader{'NAXIS1'} or die("Can't find NAXIS1");
    75 my $naxis2 = $$wcsheader{'NAXIS2'} or die("Can't find NAXIS2");
     84my $naxis1 = $$wcsheader{'NAXIS1'};
     85my $naxis2;
     86if ($naxis1) {
     87    $naxis2 = $$wcsheader{'NAXIS2'} or die("Can't find NAXIS2");
     88} else {
     89    # if the skyfile is compressed then the WCS won't be in the primary header
     90    my $hdutype;
     91    $skyfile_fits->movrel_hdu(1, $hdutype, $status);
     92    die("Unable to movrel_hdu: $status") if $status;
     93
     94    ($wcsheader, $status) = Astro::FITS::CFITSIO::fits_read_header( $skyfile_fits );
     95    die("Unable to read extension header: $status") if $status;
     96    my $xtension = $$wcsheader{'XTENSION'} or die("Can't find XTENSION");
     97    die("XTENSION found: $xtension") if $xtension ne "'BINTABLE'";
     98    $naxis1 = $$wcsheader{'ZNAXIS1'} or die("Can't find ZNAXIS1");
     99    $naxis2 = $$wcsheader{'ZNAXIS2'} or die("Can't find ZNAXIS2");
     100}
     101
    76102my $ctype1 = $$wcsheader{'CTYPE1'} or die("Can't find CTYPE1");
    77103my $ctype2 = $$wcsheader{'CTYPE2'} or die("Can't find CTYPE2");
     
    185211
    186212# Stellar PSF
    187 my $fwhm = 0.5 * 3600 * ($inHeader->{'FWHM_X'} * $cdelt1 + $inHeader->{'FWHM_Y'} * $cdelt2); # FWHM for star
     213my $fwhm = 0.5 * 3600 * ($inHeader->{'FWHM_MAJ'} * $cdelt1 + $inHeader->{'FWHM_MIN'} * $cdelt2); # FWHM for star
    188214$outFits->write_key( TSTRING, 'STARPSF', $fwhm, 'Stellar PSF (arcsec)', $status );
    189215check_fitsio( $status );
Note: See TracChangeset for help on using the changeset viewer.