Commit 952f3275 authored by Emmanuel Bertin's avatar Emmanuel Bertin
Browse files

Added FOCAL coordinates for centering parameters.

Re-organized astrometric calls.
parent f823a212
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
.TH SEXTRACTOR "1" "June 2009" "SWarp 2.8.8" "User Commands"
.TH SEXTRACTOR "1" "July 2009" "SWarp 2.8.8" "User Commands"
.SH NAME
sex \- extract a source catalog from an astronomical FITS image
.SH SYNOPSIS
+68 −5
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
*
*	Contents:	analyse(), endobject()...: measurements on detections.
*
*	Last modify:	18/11/2008
*	Last modify:	20/07/2009
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
@@ -385,9 +385,11 @@ Final processing of object data, just before saving it to the catalog.
void	endobject(picstruct *field, picstruct *dfield, picstruct *wfield,
		picstruct *dwfield, int n, objliststruct *objlist)
  {
   objstruct	*obj;
   checkstruct	*check;
   double	rawpos[NAXIS],
		pixscale2;
   int		i,j, ix,iy,selecflag, newnumber,nsub;
   objstruct	*obj;

  obj = &objlist->obj[n];

@@ -468,6 +470,43 @@ void endobject(picstruct *field, picstruct *dfield, picstruct *wfield,
      obj2->polar = (obj->a*obj->a - obj->b*obj->b)
		/ (obj->a*obj->a + obj->b*obj->b);

/*-- Express positions in FOCAL or WORLD coordinates */
    if (FLAG(obj2.mxf) || FLAG(obj2.mxw))
      astrom_pos(field, obj);

    if (FLAG(obj2.mx2w)
	|| FLAG(obj2.win_mx2w)
	|| FLAG(obj2.poserr_mx2w)
	|| FLAG(obj2.winposerr_mx2w)
	|| FLAG(obj2.poserrmx2w_prof)
	|| FLAG(obj2.prof_flagw)
	|| ((!prefs.pixel_scale) && (FLAG(obj2.npixw)
		|| FLAG(obj2.fdnpixw)
		|| FLAG(obj2.fwhmw))))
      {
      rawpos[0] = obj2->posx;
      rawpos[1] = obj2->posy;
      pixscale2 = wcs_jacobian(field->wcs, rawpos, obj2->jacob);
      }

/*-- Express shape parameters in the FOCAL or WORLD frame */
    if (FLAG(obj2.mx2w))
      astrom_shapeparam(field, obj);
/*-- Express position error parameters in the FOCAL or WORLD frame */
    if (FLAG(obj2.poserr_mx2w))
      astrom_errparam(field, obj);

    if (FLAG(obj2.npixw))
      obj2->npixw = obj->npix * (prefs.pixel_scale?
	field->pixscale/3600.0*field->pixscale/3600.0 : pixscale2);
    if (FLAG(obj2.fdnpixw))
      obj2->fdnpixw = obj->fdnpix * (prefs.pixel_scale?
	field->pixscale/3600.0*field->pixscale/3600.0 : pixscale2);

    if (FLAG(obj2.fwhmw))
      obj2->fwhmw = obj->fwhm * (prefs.pixel_scale?
	field->pixscale/3600.0 : sqrt(pixscale2));

/*------------------------------- Photometry -------------------------------*/

/*-- Convert the father of photom. error estimates from variance to RMS */
@@ -493,11 +532,25 @@ void endobject(picstruct *field, picstruct *dfield, picstruct *wfield,

/*--------------------------- Windowed barycenter --------------------------*/
    if (FLAG(obj2.winpos_x))
      {
      compute_winpos(field, wfield, obj);

/*-- What about the peak of the profile? */
/*---- Express positions in FOCAL or WORLD coordinates */
      if (FLAG(obj2.winpos_xf) || FLAG(obj2.winpos_xw))
        astrom_winpos(field, obj);
/*---- Express shape parameters in the FOCAL or WORLD frame */
      if (FLAG(obj2.mx2w))
        astrom_winshapeparam(field, obj);
/*---- Express position error parameters in the FOCAL or WORLD frame */
      if (FLAG(obj2.poserr_mx2w))
        astrom_winerrparam(field, obj);
      }

/*---------------------------- Peak information ----------------------------*/
    if (obj->peak+obj->bkg >= field->satur_level)
      obj->flag |= OBJ_SATUR;
/*-- Express positions in FOCAL or WORLD coordinates */
    if (FLAG(obj2.peakxf) || FLAG(obj2.peakxw))
      astrom_peakpos(field, obj);

/*-- Check-image CHECK_APERTURES option */

@@ -639,14 +692,24 @@ void endobject(picstruct *field, picstruct *dfield, picstruct *wfield,
/*----------------------------- Profile fitting -----------------------------*/
    nsub = 1;
    if (prefs.prof_flag)
      {
      profit_fit(theprofit, field, wfield, obj, obj2);
/*---- Express positions in FOCAL or WORLD coordinates */
      if (FLAG(obj2.winpos_xf) || FLAG(obj2.winpos_xw))
        astrom_profpos(field, obj);
/*---- Express shape parameters in the FOCAL or WORLD frame */
      if (FLAG(obj2.mx2w))
        astrom_profshapeparam(field, obj);
/*---- Express position error parameters in the FOCAL or WORLD frame */
      if (FLAG(obj2.poserr_mx2w))
        astrom_proferrparam(field, obj);
      }

/*--- Express everything in magnitude units */
    computemags(field, obj);

/*-------------------------------- Astrometry ------------------------------*/
    if (prefs.world_flag)
      computeastrom(field, obj);

/*-- Edit min and max coordinates to follow the FITS conventions */
    obj->xmin += 1;
    obj->ymin += 1;
+120 −60
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
*
*	Contents:	Astrometrical computations.
*
*	Last modify:	19/05/2008
*	Last modify:	20/07/2009
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
@@ -79,11 +79,11 @@ void initastrom(picstruct *field)
  }


/**************************** computeastrom *********************************/
/***************************** astrom_pos **********************************/
/*
Compute real WORLD coordinates and dimensions according to FITS info.
Compute real FOCAL and WORLD coordinates according to FITS info.
*/
void	computeastrom(picstruct *field, objstruct *obj)
void	astrom_pos(picstruct *field, objstruct *obj)

  {
   wcsstruct	*wcs;
@@ -94,7 +94,16 @@ void computeastrom(picstruct *field, objstruct *obj)
  wcs = field->wcs;
  lng = wcs->lng;
  lat = wcs->lat;
  pixscale2 = 0.0;	/* To avoid gcc -Wall warnings */

/* If working with WCS, compute FOCAL coordinates and local matrix */
  if (FLAG(obj2.mxf))
    {
    rawpos[0] = obj2->posx;
    rawpos[1] = obj2->posy;
    raw_to_red(wcs, rawpos, wcspos);
    obj2->mxf = wcspos[0];
    obj2->myf = wcspos[1];
    }

/* If working with WCS, compute WORLD coordinates and local matrix */
  if (FLAG(obj2.mxw))
@@ -145,7 +154,58 @@ void computeastrom(picstruct *field, objstruct *obj)
      }
    }

/* Idem for peak-flux positions */
/* Custom coordinate system for the MAMA machine */
  if (FLAG(obj2.mamaposx))
    {
    rawpos[0] = obj2->posx - 0.5;
    rawpos[1] = obj2->posy - 0.5;
    raw_to_wcs(wcs, rawpos, wcspos);
    obj2->mamaposx = wcspos[1]*(MAMA_CORFLEX+1.0);
    obj2->mamaposy = wcspos[0]*(MAMA_CORFLEX+1.0);
    }

  if (FLAG(obj2.mx2w)
	|| FLAG(obj2.win_mx2w)
	|| FLAG(obj2.poserr_mx2w)
	|| FLAG(obj2.winposerr_mx2w)
	|| FLAG(obj2.poserrmx2w_prof)
	|| FLAG(obj2.prof_flagw)
	|| ((!prefs.pixel_scale) && (FLAG(obj2.npixw)
		|| FLAG(obj2.fdnpixw)
		|| FLAG(obj2.fwhmw))))
    {
    rawpos[0] = obj2->posx;
    rawpos[1] = obj2->posy;
    pixscale2 = wcs_jacobian(wcs, rawpos, obj2->jacob);
    }

  return;
  }


/***************************** astrom_peakpos *******************************/
/*
Compute real FOCAL and WORLD peak coordinates according to FITS info.
*/
void	astrom_peakpos(picstruct *field, objstruct *obj)

  {
   wcsstruct	*wcs;
   double	rawpos[NAXIS], wcspos[NAXIS];
   int		lng,lat;

  wcs = field->wcs;
  lng = wcs->lng;
  lat = wcs->lat;

  if (FLAG(obj2.peakxf))
    {
    rawpos[0] = obj->peakx;
    rawpos[1] = obj->peaky;
    raw_to_red(wcs, rawpos, wcspos);
    obj2->peakxf = wcspos[0];
    obj2->peakyf = wcspos[1];
    }
  if (FLAG(obj2.peakxw))
    {
    rawpos[0] = obj->peakx;
@@ -174,7 +234,33 @@ void computeastrom(picstruct *field, objstruct *obj)
      }
    }

/* Idem for Windowed positions */
  return;
  }


