astropyで読み込んだfit画像をpycudaで加工する

その買うを、もっとハッピーに。|ハピタス

astropyのpyfitsを使ってfit(s)画像を読み込んで、読み込んだ画像をpycudaを使って加工して少しでも処理を高速化するというプログラムを試してみた。

スポンサーリンク

fitデータをダウンロードして加工する

先ずはfitのチュートリアル用サンプル画像データをダウンロード

%download http://data.astropy.org/tutorials/FITS-images/HorseHead.fits
Downloaded 'HorseHead.fits'.

次にダウンロードしたfits画像データをastropyのpyfitsで読み込んで加工する。

import astropy.io.fits as pyfits   # Library to read FITS
import pycuda.autoinit             # PyCuda autoinit
import pycuda.driver as cuda       # PyCuda In, Out helpers
import matplotlib.pyplot as plot   # Library to plot
import matplotlib.cm as colormap   # Library to plot
import numpy                       # Fast math library
import time
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
pylab.rcParams['figure.figsize'] = 20, 30
pylab.rcParams["font.size"] = "20"

from pycuda.compiler import SourceModule

# Open FITS image
fits = pyfits.open('HorseHead.fits')
# Get the image data as array
data = fits[0].data.astype(numpy.float32)
# Read image metadata
header = fits[0].header
# Show all metadata
print(header.keys)

# PyCuda: Create kernel
kernel = SourceModule("""
__global__ void log_fast(float *result, float *source) {
    const int i = blockIdx.x * blockDim.x + threadIdx.x;
    result[i] = log10(source[i]);
}
""")

# PyCuda: Get function
log_fast = kernel.get_function("log_fast")

# PyCuda: Calculate block size
BLOCK_SIZE = 1024
block = (BLOCK_SIZE, 1, 1)
grid = (int(data.shape[0] * data.shape[1] / BLOCK_SIZE) + 1, 1, 1)

# PyCuda: Call the function to transform image
data_result = numpy.zeros_like(data)
start_time = time.time()
log_fast(cuda.Out(data_result), cuda.In(data), block=block, grid=grid)
end_time = time.time()
cuda_time = end_time - start_time
print("PyCuda log10 {0:.4f} seconds".format(cuda_time))

# NumPy
start_time = time.time()
np_data_result = numpy.log10(data)
end_time = time.time()
numpy_time = end_time - start_time
print("NumPy log10 {0:.4f} seconds ".format(numpy_time))

print("PyCuda is {0:.1f} times faster than NumPy".format(numpy_time / cuda_time))

