Download presentation
Presentation is loading. Please wait.
Published byPhyllis Burns Modified over 8 years ago
1
Computational Astronomy 제 5 장 프로그래밍 기초 전산천문학 1 2007. 봄
2
Computational Astronomy Mission 프로그래밍의 기초를 배운다. 프로그래밍에 필요한 블록문을 배운다. 프로그래밍의 콤파일 및 실행을 할 수 있다. 외부의 유용한 루틴을 가져다가 쓰는 방법을 배운다.
3
Computational Astronomy 프로그래밍 기초 pro twotimes, value value = 2.0 * value print, 'It was multiplied by 2.0!!!‘ print, value end 1.Save it as twotimes.pro 2.Place it anywhere 3.IDL> twotimes, 3
4
Computational Astronomy Programming 실행원리 pro myplot, x, y, MYTITLE=plot_title print, n_params() case n_params() of 1 : plot, x, title=plot_title 2 : plot, x, y, title=plot_title else : print, 'error' endcase end function multiply_value, x, y return, x*y end pro general degree=findgen(360) sin_value=sin(degree*!dtor) curve=multiply_value(sin_value, 3) myplot, degree, curve, mytitle=‘OK’ end Saved as ‘general.pro’ IDL> general 이 때 IDL 은, general.pro 를 찾아 로딩 컴파일 procedure general 수행 IDL> print, multiply_value(30,2)
5
Computational Astronomy 반복문 (For loops) pro for_loops for j = 0, 9 do print, j for j = 0, 20, 2 do begin print, j endfor end
6
Computational Astronomy If then else 문 pro if_then_else, x, y, z if (x lt 0) then x = 0 if (y le 0) then print, -y else print, y if (z eq 0) then begin print, x help, y endif end : gt, = : ge, != : ne, == : eq
7
Computational Astronomy While 문 1.pro while_loops, previous, current 2. while (current lt 100) do begin 3. next = current + previous 4. previous = current 5. current = next 6. endwhile 7. print, current 8.end
8
Computational Astronomy Repeat until 1.pro repeat_until, n 2. repeat begin 3. n = n + 2 4. endrep until (n gt 20) 5. print, n 6.end
9
Computational Astronomy Case 1.pro case_statments, piechoice 2. case piechoice of 3. 0: begin 4. pie = 'apple' 5. topping = 'ice cream' 6. end 7. 1: pie = 'pumpkin' 8. else: pie = 'cherry' 9. endcase 10. print, pie 11.end
10
Computational Astronomy 외부루틴 가져다쓰는법 외부루틴의 일반적인 사항 모두 확장자가.pro 인 파일로 끝남 IDL 은 프로시저나 함수가 호출될 때 자동으로 호 출된 프로시저 또는 함수 콤파일 및 실행 링크할 필요는 없으며 다만, IDL 의 자동검색경로 에 등록되어 있는 디렉토리에 프로시저나 함수가 등록되어야 함.(file>preference>path)
11
Computational Astronomy 외부루틴 설치 및 사용 예제 IDL astro library http://idlastro.gsfc.nasa.gov
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.