IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 13, 2009, 4:08:06 PM (17 years ago)
Author:
giebink
Message:

Support for simtests using nebulous for SIMTEST and SIMMOSAIC cameras.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/simtest_nebulous_branches/ppSim/src/ppSimSequenceDark.c

    r19315 r25069  
    11# include "ppSimSequence.h"
    22
    3 bool ppSimSequenceDark (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand) {
     3bool ppSimSequenceDark (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand, const char *camera) {
    44
    55    bool status, setRate;
     
    99    min = psMetadataLookupF32 (&status, sequence, "DARK.MIN");
    1010    if (status) {
    11         max = psMetadataLookupF32 (&status, sequence, "DARK.MAX");
    12         setRate = true;
     11                max = psMetadataLookupF32 (&status, sequence, "DARK.MAX");
     12                setRate = true;
    1313    }
    1414
     
    2222    for (int i = 0; i < nImages->n; i++) {
    2323           
    24         float exptime = exptimes->data.F32[i];
    25         float n = nImages->data.S32[i];
     24                float exptime = exptimes->data.F32[i];
     25                float n = nImages->data.S32[i];
    2626
    27         for (int j = 0; j < n; j++) {
     27            for (int j = 0; j < n; j++) {
    2828
    29             // XXX need to add output filename
    30             psString filename = NULL;
    31             if (path) {
    32                 psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
    33             } else {
    34                 psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
    35             }
     29                // XXX need to add output filename
     30                psString filename = NULL;
     31                if (path) {
     32                        psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
     33                } else {
     34                        psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
     35                }
    3636
    37             // define the ppSim command
    38             psString command = NULL;
     37                // define the ppSim command
     38                psString command = NULL;
    3939
    40             psStringAppend (&command, "%s -type DARK", ppSimCommand);
    41      
    42             if (setRate) {
    43                 double frnd = psRandomUniform(rng);
    44                 float rate = min + (max - min)*frnd;
    45                 psStringAppend (&command, " -darkrate %f", rate);
    46             }
     40                psStringAppend (&command, "%s -type DARK", ppSimCommand);
     41         
     42                if (setRate) {
     43                                double frnd = psRandomUniform(rng);
     44                                float rate = min + (max - min)*frnd;
     45                                psStringAppend (&command, " -darkrate %f", rate);
     46                }
    4747
    48             psStringAppend (&command, " -exptime %f", exptime);
     48                psStringAppend (&command, " -exptime %f", exptime);
    4949
    50             psStringAppend (&command, " %s", filename);
     50                psStringAppend (&command, " %s", filename);
    5151
    52             fprintf (simfile, "%s\n", command);
    53             psFree (command);
    54                            
    55             // define the inject command
    56             // path should be dirname/filename
    57             command = psStringCopy (injectCommand);
    58             psStringAppend (&command, " %s*.fits",    filename);
    59             fprintf (inject, "%s\n", command);
    60             psFree (command);
    61             psFree (filename);
     52                fprintf (simfile, "%s\n", command);
     53                psFree (command);
     54                               
     55                // define the inject command
     56                    // path should be dirname/filename
     57                    // for SIMTEST camera nebulous insertion append .fits
     58                    // SIMMOSAIC nebulous insertions are appended with ChipXX.fits
     59                    // non-nebulous insertions use *.fits
     60                    const char *neb = "neb";
    6261
    63             nImage ++;
    64         }
     62                    if (strncmp (path, neb, 3) == 0) {
     63                               
     64                if (strcmp (camera, "SIMTEST") == 0) {
     65                    command = psStringCopy (injectCommand);
     66                    psStringAppend (&command, " %s.fits", filename);
     67                    fprintf (inject, "%s\n", command);
     68                                       
     69                } else if (strcmp (camera, "SIMMOSAIC") == 0) {
     70                    for (int i = 0; i < 2; i++) {
     71                        for (int j = 0; j < 2; j++) {
     72                            command = psStringCopy (injectCommand);
     73                                        psStringAppend (&command, " %s.Chip%d%d.fits", filename, i, j);
     74                                        fprintf (inject, "%s\n", command);
     75                                            command = NULL;
     76                                            }
     77                    }
     78                                           
     79                } else {
     80                    psLogMsg ("ppSimSequence", PS_LOG_WARN, "unsupported camera type for nebulous insertion");
     81                    exit (1);
     82                }
     83               
     84            } else {
     85                command = psStringCopy (injectCommand);
     86                psStringAppend (&command, " %s*.fits",    filename);
     87                fprintf (inject, "%s\n", command);
     88            }
     89
     90            psFree (command);
     91            psFree (filename);
     92            nImage ++;
     93        }
    6594    }
    6695    return true;
Note: See TracChangeset for help on using the changeset viewer.