Commit b13bfdc5 authored by Emmanuel Bertin's avatar Emmanuel Bertin
Browse files

Added ...

Added  POLAR1ERRMODEL_WORLD,POLAR2ERRMODEL_WORLD,POLARCORRMODEL_WORLD,ELLIP1ERRMODEL_WORLD,ELLIP2ERRMODEL_WORLD and ELLIPCORRMODEL_WORLD measurement parameters.
parent 3959d99d
Loading
Loading
Loading
Loading
+63 −14
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
*
*	Contents:	Astrometrical computations.
*
*	Last modify:	03/08/2010
*	Last modify:	20/08/2010
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
@@ -854,7 +854,9 @@ Compute profile-fitting shape parameters in WORLD and SKY coordinates.
void	astrom_profshapeparam(picstruct *field, objstruct *obj)
  {
   wcsstruct	*wcs;
   double	dx2,dy2,dxy, xm2,ym2,xym, temp,pm2, lm0,lm1,lm2,lm3, ct,st;
   double	mat[9], tempmat[9], mx2wcov[9], dpdmx2[6], cov[4],
		dx2,dy2,dxy, xm2,ym2,xym, pm2, lm0,lm1,lm2,lm3, ct,st,
		temp, invstemp, den, invden, dval;
   int		lng,lat, naxis;

  wcs = field->wcs;
@@ -1047,9 +1049,18 @@ void astrom_profshapeparam(picstruct *field, objstruct *obj)
    dx2 = obj2->prof_mx2;
    dy2 = obj2->prof_my2;
    dxy = obj2->prof_mxy;
    obj2->prof_mx2w = xm2 = lm0*lm0*dx2 + lm1*lm1*dy2 + lm0*lm1*dxy;
    obj2->prof_my2w = ym2 = lm2*lm2*dx2 + lm3*lm3*dy2 + lm2*lm3*dxy;
    obj2->prof_mxyw = xym = lm0*lm2*dx2 + lm1*lm3*dy2 + (lm0*lm3+lm1*lm2)*dxy;
    mat[0] = lm0*lm0;
    mat[3] = lm1*lm1;
    mat[6] = lm0*lm1;
    mat[1] = lm2*lm2;
    mat[4] = lm3*lm3;
    mat[7] = lm2*lm3;
    mat[2] = lm0*lm2;
    mat[5] = lm1*lm3;
    mat[8] = lm0*lm3+lm1*lm2;
    obj2->prof_mx2w = xm2 = mat[0]*dx2 + mat[3]*dy2 + mat[6]*dxy;
    obj2->prof_my2w = ym2 = mat[1]*dx2 + mat[4]*dy2 + mat[7]*dxy;
    obj2->prof_mxyw = xym = mat[2]*dx2 + mat[5]*dy2 + mat[8]*dxy;
    temp=xm2-ym2;
    if (FLAG(obj2.prof_thetaw))
      {
@@ -1093,15 +1104,36 @@ void astrom_profshapeparam(picstruct *field, objstruct *obj)
      obj2->prof_cxyw = (float)(-2*xym/temp);
      }
  
/*-- Use the Jacobians to compute the moment covariance matrix */
    if (FLAG(obj2.prof_pol1errw) || FLAG(obj2.prof_e1errw))
      propagate_covar(obj2->prof_mx2cov, mat, mx2wcov, 3, 3, tempmat);

    if (FLAG(obj2.prof_pol1w))
      {
      if (xm2+ym2 > 1.0/BIG)
        {
        obj2->prof_pol1w = (xm2 - ym2) / (xm2+ym2);
        obj2->prof_pol2w = 2.0*xym / (xm2 + ym2);
        if (FLAG(obj2.prof_pol1errw))
          {
/*-------- Compute the Jacobian of polarisation */
          invden = 1.0/(xm2+ym2);
          dpdmx2[0] =  2.0*ym2*invden*invden;
          dpdmx2[1] = -2.0*xm2*invden*invden;
          dpdmx2[2] =  0.0;
          dpdmx2[3] = -2.0*xym*invden*invden;
          dpdmx2[4] = -2.0*xym*invden*invden;
          dpdmx2[5] =  2.0*invden;
          propagate_covar(mx2wcov, dpdmx2, cov, 3, 2, tempmat);
          obj2->prof_pol1errw = (float)sqrt(cov[0]<0.0? 0.0: cov[0]);
          obj2->prof_pol2errw = (float)sqrt(cov[3]<0.0? 0.0: cov[3]);
          obj2->prof_pol12corrw = (dval=cov[0]*cov[3]) > 0.0?
					(float)(cov[1]/sqrt(dval)) : 0.0;
          }
        }
      else
        obj2->prof_pol1w = obj2->prof_pol2w = 0.0;
        obj2->prof_pol1w = obj2->prof_pol2w = obj2->prof_pol1errw
		= obj2->prof_pol2errw = obj2->prof_pol12corrw = 0.0;
      }

    if (FLAG(obj2.prof_e1w))
@@ -1109,15 +1141,32 @@ void astrom_profshapeparam(picstruct *field, objstruct *obj)
      if (xm2+ym2 > 1.0/BIG)
        {
        temp = xm2*ym2 - xym*xym;
        if (temp>=0.0)
          temp = xm2+ym2+2.0*sqrt(temp);
        else
          temp = xm2+ym2;
        obj2->prof_e1w = (xm2 - ym2) / temp;
        obj2->prof_e2w = 2.0*xym / temp;
        den = (temp>=0.0) ? xm2+ym2+2.0*sqrt(temp) : xm2+ym2;
        invden = 1.0/den;
        obj2->prof_e1w = (float)(invden*(xm2 - ym2));
        obj2->prof_e2w = (float)(2.0 * invden * xym);
        if (FLAG(obj2.prof_e1errw))
        {
/*------ Compute the Jacobian of ellipticity */
        invstemp = (temp>=0.0) ? 1.0/sqrt(temp) : 0.0;
        dpdmx2[0] = ( den - (1.0+ym2*invstemp)*(xm2-ym2))*invden*invden;
        dpdmx2[1] = (-den - (1.0+xm2*invstemp)*(xm2-ym2))*invden*invden;
        dpdmx2[2] = 2.0*xym*invstemp*(xm2-ym2)*invden*invden;
        dpdmx2[3] = -2.0*xym*(1.0+ym2*invstemp)*invden*invden;
        dpdmx2[4] = -2.0*xym*(1.0+xm2*invstemp)*invden*invden;
        dpdmx2[5] =  (2.0*den+4.0*xym*xym*invstemp)*invden*invden;

/*------ Use the Jacobian to compute the ellipticity covariance matrix */
        propagate_covar(mx2wcov, dpdmx2, cov, 3, 2, tempmat);
        obj2->prof_e1errw = (float)sqrt(cov[0]<0.0? 0.0: cov[0]);
        obj2->prof_e2errw = (float)sqrt(cov[3]<0.0? 0.0: cov[3]);
        obj2->prof_e12corrw = (dval=cov[0]*cov[3]) > 0.0?
					(float)(cov[1]/sqrt(dval)) : 0.0;
        }
        }
      else
        obj2->prof_e1w = obj2->prof_e2w = 0.0;
        obj2->prof_e1w = obj2->prof_e2w = obj2->prof_e1errw
		= obj2->prof_e2errw = obj2->prof_e12corrw = 0.0;
      }
    }

