IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41173


Ignore:
Timestamp:
Nov 27, 2019, 12:05:20 PM (6 years ago)
Author:
eugene
Message:

merge fixes from EAM dev branch ipp-20191011

Location:
trunk/ppSim/src
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/Makefile.am

    r38041 r41173  
    1515        ppSimLoadStars.c          \
    1616        ppSimMakeStars.c          \
     17        ppSimMakeStarCluster.c    \
    1718        ppSimMakeStarGrid.c       \
    1819        ppSimMakeGalaxies.c       \
  • trunk/ppSim/src/ppSim.h

    r28125 r41173  
    103103bool ppSimLoadStars (psArray *stars, pmFPA *fpa, pmConfig *config);
    104104bool ppSimMakeStars(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng);
     105bool ppSimMakeStarCluster(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng);
    105106bool ppSimMakeStarGrid(psArray *stars, pmFPA *fpa, pmConfig *config, const psRandom *rng);
    106107bool ppSimInsertStars (pmReadout *readout, psImage *expCorr, psArray *stars, pmConfig *config);
  • trunk/ppSim/src/ppSimCreate.c

    r30618 r41173  
    159159        return false;
    160160    }
    161     simSources->save = true;
     161
     162    // XXXX TEST this is causing trouble for unknown reasons -- output step is blowing up.
     163    // simSources->save = true;
     164    simSources->save = false;
    162165
    163166    // if we have loaded an input image, we derive certain values from the image, if possible
  • trunk/ppSim/src/ppSimLoadStars.c

    r26975 r41173  
    2424    float pa      = psMetadataLookupF32(NULL, recipe, "PA");        // Position angle (radians)
    2525    float seeing  = psMetadataLookupF32(NULL, recipe, "SEEING");    // Seeing SIGMA (pixels)
    26     float scale   = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)
     26    float scale   = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE"); // Plate scale (arcsec/pixel)
     27    float scaleRad = scale * M_PI / 3600.0 / 180.0; // Plate scale in radians/pixel for WCS below
    2728    float expTime = psMetadataLookupF32(NULL, recipe, "EXPTIME");   // Exposure time (sec)
    2829
    2930    // Size of FPA
    3031    psRegion *bounds = ppSimFPABounds (fpa);
    31     float radius = 0.5 * PS_MAX(bounds->x1 - bounds->x0, bounds->y1 - bounds->y0) * scale;
     32    float radius = 0.5 * PS_MAX(bounds->x1 - bounds->x0, bounds->y1 - bounds->y0) * scaleRad;
    3233
    3334    float x0fpa = 0.5*(bounds->x0 + bounds->x1);
     
    5354    stars = psArrayRealloc (stars, refStars->n);
    5455
    55     psProjection *proj = psProjectionAlloc(ra0, dec0, scale, scale, PS_PROJ_TAN); // Projection
     56    psProjection *proj = psProjectionAlloc(ra0, dec0, scaleRad, scaleRad, PS_PROJ_TAN); // Projection
    5657
    5758    // Conversion loop
  • trunk/ppSim/src/ppSimLoop.c

    r30618 r41173  
    5151
    5252        // Add random stars
    53         if (!ppSimMakeStarGrid (stars, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make random stars");
     53        if (!ppSimMakeStarGrid (stars, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make star grid");
     54
     55        // Add random stars
     56        if (!ppSimMakeStarCluster (stars, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make cluster stars");
    5457
    5558        // Add random galaxies
  • trunk/ppSim/src/ppSimMakeGalaxies.c

    r36079 r41173  
    4545    float zp              = psMetadataLookupF32(&mdok, recipe, "ZEROPOINT"); // Photometric zero point
    4646    float seeing          = psMetadataLookupF32(&mdok, recipe, "SEEING"); // Seeing sigma (pix)
    47     float scale           = psMetadataLookupF32(&mdok, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)
     47    float scale           = psMetadataLookupF32(&mdok, recipe, "PIXEL.SCALE"); // Plate scale (arcsec/pixel)
    4848    float skyRate         = psMetadataLookupF32(&mdok, recipe, "SKY.RATE"); // Sky rate
    4949    if (isnan(skyRate)) {
    5050        float skyMags = psMetadataLookupF32(&mdok, recipe, "SKY.MAGS");  assert (mdok);
    5151        skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
     52        // skyMags is in mags / square arcsec so scale must be arcsec / pixel
    5253    }
    5354
     
    9495
    9596    // Normalisation, set by the specified stellar density at the specified bright magnitude
    96     float refSum = galaxyDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI);
     97    float refSum = galaxyDensity * xSize * ySize * PS_SQR(scale / 3600.0);
    9798    float normLum =  refSum / (galaxyAlpha * logf(10.0) * powf(10.0, (galaxyAlpha * brightMag)));
    9899    float normScale = normLum * galaxyAlpha * logf(10.0);
     
    143144                rndValue = galaxyGridRandom ? drand48() : i / (float) nTotal;
    144145                float scale = (galaxyRmajorMin + rndValue * galaxyRmajorSlope);
    145 
    146146                galaxy->Rmaj  = scale;
    147147
  • trunk/ppSim/src/ppSimMakeStarGrid.c

    r26900 r41173  
    2222    float zp           = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); // Photometric zero point
    2323    float seeing       = psMetadataLookupF32(&status, recipe, "SEEING"); // Seeing SIGMA (pixels)
    24     float scale        = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)
     24    float scale        = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); // Plate scale (arcsec/pixel)
    2525
    2626    if (isnan(expTime))  ESCAPE("EXPTIME is not defined");
  • trunk/ppSim/src/ppSimMakeStars.c

    r25760 r41173  
    2727    float zp           = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); // Photometric zero point
    2828    float seeing       = psMetadataLookupF32(&status, recipe, "SEEING"); // Seeing SIGMA (pixels)
    29     float scale        = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)
     29    float scale        = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); // Plate scale (arcsec/pixel)
     30    // there has been some confusion over pixel scale: PIXEL.SCALE is supplied in arcsec / pixel.
     31    // In some other places (ppSimLoadStars.c, ppSimUtils.c) it is needed in radius for WCS conversion.
     32    // in the past, it was converted to radians on load (but applied inconsisently elsewhere)
     33    // Now the radian version is carried as scaleRad to be more explicit
    3034
    3135    if (isnan(darkRate)) darkRate = 0.0;
     
    4246        float skyMags = psMetadataLookupF32(&status, recipe, "SKY.MAGS");  assert (status);
    4347        skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
     48        // skyMags is in mags / square arcsec, so scale must be in arcsec / pixel
    4449    }
    4550
     
    6166        if (!status) {
    6267            refMag = brightMag;
    63             refSum = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI);
     68            refSum = starsDensity * xSize * ySize * PS_SQR(scale / 3600.0);
    6469        }
    6570    } else {
    6671        refMag = brightMag;
    67         refSum = starsDensity * xSize * ySize * PS_SQR(scale * 180.0 / M_PI);
     72        refSum = starsDensity * xSize * ySize * PS_SQR(scale / 3600.0);
    6873    }
    6974    psTrace("ppSim", 6, "refMag: %f, refSum: %f\n", refMag, refSum);
     
    120125    psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld stars between %f and %f mag\n", nTotal, brightMag, faintMag);
    121126
     127    if (nTotal > 1e7) {
     128      psLogMsg("ppSim", PS_LOG_INFO, "Trying to add %d stars (far more than 10M stars!), giving up\n", (int) nTotal);
     129      exit (2);
     130    }
     131
    122132    long oldSize = stars->n;
    123133    psArrayRealloc (stars, stars->n + nTotal);
  • trunk/ppSim/src/ppSimUtils.c

    r40738 r41173  
    1616    float pa    = psMetadataLookupF32(NULL, recipe, "PA");  // Position angle (radians)
    1717    float scale = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE"); // plate scale in arcsec / pixel
    18     scale *= M_PI / 3600.0 / 180.0; // convert plate scale to radians/pixel
     18    float scaleRad = scale * M_PI / 3600.0 / 180.0; // convert plate scale to radians/pixel
    1919
    2020    int binning = psMetadataLookupS32(NULL, recipe, "BINNING"); // Binning in x and y
     
    6161    psMetadata *header = psMetadataAlloc(); // Header, to return
    6262    pmAstromWCS *wcs = pmAstromWCSAlloc(1, 1); // WCS structure
    63     wcs->toSky = psProjectionAlloc(ra0, dec0, scale * xParity, scale * yParity, PS_PROJ_TAN);
    64     wcs->cdelt1 = scale * PM_DEG_RAD * xParity;
    65     wcs->cdelt2 = scale * PM_DEG_RAD * yParity;
     63    wcs->toSky = psProjectionAlloc(ra0, dec0, scaleRad * xParity, scaleRad * yParity, PS_PROJ_TAN);
     64    wcs->cdelt1 = scaleRad * PM_DEG_RAD * xParity;
     65    wcs->cdelt2 = scaleRad * PM_DEG_RAD * yParity;
    6666    wcs->crpix1 = x0;
    6767    wcs->crpix2 = y0;
Note: See TracChangeset for help on using the changeset viewer.