Source code for shapelets_active_focus.pro:

;$Id: shapelets_active_focus.pro, v2$
;
; Copyright © 2010 Richard Massey and Alexandre Refregier.
;
; This file is a part of the Shapelets analysis code.
; www.astro.caltech.edu/~rjm/shapelets/
;
; The Shapelets code is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public Licence as published
; by the Free Software Foundation; either version 2 of the Licence, or
; (at your option) any later version.
;
; The Shapelets code is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public Licence for more details.
;
; You should have received a copy of the GNU General Public Licence
; along with the Shapelets code; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
;
;+
; NAME:
;       SHAPELETS_ACTIVE_FOCUS
;
; PURPOSE:
;       Find the position, shear and scale size in which a shapelet model
;       looks circular (a la BJ02).
;
; CATEGORY:
;       Shapelets.
;
; INPUTS:
;       PSTAMP - Postage stamp structure containing the image (and other
;                parameters) around a single object. This can be created with
;                shapelets_sexcat2pstamp.pro
;
; OPTIONAL INPUTS:
;       BETA_GUESS      - Starting point for shapelet scale size beta.
;       N_MAX_GUESS     - Starting point for truncation order n_max.
;       CENTRE_GUESS    - Starting point for centre of shapelet basis functions.
;       CHISQ_TARGET    - Ideal value of reduced chi^2 for the residual image.
;       CHISQ_TOLERANCE - Acceptable accuracy for chi^2, in units of the rms.
;       CHISQ_FLATNESS  - Minimum difference in chi^2 between two decompositions
;                         with n_max differing by two to trigger the flatness
;                         constraint in shapelets_focus_nmax
;       BETA_TOLERANCE  - Fractional tolerance for finding beta.
;       FIXED_BETA      - Force this value of beta for all objects. Still iterates
;                         to find the best centroid and n_max.
;       AMOEBA_SCALE    - Controls the size of the amoeba's steps.
;       THETA_MIN_GEOM  - Minimum scale on which it is possible for the image to
;                         contain data.
;       N_MAX_RANGE     - Range of n_max values to consider.
;       PSF             - A shapelet decomp structure representing the local PSF.
;                         The shapelet model of the galaxy will be deconvolved
;                         from this.
;
; KEYWORD PARAMETERS:
;       SILENT          - Operate silently.
;       VERBOSE         - Operate noisily.
;       SKY             - 1: fit sky background with a constant value around object.
;                         2: fit sky gradient with a plane around object.
;                         DEFAULT: no sky subtraction.
;       NON1            - a_01 and a_10 are forced to be zero, Kuijken-like.
;       FULL_FOCUS      - Record every single attempt made at decomposition during
;                         iteration. Makes things a little slower, but plots nicer. 
;
; OUTPUTS:
;       DECOMP     	- Decomposition structure containing the shapelet
;                  	  coefficients with the optimal beta, n_max and centroid
;                  	  parameters.
;
; OPTIONAL OUTPUTS:
;       FOCUS      	- IDL structure tracing the search on the beta-n_max plane.
;       RECOMP     	- Recomposed image using optimal shapelet parameters.
;
; CALLING SEQUENCE:
;       decomp=shapelets_focus(pstamp,focus=focus)
;
; MODIFICATION HISTORY:
;       Jun 10 - Written by Richard Massey.
;-

function shapelets_focus, PSTAMP,                                  $
                          FOCUS=focus,                             $
                          RECOMP=recomp,                           $
                          BETA_GUESS=beta_guess,	                 $
                          BETA_TOLERANCE=beta_tolerance,           $
                          FIXED_BETA=fixed_beta,	                 $
                          N_MAX_GUESS=n_max_guess,	               $
                          N_MAX_RANGE=n_max_range,	               $
                          CENTRE_GUESS=centre_guess,	             $
                          CHISQ_TARGET=chisq_target,	             $
                          CHISQ_TOLERANCE=chisq_tolerance,         $
                          CHISQ_FLATNESS=chisq_flatness,           $
                          THETA_MIN_GEOM=theta_min_geom,           $
                          GAUSSIAN_RECENTRING=gaussian_recentring, $
                          AMOEBA_SCALE=amoeba_scale,               $
                          MAX_LOOPS=max_loops,                     $
                          MAX_TIME=max_time,                       $
                          FULL_FOCUS=full_focus,                   $
                          NAME=name,                               $
                          PSF=psf,                                 $
                          SKY=sky,			                           $
                          REBIN_RESIDUAL=rebin_residual,           $
                          SMOOTH_RESIDUAL=smooth_residual,         $
                          NUDGE_BETA=nudge_beta,                   $
                          NUDGE_N_MAX=nudge_n_max,                 $
                          NON1=non1,			                         $
                          DIAMOND=diamond,                         $
                          POLAR=polar,                             $
                          VERBOSE=verbose,		                     $
                          SILENT=silent

COMPILE_OPT idl2


; Display a summary of the results
;message,"Focus flag: "+strtrim(focus.flag,1)+$
;        ", n_max="+strtrim(focus.n_max,1)+$
;        ", chi^2="+strtrim(focus.chisq,1),/INFO,NOPRINT=SILENT
return,decomp

end


Return to the shapelets web page or the code help menu.





Valid HTML 4.01!

Valid CSS!