+12 −8
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
*
*	Contents:	functions for output of catalog data.
*
*	Last modify:	03/08/2010
*	Last modify:	20/08/2010
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
@@ -233,8 +233,11 @@ void updateparamflags()
  FLAG(obj2.prof_bar_aspect) |= FLAG(obj2.prof_bar_aspecterr);
  FLAG(obj2.prof_bar_theta) |= FLAG(obj2.prof_bar_thetaerr);
  FLAG(obj2.prof_arms_mag) |= FLAG(obj2.prof_arms_magerr);
  FLAG(obj2.prof_e1w) |= FLAG(obj2.prof_e2w);
  FLAG(obj2.prof_pol1w) |= FLAG(obj2.prof_pol2w);
  FLAG(obj2.prof_e1errw) |= FLAG(obj2.prof_e2errw) | FLAG(obj2.prof_e12corrw);
  FLAG(obj2.prof_e1w) |= FLAG(obj2.prof_e2w) | FLAG(obj2.prof_e1errw);
  FLAG(obj2.prof_pol1errw) |= FLAG(obj2.prof_pol2errw)
			| FLAG(obj2.prof_pol12corrw);
  FLAG(obj2.prof_pol1w) |= FLAG(obj2.prof_pol2w) | FLAG(obj2.prof_pol1errw);
  FLAG(obj2.prof_aw) |= FLAG(obj2.prof_bw);
  FLAG(obj2.prof_cxxw) |= FLAG(obj2.prof_cyyw) | FLAG(obj2.prof_cxyw);
  FLAG(obj2.prof_thetas) |= FLAG(obj2.prof_theta1950)
