IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29011 for trunk/ppSim


Ignore:
Timestamp:
Aug 23, 2010, 7:26:50 AM (16 years ago)
Author:
eugene
Message:

add option to change output image size (not yet working); fix scale parameters for random galaxies

Location:
trunk/ppSim/src
Files:
3 edited

Legend:

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

    r24807 r29011  
    5555    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-galmodel", 0, "Type of Galaxy model", NULL);
    5656    psMetadataAddS32(arguments,  PS_LIST_TAIL, "-bin", 0, "Binning in x and y", 1);
     57    psMetadataAddS32(arguments,  PS_LIST_TAIL, "-nx", 0, "cell x-size in pixels", 0);
     58    psMetadataAddS32(arguments,  PS_LIST_TAIL, "-ny", 0, "cell y-size in pixels", 0);
    5759    psMetadataAddBool(arguments, PS_LIST_TAIL, "+photom", 0, "Perform photometry on fake sources", false);
    5860
     
    197199    ppSimArgToRecipeS32(&status,  options, "BINNING",       arguments, "-bin");
    198200
     201    ppSimArgToRecipeS32(&status,  config->arguments, "NX.CELL", arguments, "-nx");
     202    ppSimArgToRecipeS32(&status,  config->arguments, "NY.CELL", arguments, "-ny");
     203
    199204    if (type == PPSIM_TYPE_OBJECT) {
    200205        // Load values required for adding stars
  • trunk/ppSim/src/ppSimCreate.c

    r27989 r29011  
    2626    }
    2727
     28    assert (config->camera);
     29
     30    // int nx = psMetadataLookupS32 (&status, config->arguments, "NX.CELL");
     31    // if (nx) {
     32    //   psMetadata *defaults = psMetadataLookupPtr(&status, config->camera, "DEFAULTS");
     33    //   psMetadataLookupS32 (&status, defaults, "CELL.XSIZE");
     34    //   psAssert (status, "CELL.XSIZE should be in DEFAULTS");
     35    //   psMetadataAddF32(defaults, PS_LIST_TAIL, "CELL.XSIZE", PS_META_REPLACE, "", nx);
     36    // }
     37    // int ny = psMetadataLookupS32 (&status, config->arguments, "NY.CELL");
     38    // if (ny) {
     39    //   psMetadata *defaults = psMetadataLookupPtr(&status, config->camera, "DEFAULTS");
     40    //   psMetadataLookupS32 (&status, defaults, "CELL.YSIZE");
     41    //   psAssert (status, "CELL.YSIZE should be in DEFAULTS");
     42    //   psMetadataAddF32(defaults, PS_LIST_TAIL, "CELL.YSIZE", PS_META_REPLACE, "", ny);
     43    // }
     44
    2845    // generate the fpa structure used by the output camera (determined from INPUT or specified)
    29     assert (config->camera);
    3046    fpa = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the observation
    3147    if (!fpa) {
  • trunk/ppSim/src/ppSimMakeGalaxies.c

    r29002 r29011  
    109109                // galaxy->index = (1/2n)
    110110
    111                 float factor = galaxyGridRandom ? drand48() : i / num;
    112                 float index = (galaxyIndexMin  + factor * galaxyIndexSlope); // factor of 0.5 because the Sersic model creates exp(-z^n), not exp(-r^n)
    113                 galaxy->index = 0.5/index;
     111                float rndValue;
    114112
    115                 factor = galaxyGridRandom ? drand48() : i / num;
    116                 float scale = (galaxyRmajorMin + factor * galaxyRmajorSlope);
     113                rndValue = galaxyGridRandom ? drand48() : i / num;
     114                float index = (galaxyIndexMin  + rndValue * galaxyIndexSlope);
     115                galaxy->index = 0.5/index; // factor of 0.5 because the Sersic model creates exp(-z^n), not exp(-r^n)
     116
     117                rndValue = galaxyGridRandom ? drand48() : i / num;
     118                float scale = (galaxyRmajorMin + rndValue * galaxyRmajorSlope);
    117119
    118120                // for a sersic model,
     
    121123                float Io = exp(bn);
    122124
    123                 // galaxy->Rmaj  = scale * fR;
    124 
    125125                galaxy->Rmaj  = scale;
    126126
    127                 factor = galaxyGridRandom ? drand48() : i / num;
    128                 galaxy->Rmin  = (galaxyARatioMin + factor * galaxyARatioSlope) * galaxy->Rmaj;
     127                rndValue = galaxyGridRandom ? drand48() : i / num;
     128                galaxy->Rmin  = (galaxyARatioMin + rndValue * galaxyARatioSlope) * galaxy->Rmaj;
    129129
    130                 factor = galaxyGridRandom ? drand48() : i / num;
    131                 galaxy->theta = (galaxyThetaMin  + factor * galaxyThetaSlope);
     130                rndValue = galaxyGridRandom ? drand48() : i / num;
     131                galaxy->theta = (galaxyThetaMin  + rndValue * galaxyThetaSlope);
    132132
    133133                // galaxy->peak *= Io;
     
    158158            galaxy->y    = psRandomUniform(rng) * ySize; // y position
    159159
    160             // galaxy->flux = pow ((double)((i + 1) / norm), (double) (1.0 / galaxyLum));
     160            float index = (sqrt(psRandomUniform(rng)) * galaxyIndexSlope  + galaxyIndexMin);
     161            galaxy->index = 0.5/index; // factor of 0.5 because the Sersic model creates exp(-z^n), not exp(-r^n)
    161162
    162             galaxy->index = (sqrt(psRandomUniform(rng)) * galaxyIndexSlope  + galaxyIndexMin);
     163            float scale = (psRandomUniform(rng) * galaxyRmajorSlope + galaxyRmajorMin);
     164
     165            // for a sersic model,
     166            float bn = 1.9992*index - 0.3271;
     167            float fR = 1.0 / (sqrt(2.0) * pow (bn, index));
     168            float Io = exp(bn);
     169
     170            galaxy->Rmaj  = scale;
     171
     172            galaxy->Rmin  = (PS_SQR(psRandomUniform(rng)) * galaxyARatioSlope + galaxyARatioMin) * galaxy->Rmaj;
     173
    163174            galaxy->theta = (psRandomUniform(rng) * galaxyThetaSlope  + galaxyThetaMin);
    164             galaxy->Rmaj  = (psRandomUniform(rng) * galaxyRmajorSlope + galaxyRmajorMin);
    165             galaxy->Rmin  = (PS_SQR(psRandomUniform(rng)) * galaxyARatioSlope + galaxyARatioMin) * galaxy->Rmaj;
    166175
    167176            // the flux is only approximately correct (scaling of the peak is wrong)
     
    170179            galaxy->peak = galaxy->flux / (2.0*M_PI*PS_SQR(seeing));
    171180
     181            if (0) {
     182              fprintf (stderr, "Rmaj: %f, scale: %f, index: %f, bn: %f, Ro: %f, Io: %f\n", galaxy->Rmaj, scale, index, bn, fR, Io);
     183            }
     184
    172185            psArrayAdd (galaxies, 100, galaxy);
    173186        }
Note: See TracChangeset for help on using the changeset viewer.