Source code for shapelets_create_decomp.pro:

function shapelets_create_decomp, n_max,                   $
                                  BETA=beta,               $
                                  X=x,                     $
                                  N_PIXELS=n_pixels,       $
                                  NAME=name,               $
                                  FLAG=flag,               $
                                  POLAR=polar,             $
                                  EXPONENTIAL=exponential, $
                                  INTEGRATE=integrate,     $
                                  BASIS_ELLIPTICITY=basis_ellipticity, $
                                  THETA_ZERO=theta_zero

;$Id: shapelets_create_decomp.pro, v1$
;
; Copyright © 2005 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_CREATE_DECOMP
;
; CATEGORY:
;      Shapelets.
;
; PURPOSE:
;      Initiliase a band new decomp structure.
;      Works like an IDL __DEFINE procedure, but for an anonymous structure
;      (which we need because they will shrink or expand to accomodate
;      varying amounts of data).
;
; INPUTS:
;      N_MAX  - The desired truncation order of the shapelet expansion.
;
; OPTIONAL INPUTS:
;      BETA       - Shapalet scale size beta.
;      BASIS_ELLIP- Ellipticity of basis functions, in weak lensing notation:
;                   either [e1,e2] or complex(e1,e2), where e1=e*cos(2theta) and
;                   e2=e*sin(2theta), with e=(a-b)/(a+b) for major and minor axes
;                   and theta is the angle of the major axis, a/c/w from x axis.
;      THETA_ZERO - Basis functions are rotated by this anlge, a/c/w from x axis.
;
; KEYWORD PARAMETERS:
;      FLAG   - Starting flag status (DEFAULT: 0).
;      POLAR  - Whether or not the expansion should be in polar (set) or
;               Cartesian (unset) shapelet coefficients.
;
; OUTPUTS:
;      DECOMP - Returns the new decomp structure.
;
; MODIFICATION HISTORY:
;      Aug 10 - Bug in nl,nr (which had been just n,m) fixed by RM.
;      Jul 10 - EXPONENTIAL, X AND N_PIXEL options added by RM.
;      Apr 07 - BETA and THETA_ZERO input options added by RM.
;      Mar 07 - INTEGRATE and ELLIPTICITY input options added by RM.
;      Mar 07 - FLAG and NAME input options added by RM.
;      Jul 05 - Written by Richard Massey.
;-

COMPILE_OPT idl2

; Parse input
if keyword_set(exponential) then profile="EXPONENTIAL" else profile="GAUSSIAN"
n_coeffs=((long(n_max)+1)*(long(n_max)+2))/2
if not keyword_set(flag) then flag=fix(0)
if not keyword_set(name) then name=""
if not keyword_set(beta) then beta=1.
if not keyword_set(x) then x=fltarr(2)
if not keyword_set(n_pixels) then n_pixels=intarr(2)
if n_elements(integrate) eq 0 then integrate=1B ; Integrate basis functions within pixels
if keyword_set(basis_ellipticity) then begin
  if size(basis_ellipticity,/TYPE) eq 6 then begin
    ellipticity=basis_ellipticity
  endif else if n_elements(basis_ellipticity) ge 2 then begin
    ellipticity=complex(basis_ellipticity[0],basis_ellipticity[1])
  endif else message,"Ellipticity format not recognised!"
  if n_elements(theta_zero) eq 0 then theta_zero=atan(imaginary(ellipticity),float(ellipticity))/2.*!radeg
endif else begin
  ellipticity=complex(0.,0.)
  if not keyword_set(theta_zero) then theta_zero=0
endelse

; Initialise history record
systime=systime()
date=strmid(systime,0,4)+strmid(systime,8,3)+strmid(systime,4,4)+strmid(systime,20,4)
time=strmid(systime,11,5)

; Create shiny new decomp structure
decomp=create_struct("name",name,"type","decomp","profile",profile)
shapelets_make_nvec,fix(n_max),n1,n2,n_coeffs,POLAR=polar,EXPONENTIAL=exponential
coeffs=complexarr(n_coeffs)
coeffs_error=complexarr(n_coeffs)
if keyword_set(polar) then begin
;  coeffs=complexarr(n_coeffs)
;  coeffs_error=complexarr(n_coeffs)
;  shapelets_make_nvec,fix(n_max),n,m,/POLAR,EXPONENTIAL=exponential
  shapelets_make_nvec,fix(n_max),nr,nl,POLAR=0,EXPONENTIAL=exponential
  decomp=create_struct(decomp,"polar",1B,"coeffs",coeffs,"coeffs_error",coeffs_error,"n",fix(n1),"m",fix(n2),"nl",fix(nl),"nr",fix(nr))
endif else begin
  if keyword_set(exponential) then message,"Cartesian exponential shapelets not (yet) possible!"
;  coeffs=fltarr(n_coeffs)
;  coeffs_error=fltarr(n_coeffs)
;  shapelets_make_nvec,fix(n_max),n1,n2,n_coeffs,EXPONENTIAL=exponential
  decomp=create_struct(decomp,"polar",0B,"coeffs",coeffs,"coeffs_error",coeffs_error,"n1",fix(n1),"n2",fix(n2))
endelse

; Add meta-parameters to structure
decomp=create_struct(decomp,"beta",float(beta),$
                            "n_max",fix(n_max),$
                            "basis_ellipticity",ellipticity,$
                            "theta_zero",float(theta_zero),$
                            "n_coeffs",fix(n_coeffs),$
                            "x",x,$
                            "n_pixels",n_pixels,$
                            "oversample",float(1),$
                            "integrate",byte(integrate),$
                            "chisq",fltarr(2),$
                            "flag",flag,$
                            "sky_level",0.,$
                            "sky_slope",fltarr(2),$
                            "history","Created at "+time+" on "+date+".")
; Add flags to show whether calculations have been pre-done
;decomp=create_struct(decomp,"sextractor",0B,"moments",0B)

; Return the shiny new decomp structure
return,decomp

end

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





Valid HTML 4.01!

Valid CSS!