Python C/C++ IPMU IRAF

Similar documents
untitled

RHEA key

double float

C

Java学習教材

1.ppt

Python Speed Learning

nakao

Java演習(4) -- 変数と型 --

新コンフィギュレータのフレームワークについて

Specview Specview Specview STSCI(Space Telescope SCience Institute) VO Specview Web page htt

untitled

cpp1.dvi

r07.dvi

ohp07.dvi

Python Speed Learning

ex01.dvi

コンピュータ概論

MultiWriter 5650F 活用マニュアル

New version (2.15.1) of Specview is now available Dismiss Windows Specview.bat set spv= Specview set jhome= JAVA (C:\Program Files\Java\jre<version>\

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

ex01.dvi

新版明解C言語 実践編

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

OpenCV IS Report No Report Medical Information System Labratry

comment.dvi

P05.ppt

1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>

joho07-1.ppt


やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

明解Java入門編

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

K227 Java 2

untitled

2 1 Web Java Android Java 1.2 6) Java Java 7) 6) Java Java (Swing, JavaFX) (JDBC) 7) OS 1.3 Java Java

listings-ext

新版 明解C++入門編

r08.dvi

programmingII2019-v01

つるい27-5月号PDF.indd

超初心者用

untitled

Condition DAQ condition condition 2 3 XML key value

解きながら学ぶC++入門編

3.1 stdio.h iostream List.2 using namespace std C printf ( ) %d %f %s %d C++ cout cout List.2 Hello World! cout << float a = 1.2f; int b = 3; cout <<

解きながら学ぶJava入門編

cpp4.dvi

SystemC言語概論

CX-Checker CX-Checker (1)XPath (2)DOM (3) 3 XPath CX-Checker. MISRA-C 62%(79/127) SQMlint 76%(13/17) XPath CX-Checker 3. CX-Checker 4., MISRA-C CX- Ch


新・明解C言語 実践編

: : : TSTank 2


CLI Python モジュール

XJTAG

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2;

text_08.dvi

yacc.dvi

version 1.0 November 2010 PyRAF Y. Nakajima Computer and Data Management Division Subaru Telescope NAOJ

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

Visual Python, Numpy, Matplotlib

haskell.gby

[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1:

thesis.dvi

文字列操作と正規表現

2 1. Ubuntu 1.1 OS OS OS ( OS ) OS ( OS ) VMware Player VMware Player jp/download/player/ URL VMware Plaeyr VMware

Transcription:

Python C/C++ IPMU 2010 11 24IRAF

Python Swig Numpy array Image

Python 2.6.6 swig 1.3.40 numpy 1.5.0 pyfits 2.3 pyds9 1.1 svn co hjp://svn.scipy.org/svn/numpy/tags/1.5.0/doc/swig swig/numpy.i /usr/local/share/swig/1.3.40/python swig

Python

Hello Python Python python/hello.py % python Python 2.6.6 (r266:84292, Nov 16 2010, 16:27:48) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 Type help, copyright, credits or license for more information. >>> print Hello Python! Hello Python! >>> print 5 + 3 8 >>> ^D (Crtl+D) % % python hello.py Hello Python! 8 %

python/loop.py a = [ abc, def, ghi, jkl ] for b in a: print b for for i in range(5): print i range(5) [0,1,2,3,4]

I/O python/io.py file = open( test.txt ) file = open( out.txt, w ) line = file.readline() file.write(line)

python/func.py def times(x, y): return x * y import func from func import * x = func.times(3.14, 4)

pyfits FITS http://www.stsci.edu/resources/software_hardware/pyfits hdulist = pyfits.open( test.fits ) hdulist[0].header[ OBJECT ] hdulist[0].data[y, x] pyfits/sample.py numpy array 0- indexed ds9 [y, x]

pyds9 ds9 http://hea-www.harvard.edu/saord/ds9/pyds9 X Public Access (XPA) XPA Access Points http://hea-www.harvard.edu/saord/ds9/ref/xpa.html d = ds9.ds9() ds9 d.set( file test.fits ) pyds9/sample.py array d.set( array [xdim=2080,ydim=4100,bitpix=-32], data)

Python Numpy hjp://www.scipy.org/numpy_example_list pyfits/stats.py Python Numpy

Python C/C++ Python C/C++ Python C/C++

Python C/C++ boost.python swig ctypes swig

Swig C swig/example.*

C /* File : example.c */ swig/example.c #include <time.h> double My_variable = 3.0; int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } int my_mod(int x, int y) { return (x%y); } char *get_time() { time_t ltime; time(&ltime); return ctime(&ltime); }

Swig swig/example.* C Swig

Swig swig/example.i /* example.i */ %module example Python %{ /* Put header files here or function declarations like below */ extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); %} extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time();

