from ISM.Extinction import * from ISM.Extinction.Nicer import * from ISM.FITS.FITS import MakeEmptyFitsDim # Select a target cloud ra0 = HMS2RAD( 15, 39, 42.0) de0 = DMS2RAD( -7, 10, 0.0) box = 60.0*ARCMIN_TO_RADIAN # map size in radians pix = 0.5*ARCMIN_TO_RADIAN # pixel size fwhm = 3.0*ARCMIN_TO_RADIAN # fwhm of the Av map npix = int(box/pix) # map size as number of pixels # Read 2Mass stars for a reference field (OFF field) coo, mag, dmag = read_2mass_www(ra0, de0+box, box_size=0.5*box, filename='OFF.2Mass') # Read 2Mass stars for the ON field COO, MAG, DMAG = read_2mass_www(ra0, de0 , box_size=box, filename='ON.2Mass') # Make a template FITS image for the extinction map and the error map F = MakeEmptyFitsDim(ra0, de0, 0.5*ARCMIN_TO_RADIAN, npix, npix) dF = MakeEmptyFitsDim(ra0, de0, 0.5*ARCMIN_TO_RADIAN, npix, npix) # Choose extinction curve EX_AV = get_AX_AV(['J', 'H', 'Ks'], Rv=3.1) # Calculate extinction and save the results to FITS files NICER_with_OpenCL(F, COO, MAG, DMAG, mag, dmag, EX_AV, FWHM=3.0*ARCMIN_TO_RADIAN, CLIP=3.0, GPU=0, dF=dF) F.writeto( 'test_Av.fits' , overwrite=True) dF.writeto('test_dAv.fits', overwrite=True)
for i in range(1000): K = 4.0 * log(2.0) / (clip(2.0 + 1.0 * randn(), 2.0, 99)**2.0) G[0].data += 98.0 * rand() * exp(-K * ((J - N * rand())**2.0 + (I - M * rand())**2.0)) G[0].data = clip(G[0].data, 1.0, +100.0) G[0].data[0:3, :] = 0.0 G[0].data[-3:, :] = 0.0 G[0].data[:, 0:3] = 0.0 G[0].data[:, -3:] = 0.0 if (1): # rotate the input image rot = 30 * DEGREE_TO_RADIAN G[0].header['CD1_1'] = G[0].header['CDELT1'] * cos(rot) G[0].header['CD1_2'] = -G[0].header['CDELT2'] * sin(rot) G[0].header['CD2_1'] = G[0].header['CDELT1'] * sin(rot) G[0].header['CD2_2'] = G[0].header['CDELT2'] * cos(rot) G.writeto('g.fits', overwrite=True) # Run montage.reproject A[0].header.totextfile('ref.header', overwrite=True) montage.reproject('g.fits', 'A.fits', 'ref.header', exact_size=True, factor=factor) A = pyfits.open('A.fits') # Run the OpenCL routine Reproject(G, B, GPU=GPU, cstep=cstep, shrink=1.0) # ignore the borders .... note that pixel values may be very small for the last pixels # on the edges of the area covered by the input data
J, I = indices((N, M), np.float32) for i in range(30): K = 4.0 * log(2.0) / (clip(2.0 + 1.0 * randn(), 2.0, 99)**2.0) G[0].data += 100.0 * rand() * exp(-K * ((J - N * rand())**2.0 + (I - M * rand())**2.0)) G[0].data[0:3, :] = 0.0 G[0].data[-3:, :] = 0.0 G[0].data[:, 0:3] = 0.0 G[0].data[:, -3:] = 0.0 if (1): # rotate the input image rot = 30 * DEGREE_TO_RADIAN G[0].header['CD1_1'] = G[0].header['CDELT1'] * cos(rot) G[0].header['CD1_2'] = -G[0].header['CDELT2'] * sin(rot) G[0].header['CD2_1'] = G[0].header['CDELT1'] * sin(rot) G[0].header['CD2_2'] = G[0].header['CDELT2'] * cos(rot) G.writeto('g.fits', overwrite=True) # Run montage.reproject if ( N < 10000 ): # laptop tmp directory was running out of space for larger images... time.sleep( SLEEP ) # sleep before and after Montage, to avoid (reduce) CPU throttling t0 = time.time() A[0].header.totextfile('ref.header', overwrite=True) montage.reproject('g.fits', 'A.fits', 'ref.header', exact_size=True, factor=factor)