IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38056


Ignore:
Timestamp:
Mar 29, 2015, 5:51:35 AM (11 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20150112/ppSub/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150112/ppSub/src

    • Property svn:ignore
      •  

        old new  
        1414ppSubVersionDefinitions.h
        1515ppSubConvolve
         16ppSubVersionDefinitions.h.tmp
  • branches/eam_branches/ipp-20150112/ppSub/src/Makefile.am

    r29937 r38056  
    11bin_PROGRAMS = ppSub ppSubKernel ppSubConvolve
    2 
    3 if HAVE_SVNVERSION
    4 PPSUB_VERSION=`$(SVNVERSION) ..`
    5 else
    6 PPSUB_VERSION="UNKNOWN"
    7 endif
    8 
    9 if HAVE_SVN
    10 PPSUB_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'`
    11 PPSUB_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`
    12 else
    13 PPSUB_BRANCH="UNKNOWN"
    14 PPSUB_SOURCE="UNKNOWN"
    15 endif
    162
    173# Force recompilation of ppSubVersion.c, since it gets the version information
    184ppSubVersion.c: ppSubVersionDefinitions.h
    195ppSubVersionDefinitions.h: ppSubVersionDefinitions.h.in FORCE
    20         -$(RM) ppSubVersionDefinitions.h
    21         $(SED) -e "s|@PPSUB_VERSION@|\"$(PPSUB_VERSION)\"|" -e "s|@PPSUB_BRANCH@|\"$(PPSUB_BRANCH)\"|" -e "s|@PPSUB_SOURCE@|\"$(PPSUB_SOURCE)\"|" ppSubVersionDefinitions.h.in > ppSubVersionDefinitions.h
     6        pslib-setsvnversion.pl PPSUB ppSubVersionDefinitions.h.in ppSubVersionDefinitions.h
    227FORCE: ;
    238
  • branches/eam_branches/ipp-20150112/ppSub/src/ppSubCamera.c

    r29954 r38056  
    2222#include "ppSub.h"
    2323
     24bool checkFileruleFileSave (pmFPAfile *file, pmConfig *config) {
     25
     26  bool status;
     27
     28  psMetadata *filerule = pmConfigFileRule(config, file->camera, file->name); // File rule
     29  if (!filerule) return false;
     30
     31  char *myString = psMetadataLookupStr(&status, filerule, "FILE.SAVE");
     32  if (!myString) return false;
     33
     34  // do not change the value from the default unless TRUE or FALSE are found
     35  if (!strcasecmp(myString, "TRUE")) {
     36    file->save = true;
     37    return true;
     38  }
     39  if (!strcasecmp(myString, "FALSE")) {
     40    file->save = false;
     41    return true;
     42  }
     43 
     44  return false;
     45}
     46
    2447// Define an input file
    2548static pmFPAfile *defineInputFile(bool *success,
     
    131154        }
    132155        if (file) {
    133             // It's an output
    134             file->save = true;
     156            // It's an output (respect filerules)
     157          checkFileruleFileSave(file, config);
    135158        }
    136159    }
     
    244267        return false;
    245268    }
     269    // these ->save values below are set by command-line arguments (in ppSubArguments.c) : -save-inconv, -save-refconv
    246270    inConvImage->save = data->saveInConv;
    247271    inConvMask->save = data->saveInConv;
     
    283307        return false;
    284308    }
    285     output->save = true;
    286     outMask->save = true;
     309    checkFileruleFileSave (output, config);
     310    checkFileruleFileSave (outMask, config);
    287311    if (inVar && refVar) {
    288312        pmFPAfile *outVar = defineOutputFile(config, output, false, "PPSUB.OUTPUT.VARIANCE",
     
    292316            return false;
    293317        }
    294         outVar->save = true;
     318        checkFileruleFileSave (outVar, config);
    295319    }
    296320
     
    305329            return false;
    306330        }
    307         inverse->save = true;
    308         invMask->save = true;
     331        checkFileruleFileSave (inverse, config);
     332        checkFileruleFileSave (invMask, config);
    309333        if (inVar && refVar) {
    310334            pmFPAfile *invVar = defineOutputFile(config, inverse, false, "PPSUB.INVERSE.VARIANCE",
     
    314338                return false;
    315339            }
    316             invVar->save = true;
     340            checkFileruleFileSave(invVar, config);
    317341        }
    318342    }
     
    329353        return false;
    330354    }
    331     jpeg1->save = true;
     355    checkFileruleFileSave(jpeg1, config);
    332356    pmFPAfile *jpeg2 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.JPEG2");
    333357    if (!jpeg2) {
     
    339363        return false;
    340364    }
    341     jpeg2->save = true;
     365    checkFileruleFileSave(jpeg2, config);
    342366
    343367    // Output residual JPEG
     
    351375        return false;
    352376    }
    353     jpeg3->save = true;
     377    checkFileruleFileSave(jpeg3, config);
    354378
    355379    // Output subtraction kernel
     
    395419        // Deactivate psphot output sources --- we want to define output source files of our own
    396420        pmFPAfile *psphotOutput = pmFPAfileSelectSingle(config->files, "PSPHOT.OUTPUT", 0);
    397         psphotOutput->save = false;
     421        psphotOutput->save = false;  // this one should NOT be set
    398422
    399423        pmFPAfile *outSources = defineOutputFile(config, output, false, "PPSUB.OUTPUT.SOURCES",
     
    403427            return false;
    404428        }
    405         outSources->save = true;
     429        checkFileruleFileSave(outSources, config);
    406430
    407431        if (data->inverse) {
     
    412436                return false;
    413437            }
    414             invSources->save = true;
     438            checkFileruleFileSave(invSources, config);
    415439        }
    416440
     
    423447                return false;
    424448            }
    425             posSources1->save = true;
     449            checkFileruleFileSave(posSources1, config);
    426450
    427451            // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #1
     
    431455                return false;
    432456            }
    433             frcSources1->save = true;
     457            checkFileruleFileSave(frcSources1, config);
    434458        }
    435459
     
    441465                return false;
    442466            }
    443             posSources2->save = true;
     467            checkFileruleFileSave(posSources2, config);
    444468
    445469            // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #2
     
    449473                return false;
    450474            }
    451             frcSources2->save = true;
     475            checkFileruleFileSave(frcSources2, config);
    452476        }
    453477    }
  • branches/eam_branches/ipp-20150112/ppSub/src/ppSubDefineOutput.c

    r31435 r38056  
    2222#include "ppSub.h"
    2323
     24bool ppSubCopyWarpToChip (psMetadata *tgtHeader, psMetadata *srcHeader);
     25
    2426bool ppSubDefineOutput(const char *name, pmConfig *config)
    2527{
    2628    psAssert(name, "Require name");
    2729    psAssert(config, "Require configuration");
     30
     31    bool status = false;
    2832
    2933    pmFPAview *view = ppSubViewReadout(); // View to readout
     
    4448
    4549    // Convolved input images
    46     psMetadata *recipe = psMetadataLookupPtr(NULL, config->recipes, PPSUB_RECIPE);
    47     bool noConvolve = psMetadataLookupBool(NULL, recipe, "NOCONVOLVE"); // Do not use convolved images.
     50    psMetadata *recipe = psMetadataLookupPtr(&status, config->recipes, PPSUB_RECIPE);
     51    bool noConvolve = psMetadataLookupBool(&status, recipe, "NOCONVOLVE"); // Do not use convolved images.
     52    bool reverse = psMetadataLookupBool(&status, config->arguments, "REVERSE"); // Reverse sense of subtraction?
     53    bool mapFromPositive = psMetadataLookupBool(&status, config->arguments, "CHIP.MAP.FROM.POSITIVE");
     54    // mapFromPositive = true means "always grab the warp->chip map from the positive image (eg, A for A - B, B for B - A)
     55    // mapFromPositive = false means "always grab the warp->chip map from the first image (eg, PPSUB.INPUT if not 'reverse')
    4856
    4957    pmReadout *inConv;
    5058    if (noConvolve) {
    5159      inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT"); // Input readout
    52     }
    53     else {
     60    } else {
    5461      inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input readout
    5562    }
     
    5764    if (noConvolve) {
    5865      refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF"); // Reference readout
    59     }
    60     else {
     66    } else {
    6167      refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference readout
    6268    }
    63     psFree(view);
    6469
    6570    // Add kernel descrption to header.
     
    7883        psError(PPSUB_ERR_UNKNOWN, true, "Unable to find SUBTRACTION.KERNEL");
    7984        psFree(outRO);
     85        psFree(view);
    8086        return false;
    8187    }
     
    8591    }
    8692    outHDU->header = psMetadataCopy(outHDU->header, hdu->header);
     93
     94    // in warp-stack mode, we should always use the warp
     95    // in warp-warp mode, we should use the positive warp for the positive subtraction
     96
     97    bool normalDiff = true;
     98    if (!strcmp (name, "PPSUB.INVERSE"))  {
     99      normalDiff = false;
     100    }
     101
     102    if (reverse) {
     103      // normal  = PPSUB.REF - PPSUB.INPUT
     104      // inverse = PPSUB.INPUT - PPSUB.REF
     105      if (mapFromPositive) {
     106        pmCell *cell_Pos = normalDiff ? pmFPAfileThisCell(config->files, view, "PPSUB.REF") : pmFPAfileThisCell(config->files, view, "PPSUB.INPUT");
     107        pmHDU *hdu_Pos = pmHDUFromCell(cell_Pos);
     108        ppSubCopyWarpToChip (outHDU->header, hdu_Pos->header);
     109      } else {
     110        pmCell *cell_Pos = pmFPAfileThisCell(config->files, view, "PPSUB.REF");
     111        pmHDU *hdu_Pos = pmHDUFromCell(cell_Pos);
     112        ppSubCopyWarpToChip (outHDU->header, hdu_Pos->header);
     113      }
     114    } else {
     115      // normal  = PPSUB.INPUT - PPSUB.REF
     116      // inverse = PPSUB.REF - PPSUB.INPUT
     117      if (mapFromPositive) {
     118        pmCell *cell_Pos = normalDiff ? pmFPAfileThisCell(config->files, view, "PPSUB.INPUT") : pmFPAfileThisCell(config->files, view, "PPSUB.REF");
     119        pmHDU *hdu_Pos = pmHDUFromCell(cell_Pos);
     120        ppSubCopyWarpToChip (outHDU->header, hdu_Pos->header);
     121      } else {
     122        pmCell *cell_Pos = pmFPAfileThisCell(config->files, view, "PPSUB.INPUT");
     123        pmHDU *hdu_Pos = pmHDUFromCell(cell_Pos);
     124        ppSubCopyWarpToChip (outHDU->header, hdu_Pos->header);
     125      }
     126    }
    87127
    88128    // Add additional data to the header
     
    104144
    105145    psFree(outRO);
     146    psFree(view);
    106147
    107148    return true;
    108149}
     150
     151// we have 4 sets of header keywords to copy:
     152// SRC_nnnn, SEC_nnnn, MPX_nnnn, MPY_nnnn
     153
     154bool ppSubCopyWarpToChip (psMetadata *tgtHeader, psMetadata *srcHeader) {
     155
     156  char keyword[80];
     157
     158  bool status = false;
     159
     160  int Nchip = 0;
     161  while (true) {
     162    snprintf (keyword, 80, "SRC_%04d", Nchip);
     163    char *string = psMetadataLookupStr (&status, srcHeader, keyword);
     164    if (!status) {
     165      break;
     166    }
     167    psMetadataAddStr(tgtHeader, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", string);
     168    Nchip ++;
     169  }
     170   
     171  for (int i = 0; i < Nchip; i++) {
     172    snprintf (keyword, 80, "SEC_%04d", i);
     173    char *string = psMetadataLookupStr (&status, srcHeader, keyword);
     174    if (!status) {
     175      psWarning ("cannot find keyword %s\n", keyword);
     176      continue;
     177    }
     178    psMetadataAddStr(tgtHeader, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", string);
     179  }
     180
     181  for (int i = 0; i < Nchip; i++) {
     182    snprintf (keyword, 80, "MPX_%04d", i);
     183    char *string = psMetadataLookupStr (&status, srcHeader, keyword);
     184    if (!status) {
     185      psWarning ("cannot find keyword %s\n", keyword);
     186      continue;
     187    }
     188    psMetadataAddStr(tgtHeader, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", string);
     189  }
     190
     191  for (int i = 0; i < Nchip; i++) {
     192    snprintf (keyword, 80, "MPY_%04d", i);
     193    char *string = psMetadataLookupStr (&status, srcHeader, keyword);
     194    if (!status) {
     195      psWarning ("cannot find keyword %s\n", keyword);
     196      continue;
     197    }
     198    psMetadataAddStr(tgtHeader, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", string);
     199  }
     200  return true;
     201}
     202
     203bool ppSubCopyWarpToChip_Alt (psMetadata *tgtHeader, psMetadata *srcHeader, bool isPositive) {
     204
     205  char srcKeyword[80], tgtKeyword[80];
     206
     207  bool status = false;
     208
     209  int Nchip = 0;
     210  while (true) {
     211    snprintf (srcKeyword, 80, "SRC_%04d", Nchip);
     212    if (isPositive) {
     213      snprintf (tgtKeyword, 80, "SRCP_%03d", Nchip);
     214    } else {
     215      snprintf (tgtKeyword, 80, "SRCM_%03d", Nchip);
     216    }
     217
     218    char *string = psMetadataLookupStr (&status, srcHeader, srcKeyword);
     219    if (!status) {
     220      break;
     221    }
     222    psMetadataAddStr(tgtHeader, PS_LIST_TAIL, srcKeyword, PS_META_REPLACE, "input image", string);
     223    Nchip ++;
     224  }
     225   
     226  for (int i = 0; i < Nchip; i++) {
     227    snprintf (srcKeyword, 80, "SEC_%04d", i);
     228    if (isPositive) {
     229      snprintf (tgtKeyword, 80, "SECP_%03d", Nchip);
     230    } else {
     231      snprintf (tgtKeyword, 80, "SECM_%03d", Nchip);
     232    }
     233
     234    char *string = psMetadataLookupStr (&status, srcHeader, srcKeyword);
     235    if (!status) {
     236      psWarning ("cannot find keyword %s\n", srcKeyword);
     237      continue;
     238    }
     239    psMetadataAddStr(tgtHeader, PS_LIST_TAIL, srcKeyword, PS_META_REPLACE, "input image", string);
     240  }
     241
     242  for (int i = 0; i < Nchip; i++) {
     243    snprintf (srcKeyword, 80, "MPX_%04d", i);
     244    if (isPositive) {
     245      snprintf (tgtKeyword, 80, "MPXP_%03d", Nchip);
     246    } else {
     247      snprintf (tgtKeyword, 80, "MPXM_%03d", Nchip);
     248    }
     249
     250    char *string = psMetadataLookupStr (&status, srcHeader, srcKeyword);
     251    if (!status) {
     252      psWarning ("cannot find keyword %s\n", srcKeyword);
     253      continue;
     254    }
     255    psMetadataAddStr(tgtHeader, PS_LIST_TAIL, srcKeyword, PS_META_REPLACE, "input image", string);
     256  }
     257
     258  for (int i = 0; i < Nchip; i++) {
     259    snprintf (srcKeyword, 80, "MPY_%04d", i);
     260    if (isPositive) {
     261      snprintf (tgtKeyword, 80, "MPYP_%03d", Nchip);
     262    } else {
     263      snprintf (tgtKeyword, 80, "MPYM_%03d", Nchip);
     264    }
     265
     266    char *string = psMetadataLookupStr (&status, srcHeader, srcKeyword);
     267    if (!status) {
     268      psWarning ("cannot find keyword %s\n", srcKeyword);
     269      continue;
     270    }
     271    psMetadataAddStr(tgtHeader, PS_LIST_TAIL, srcKeyword, PS_META_REPLACE, "input image", string);
     272  }
     273  return true;
     274}
     275
  • branches/eam_branches/ipp-20150112/ppSub/src/ppSubReadoutPhotometry.c

    r32822 r38056  
    4646        psFree(view);
    4747        return false;
     48    }
     49
     50    // psphot may need the PHU header
     51    if (!photFile->fpa->hdu) {
     52      photFile->fpa->hdu = psMemIncrRefCounter (inFile->fpa->hdu);
    4853    }
    4954
Note: See TracChangeset for help on using the changeset viewer.