; Copyright 2007 IAS ; This file is part of the Planck Sky Model. ; ; The Planck Sky Model is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; version 2 of the License. ; ; The Planck Sky Model 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 License for more details. ; ; You should have received a copy of the GNU General Public License ; along with the Planck Sky Model. If not, write to the Free Software ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ;+ ; ; read healpix fits file, convert map to given NSIDE and ordering=NESTED ; add small scales if keyword smallscale is set ; returns pointer to converted map ; ; @param name {in}{required}{type=string} ... ; @keyword polar{in}{optional}{type=boolean} ... ; @keyword min{in}{optional}{type=float} ... ; @keyword max{in}{optional}{type=float} ... ; ; @history

MAMD 14/03/2007 - creation

; @history

MAMD 24/05/2007 - introduce dataptr

; @history

MAMD 04/03/2008 - add polar keyword (for call to ; add_smallscale) and min, max keywords

; ;- function file2ptr, name, polar=polar, min=min, max=max, struct, nside, smallscale=smallscale if not keyword_set(polar) then polar=0 ; find structure index id = -1 tags = tag_names( (*!sky_model).ancillary ) for i=0, n_elements(tags)-1 do begin if (name eq tags(i)) then id = i endfor if (id eq -1) then begin print, 'Can not find data ', name return, -1 endif ; read template if necessary struct = (*!sky_model).ancillary.(id) if not keyword_set( struct.dataptr ) then begin nside = (*!sky_model).nside fitsfile = struct.file ok = FILE_TEST(fitsfile) IF NOT ok THEN GET_PSM_DATA, datafile=fitsfile print, 'read ', fitsfile read_fits_map, fitsfile, d, hdr, exthdr if (n_elements(exthdr) gt 1) then order_in = sxpar(exthdr, 'ORDERING') else order_in='RING' ;; If the original map has better resolution than requested, ;; smooth it IF struct.resolution LT SKY_RESOLUTION() THEN BEGIN beam_in = GET_BEAM_STRUCT('GAUSSIAN',beamsize=struct.resolution,sizeunits='arcmin') beam_out = GET_BEAM_STRUCT('GAUSSIAN',beamsize=SKY_RESOLUTION(),sizeunits='arcmin') CHANGE_MAP_RESOLUTION, d, dd, beam_in=beam_in, beam_out=beam_out, $ /nohdr, ordering_in=order_in, ordering_out='NESTED', nside_out=nside, $ double = PRECISION_ISDOUBLE(), lmax=SKY_LMAX() ENDIF ELSE BEGIN ;; Here we need first to go to the proper nside, and then ;; add small scales nside_in = NPIX2NSIDE(N_ELEMENTS(d[*,0])) order = 'RING' IF nside_in LT nside THEN BEGIN PSM_MAP2ALM, d, alm, lmax = SKY_LMAX()<(3*nside_in-1), ordering=order_in PSM_ALM2MAP, TEMPORARY(alm), dd, hpx_nside=nside, ordering=order ENDIF ELSE BEGIN ud_grade,d,dd,nside_out=nside,order_in=order_in,order_out=order ENDELSE ;; add small scale structure if needed IF struct.resolution GT SKY_RESOLUTION() THEN BEGIN ;; Add small scales if requested if keyword_set(smallscale) then dd = add_smallscale(TEMPORARY(dd), struct, polar=polar, ordering=order) ENDIF ;; Reorder dd = REORDER(TEMPORARY(dd),/r2n) ENDELSE d=TEMPORARY(dd) ;; Check for min and max if keyword_set(min) then d=d>min if keyword_set(max) then d=d