/****************************** astrom_winpos *******************************/
/*
Compute real FOCAL and WORLD windowed coordinates according to FITS info.
*/
void	astrom_winpos(picstruct *field, objstruct *obj)

  {
   wcsstruct	*wcs;
   double	rawpos[NAXIS], wcspos[NAXIS];
   int		lng,lat;

  wcs = field->wcs;
  lng = wcs->lng;
  lat = wcs->lat;

  if (FLAG(obj2.winpos_xf))
    {
    rawpos[0] = obj2->winpos_x;
    rawpos[1] = obj2->winpos_y;
    raw_to_red(wcs, rawpos, wcspos);
    obj2->winpos_xf = wcspos[0];
    obj2->winpos_yf = wcspos[1];
    }
  if (FLAG(obj2.winpos_xw))
    {
    rawpos[0] = obj2->winpos_x;
@@ -203,7 +289,33 @@ void computeastrom(picstruct *field, objstruct *obj)
      }
    }

/* Idem for Model-fitted positions */
  return;
  }


/****************************** astrom_profpos *******************************/
/*
Compute real FOCAL and WORLD profit coordinates according to FITS info.
*/
void	astrom_profpos(picstruct *field, objstruct *obj)

  {
   wcsstruct	*wcs;
   double	rawpos[NAXIS], wcspos[NAXIS];
   int		lng,lat;

  wcs = field->wcs;
  lng = wcs->lng;
  lat = wcs->lat;

  if (FLAG(obj2.xf_prof))
    {
    rawpos[0] = obj2->x_prof;
    rawpos[1] = obj2->y_prof;
    raw_to_red(wcs, rawpos, wcspos);
    obj2->xf_prof = wcspos[0];
    obj2->yf_prof = wcspos[1];
    }
  if (FLAG(obj2.xw_prof))
    {
    rawpos[0] = obj2->x_prof;
@@ -232,58 +344,6 @@ void computeastrom(picstruct *field, objstruct *obj)
      }
    }

