IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42584


Ignore:
Timestamp:
Jan 13, 2024, 2:39:37 PM (3 years ago)
Author:
eugene
Message:

tweaks to cdensify, still not ideal

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20230313/Ohana/src/opihi/cmd.astro/cdensify.c

    r41515 r42584  
    11# include "data.h"
     2# define dCOS(A)   ((double) cos ((double)RAD_DEG*A))
    23
    34# define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); }
     
    116117  PutCoords (&newcoords, &bf[0].header);
    117118 
     119  // use the mask to prevent double-counting
     120  ALLOCATE_PTR (mask, char, Nx*Ny);
     121
    118122  float scalescale = scale*scale;
    119123  float scale2 = (scale + 1.0) * (scale + 1.0);
     
    142146    coords.crval1 = rn;
    143147    coords.crval2 = *d;
     148   
     149    // XXX do not oversample by more than a factor of 10
     150    float dXn = dX * MAX(fabs(dCOS(*d)), 0.1);
    144151
    145152    float F = 1.0;
    146153    if (vv) { F = isFloatScale ? Fs[i] : Is[i]; }
     154
     155    // reset the mask so we do not double-count
     156    memset (mask, 0, Nx*Ny);
    147157
    148158    switch (PSFTYPE) {
     
    162172        break;
    163173      case IS_SQUARE:
    164         for (ix = -scale; ix <= scale; ix += dX) {
     174        for (ix = -scale; ix <= scale; ix += dXn) {
    165175          for (iy = -scale; iy <= scale; iy += dY) {
    166176            double rp, dp;
     
    184194        break;
    185195      case IS_CIRCLE:
    186         for (ix = -scale; ix <= scale; ix += dX) {
    187           for (iy = -scale; iy <= scale; iy += dY) {
     196        for (ix = -scale - dXn; ix <= scale + dXn; ix += dXn) {
     197          for (iy = -scale - dY; iy <= scale + dY; iy += dY) {
    188198            float r2 = ix*ix + iy*iy;
    189199            double rp, dp;
     
    199209            if (Xb < 0) continue;
    200210            if (Yb < 0) continue;
     211            if (mask[Xb + Yb*Nx]) continue;
     212            mask[Xb + Yb*Nx] = 1;
    201213            if (vv) {
    202214              val[Xb + Yb*Nx] += Normalize ? fCircle*F : F;
     
    208220        break;
    209221      case IS_GAUSS:
    210         for (ix = -3.0*scale; ix <= 3.0*scale; ix += dX) {
     222        for (ix = -3.0*scale; ix <= 3.0*scale; ix += dXn) {
    211223          for (iy = -3.0*scale; iy <= 3.0*scale; iy += dY) {
    212224            float r2 = ix*ix + iy*iy;
     
    232244    }
    233245  }
     246
     247  free (mask);
    234248  return (TRUE);
    235249}
Note: See TracChangeset for help on using the changeset viewer.