IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14813


Ignore:
Timestamp:
Sep 11, 2007, 10:37:55 AM (19 years ago)
Author:
Paul Price
Message:

Catalogue stars were missing from the list, because the size of the
array wasn't being adjusted after adding them.

File:
1 edited

Legend:

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

    r14667 r14813  
    1414    psMetadata *astroRecipe = psMetadataLookupPtr(NULL, config->recipes, PSASTRO_RECIPE);
    1515    if (!astroRecipe) {
    16         psError(PSASTRO_ERR_CONFIG, false, "Can't find recipe %s", PSASTRO_RECIPE);
    17         return NULL;
     16        psError(PSASTRO_ERR_CONFIG, false, "Can't find recipe %s", PSASTRO_RECIPE);
     17        return NULL;
    1818    }
    1919
     
    2525    float scale = psMetadataLookupF32(NULL, config->arguments, "SCALE") * M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)
    2626    float expTime = psMetadataLookupF32(NULL, config->arguments, "EXPTIME"); // Exposure time
    27    
     27
    2828    // Size of FPA
    2929    psRegion *bounds = ppSimFPABounds (fpa);
     
    4040    psArray *refStars = psastroLoadRefstars(config);
    4141    if (!refStars || refStars->n == 0) {
    42         psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars.");
    43         psFree(refStars);
    44         return NULL;
     42        psError(PS_ERR_UNKNOWN, false, "Unable to find reference stars.");
     43        psFree(refStars);
     44        return NULL;
    4545    }
    4646    psLogMsg("ppSim", PS_LOG_INFO, "Adding %ld reference stars", refStars->n);
     
    5151    // Conversion loop
    5252    for (long i = 0; i < refStars->n; i++) {
    53         ppSimStar *star = ppSimStarAlloc ();
     53        ppSimStar *star = ppSimStarAlloc ();
    5454
    55         pmAstromObj *ref = refStars->data[i]; // Reference star
    56         star->ra  = ref->sky->r; // RA of star
    57         star->dec = ref->sky->d; // Dec of star
    58         star->mag = ref->Mag;       // Magnitude of star
     55        pmAstromObj *ref = refStars->data[i]; // Reference star
     56        star->ra  = ref->sky->r; // RA of star
     57        star->dec = ref->sky->d; // Dec of star
     58        star->mag = ref->Mag;       // Magnitude of star
    5959
    60         // Convert to x,y position on tangent plane, in pixels
    61         float div = (sin(star->ra) * sin(dec0) + cos(star->dec) * cos(dec0) * cos(star->ra - ra0)) * scale;
    62         float xi = cos(star->dec) * sin(star->ra - ra0) / div;
    63         float eta = (sin(star->dec) * cos(dec0) - cos(star->dec) * sin(dec0) * cos(star->ra - ra0)) / div;
     60        // Convert to x,y position on tangent plane, in pixels
     61        float div = (sin(star->ra) * sin(dec0) + cos(star->dec) * cos(dec0) * cos(star->ra - ra0)) * scale;
     62        float xi = cos(star->dec) * sin(star->ra - ra0) / div;
     63        float eta = (sin(star->dec) * cos(dec0) - cos(star->dec) * sin(dec0) * cos(star->ra - ra0)) / div;
    6464
    65         // Apply rotation, make FPA center of boresite
    66         star->x = cos(pa) * xi - sin(pa) * eta + x0fpa;
    67         star->y = sin(pa) * xi + cos(pa) * eta + y0fpa;
     65        // Apply rotation, make FPA center of boresite
     66        star->x = cos(pa) * xi - sin(pa) * eta + x0fpa;
     67        star->y = sin(pa) * xi + cos(pa) * eta + y0fpa;
    6868
    69         // Convert magnitude to peak flux
    70         star->flux = powf(10.0, -0.4 * (star->mag - zp)) * expTime;
    71         star->peak = star->flux / sqrt(2.0*M_PI) / seeing;
    72         stars->data[oldSize + i] = star;
     69        // Convert magnitude to peak flux
     70        star->flux = powf(10.0, -0.4 * (star->mag - zp)) * expTime;
     71        star->peak = star->flux / (2.0*M_PI * PS_SQR(seeing));
     72        stars->data[oldSize + i] = star;
     73
     74        psTrace("ppSim", 10, "Adding catalogue star: %.1f,%.1f --> %.2f\n", star->x, star->y, star->flux);
    7375    }
     76    stars->n = oldSize + refStars->n;
    7477    psFree(refStars);
    7578
Note: See TracChangeset for help on using the changeset viewer.