/* Custom coordinate system for the MAMA machine */
  if (FLAG(obj2.mamaposx))
    {
    rawpos[0] = obj2->posx - 0.5;
    rawpos[1] = obj2->posy - 0.5;
    raw_to_wcs(wcs, rawpos, wcspos);
    obj2->mamaposx = wcspos[1]*(MAMA_CORFLEX+1.0);
    obj2->mamaposy = wcspos[0]*(MAMA_CORFLEX+1.0);
    }

  if (FLAG(obj2.mx2w)
	|| FLAG(obj2.win_mx2w)
	|| FLAG(obj2.poserr_mx2w)
	|| FLAG(obj2.winposerr_mx2w)
	|| FLAG(obj2.poserrmx2w_prof)
	|| FLAG(obj2.prof_flagw)
	|| ((!prefs.pixel_scale) && (FLAG(obj2.npixw)
		|| FLAG(obj2.fdnpixw)
		|| FLAG(obj2.fwhmw))))
    {
    rawpos[0] = obj2->posx;
    rawpos[1] = obj2->posy;
    pixscale2 = wcs_jacobian(wcs, rawpos, obj2->jacob);
    }

/* Express shape parameters in WORLD frame */
  if (FLAG(obj2.mx2w))
    astrom_shapeparam(field, obj);
  if (FLAG(obj2.win_mx2w))
    astrom_winshapeparam(field, obj);
  if (FLAG(obj2.prof_flagw))
    astrom_profshapeparam(field, obj);

/* Express position error parameters in WORLD frame */
  if (FLAG(obj2.poserr_mx2w))
    astrom_errparam(field, obj);
  if (FLAG(obj2.winposerr_mx2w))
    astrom_winerrparam(field, obj);
  if (FLAG(obj2.poserrmx2w_prof))
    astrom_proferrparam(field, obj);

  if (FLAG(obj2.npixw))
    obj2->npixw = obj->npix * (prefs.pixel_scale?
	field->pixscale/3600.0*field->pixscale/3600.0 : pixscale2);
  if (FLAG(obj2.fdnpixw))
    obj2->fdnpixw = obj->fdnpix * (prefs.pixel_scale?
	field->pixscale/3600.0*field->pixscale/3600.0 : pixscale2);

  if (FLAG(obj2.fwhmw))
    obj2->fwhmw = obj->fwhm * (prefs.pixel_scale?
	field->pixscale/3600.0 : sqrt(pixscale2));

  return;
  }