Swig C Swig swig % swig -python example.i example.py, example_wrap.c % gcc fpic c example.c example_wrap.c I/adc/local/include/ python2.6/ example.o, example_wrap.o shared object % gcc -shared example.o example_wrap.o -o _example.so _example.so swig/example.* compile.sh

import example swig/sample.py print example.cvar.my_variable print example.fact(4) print example.my_mod(10,3) print example.get_time() <>.cvar.< > Python

Swig output/example.* void add(double a, double b, double *result) %include typemaps.i %apply double *OUTPUT { double *result }; typemaps.i void mod(int a, int b, int *quo, int *rem) %include typemaps.i # %apply int *OUTPUT { int*quo, int *rem };

Swig import example output/sample.py a = example.add_0(3,4) print a b = example.add(3,4) print b quo, rem = example.mod(7,3) print quo, rem

Swig C++ vector double average(std::vector<int> v) std::vector<double> half(const std::vector<double>& v) %include std_vector.i %template(intvector) std::vector<int>; %template(doublevector) std::vector<double>; vector/example.*

Swig from example import * iv = IntVector(4) for i in range(0,4): iv[i] = i print average(iv) vector<int> vector/sample.py print average([0,1,2,3]) print half([1,2,3]) Swig http://www.swig.org/doc1.3/index.html

Numpy array C Numpy array rms C double rms(double *seq, int n) Python v = rms(array) numpy/rms.* numpy.itypemaps

Numpy array C %module rms %{ #define SWIG_FILE_WITH_INIT #include rms.h %} %include numpy.i %init %{ import_array(); %} numpy/rms.i %apply (double *IN_ARRAY1, int DIM1) {(double *seq, int n)}; %include rms.h 1 array http://projects.scipy.org/numpy/export/3714/trunk/numpy/doc/swig/ numpy_swig.pdf

CNumpy array ezrange/ezrange.i Cnumpy array Python %apply (double *IN_ARRAY1, int DIM1) {(double *seq, int n)}; %apply (int *ARGOUT_ARRAY1, int DIM1) {(int *rangevec, int n)}; array Python

array 2 array(=) %apply (double *IN_ARRAY1, int DIM1) %apply (double *IN_ARRAY2, int DIM1, DIM2) C array double mean(double *array, int n, int m) numpy2/stats.* Numpy

Python C++

Image image0/image.* Numpy array Image Numpy array vector class Image { int npx, npy, npix; double *data; public: Image(); Image(double *array, int n, int m); ~Image(); int getnpx() const; int getnpy() const; int getnpix() const; void getnaxis(int *npx, int *npy); double getvalue(int x, int y) const; };

Image image0/image.* Image::Image(double *array, int n, int m) { data = new double[n*m]; // for (int j = 0; j < n; j++) { for (int i = 0; i < m; i++) { data[i+j*m] = array[i+j*m]; // } } npx = m; npy = n; npix = n*m; }

Image image0/sample.py pyfits Image img = Image.Image(hdulist[0].data) ds9 image01/image.*

median median image1/image.* 15-20 6 medianmedian

Image::Image(int npx, int npy) void Image::setValue(int x, int y double v) void Image::getData(float *oarray, int n) numpy array Image& Image::operator/=(double a) a double Image::median() median static Image Image::getMedian(std::vector<Image>& v) vmedian image1/image.*

ds9 image2/image.* n x n

Image& Image::operator/=(const Image& a) image2/image.* Image Image::boxavg(int width) width x width std::vector<point> findpeaks(double thres) thres vector Point class Point { int x, y; public: Point(int x, int y); int getx(); int gety(); }

Image median Gaussian

Swig C/C++ Python Swig Python C++