# Show image using matplotlib
figure = plot.figure()
figure.add_subplot(3,1,1)
plot.imshow(data, cmap = colormap.Greys_r)
plt.colorbar()
figure.add_subplot(3,1,2)
plot.imshow(data_result, cmap = colormap.Greys_r)
plt.colorbar()
figure.add_subplot(3,1,3)
plot.imshow(np_data_result, cmap = colormap.Greys_r)
plt.colorbar()
plot.show()
<bound method Header.keys of SIMPLE  =                    T /FITS: Compliance                                
BITPIX  =                   16 /FITS: I*2 Data                                  
NAXIS   =                    2 /FITS: 2-D Image Data                            
NAXIS1  =                  891 /FITS: X Dimension                               
NAXIS2  =                  893 /FITS: Y Dimension                               
EXTEND  =                    T /FITS: File can contain extensions               
DATE    = '2014-01-09        '  /FITS: Creation Date                            
ORIGIN  = 'STScI/MAST'         /GSSS: STScI Digitized Sky Survey                
SURVEY  = 'SERC-ER '           /GSSS: Sky Survey                                
REGION  = 'ER768   '           /GSSS: Region Name                               
PLATEID = 'A0JP    '           /GSSS: Plate ID                                  
SCANNUM = '01      '           /GSSS: Scan Number                               
DSCNDNUM= '00      '           /GSSS: Descendant Number                         
TELESCID=                    4 /GSSS: Telescope ID                              
BANDPASS=                   36 /GSSS: Bandpass Code                             
COPYRGHT= 'AAO/ROE '           /GSSS: Copyright Holder                          
SITELAT =              -31.277 /Observatory: Latitude                           
SITELONG=              210.934 /Observatory: Longitude                          
TELESCOP= 'UK Schmidt - Doubl' /Observatory: Telescope                          
INSTRUME= 'Photographic Plate' /Detector: Photographic Plate                    
EMULSION= 'IIIaF   '           /Detector: Emulsion                              
FILTER  = 'OG590   '           /Detector: Filter                                
PLTSCALE=                67.20 /Detector: Plate Scale arcsec per mm             
PLTSIZEX=              355.000 /Detector: Plate X Dimension mm                  
PLTSIZEY=              355.000 /Detector: Plate Y Dimension mm                  
PLATERA =        85.5994550000 /Observation: Field centre RA degrees            
PLATEDEC=       -4.94660910000 /Observation: Field centre Dec degrees           
PLTLABEL= 'OR14052 '           /Observation: Plate Label                        
DATE-OBS= '1990-12-22T13:49:00' /Observation: Date/Time                         
EXPOSURE=                 65.0 /Observation: Exposure Minutes                   
PLTGRADE= 'AD2     '           /Observation: Plate Grade                        
OBSHA   =             0.158333 /Observation: Hour Angle                         
OBSZD   =              26.3715 /Observation: Zenith Distance                    
AIRMASS =              1.11587 /Observation: Airmass                            
REFBETA =        66.3196420000 /Observation: Refraction Coeff                   
REFBETAP=     -0.0820000000000 /Observation: Refraction Coeff                   
REFK1   =        6423.52290000 /Observation: Refraction Coeff                   
REFK2   =       -102122.550000 /Observation: Refraction Coeff                   
CNPIX1  =                12237 /Scan: X Corner                                  
CNPIX2  =                19965 /Scan: Y Corner                                  
XPIXELS =                23040 /Scan: X Dimension                               
YPIXELS =                23040 /Scan: Y Dimension                               
XPIXELSZ=              15.0295 /Scan: Pixel Size microns                        
YPIXELSZ=              15.0000 /Scan: Pixel Size microns                        
PPO1    =       -3069417.00000 /Scan: Orientation Coeff                         
PPO2    =       0.000000000000 /Scan: Orientation Coeff                         
PPO3    =        177500.000000 /Scan: Orientation Coeff                         
PPO4    =       0.000000000000 /Scan: Orientation Coeff                         
PPO5    =        3069417.00000 /Scan: Orientation Coeff                         
PPO6    =        177500.000000 /Scan: Orientation Coeff                         
PLTRAH  =                    5 /Astrometry: Plate Centre H                      
PLTRAM  =                   42 /Astrometry: Plate Centre M                      
PLTRAS  =                23.86 /Astrometry: Plate Centre S                      
PLTDECSN= '-       '           /Astrometry: Plate Centre +/-                    
PLTDECD =                    4 /Astrometry: Plate Centre D                      
PLTDECM =                   56 /Astrometry: Plate Centre M                      
PLTDECS =                 47.9 /Astrometry: Plate Centre S                      
EQUINOX =               2000.0 /Astrometry: Equinox                             
AMDX1   =        67.1550859799 /Astrometry: GSC1 Coeff                          
AMDX2   =      0.0431478884485 /Astrometry: GSC1 Coeff                          
AMDX3   =       -292.435619180 /Astrometry: GSC1 Coeff                          
AMDX4   =  -2.68934864702E-005 /Astrometry: GSC1 Coeff                          
AMDX5   =   1.99133423290E-005 /Astrometry: GSC1 Coeff                          
AMDX6   =  -2.37011931379E-006 /Astrometry: GSC1 Coeff                          
AMDX7   =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDX8   =   2.21426387429E-006 /Astrometry: GSC1 Coeff                          
AMDX9   =  -8.12841581455E-008 /Astrometry: GSC1 Coeff                          
AMDX10  =   2.48169090021E-006 /Astrometry: GSC1 Coeff                          
AMDX11  =   2.77618933926E-008 /Astrometry: GSC1 Coeff                          
AMDX12  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDX13  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDX14  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDX15  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDX16  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDX17  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDX18  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDX19  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDX20  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY1   =        67.1593591466 /Astrometry: GSC1 Coeff                          
AMDY2   =     -0.0471363749174 /Astrometry: GSC1 Coeff                          
AMDY3   =        316.004963520 /Astrometry: GSC1 Coeff                          
AMDY4   =   2.86798151430E-005 /Astrometry: GSC1 Coeff                          
AMDY5   =  -2.00968236347E-005 /Astrometry: GSC1 Coeff                          
AMDY6   =   2.27840393227E-005 /Astrometry: GSC1 Coeff                          
AMDY7   =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY8   =   2.23885090381E-006 /Astrometry: GSC1 Coeff                          
AMDY9   =  -2.28360163464E-008 /Astrometry: GSC1 Coeff                          
AMDY10  =   2.44828851495E-006 /Astrometry: GSC1 Coeff                          
AMDY11  =  -5.76717487998E-008 /Astrometry: GSC1 Coeff                          
AMDY12  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY13  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY14  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY15  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY16  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY17  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY18  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY19  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDY20  =       0.000000000000 /Astrometry: GSC1 Coeff                          
AMDREX1 =        67.1532034737 /Astrometry: GSC2 Coeff                          
AMDREX2 =      0.0434354199559 /Astrometry: GSC2 Coeff                          
AMDREX3 =       -292.435438892 /Astrometry: GSC2 Coeff                          
AMDREX4 =   4.60919247070E-006 /Astrometry: GSC2 Coeff                          
AMDREX5 =  -3.21138058537E-006 /Astrometry: GSC2 Coeff                          
AMDREX6 =   7.23651736725E-006 /Astrometry: GSC2 Coeff                          
AMDREX7 =       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX8 =       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX9 =       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX10=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX11=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX12=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX13=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX14=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX15=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX16=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX17=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX18=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX19=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREX20=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY1 =        67.1522589487 /Astrometry: GSC2 Coeff                          
AMDREY2 =     -0.0481758265285 /Astrometry: GSC2 Coeff                          
AMDREY3 =        315.995683716 /Astrometry: GSC2 Coeff                          
AMDREY4 =  -7.47397531230E-006 /Astrometry: GSC2 Coeff                          
AMDREY5 =   9.55221105409E-007 /Astrometry: GSC2 Coeff                          
AMDREY6 =   7.60954485251E-006 /Astrometry: GSC2 Coeff                          
AMDREY7 =       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY8 =       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY9 =       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY10=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY11=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY12=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY13=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY14=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY15=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY16=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY17=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY18=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY19=       0.000000000000 /Astrometry: GSC2 Coeff                          
AMDREY20=       0.000000000000 /Astrometry: GSC2 Coeff                          
ASTRMASK= 'er.mask '           /Astrometry: GSC2 Mask                           
WCSAXES =                    2 /GetImage: Number WCS axes                       
WCSNAME = 'DSS               ' /GetImage: Local WCS approximation from full plat
RADESYS = 'ICRS              ' /GetImage: GSC-II calibration using ICRS system  
CTYPE1  = 'RA---TAN          ' /GetImage: RA-Gnomic projection                  
CRPIX1  =           446.000000 /GetImage: X reference pixel                     
CRVAL1  =            85.274970 /GetImage: RA of reference pixel                 
CUNIT1  = 'deg               ' /GetImage: degrees                               
CTYPE2  = 'DEC--TAN          ' /GetImage: Dec-Gnomic projection                 
CRPIX2  =           447.000000 /GetImage: Y reference pixel                     
CRVAL2  =            -2.458265 /GetImage: Dec of reference pixel                
CUNIT2  = 'deg               ' /Getimage: degrees                               
CD1_1   =        -0.0002802651 /GetImage: rotation matrix coefficient           
CD1_2   =         0.0000003159 /GetImage: rotation matrix coefficient           
CD2_1   =         0.0000002767 /GetImage: rotation matrix coefficient           
CD2_2   =         0.0002798187 /GetImage: rotation matrix coefficient           
OBJECT  = 'data              ' /GetImage: Requested Object Name                 
DATAMIN =                 3759 /GetImage: Minimum returned pixel value          
DATAMAX =                22918 /GetImage: Maximum returned pixel value          
OBJCTRA = '05 41 06.000      ' /GetImage: Requested Right Ascension (J2000)     
OBJCTDEC= '-02 27 30.00      ' /GetImage: Requested Declination (J2000)         
OBJCTX  =             12682.48 /GetImage: Requested X on plate (pixels)         
OBJCTY  =             20411.37 /GetImage: Requested Y on plate (pixels)         >
PyCuda log10 0.0022 seconds
NumPy log10 0.0121 seconds 
PyCuda is 5.5 times faster than NumPy