+5 −2
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
*
*	Contents:	Astrometrical stuff.
*
*	Last modify:	18/05/2008
*	Last modify:	20/07/2009
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
@@ -30,12 +30,15 @@
/*------------------------------- structures --------------------------------*/
/*------------------------------- functions ---------------------------------*/
extern void		astrom_errparam(picstruct *, objstruct *),
			astrom_peakpos(picstruct *, objstruct *),
			astrom_pos(picstruct *, objstruct *),
			astrom_proferrparam(picstruct *, objstruct *),
			astrom_profpos(picstruct *, objstruct *),
			astrom_profshapeparam(picstruct *, objstruct *),
			astrom_shapeparam(picstruct *, objstruct *),
			astrom_winerrparam(picstruct *, objstruct *),
			astrom_winpos(picstruct *, objstruct *),
			astrom_winshapeparam(picstruct *, objstruct *),
			computeastrom(picstruct *, objstruct *),
			initastrom(picstruct *),
			j2b(double, double, double, double *, double *),
			precess(double,double,double,double,double *,double *);
+11 −4
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
*
*	Contents:	functions for output of catalog data.
*
*	Last modify:	29/05/2009
*	Last modify:	20/07/2009
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
@@ -201,13 +201,15 @@ void updateparamflags()
			| FLAG(obj2.alpha2000_prof);
  FLAG(obj2.xw_prof) |= FLAG(obj2.yw_prof)
			| FLAG(obj2.alphas_prof);

  FLAG(obj2.xf_prof) |= FLAG(obj2.yf_prof);
  FLAG(obj2.x_prof) |= FLAG(obj2.y_prof)
			| FLAG(obj2.xw_prof)
			| FLAG(obj2.xf_prof)
			| FLAG(obj2.poserra_prof)
			| FLAG(obj2.poserrcxx_prof)
			| FLAG(obj2.prof_concentration)
			| FLAG(obj2.prof_class_star);

  FLAG(obj2.mag_prof) |= FLAG(obj2.magerr_prof);
  FLAG(obj2.magerr_prof) |= FLAG(obj2.fluxerr_prof);
  FLAG(obj2.flux_prof) |= FLAG(obj2.mag_prof) | FLAG(obj2.fluxerr_prof);
@@ -392,6 +394,7 @@ void updateparamflags()
			| FLAG(obj2.winposerr_theta2000);
  FLAG(obj2.winpos_alphas) |= FLAG(obj2.winpos_deltas)
			| FLAG(obj2.winpos_alpha2000);
  FLAG(obj2.winpos_xf) |= FLAG(obj2.winpos_yf);
  FLAG(obj2.winpos_xw) |= FLAG(obj2.winpos_yw)
			| FLAG(obj2.winpos_alphas);

@@ -432,8 +435,11 @@ void updateparamflags()
			| FLAG(obj2.npixw) | FLAG(obj2.fdnpixw)
			| FLAG(obj2.fwhmw);
  
  FLAG(obj2.peakxw) |= FLAG(obj2.peakyf);
  FLAG(obj2.peakxw) |= FLAG(obj2.peakyw) | FLAG(obj2.peakalphas);
  FLAG(obj.peakx) |= FLAG(obj.peaky) | FLAG(obj2.peakxw);
  FLAG(obj.peakx) |= FLAG(obj.peaky) | FLAG(obj2.peakxw) | FLAG(obj2.peakxf);

  FLAG(obj2.mxf) |= FLAG(obj2.myf);

  FLAG(obj2.mxw) |= FLAG(obj2.myw) | FLAG(obj2.mx2w) | FLAG(obj2.alphas)
		| FLAG(obj2.poserr_mx2w);
@@ -442,7 +448,8 @@ void updateparamflags()
			    | FLAG(obj2.flux_win) | FLAG(obj2.fluxerr_win);
  FLAG(obj2.winpos_x) |= FLAG(obj2.winpos_y)
			| FLAG(obj2.winposerr_mx2) | FLAG(obj2.win_mx2)
			| FLAG(obj2.winpos_xw) | FLAG(obj2.win_flag)
			| FLAG(obj2.winpos_xw) | FLAG(obj2.winpos_xf)
			| FLAG(obj2.win_flag)
			| FLAG(obj2.flux_win) |FLAG(obj2.winpos_niter);

/*------------------------------ Photometry ---------------------------------*/
Loading