IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17270


Ignore:
Timestamp:
Apr 1, 2008, 3:22:14 PM (18 years ago)
Author:
bills
Message:

support astrometry supplied on the command line

Location:
trunk/pstamp/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/src/ppstampArguments.c

    r16239 r17270  
    2121    fprintf(stderr, "\n");
    2222    fprintf(stderr, "Optional arguments:\n");
    23     fprintf(stderr, "         -chip chipName    selects chip (only used with -pixcenter)\n");
     23    fprintf(stderr, "   [-chip chipName]     selects chip (only used with -pixcenter)\n");
     24    fprintf(stderr, "   [-astrom astrom.cmp] : provide an alternative astrometry calibration\n");
    2425    fprintf(stderr, "\n");
    2526
     
    6061    }
    6162
    62 
    6363    if (!gotCenter) {
    6464        psError(PSTAMP_ERR_ARGUMENTS, true, "must specify center of region of interest\n");
     
    7777    }
    7878
     79    pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM",   "-astrom", "-astromlist");
     80
    7981    // the input file is a required argument; if not found, we will exit
    8082    bool status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
     
    8385        usage();
    8486    }
     87   
    8588
    8689    // finally the output file
  • trunk/pstamp/src/ppstampMakeStamp.c

    r17052 r17270  
    381381// is completely contained on a single chip
    382382
    383 static ppstampOverlap findROI(ppstampOptions *options, pmFPAview *view, pmFPAfile *input, pmChip *chip,
    384                        pmAstromObj *center)
     383static ppstampOverlap findROI(ppstampOptions *options, pmFPAview *view,
     384                    pmFPAfile *input, pmFPAfile *astrom, bool bilevelAstrometry,
     385                    pmChip *chip, pmAstromObj *center)
    385386{
    386387    psString chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
     
    392393
    393394    // set up the astrometry
    394     pmHDU *hdu = pmHDUFromChip(chip);
     395    pmHDU *hdu = pmFPAviewThisHDU(view, astrom->fpa);
    395396    PS_ASSERT_PTR_NON_NULL(hdu, 1)
    396397    PS_ASSERT_PTR_NON_NULL(hdu->header, 1)
    397398
    398     // for some reason these are getting initialized to garbag
    399     input->fpa->fromTPA = 0;
    400     input->fpa->toTPA = 0;
    401     input->fpa->toSky = 0;
    402     chip->toFPA = 0;
    403     chip->fromFPA = 0;
    404 
    405     if (!pmAstromReadWCS(input->fpa, chip, hdu->header, 1.0)) {
    406         // we can live without WCS if the ROI is specified in pixels
    407 
    408         if (options->roip.celestialCenter || options->roip.celestialRange) {
    409             psError(PSTAMP_ERR_DATA, false, "Failed to Read WCS, cannot proceed\n");
    410             psFree(chipBounds);
    411             return PSTAMP_ERROR;
     399    // we can live without astrometry if the ROI is completely specified in pixel coordinates
     400    bool mustHaveAstrometry = false;
     401    if (options->roip.celestialCenter || options->roip.celestialRange) {
     402        mustHaveAstrometry = true;
     403    }
     404    if (bilevelAstrometry) {
     405        if (!pmAstromReadBilevelChip (chip, hdu->header) && mustHaveAstrometry) {
     406            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel chip astrometry for input FPA.");
     407            return false;
     408        }
     409    } else {
     410        // we use a default FPA pixel scale of 1.0
     411        if (!pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0) && mustHaveAstrometry) {
     412            psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for input FPA.");
     413            return false;
    412414        }
    413415    }
     
    478480    bool        returnval = false;;
    479481    bool        foundOverlap = false;
    480     pmAstromObj *center = pmAstromObjAlloc();
    481482
    482483    pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPSTAMP.INPUT");
    483484    if (!status) {
    484         psError(PS_ERR_UNKNOWN, true, "Can't find input data!\n");
    485         psFree(center);
     485        psError(PS_ERR_UNKNOWN, true, "Can't find input file!\n");
     486        return false;
     487    }
     488
     489    pmFPAfile *astrom = psMetadataLookupPtr(&status, config->files, "PSWARP.ASTROM");
     490    if (!status) {
     491        psError(PS_ERR_UNKNOWN, true, "Can't find input astrometry!\n");
     492        return false;
     493    }
     494    if (!astrom) {
     495        astrom = input;
     496    } else if (astrom->camera != input->camera) {
     497        psError(PS_ERR_UNKNOWN, true, "Input camera and astrometry camera do not match");
    486498        return false;
    487499    }
     
    492504    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    493505        psError(PS_ERR_UNKNOWN, false, "Failed to load input.");
    494         psFree(center);
    495506        psFree (view);
    496507        return false;
    497508    }
     509    bool bilevelAstrometry  = false;
     510    pmHDU *phu = pmFPAviewThisPHU(view, astrom->fpa);
     511    if (phu) {
     512        char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1");
     513        if (ctype) {
     514            bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
     515        }
     516    }
     517    if (bilevelAstrometry) {
     518        if (!pmAstromReadBilevelMosaic(input->fpa, phu->header)) {
     519            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input FPA.");
     520            psFree(view);
     521            return false;
     522        }
     523    }
    498524
    499525    // Loop over the chips and find the one that contains the center
     526    pmAstromObj *center = pmAstromObjAlloc();
    500527    pmChip *chip;
    501528    while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) {
     
    512539        }
    513540
    514         ppstampOverlap overlap = findROI(options, view, input, chip, center);
     541        ppstampOverlap overlap = findROI(options, view, input, astrom, bilevelAstrometry, chip, center);
    515542
    516543        switch (overlap) {
  • trunk/pstamp/src/ppstampParseCamera.c

    r16593 r17270  
    3434    }
    3535
     36    // XXX: create a filerule for PPSTAMP.ASTROM
     37    pmFPAfile *astrom = pmFPAfileDefineFromArgs(&status, config, "PSWARP.ASTROM", "ASTROM");
     38    if (!status) {
     39        psError(PS_ERR_UNKNOWN, false, "failed to find astrom definitiion");
     40        return NULL;
     41    }
     42    if (astrom) {
     43        psLogMsg ("ppstamp", 3, "using supplied astrometry\n");
     44    } else {
     45        psLogMsg ("ppstamp", 3, "using header astrometry\n");
     46    }
     47
    3648#ifdef notyet
    3749    // add recipe options supplied on command line
     
    5567    }
    5668
    57     // TODO: only do the workaround if the file level is chip, skycells should be fine
     69    // XXX: TODO: only do the workaround if the file level is chip, skycells should be fine
    5870    if (!strcmp(config->cameraName, "MEGACAM")) {
    5971        // workaround bug 986 and related
Note: See TracChangeset for help on using the changeset viewer.