IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19315


Ignore:
Timestamp:
Sep 2, 2008, 9:14:17 AM (18 years ago)
Author:
eugene
Message:

adding ppsim_recipe and camera options

Location:
trunk/ppSim/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSimSequence.c

    r19080 r19315  
    4343        psArgumentRemove(argNum, &argc, argv);
    4444        workdir = psStringCopy (argv[argNum]);
     45        psArgumentRemove(argNum, &argc, argv);
     46    }
     47
     48    char *ppsim_recipe = NULL;
     49    if ((argNum = psArgumentGet (argc, argv, "-ppsim_recipe"))) {
     50        psArgumentRemove(argNum, &argc, argv);
     51        ppsim_recipe = psStringCopy (argv[argNum]);
    4552        psArgumentRemove(argNum, &argc, argv);
    4653    }
     
    8390        fprintf (stderr, " (inject)   : an output file with commands to inject the images into the pipeline\n");
    8491        fprintf (stderr, "options:\n");
     92        fprintf (stderr, " -camera (camera) [otherwise must be set in sequences file]\n");
     93        fprintf (stderr, " -ppsim_recipe (recipe)\n");
    8594        fprintf (stderr, " -dbname (dbname)\n");
    8695        fprintf (stderr, " -path (path)\n");
     
    120129    if (tess_id) psStringAppend (&injectCommand, " --tess_id %s", tess_id);
    121130
     131    // build the base ppSimCommand string
     132    psString ppSimCommand = psStringCopy ("ppSim");
     133    if (ppsim_recipe) psStringAppend (&ppSimCommand, " -recipe PPSIM %s", ppsim_recipe);
     134
    122135    unsigned long seed = psMetadataLookupS32 (&status, config, "RND_SEED");
    123136    if (!status) seed = 0;
     
    157170        }
    158171
     172        // determine the camera for the sequence and define the ppSim command
     173        if (camera == NULL) {
     174            camera = psMetadataLookupStr (&status, sequence, "CAMERA");
     175        }
     176
     177        psString injectCommandReal = NULL;
     178        psString ppSimCommandReal = NULL;
     179
     180        psStringAppend (&injectCommandReal, "%s --camera %s", injectCommand, camera);
     181        psStringAppend (&ppSimCommandReal, "%s -camera %s", ppSimCommand, camera);
     182
    159183        if (!strcasecmp (type, "BIAS")) {
    160             ppSimSequenceBias (simfile, inject, sequence, i, rng, path, basename, camera, injectCommand);
     184            ppSimSequenceBias (simfile, inject, sequence, i, rng, path, basename, ppSimCommandReal, injectCommandReal);
    161185            continue;
    162186        }
    163187        if (!strcasecmp (type, "DARK")) {
    164             ppSimSequenceDark (simfile, inject, sequence, i, rng, path, basename, camera, injectCommand);
     188            ppSimSequenceDark (simfile, inject, sequence, i, rng, path, basename, ppSimCommandReal, injectCommandReal);
    165189            continue;
    166190        }
    167191        if (!strcasecmp (type, "FLAT")) {
    168             ppSimSequenceFlat (simfile, inject, sequence, i, rng, path, basename, camera, injectCommand);
     192            ppSimSequenceFlat (simfile, inject, sequence, i, rng, path, basename, ppSimCommandReal, injectCommandReal);
    169193            continue;
    170194        }
    171195        if (!strcasecmp (type, "OBJECT")) {
    172             ppSimSequenceObject (simfile, inject, sequence, i, rng, path, basename, camera, injectCommand);
     196            ppSimSequenceObject (simfile, inject, sequence, i, rng, path, basename, ppSimCommandReal, injectCommandReal);
    173197            continue;
    174198        }
  • trunk/ppSim/src/ppSimSequence.h

    r19080 r19315  
    1212#include <psastro.h>
    1313
    14 bool ppSimSequenceBias   (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand);
    15 bool ppSimSequenceDark   (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand);
    16 bool ppSimSequenceFlat   (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand);
    17 bool ppSimSequenceObject (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand);
     14bool ppSimSequenceBias   (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand);
     15bool ppSimSequenceDark   (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand);
     16bool ppSimSequenceFlat   (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand);
     17bool ppSimSequenceObject (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand);
    1818
    1919#endif
  • trunk/ppSim/src/ppSimSequenceBias.c

    r19080 r19315  
    11# include "ppSimSequence.h"
    22
    3 bool ppSimSequenceBias (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand) {
     3bool ppSimSequenceBias (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand) {
    44
    55    bool status, setLevel, setRange;
    6 
    7     if (camera == NULL) {
    8         camera = psMetadataLookupStr (&status, sequence, "CAMERA");
    9     }
    106
    117    // optional details
     
    1915    for (int i = 0; i < nImages; i++) {
    2016           
    21       psString command = NULL;
     17        // define the output filename
     18        psString filename = NULL;
     19        if (path) {
     20            psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
     21        } else {
     22            psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
     23        }
    2224
    23       psStringAppend (&command, "ppSim -type BIAS");
    24       psStringAppend (&command, " -camera %s", camera);
     25        // define the ppSim command
     26        psString command = NULL;
    2527
    26       if (setLevel) psStringAppend (&command, " -biaslevel %f", level);
    27       if (setRange) psStringAppend (&command, " -biasrange %f", range);
     28        psStringAppend (&command, "%s -type BIAS", ppSimCommand);
    2829
    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       }
    36       psStringAppend (&command, " %s", filename);
     30        if (setLevel) psStringAppend (&command, " -biaslevel %f", level);
     31        if (setRange) psStringAppend (&command, " -biasrange %f", range);
     32     
     33        psStringAppend (&command, " %s", filename);
    3734
    38       fprintf (simfile, "%s\n", command);
    39       psFree (command);
     35        fprintf (simfile, "%s\n", command);
     36        psFree (command);
    4037                           
    41       // path should be dirname/filename
    42       command = psStringCopy (injectCommand);
    43       psStringAppend (&command, " --camera %s", camera);
    44       psStringAppend (&command, " %s*.fits",    filename);
    45       fprintf (inject, "%s\n", command);
    46       psFree (command);
    47       psFree (filename);
     38        // define the inject command
     39        // path should be dirname/filename
     40        command = psStringCopy (injectCommand);
     41        psStringAppend (&command, " %s*.fits",    filename);
     42        fprintf (inject, "%s\n", command);
     43        psFree (command);
     44        psFree (filename);
    4845
    49       nImage ++;
     46        nImage ++;
    5047    }
    5148    return true;
  • trunk/ppSim/src/ppSimSequenceDark.c

    r19080 r19315  
    11# include "ppSimSequence.h"
    22
    3 bool ppSimSequenceDark (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, 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) {
    44
    55    bool status, setRate;
    66    float min, max = 0;
    7 
    8     if (camera == NULL) {
    9         camera = psMetadataLookupStr (&status, sequence, "CAMERA");
    10     }
    117
    128    setRate = false;
     
    3026
    3127        for (int j = 0; j < n; j++) {
     28
     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            }
     36
     37            // define the ppSim command
    3238            psString command = NULL;
    3339
    34             psStringAppend (&command, "ppSim -type DARK");
    35             psStringAppend (&command, " -camera %s", camera);
    36 
     40            psStringAppend (&command, "%s -type DARK", ppSimCommand);
     41     
    3742            if (setRate) {
    3843                double frnd = psRandomUniform(rng);
     
    4348            psStringAppend (&command, " -exptime %f", exptime);
    4449
    45             // XXX need to add output filename
    46             psString filename = NULL;
    47             if (path) {
    48                 psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
    49             } else {
    50                 psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
    51             }
    5250            psStringAppend (&command, " %s", filename);
    5351
     
    5553            psFree (command);
    5654                           
     55            // define the inject command
    5756            // path should be dirname/filename
    5857            command = psStringCopy (injectCommand);
    59             psStringAppend (&command, " --camera %s", camera);
    6058            psStringAppend (&command, " %s*.fits",    filename);
    6159            fprintf (inject, "%s\n", command);
  • trunk/ppSim/src/ppSimSequenceFlat.c

    r19080 r19315  
    11# include "ppSimSequence.h"
    22
    3 bool ppSimSequenceFlat (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand) {
     3bool ppSimSequenceFlat (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand) {
    44
    55    bool status;
    6 
    7     if (camera == NULL) {
    8         camera = psMetadataLookupStr (&status, sequence, "CAMERA");
    9     }
    106
    117    // determine the filters & exposure times
     
    2824    for (int i = 0; i < filters->n; i++) {
    2925           
    30       // loop over the filters & exposure times
    31       for (int j = 0; j < nSetup; j++) {
     26        // loop over the filters & exposure times
     27        for (int j = 0; j < nSetup; j++) {
    3228           
    33         psString command = NULL;
     29            // define the 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            }
    3436
    35         psStringAppend (&command, "ppSim -type FLAT");
    36         psStringAppend (&command, " -camera %s", camera);
     37            // define the ppSim comand
     38            psString command = NULL;
    3739
    38         psStringAppend (&command, " -filter %s", (char *) filters->data[i]);
    39         psStringAppend (&command, " -exptime %f", exptimes->data.F32[i]);
     40            psStringAppend (&command, "%s -type FLAT", ppSimCommand);
    4041
    41         // XXX need to add output filename
    42         psString filename = NULL;
    43         if (path) {
    44           psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
    45         } else {
    46           psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
     42            psStringAppend (&command, " -filter %s", (char *) filters->data[i]);
     43            psStringAppend (&command, " -exptime %f", exptimes->data.F32[i]);
     44
     45            psStringAppend (&command, " %s", filename);
     46
     47            fprintf (simfile, "%s\n", command);
     48            psFree (command);
     49
     50            // define the inject command
     51            // path should be dirname/filename
     52            command = psStringCopy (injectCommand);
     53            psStringAppend (&command, " %s*.fits",    filename);
     54            fprintf (inject, "%s\n", command);
     55            psFree (command);
     56            psFree (filename);
     57
     58            nImage ++;
    4759        }
    48         psStringAppend (&command, " %s", filename);
    49 
    50 
    51         fprintf (simfile, "%s\n", command);
    52         psFree (command);
    53 
    54         // path should be dirname/filename
    55         command = psStringCopy (injectCommand);
    56         psStringAppend (&command, " --camera %s", camera);
    57         psStringAppend (&command, " %s*.fits",    filename);
    58         fprintf (inject, "%s\n", command);
    59         psFree (command);
    60         psFree (filename);
    61 
    62         nImage ++;
    63       }
    6460    }
    6561    return true;
  • trunk/ppSim/src/ppSimSequenceObject.c

    r19080 r19315  
    11# include "ppSimSequence.h"
    22
    3 bool ppSimSequenceObject (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand) {
     3bool ppSimSequenceObject (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand) {
    44
    55    bool status;
     
    88    // ppSim -camera $camera -type OBJECT -filter $filter -exptime $exptime
    99    //       -skyrate $sky -ra $ra -dec $dec -pa $pa -scale $scale -zp $zp -seeing $seeing $filename",
    10 
    11     if (camera == NULL) {
    12         camera = psMetadataLookupStr (&status, sequence, "CAMERA");
    13     }
    1410
    1511    // sequence reference coordinate
     
    8076                        for (float pos = pos_min; pos <= pos_max; pos += pos_delta) {
    8177             
     78                            // define the output filename
     79                            psString filename = NULL;
     80                            if (path) {
     81                                psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
     82                            } else {
     83                                psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
     84                            }
     85
     86                            // define the ppSim command
    8287                            psString command = NULL;
    8388
    84                             psStringAppend (&command, "ppSim -type OBJECT");
    85                             psStringAppend (&command, " -camera %s", camera);
     89                            psStringAppend (&command, "%s -type OBJECT", ppSimCommand);
    8690                            psStringAppend (&command, " -filter %s", (char *) filters->data[i]);
    8791                            psStringAppend (&command, " -exptime %f", exptimes->data.F32[i]);
     
    97101                            psStringAppend (&command, " -seeing %f", seeing);
    98102
    99                             // XXX need to add output filename
    100                             psString filename = NULL;
    101                             if (path) {
    102                                 psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
    103                             } else {
    104                                 psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
    105                             }
    106103                            psStringAppend (&command, " %s", filename);
    107104
     
    109106                            psFree (command);
    110107                           
     108                            // define the inject command
    111109                            // path should be dirname/filename
    112110                            command = psStringCopy (injectCommand);
    113                             psStringAppend (&command, " --camera %s", camera);
    114111                            psStringAppend (&command, " %s*.fits",    filename);
    115112                            fprintf (inject, "%s\n", command);
Note: See TracChangeset for help on using the changeset viewer.