Source code for shapelets_read.pro:

;+
; NAME:
;      SHAPELETS_READ
;
; CATEGORY:
;      Shapelets.
;
; PURPOSE:
;      Generic (wrapper) routine to read in 
;       * FITS images (and also cope with fits tables),
;       * SExtractor catalogues, 
;       * shapelet catalogues and indivudal decomps,
;       * PSF models,
;      and store each in a structure compatible with the shapelets software.
;
; INPUTS:
;      FILE_NAME - Input file name. Must contain extension.
;                  This can be absolute (This is the default assumption if 
;                  it starts with / \ ~ or ?:, or keyword FULL_PATH is set)
;                  or relative to the path defined in shapelets_path.pro.
;
; OPTIONAL INPUTS:
;      The type of file is guessed by default from the extension. However, this
;      behaviour can be overridden by specifying FILE_TYPE, or setting one of 
;      the keywords IMAGE, SHAPECAT, DECOMP, etc.
;
; KEYWORD PARAMETERS:
;      None.
;
; OUTPUTS:
;      Returns a structure compatible with the shapelets software.
;
; MODIFICATION HISTORY:
;      Aug 09 - Written by Richard Massey.
;-

function shapelets_read, file_name, $
                         SILENT=silent, $
                         VERBOSE=verbose, $
                         FULL_PATH=full_path, $
                         FILE_TYPE=file_type, $
                         IMAGE=IMAGE, $
                         TABLE=TABLE, $
                         EXTENSION=extension, $
                         SEXCAT=sexcat, $
                         POLAR=polar,         $
                             CARTESIAN=cartesian, $
                             N_MAX=n_max,         $
                             MOMENTS=moments, $
                                       FITS_READ=fits_read,             $
                                       PIXEL_SCALE=pixel_scale,         $
                                       UNITS=units,                     $
                                       PHOTO_ZP=photo_zp,               $
                                       EXPOSURE_TIME=exposure_time,     $
                                       NO_MASK=no_mask,                 $
                                       NO_SEGMENTATION=no_segmentation, $
                                       NO_NOISE=no_noise,               $
                                       NOISE_LEVEL=noise_level,         $
                                       ESTIMATE_NOISE=estimate_noise,   $
                                       N_GROW=n_grow,                   $
			                                 SKY_SUBTRACT=sky_subtract,       $
                       FWHM=fwhm,                         $
                      ;N_MAX=n_max,                       $
                       RECOMP=recomp,                     $
                       PIXSIZE=pixsize,                   $
                       SNAP=snap,                         $
                       HST=hst,                           $
                       GEMS=gems,                         $
                       SUBARU=subaru, SINDEX=sindex,      $
                       DIFFSNAP=diffsnap,                 $
                       CHARGE_DIFFUSION=charge_diffusion, $
                                       _ref_extra = ex

COMPILE_OPT idl2

; Determine file type
if not keyword_set(file_name) then message,"Input file name not specified!"
if not keyword_set(file_type) then case 1 of
  keyword_set(image):    file_type="IMAGE" 
  keyword_set(table):    file_type="TABLE" 
  keyword_set(sexcat):   file_type="SEXCAT" 
  keyword_set(shapecat): file_type="SHAPECAT" 
  keyword_set(decomp):   file_type="DECOMP" 
  keyword_set(PSF):      file_type="PSF" 
  else: begin
          dotpos=strpos(strlowcase(file_name),".",/REVERSE_SEARCH) ; Locate the final dot in the file name
          if dotpos eq -1 or strlen(file_name) lt (dotpos+2) then message,"Input file name must include extension!"
          file_type=strupcase(strmid(file_name,dotpos+1)) ; Extract file suffix
          if file_type eq "FITS" then file_type="IMAGE" ; To read in a FITS table, it must be explicitly specified via the FILE_TYPE or TABLE keywords
          if (total(strmatch(["SEX","SXT"],file_type,/FOLD_CASE)))[0] gt 0 then file_type="SEXCAT" ; Cope with Jason's more prudish setups :)
        end
endcase
if not keyword_set(full_path) then begin ; Make sure that the subroutines can always be given absolute file paths
  first_char=strmid(file_name,0,1)
  if strlen(file_name) ge 2 then second_char=strmid(file_name,1,1) else second_char=""
  if first_char eq path_sep() or first_char eq "~" or second_char eq ":" then full_path=1B else full_path=0B
endif

; Call whichever one of the subroutines is required
case strupcase(file_type) of
  "IMAGE":    begin
                if keyword_set(extension) then begin
                  message,"To do."
                endif else begin
                 if not keyword_set(full_path) then file_path=shapelets_paths(3,silent=silent) else file_path=""
                 shapelets_read_image, output, file_path+file_name, /FULL_PATH, $
                                       FITS_READ=fits_read,             $
                                       PIXEL_SCALE=pixel_scale,         $
                                       UNITS=units,                     $
                                       PHOTO_ZP=photo_zp,               $
                                       EXPOSURE_TIME=exposure_time,     $
                                       NO_MASK=no_mask,                 $
                                       NO_SEGMENTATION=no_segmentation, $
                                       NO_NOISE=no_noise,               $
                                       NOISE_LEVEL=noise_level,         $
                                       ESTIMATE_NOISE=estimate_noise,   $
                                       N_GROW=n_grow,                   $
			                                 SKY_SUBTRACT=sky_subtract, $
                                       SILENT=silent,       $
                                       _extra= ex
                endelse
              end
  "TABLE":    begin
                
              end
  "SHAPECAT": begin
                if not keyword_set(full_path) then file_path=shapelets_paths(2,silent=silent) else file_path=""
                shapelets_read_shapecat, output, file_path+file_name, /FULL_PATH, $
                                         POLAR=polar,         $
                                         CARTESIAN=cartesian, $
                                         N_MAX=n_max,         $
                                         MOMENTS=moments,     $
                                         PARITY=parity, $
                                         SILENT=silent,       $
                                         _extra= ex
              end
  "SEXCAT":   begin
                if not keyword_set(full_path) then file_path=shapelets_paths(2,silent=silent) else file_path=""
                shapelets_read_sexcat, output, file_path+file_name, /FULL_PATH, $
	                                     ASCII=ascii,         $
                                       COMMENT=comment,     $
                                       UNIT=unit,           $
                                       XBUGFIXED=xbugfixed, $
                                       SILENT=silent, $
                                       _extra= ex
              end
  "DECOMP":   begin
                message,"To do."                       
              end
  "PSF":      begin
                if not keyword_set(full_path) then file_path=shapelets_paths(2,silent=silent) else file_path=""
                shapelets_read_psf, output, file_path+file_name, /FULL_PATH, $
	                                  FWHM,                              $
                                    N_MAX=n_max,                       $
                                    RECOMP=recomp,                     $
                                    PIXSIZE=pixsize,                   $
                                    SNAP=snap,                         $
                                    HST=hst,                           $
                                    GEMS=gems,                         $
                                    SUBARU=subaru, SINDEX=sindex,      $
                                    DIFFSNAP=diffsnap,                 $
                                    CHARGE_DIFFUSION=charge_diffusion, $
                                    SILENT=silent, $
                                    _extra= ex
              end
  else: message,"Input file type not recognised!"
endcase                           

help,/struct,output
return,output

end

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





Valid HTML 4.01!

Valid CSS!