pycudaを使うことでnumpyよりも5.5倍も画像処理速度が高速化されている。

スポンサーリンク

別の画像データを試してみる

別のfits画像データを下記のサイトからダウンロードする。

%download https://astropy.stsci.edu/data/photometry/spitzer_example_image.fits
Downloaded 'spitzer_example_image.fits'.

ダウンロードしたfitsデータを読み込んで再びlog10画像処理する。

import astropy.io.fits as pyfits   # Library to read FITS
import pycuda.autoinit             # PyCuda autoinit
import pycuda.driver as cuda       # PyCuda In, Out helpers
import matplotlib.pyplot as plot   # Library to plot
import matplotlib.cm as colormap   # Library to plot
import numpy                       # Fast math library
import time
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
pylab.rcParams['figure.figsize'] = 20, 30
pylab.rcParams["font.size"] = "20"

from pycuda.compiler import SourceModule

# Open FITS image
fits = pyfits.open('spitzer_example_image.fits')
# Get the image data as array
data = fits[0].data.astype(numpy.float32)
# Read image metadata
header = fits[0].header
# Show all metadata
print(header.keys)

# PyCuda: Create kernel
kernel = SourceModule("""
__global__ void log_fast(float *result, float *source) {
    const int i = blockIdx.x * blockDim.x + threadIdx.x;
    result[i] = log10(source[i]);
}
""")

