IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36307


Ignore:
Timestamp:
Nov 23, 2013, 12:09:42 PM (13 years ago)
Author:
eugene
Message:

add gauss to 2d cache smooth; some test code in pmPCM_Minimize

Location:
branches/eam_branches/ipp-20130904
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/psLib/src/imageops/psImageConvolve.h

    r36282 r36307  
    328328psImageSmooth2dCacheData *psImageSmooth2dCacheAlloc (float Nsigma);
    329329bool psImageSmooth2dCacheKernel_PS1_V1 (psImageSmooth2dCacheData *smdata, float sigma, float kappa);
     330bool psImageSmooth2dCacheKernel_Gauss (psImageSmooth2dCacheData *smdata, float sigma);
    330331bool psImageSmooth2dCache_F32(psImage *image, psImageSmooth2dCacheData *smdata);
    331332
  • branches/eam_branches/ipp-20130904/psLib/src/imageops/psImageConvolve2dCache.c

    r36285 r36307  
    125125}
    126126
     127// generate a 2D smoothing kernel for supplied sigma & kappa (PS1_V1 profile). 
     128bool psImageSmooth2dCacheKernel_Gauss (psImageSmooth2dCacheData *smdata, float sigma) {
     129
     130    // check for NULL structure elements?
     131    int Ns = (int)(smdata->Nsigma * sigma);
     132    Ns = PS_MAX (3, PS_MIN (Ns, 10));
     133    smdata->Ns = Ns;
     134
     135    int Ns2 = Ns * Ns;
     136
     137    // we are going to use a hard-wired set of radial points
     138    smdata->radflux = psAlloc(sizeof(float)*NRAD_MAX);
     139
     140    float sum = 0.0;
     141    for (int i = 0; i < NRAD_MAX; i++) {
     142        if (radii2[i] > Ns2) {
     143            smdata->radflux[i] = 0.0;
     144            continue;
     145        }
     146        float z = 0.5 * radii2[i] / PS_SQR(sigma);
     147        smdata->radflux[i] = exp(-z);
     148        sum += radiiN[i] * smdata->radflux[i];
     149    }
     150    for (int i = 0; i < NRAD_MAX; i++) {
     151        smdata->radflux[i] = smdata->radflux[i] / sum;
     152    }
     153
     154    return true;
     155}
     156
    127157// we can use the same DATA structure on multiple images of the same size
    128158bool psImageSmooth2dCache_F32(psImage *image, psImageSmooth2dCacheData *smdata)
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCM_MinimizeChisq.c

    r36283 r36307  
    134134            psTrace(FACILITY, 5, "Last delta is %f.  stop if < %f, accept if < %f\n", min->rParSigma, min->minTol*pcm->nPar, min->maxTol*pcm->nPar);
    135135        }
     136
     137        fprintf (stderr, "%d : \n", min->iter);
     138        for (int ti = 0; ti < params->n; ti++) {
     139          fprintf (stderr, "%f  ", params->data.F32[ti]);
     140        }
     141        fprintf (stderr, "\n");
    136142
    137143        char key[10]; // used for interactive responses
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCMdata.c

    r36298 r36307  
    357357
    358358    if (modelPSF->type == modelType_GAUSS) {
    359         // psImageSmooth2dCacheKernel_Gauss (smdata, *sigma);
     359        psImageSmooth2dCacheKernel_Gauss (smdata, *sigma);
    360360    }
    361361    if (modelPSF->type == modelType_PS1_V1) {
  • branches/eam_branches/ipp-20130904/psphot/src/psphotExtendedSourceFits.c

    r36298 r36307  
    315315
    316316// XXX TEST
    317             if (!isInteractive) {
     317            if (false && !isInteractive) {
    318318                if (!psThreadJobAddPending(job)) {
    319319                    psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
  • branches/eam_branches/ipp-20130904/psphot/test/tap_psphot_galaxygrid.pro

    r36292 r36307  
    3030$RefOptions = $RefOptions -nx 3000 -ny 3000
    3131
     32if (not($?PSFMODEL))
     33  $PSFMODEL = PS1_V1
     34end
     35
     36macro reset.options
    3237# options for the simulated images (using the refimage for the stars)
    3338$FakeOptions = $BaseOptions
    3439$FakeOptions = $FakeOptions -exptime 30.0
    3540# $FakeOptions = $FakeOptions -D PSF.MODEL PS_MODEL_GAUSS
    36 $FakeOptions = $FakeOptions -D PSF.MODEL PS_MODEL_PS1_V1
     41$FakeOptions = $FakeOptions -D PSF.MODEL PS_MODEL_$PSFMODEL
    3742$FakeOptions = $FakeOptions -nx 3000 -ny 3000
    3843 
     
    7075$FakeConfig = $FakeConfig -Di GALAXY.GRID.DX 300
    7176$FakeConfig = $FakeConfig -Di GALAXY.GRID.DY 300
     77end
     78
     79if (not($?FakeConfig)) reset.options
    7280
    7381list fwhm
     
    317325end
    318326
     327macro grid.plot.stars
     328  if ($0 != 2)
     329    echo "USAGE: grid.plot.stars (version)"
     330    break
     331  end
     332  # things to examine: theta, Rmajor, AR
     333
     334  # go.grid.check.devexp
     335
     336  # check on position
     337  set dX = Xot_s - int(Xin_s) - 0.5
     338  set dY = Yot_s - int(Yin_s) - 0.5
     339  set ARin = rin_s / Rin_s
     340  set dR = Rin_s - Rot_s
     341
     342  create n 0 dR[]
     343  set dRf = dR / Rin_s
     344  lim -n 1$1 n -0.5 0.5; clear; box; plot n dRf
     345  label -x sequence -y "1 - R_out| / R_in|"
     346  resize 700 320
     347
     348  # check on A.Ratio
     349  set ARot = rot_s / Rot_s
     350  # lim ARin ARot; clear; box; plot ARin ARot
     351  set fAR = ARot / ARin
     352  lim -n 2$1 n 0.5 1.5; clear; box; plot n fAR
     353  label -x sequence -y "AR_out| / AR_in|"
     354  resize 700 320
     355
     356  # check on magnitude
     357  set dM = Mot_s - Min_s
     358  lim -n 3$1 n -0.5 0.5; clear; box; plot n dM   
     359  label -x sequence -y "M_out| - M_in|"
     360  resize 700 320
     361
     362  lim -n 4$1 n -1.5 1.5; clear; box; plot n dX
     363  label -x sequence -y "X_out| - X_in|"
     364  resize 700 320
     365
     366  lim -n 5$1 n -1.5 1.5; clear; box; plot n dY
     367  label -x sequence -y "Y_out| - Y_in|"
     368  resize 700 320
     369end
     370
    319371macro grid.mkexp.sersic
    320372  if ($0 != 2)
     
    550602  $psphotConfig = $psphotConfig -Db PSPHOT:SAVE.RESID T
    551603  $psphotConfig = $psphotConfig -D  PSPHOT:EXTENDED_SOURCE_MODELS_SELECTION $fitModel
    552   $psphotConfig = $psphotConfig -D  PSPHOT:PSF_MODEL PS_MODEL_PS1_V1
     604  $psphotConfig = $psphotConfig -D  PSPHOT:PSF_MODEL PS_MODEL_$PSFMODEL
     605
     606  $psphotConfig = $psphotConfig -Db PSPHOT:PSF.RESIDUALS F
     607  $psphotConfig = $psphotConfig -Db PSPHOT:POISSON.ERRORS.PHOT.LMM F
     608  $psphotConfig = $psphotConfig -Db PSPHOT:EXTENDED_SOURCE_FITS_POISSON F
    553609
    554610  # ppImage / psphot on the output
     
    649705  concat min min_S
    650706  concat Min Min_S
     707end
     708
     709macro cmf.load.stars.concat
     710  if ($0 != 3)
     711    echo "USAGE: cmf.load.concat (dat) (cmf)"
     712    break
     713  end
     714
     715  data $1
     716  read Xin_all 1 Yin_all 2 Type 4 Min_all 5 RmajIn_all 7 RminIn_all 8 ThetaIn_all 9 IndexIn_all 10
     717
     718  subset Xin     = Xin_all     if (Type == 0)
     719  subset Yin     = Yin_all     if (Type == 0)
     720  subset Min     = Min_all     if (Type == 0)
     721  subset RmajIn  = RmajIn_all  if (Type == 0)
     722  subset RminIn  = RminIn_all  if (Type == 0)
     723  subset IndexIn = IndexIn_all if (Type == 0)
     724  subset Tin_rad = ThetaIn_all if (Type == 0)
     725  set Tin = Tin_rad * 180 / 3.14159265
     726
     727  data $2
     728
     729  break -auto off
     730  read -fits Chip.psf X_PSF Y_PSF PSF_INST_MAG PSF_MAJOR PSF_MINOR PSF_THETA
     731  set PSF_THETA_ALT = PSF_THETA * (PSF_THETA >= 0.0) + (PSF_THETA + 3.14159265) * (PSF_THETA < 0.0)
     732  set PSF_THETA = PSF_THETA_ALT * 180 / 3.14159265
     733 
     734  match2d X_PSF Y_PSF Xin Yin 1.0 -index1 index1 -index2 index2
     735
     736  reindex Xot_m = X_PSF using index1
     737  reindex Yot_m = Y_PSF using index1
     738
     739  reindex Xin_m = Xin using index2
     740  reindex Yin_m = Yin using index2
     741
     742  reindex Mot_m = PSF_INST_MAG using index1
     743  reindex Tot_m = PSF_THETA using index1
     744
     745  reindex Min_m = Min using index2
     746  reindex Tin_m = Tin using index2
     747
     748  reindex Rot_m = PSF_MAJOR using index1
     749  reindex rot_m = PSF_MINOR using index1
     750
     751  reindex Rin_m = RmajIn using index2
     752  reindex rin_m = RminIn using index2
     753 
     754  $fields = X Y M T R r
     755  foreach field $fields
     756    foreach set in ot
     757      concat $field\$set\_m $field\$set\_s
     758    end
     759  end
    651760end
    652761
     
    11441253  exit 0
    11451254end
     1255
     1256# note that t1 = original confi
     1257# t2 = no residuals
     1258# t3 = const weight PSF fit
     1259# t4 = const weight galaxy fits
     1260
     1261macro run.radius.loop
     1262  local radius Nrun
     1263
     1264  $Nrun = 0
     1265  foreach radius 1.0 1.5 2.0 2.5 3.0 4.0 6.0 8.0
     1266    mkexp.devexp.single tests.20131120/testrad.ps1v1.exp.$Nrun EXP $radius 1.0
     1267    fitexp tests.20131120/testrad.ps1v1.exp.$Nrun tests.20131120/testrad.ps1v1.exp.$Nrun.t4 EXP_CONV
     1268    $Nrun ++
     1269  end
     1270
     1271  $Nrun = 0
     1272  foreach radius 1.0 1.5 2.0 2.5 3.0 4.0 6.0 8.0
     1273    cmf.load.concat tests.20131120/testrad.ps1v1.exp.$Nrun.dat tests.20131120/testrad.ps1v1.exp.$Nrun.t4.cmf EXP
     1274    set dM_m = Mot_m - Min_m
     1275    vstat -q dM_m
     1276    $mag_off = $MEDIAN
     1277    set dR_m = Rot_m - Rin_m
     1278    vstat -q dR_m
     1279    $rad_off = $MEDIAN
     1280    echo $radius $mag_off $rad_off
     1281    $Nrun ++
     1282  end
     1283
     1284  grid.plots.devexp a
     1285end
Note: See TracChangeset for help on using the changeset viewer.