@@ -325,14 +328,15 @@ void updateparamflags()
			| FLAG(obj2.prof_arms_scalew)
			| FLAG(obj2.prof_mx2w);

  FLAG(obj2.proferr_e1) |= FLAG(obj2.proferr_e2) | FLAG(obj2.profcorr_e12);
  FLAG(obj2.prof_e1err) |= FLAG(obj2.prof_e2err) | FLAG(obj2.prof_e12corr)
			| FLAG(obj2.prof_e1errw);
			
  FLAG(obj2.prof_e1) |= FLAG(obj2.prof_e2)
			| FLAG(obj2.proferr_e1) | FLAG(obj2.prof_e1w);
  FLAG(obj2.proferr_pol1) |= FLAG(obj2.proferr_pol2)
			| FLAG(obj2.profcorr_pol12);
			| FLAG(obj2.prof_e1err) | FLAG(obj2.prof_e1w);
  FLAG(obj2.prof_pol1err) |= FLAG(obj2.prof_pol2err)
			| FLAG(obj2.prof_pol12corr) | FLAG(obj2.prof_pol1errw);
  FLAG(obj2.prof_pol1) |= FLAG(obj2.prof_pol2)
			| FLAG(obj2.proferr_pol1) | FLAG(obj2.prof_pol1w);
			| FLAG(obj2.prof_pol1err) | FLAG(obj2.prof_pol1w);
  FLAG(obj2.prof_a) |= FLAG(obj2.prof_b) | FLAG(obj2.prof_theta)
			| FLAG(obj2.prof_aw);
  FLAG(obj2.prof_cxx) |= FLAG(obj2.prof_cyy)
+3 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
*
*	Contents:	global declarations.
*
*	Last modify:	01/10/2009
*	Last modify:	20/08/2010
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
@@ -54,6 +54,8 @@ extern void alloccatparams(void),
		neurclose(void),
		neurresp(double *, double *),
		preanalyse(int, objliststruct *, int),
		propagate_covar(double *vi, double *d, double *vo,
				int ni, int no,	double *temp),
		readcatparams(char *),
		readdata(picstruct *, PIXTYPE *, int),
		readidata(picstruct *, FLAGTYPE *, int),
+55 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
*
*	Contents:	miscellaneous functions.
*
*	Last modify:	24/09/2009
*	Last modify:	20/08/2010
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
@@ -73,6 +73,60 @@ float hmedian(float *ra, int n)
  }


/****** propagate_covar ******************************************************
PROTO	void	propagate_covar(double *vi, double *d, double *vo,
				int ni, int no,	double *temp)
PURPOSE	Compute Dt.V.D (propagate covariance matrix errors)
INPUT	Pointer to the original covariance matrix,
	pointer to the matrix of derivatives,
	input number of parameters,
	output number of parameters,
	pointer to a ni*no work array.
OUTPUT	-.
NOTES	-.
AUTHOR	E. Bertin (IAP)
VERSION	20/08/2010
 ***/
void propagate_covar(double *vi, double *d, double *vo,
				int ni, int no,	double *temp)
  {
   double	*vit,*dt,*vot,*tempt,
		dval;
   int		i,j,k;

  tempt = temp;
  vit = vi;
  for (j=0; j<ni; j++)
    {
    dt = d;
    for (i=no; i--;)
      {
      vit = vi + j*ni;
      dval = 0.0;
      for (k=ni; k--;)
        dval += *(vit++)**(dt++);
      *(tempt++) = dval;
      }
    }

  vot = vo;
  for (j=0; j<no; j++)
    {
    for (i=0; i<no; i++)
      {
      dt = d + j*ni;
      tempt = temp + i;
      dval = 0.0;
      for (k=ni; k--; tempt+=no)
        dval += *(dt++)**tempt;
      *(vot++) = dval;
      }
    }

  return;
  }


