IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41965


Ignore:
Timestamp:
Dec 25, 2021, 2:19:17 PM (5 years ago)
Author:
eugene
Message:

working on imfit code

Location:
branches/eam_branches/ipp-20211108/Ohana/src/opihi
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20211108/Ohana/src/opihi/cmd.astro/Makefile

    r41666 r41965  
    9494$(SRC)/imfit-qfgauss.$(ARCH).o     \
    9595$(SRC)/imfit-qrgauss.$(ARCH).o     \
     96$(SRC)/imfit-rgauss.$(ARCH).o      \
    9697$(SRC)/imfit-trail.$(ARCH).o
    9798
  • branches/eam_branches/ipp-20211108/Ohana/src/opihi/cmd.astro/imfit-qgauss.c

    r39457 r41965  
    2525  par[4]  = get_variable_default ("SXYg", 0);
    2626  par[5]  = get_variable_default ("Zpk", 10000);
    27   par[6]  = get_variable_default ("Sg", 0.0);
     27  par[6]  = get_variable_default ("Sg", 0.0); // sky
    2828  par[7]  = get_variable_default ("Sr", 1.0);
    2929  fpar[0] = get_variable_default ("Npow", 2.25);
     
    4040  set_variable ("Zpk",  par[5]);
    4141  set_variable ("Sg",   par[6]);
    42   set_variable ("Sr", par[7]);
     42  set_variable ("Sr",   par[7]);
    4343}
    4444
    45 /* one component, two slopes: (1 + z^M + z^N)^(-1) -- x, y, sx, sy, sxy, I, sky, sr */
     45/* qgauss: (1 + Sr*z + z^Npow)^(-1) -- x, y, sx, sy, sxy, I, sky, sr */
    4646opihi_flt qgaussTD (opihi_flt x, opihi_flt y, opihi_flt *par, int Npar, opihi_flt *dpar) {
    4747  OHANA_UNUSED_PARAM(Npar);
     
    6060  r = 1.0 / (1 + par[7]*z + pow(z,fpar[0]));
    6161  f = par[5]*r + par[6];
    62   q = par[5]*SQ(r)*(par[7] + fpar[0]*pow(z,(fpar[0]-1)));
    6362
    6463  if (dpar != NULL) {
     64    q = par[5]*SQ(r)*(par[7] + fpar[0]*pow(z,(fpar[0]-1)));
    6565    dpar[0] = q*(2*px*par[2] + par[4]*Y);
    6666    dpar[1] = q*(2*py*par[3] + par[4]*X);
     
    7575}
    7676
     77/******************************************************************************
     78 * this file defines the QGAUSS source shape model.  Note that these model functions are
     79 * loaded by pmModelClass.c using 'include', and thus need no 'include' statements of
     80 * their own.  The models use a psVector to represent the set of parameters, with the
     81 * sequence used to specify the meaning of the parameter.  The meaning of the parameters
     82 * may thus vary depending on the specifics of the model.  All models which are used as a
     83 * PSF representations share a few parameters, for which # define names are listed in
     84 * pmModel.h:
     85
     86   power-law with fitted linear term
     87   1 / (1 + kz + z^2.25)
     88
     89   * PM_PAR_SKY 0   - local sky : note that this is unused and may be dropped in the future
     90   * PM_PAR_I0 1    - central intensity
     91   * PM_PAR_XPOS 2  - X center of object
     92   * PM_PAR_YPOS 3  - Y center of object
     93   * PM_PAR_SXX 4   - X^2 term of elliptical contour (SigmaX / sqrt(2))
     94   * PM_PAR_SYY 5   - Y^2 term of elliptical contour (SigmaY / sqrt(2))
     95   * PM_PAR_SXY 6   - X*Y term of elliptical contour
     96   * PM_PAR_7   7   - amplitude of the linear component (k)
     97   *****************************************************************************/
  • branches/eam_branches/ipp-20211108/Ohana/src/opihi/cmd.astro/imfit-rgauss.c

    r39457 r41965  
    99
    1010  fitfunc = rgaussTD;
    11   cleanup = rgaussCL;
    12   Npar = 10;
    13   Nfpar = 1;
     11  imfit_cleanup = rgaussCL;
     12  Npar =  8;
     13  Nfpar = 0;
    1414
    1515  /* allocate free and fixed parameters */
     
    2121  par[0] = get_variable_default ("Xg", 0);
    2222  par[1] = get_variable_default ("Yg", 0);
    23   par[2] = 2.35 * sqrt(2.0) / get_variable_default ("SXg", 2.0);
    24   par[3] = 2.35 * sqrt(2.0) / get_variable_default ("SYg", 2.0);
    25   par[4] = 0.0;
     23  par[2] = 2.35 / get_variable_default ("SXg", 2.0);
     24  par[3] = 2.35 / get_variable_default ("SYg", 2.0);
     25  par[4] = get_variable_default ("SXYg", 0);
    2626  par[5] = get_variable_default ("Zpk", 10000);
    27   par[6] = get_variable_default ("Sg", 0.0);
    28   par[7] = 2.35 * sqrt(2.0) / get_variable_default ("SXf", 15.0);
    29   par[8] = 2.35 * sqrt(2.0) / get_variable_default ("SYf", 15.0);
    30   par[9] = get_variable_default ("SXYf", 0.0);
     27  par[6] = get_variable_default ("Sg", 0.0); // sky
     28  par[7] = get_variable_default ("Sr", 2.0);
    3129
    32   fpar[0] = get_variable_default ("Npow", 2.25);
     30//  fpar[0] = get_variable_default ("Npow", 2.25);
    3331
    3432  sky = &par[6];
    3533}
    3634
    37 /* two components: (1 + z_1 + 0.5*z_1^2 + z_2^N)^(-1) -- x, y, sx1, sy1, sxy1, I, sky, sx2, sy2, sxy2 */
     35void rgaussCL () {
     36  set_variable ("Xg",   par[0]);
     37  set_variable ("Yg",   par[1]);
     38  set_variable ("SXg",  2.35 / par[2]);
     39  set_variable ("SYg",  2.35 / par[3]);
     40  set_variable ("SXYg", par[4]);
     41  set_variable ("Zpk",  par[5]);
     42  set_variable ("Sg",   par[6]);
     43  set_variable ("Sr",   par[7]);
     44}
     45
     46/* rgauss: (1 + z + z^alpha)^(-1) -- x, y, sx, sy, sxy, I, sky, sr */
    3847opihi_flt rgaussTD (opihi_flt x, opihi_flt y, opihi_flt *par, int Npar, opihi_flt *dpar) {
    3948  OHANA_UNUSED_PARAM(Npar);
    4049
    41   opihi_flt X, Y, px1, py1, px2, py2;
    42   opihi_flt z1, z2, r, q1, q2, f;
     50  opihi_flt X = x - par[0];
     51  opihi_flt Y = y - par[1];
     52 
     53  opihi_flt px = par[2]*X;
     54  opihi_flt py = par[3]*Y;
    4355
    44   X = x - par[0];
    45   Y = y - par[1];
    46  
    47   px1 = par[2]*X;
    48   py1 = par[3]*Y;
    49   px2 = par[7]*X;
    50   py2 = par[8]*Y;
     56  opihi_flt z = 0.5*SQ(px) + 0.5*SQ(py) + par[4]*X*Y;
    5157
    52   z1 = 0.5*SQ(px1) + 0.5*SQ(py1) + par[4]*X*Y;
    53   z2 = 0.5*SQ(px2) + 0.5*SQ(py2) + par[9]*X*Y;
    54 
    55   r = 1.0 / (1 + z1 + 0.5*SQ(z1)+ pow(z2,fpar[0]));
    56   f = par[5]*r + par[6];
    57 
    58   q1 = par[5]*SQ(r)*(1 + z1);
    59   q2 = par[5]*SQ(r)*fpar[0]*pow(z2,(fpar[0]-1));
     58  opihi_flt p = pow(z,par[7] - 1.0);
     59  opihi_flt r = 1.0 / (1 + z + z*p);
     60  opihi_flt f = par[5]*r + par[6];
    6061
    6162  if (dpar != NULL) {
    62     dpar[0] = q1*(2*px1*par[2] + par[4]*Y) + q2*(2*px2*par[7] + par[9]*Y);
    63     dpar[1] = q1*(2*py1*par[3] + par[4]*X) + q2*(2*py2*par[8] + par[9]*X);
    64     dpar[2] = -2*q1*px1*X;
    65     dpar[3] = -2*q1*py1*Y;
    66     dpar[4] = -q1*X*Y;
     63    opihi_flt t = par[5]*SQ(r);
     64    opihi_flt q = t*(1 + par[7]*p);
     65
     66    dpar[0] = +q*(par[2]*px + par[4]*Y);
     67    dpar[1] = +q*(par[3]*py + par[4]*X);
     68    dpar[2] = -q*px*X;
     69    dpar[3] = -q*py*Y;
     70    dpar[4] = -q*X*Y;
    6771    dpar[5] = +r;
    6872    dpar[6] = +1;
    69     dpar[7] = -2*q2*px2*X;
    70     dpar[8] = -2*q2*py2*Y;
    71     dpar[9] = -q2*X*Y;
     73
     74    // this model derivative is undefined at z = 0.0, but the limit is zero as z -> 0.0
     75    dpar[7] = (z == 0.0) ? 0.0 : -t*log(z)*p*z;
    7276  }
    7377  return (f);
    7478}
    7579
    76 int rgaussCL () {
    77   set_variable ("Xg",   par[0]);
    78   set_variable ("Yg",   par[1]);
    79   set_variable ("SXg",  2.35 * sqrt(2.0) / par[2]);
    80   set_variable ("SYg",  2.35 * sqrt(2.0) / par[3]);
    81   set_variable ("SXYg", par[4]);
    82   set_variable ("Zpk",  par[5]);
    83   set_variable ("Sg",   par[6]);
    84   set_variable ("SXf", 2.35 * sqrt(2.0) / par[7]);
    85   set_variable ("SYf", 2.35 * sqrt(2.0) / par[8]);
    86   set_variable ("SXYf", par[9]);
    87 }
     80/******************************************************************************
     81 * this file defines the RGAUSS source shape model (XXX need a better name!).  Note that these
     82 * model functions are loaded by pmModelClass.c using 'include', and thus need no 'include'
     83 * statements of their own.  The models use a psVector to represent the set of parameters, with
     84 * the sequence used to specify the meaning of the parameter.  The meaning of the parameters
     85 * may thus vary depending on the specifics of the model.  All models which are used as a PSF
     86 * representations share a few parameters, for which # define names are listed in pmModel.h:
     87
     88   power-law with fitted slope
     89   1 / (1 + z + z^alpha)
     90
     91 * PM_PAR_SKY 0   - local sky : note that this is unused and may be dropped in the future
     92 * PM_PAR_I0 1    - central intensity
     93 * PM_PAR_XPOS 2  - X center of object
     94 * PM_PAR_YPOS 3  - Y center of object
     95 * PM_PAR_SXX 4   - X^2 term of elliptical contour (sqrt(2) / SigmaX)
     96 * PM_PAR_SYY 5   - Y^2 term of elliptical contour (sqrt(2) / SigmaY)
     97 * PM_PAR_SXY 6   - X*Y term of elliptical contour
     98 * PM_PAR_7   7   - power-law slope (alpha)
     99 *****************************************************************************/
     100
  • branches/eam_branches/ipp-20211108/Ohana/src/opihi/cmd.astro/imfit.c

    r41962 r41965  
    6565    sgauss_setup (argv[N]);
    6666    qgauss_setup (argv[N]); // OK
     67    rgauss_setup (argv[N]);
    6768    qfgauss_setup (argv[N]); // OK
    6869    qrgauss_setup (argv[N]);
  • branches/eam_branches/ipp-20211108/Ohana/src/opihi/include/imfit.h

    r41667 r41965  
    1414void sgauss_setup (char *name);
    1515void qgauss_setup (char *name);
     16void rgauss_setup (char *name);
    1617void qfgauss_setup (char *name);
    1718void qrgauss_setup (char *name);
Note: See TracChangeset for help on using the changeset viewer.