# PyCuda: Get function
log_fast = kernel.get_function("log_fast")

# PyCuda: Calculate block size
BLOCK_SIZE = 1024
block = (BLOCK_SIZE, 1, 1)
grid = (int(data.shape[0] * data.shape[1] / BLOCK_SIZE) + 1, 1, 1)

# PyCuda: Call the function to transform image
data_result = numpy.zeros_like(data)
start_time = time.time()
log_fast(cuda.Out(data_result), cuda.In(data), block=block, grid=grid)
end_time = time.time()
cuda_time = end_time - start_time
print("PyCuda log10 {0:.4f} seconds".format(cuda_time))

# NumPy
start_time = time.time()
np_data_result = numpy.log10(data)
end_time = time.time()
numpy_time = end_time - start_time
print("NumPy log10 {0:.4f} seconds ".format(numpy_time))

print("PyCuda is {0:.1f} times faster than NumPy".format(numpy_time / cuda_time))

# Show image using matplotlib
figure = plot.figure()
figure.add_subplot(3,1,1)
plot.imshow(data, cmap = colormap.Greys_r)
plt.colorbar()
figure.add_subplot(3,1,2)
plot.imshow(data_result, cmap = colormap.Greys_r)
plt.colorbar()
figure.add_subplot(3,1,3)
plot.imshow(np_data_result, cmap = colormap.Greys_r)
plt.colorbar()
plot.show()
<bound method Header.keys of SIMPLE  =                    T / file does conform to FITS standard             
BITPIX  =                  -32 / number of bits per data pixel                  
NAXIS   =                    2 / number of data axes                            
NAXIS1  =                 1025 / length of data axis 1                          
NAXIS2  =                  513 / length of data axis 2                          
EXTEND  =                    T / FITS dataset may contain extensions            
COMMENT   FITS (Flexible Image Transport System) format is defined in 'Astronomy
COMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H 
TELESCOP= 'SPITZER '           / Telescope                                      
INSTRUME= 'IRAC    '           / Instrument ID                                  
ORIGIN  = 'UW Astronomy Dept'  / Installation where FITS file written           
CREATOR = 'GLIMPSE Pipeline'   / SW that created this FITS file                 
CREATOR1= 'S13.2.0 '           / SSC pipeline that created the BCD              
PIPEVERS= '1v04    '           / GLIMPSE pipeline version                       
MOSAICER= 'Montage V2.2'       / SW that originally created the Mosaic Image    
FILENAME= 'GLM_01800+0000_mosaic_I2.fits' / Name of this file                   
PROJECT = 'FSURVEY '           / Project ID                                     
FILETYPE= 'mosaic  '           / Calibrated image(mosaic)/residual image(resid) 
CHNLNUM =                    2 / 1 digit Instrument Channel Number              
DATE    = '2006-12-02T01:06:10' / file creation date (YYYY-MM-DDThh:mm:ss UTC)  
COMMENT --------------------                                                    
COMMENT Proposal Information                                                    
COMMENT --------------------                                                    
OBSRVR  = 'Ed Churchwell'      / Observer Name                                  
OBSRVRID=                   90 / Observer ID of Principal Investigator          
PROCYCLE=                    2 / Proposal Cycle                                 
PROGID  =                  146 / Program ID                                     
PROTITLE= 'The SIRTF Galactic Plane Surve' / Program Title                      
PROGCAT =                   27 / Program Category                               
COMMENT -----------------------------                                           
COMMENT Time and Exposure Information                                           
COMMENT -----------------------------                                           
SAMPTIME=                  0.2 / [sec] Sample integration time                  
FRAMTIME=                  2.0 / [sec] Time spent integrating (whole array)     
EXPTIME =                  1.2 / [sec] Effective integration time per pixel     
COMMENT DN per pixel=flux(photons/sec/pixel)/gain*EXPTIME                       
AFOWLNUM=                    4 / Fowler number                                  
COMMENT --------------------                                                    
COMMENT Pointing Information                                                    
COMMENT --------------------                                                    
CRPIX1  = 1.161500000000000E+03 / Reference pixel for x-position                
CRPIX2  = -3.885000000000000E+02 / Reference pixel for y-position               
CTYPE1  = 'GLON-CAR'           / Projection Type                                
CTYPE2  = 'GLAT-CAR'           / Projection Type                                
CRVAL1  =          18.00000000 / [Deg] Galactic Longtitude at reference pixel   
CRVAL2  =           0.00000000 / [Deg] Galactic Latitude at reference pixel     
EQUINOX =               2000.0 / Equinox for celestial coordinate system        
DELTA-X =           3.10666656 / [Deg] size of image in axis 1                  
DELTA-Y =           2.40666676 / [Deg] size of image in axis 2                  
BORDER  =           0.00333333 / [Deg] mosaic grid border                       
CD1_1   =      -3.33333330E-04                                                  
CD1_2   =       0.00000000E+00                                                  
CD2_1   =       0.00000000E+00                                                  
CD2_2   =       3.33333330E-04                                                  
PIXSCAL1=                1.200 / [arcsec/pixel] pixel scale for axis 1          
PIXSCAL2=                1.200 / [arcsec/pixel] pixel scale for axis 2          
OLDPIXSC=                1.213 / [arcsec/pixel] pixel scale of single IRAC frame
RA      =         275.92636108 / [Deg] Right ascension at mosaic center         
DEC     =         -13.25728989 / [Deg] Declination at mosaic center             
COMMENT ----------------------                                                  
COMMENT Photometry Information                                                  
COMMENT ----------------------                                                  
BUNIT   = 'MJy/sr  '           / Units of image data                            
GAIN    =                  3.7 / e/DN conversion                                
JY2DN   =           249988.703 / Average Jy to DN Conversion                    
ETIMEAVE=               1.2000 / [sec] Average exposure time                    
PA_AVE  =                86.62 / [deg] Average position angle                   
ZODY_AVE=              0.23927 / [Mjy/sr] Average ZODY_EST-SKYDRKZB             
COMMENT Flux conversion (FLUXCONV) for this mosaic =                            
COMMENT Average of FLXC from each frame*(old pixel scale/new pixel scale)**2    
FLUXCONV=          0.141823635 / Average MJy/sr to DN/s Conversion              
COMMENT -----------------------------                                           
COMMENT AORKEYS/ADS Ident Information                                           
COMMENT -----------------------------                                           
AOR001  = '0012104704'         / AORKEYS used in this mosaic                    
AOR002  = '0012106752'         / AORKEYS used in this mosaic                    
AOR003  = '0012108288'         / AORKEYS used in this mosaic                    
AOR004  = '0012107776'         / AORKEYS used in this mosaic                    
AOR005  = '0012103936'         / AORKEYS used in this mosaic                    
AOR006  = '0012105472'         / AORKEYS used in this mosaic                    
AOR007  = '0012102400'         / AORKEYS used in this mosaic                    
AOR008  = '0012109568'         / AORKEYS used in this mosaic                    
AOR009  = '0012111104'         / AORKEYS used in this mosaic                    
AOR010  = '0012101376'         / AORKEYS used in this mosaic                    
AOR011  = '0012107520'         / AORKEYS used in this mosaic                    
AOR012  = '0012111360'         / AORKEYS used in this mosaic                    
AOR013  = '0012110080'         / AORKEYS used in this mosaic                    
AOR014  = '0013652224'         / AORKEYS used in this mosaic                    
DSID001 = 'ads/sa.spitzer#0012104704' / Data Set Identification for ADS/journals
DSID002 = 'ads/sa.spitzer#0012106752' / Data Set Identification for ADS/journals
DSID003 = 'ads/sa.spitzer#0012108288' / Data Set Identification for ADS/journals
DSID004 = 'ads/sa.spitzer#0012107776' / Data Set Identification for ADS/journals
DSID005 = 'ads/sa.spitzer#0012103936' / Data Set Identification for ADS/journals
DSID006 = 'ads/sa.spitzer#0012105472' / Data Set Identification for ADS/journals
DSID007 = 'ads/sa.spitzer#0012102400' / Data Set Identification for ADS/journals
DSID008 = 'ads/sa.spitzer#0012109568' / Data Set Identification for ADS/journals
DSID009 = 'ads/sa.spitzer#0012111104' / Data Set Identification for ADS/journals
DSID010 = 'ads/sa.spitzer#0012101376' / Data Set Identification for ADS/journals
DSID011 = 'ads/sa.spitzer#0012107520' / Data Set Identification for ADS/journals
DSID012 = 'ads/sa.spitzer#0012111360' / Data Set Identification for ADS/journals
DSID013 = 'ads/sa.spitzer#0012110080' / Data Set Identification for ADS/journals
DSID014 = 'ads/sa.spitzer#0013652224' / Data Set Identification for ADS/journals
NIMAGES =                 2173 / Number of IRAC Frames in Mosaic                >
PyCuda log10 0.0047 seconds
NumPy log10 0.0091 seconds 
PyCuda is 1.9 times faster than NumPy

今回もpycudaを使うことでnumpyよりも処理速度が1.9倍高速化されている。ただ、色々なデータを試してみたところ、pycudaを使うことで処理速度が著しく遅くなるケースもあるので、pycudaを使用すれば必ず処理速度が上がるというわけではなくてデータのサイズによるところが大きい。

参考サイトUsing PyCuda to boost FITS image processing times

スポンサーリンク
スポンサーリンク