/****** counter_seconds *******************************************************
PROTO	double counter_seconds(void)
PURPOSE	Count the number of seconds (with an arbitrary offset).
+27 −7
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
*
*	Contents:	Model-fitting parameter list for catalog data.
*
*	Last modify:	03/08/2010
*	Last modify:	20/08/2010
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
@@ -198,23 +198,23 @@
	"src.ellipticity;stat.fit;instr.det", ""},

  {"ELLIP1ERRMODEL_IMAGE", "Ellipticity component std.error from model-fitting",
	&outobj2.proferr_e1, H_FLOAT, T_FLOAT, "%10.6f", "",
	&outobj2.prof_e1err, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.error;src.ellipticity;stat.fit;instr.det", ""},
  {"ELLIP2ERRMODEL_IMAGE", "Ellipticity component std.error from model-fitting",
	&outobj2.proferr_e2, H_FLOAT, T_FLOAT, "%10.6f", "",
	&outobj2.prof_e2err, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.error;src.ellipticity;stat.fit;instr.det", ""},
  {"ELLIPCORRMODEL_IMAGE", "Corr.coeff between ellip.components from model-fitting",
	&outobj2.profcorr_e12, H_FLOAT, T_FLOAT, "%10.6f", "",
	&outobj2.prof_e12corr, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.correlation;src.ellipticity;stat.fit;instr.det", ""},

  {"POLAR1ERRMODEL_IMAGE", "Polarisation component std.error from model-fitting",
	&outobj2.proferr_pol1, H_FLOAT, T_FLOAT, "%10.6f", "",
	&outobj2.prof_pol1err, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.error;src.ellipticity;stat.fit;instr.det", ""},
  {"POLAR2ERRMODEL_IMAGE", "Polarisation component std.error from model-fitting",
	&outobj2.proferr_pol2, H_FLOAT, T_FLOAT, "%10.6f", "",
	&outobj2.prof_pol2err, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.error;src.ellipticity;stat.fit;instr.det", ""},
  {"POLARCORRMODEL_IMAGE", "Corr.coeff between polar. components from fitting",
	&outobj2.profcorr_pol12, H_FLOAT, T_FLOAT, "%10.6f", "",
	&outobj2.prof_pol12corr, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.correlation;src.ellipticity;stat.fit;instr.det", ""},

  {"X2MODEL_WORLD", "Variance along X-WORLD (alpha) from model-fitting",
@@ -239,6 +239,26 @@
	&outobj2.prof_pol2w, H_FLOAT, T_FLOAT, "%10.6f", "",
	"src.ellipticity;stat.fit", ""},

  {"ELLIP1ERRMODEL_WORLD", "Ellipticity component std.error from model-fitting",
	&outobj2.prof_e1errw, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.error;src.ellipticity;stat.fit", ""},
  {"ELLIP2ERRMODEL_WORLD", "Ellipticity component std.error from model-fitting",
	&outobj2.prof_e2errw, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.error;src.ellipticity;stat.fit", ""},
  {"ELLIPCORRMODEL_WORLD", "Corr.coeff between ellip.components from model-fitting",
	&outobj2.prof_e12corrw, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.correlation;src.ellipticity;stat.fit", ""},

  {"POLAR1ERRMODEL_WORLD", "Polarisation component std.error from model-fitting",
	&outobj2.prof_pol1errw, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.error;src.ellipticity;stat.fit", ""},
  {"POLAR2ERRMODEL_WORLD", "Polarisation component std.error from model-fitting",
	&outobj2.prof_pol2errw, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.error;src.ellipticity;stat.fit", ""},
  {"POLARCORRMODEL_WORLD", "Corr.coeff between polar. components from fitting",
	&outobj2.prof_pol12corrw, H_FLOAT, T_FLOAT, "%10.6f", "",
	"stat.correlation;src.ellipticity;stat.fit", ""},

  {"CXXMODEL_IMAGE", "Cxx ellipse parameter from model-fitting",
	&outobj2.prof_cxx, H_EXPO, T_FLOAT, "%15.7e", "pixel**(-2)",
	"src.impactParam;stat.fit;instr.det", "pix-2"},
Loading