1 Winter Quarter 2003Rolando V. Raqueño Basic IDL Commands SIMG 726.

Slides:



Advertisements
Similar presentations
Symbol Table.
Advertisements

C Functions. What are they? In general, functions are blocks of code that perform a number of pre-defined commands to accomplish something productive.
Intro to Python Welcome to the Wonderful world of GIS programing!
Utilizing the GDB debugger to analyze programs Background and application.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
IDL Tutorials : Day 3 Angela Des Jardins Goals: 1) Learn to display images 2) Understand the basics of procedures and.
Encapsulation by Subprograms and Type Definitions
Rolando V. RaqueñoMonday, June 22, Basic IDL Commands SIMG 726.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files called M- files. M-files are.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
IDL Tutorials: Day 1 Michael Hahn
Geog Basic Skills in Scientific Programming Syllabus, Introduction, Fundamentals of IDL Syntax.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
Writing Web Pages By Shyam Gurram. Agenda Writing Web Pages Delimiting PHP Program Units. Displaying Output to Web Pages Putting Comments in PHP Programs.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
Programming I Introduction Introduction The only way to learn a new programming language is by writing programs in it. The first program to.
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Rolando V. RaqueñoSunday, October 18, 2015 Modal Widgets, Pointers, and Memory Leaks.
Shell Programming. Introducing UNIX Shells  Shell is also a programming language and provides various features like variables, branching, looping and.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Rolando V. RaqueñoWednesday, October 21, Special Function Implementation in IDL A Case Study.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room , Chris Hill, Room ,
CSC 221: Recursion. Recursion: Definition Function that solves a problem by relying on itself to compute the correct solution for a smaller version of.
With Python.  One of the most useful abilities of programming is the ability to manipulate files.  Python’s operations for file management are relatively.
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
IDL Tutorial Day 1 Goals: 1) Introduce IDL basics 2) Describe fundamental IDL structures Angela Des Jardins
Some Fortran programming tips ATM 562 Fall 2015 Fovell (see also PDF file on class page) 1.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
CS Class 08 Today  Exercises  Nested loops  for statement  Built-in functions Announcements  Homework #3, group solution to in-class.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python Karsten Hokamp, PhD Genetics TCD, 03/11/2015.
1 Homework Done the reading? –K&R –Glass Chapters 1 and 2 Applied for cs240? (If not, keep at it!) Gotten a UNIX account? (If not, keep at it!)
Python Let’s get started!.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Week Four Agenda Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines.
Postgraduate Computing Lectures PAW 1 PAW: Physicist Analysis Workstation What is PAW? –A tool to display and manipulate data. Learning PAW –See ref. in.
Matlab for Engineers Matlab Environment Chapter 2.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
IDL Tutorials Day 1 Henry (Trae) Winter Room 235
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
An Introduction to Programming in Matlab Emily Blumenthal
IST 210: PHP Basics IST 210: Organization of Data IST2101.
Linux Administration Working with the BASH Shell.
ITM 3521 ITM 352 Functions. ITM 3522 Functions  A function is a named block of code (i.e. within {}'s) that performs a specific set of statements  It.
Basic IDL Commands SIMG 726 Winter Quarter 2005 Rolando V. Raqueño.
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
RCS Revision Control System
What is Bash Shell Scripting?
Use of Mathematics using Technology (Maltlab)
Statistics Function Implementation
Presentation transcript:

1 Winter Quarter 2003Rolando V. Raqueño Basic IDL Commands SIMG 726

2 Winter Quarter 2003Rolando V. Raqueño Objective Quick Tour of IDL Writing IDL Programs

3 Winter Quarter 2003Rolando V. Raqueño Before we start % source ~rvrpci/.simg726.rc % script % set history=100 AT THE END OF THE UNIX SESSION, DON’T FORGET TO TYPE % ^D

4 Winter Quarter 2003Rolando V. Raqueño Before we END AT THE END OF THE UNIX SESSION, DON’T FORGET TO TYPE % ^D You now have file called typescript which contains a log of your UNIX session

5 Winter Quarter 2003Rolando V. Raqueño Starting IDL in UNIX To start command line interface IDL environment % idl To start graphical interface IDL environment % idlde

6 Winter Quarter 2003Rolando V. Raqueño IDL Help MOST IMPORTANT IDL COMMAND OF ALL IDL> ?

7 Winter Quarter 2003Rolando V. Raqueño IDL Help Window

8 Winter Quarter 2003Rolando V. Raqueño Other IDL Help Facilities IDL> doc_library,’moment’ Allows specially formatted code comments to be viewed without having to view the source code

9 Winter Quarter 2003Rolando V. Raqueño General IDL Information N.B. Platform specific limitation –UNIX File name conflict between lower and upper case characters –e.g. addnum.pro vs. AddNum.pro Recommend use of strictly lowercase file names

10 Winter Quarter 2003Rolando V. Raqueño IDL Character Set IDL is not case sensitive Commands and arguments are delimited by comas. –e.g. IDL> print, a Comments are started by a semicolon (;) –e.g. IDL> ; This is a comment Command options are set using a backslash (/) –e.g. IDL> tv, a, /order

11 Winter Quarter 2003Rolando V. Raqueño Other IDL Characters System variables are started with an exclamation point (!) e.g. IDL> print, !PI e.g. IDL> y = sin( x*!DTOR ) Command line continuation with $ e.g. IDL> print, 180 / $ !PI

12 Winter Quarter 2003Rolando V. Raqueño Other IDL Characters Multiple IDL commands can be separated by the & symbol –e.g. IDL> a=0.0 & b=1.0 UNIX Command execution –e.g. IDL> $ls -la

13 Winter Quarter 2003Rolando V. Raqueño Journal Facility of IDL The journal command allows you to record all IDL activity during a particular session IDL> journal, ‘sequence.pro’ IDL> print, 3*5 IDL> journal

14 Winter Quarter 2003Rolando V. Raqueño sequence.pro ; IDL Version 3.6.1a (MacOS Macintosh) ; Journal File for Rolando ; Working directory: Raqueño's Hard Drive:Applications:ENVI: ; Date: Tue Sep 17 00:56: print,3*5 ; 15

15 Winter Quarter 2003Rolando V. Raqueño Sample Commands Some sample command IDL> print,3*5 IDL> print,SysTime() IDL> num = 5*12 IDL> help,num NUM INT = 60 IDL> print,num 60

16 Winter Quarter 2003Rolando V. Raqueño Creating an Array Some sample command IDL> num = fltarr(40) IDL> help,num NUM FLOAT = Array(40) IDL> print,num

17 Winter Quarter 2003Rolando V. Raqueño Creating an “Indexed Array” Some sample command IDL> for i=0,39 do num(i)=i IDL> help,num NUM FLOAT = Array(40) IDL> print,num

18 Winter Quarter 2003Rolando V. Raqueño Shortcut Creating Indexed Array Some sample command IDL> num = findgen(40) IDL> help,num NUM FLOAT = Array(40) IDL> print,num

19 Winter Quarter 2003Rolando V. Raqueño Indexed Array Example Some sample command IDL> num = findgen(40)*10 IDL> print,num

20 Winter Quarter 2003Rolando V. Raqueño Indexed Array Example Some sample command IDL> num = findgen(40)* IDL> print,num In general you will be using a linear form y=m*x+b

21 Winter Quarter 2003Rolando V. Raqueño Extracting Array Subset Some sample command IDL> num1 = num(0:36) IDL> print,num IDL> help,num1 NUM1 FLOAT = Array(37)

22 Winter Quarter 2003Rolando V. Raqueño Scalar Operation on Arrays Some sample commands IDL> num = findgen(37)*10 IDL> print,num IDL> help,num NUM FLOAT = Array(37)

23 Winter Quarter 2003Rolando V. Raqueño Two-Dimensional Plotting Displaying Two-Dimensional Graphics IDL> line = Sin(num * !DtoR) IDL> plot,line

24 Winter Quarter 2003Rolando V. Raqueño Two-Dimensional Plotting Displaying Two-Dimensional Graphics IDL> plot,line IDL> plot,num,line

25 Winter Quarter 2003Rolando V. Raqueño Two-Dimensional Plotting Options IDL> plot,num,line,/Psym

26 Winter Quarter 2003Rolando V. Raqueño Two-Dimensional Plotting Options IDL> plot,num,line,Psym=1

27 Winter Quarter 2003Rolando V. Raqueño Other Plotting Options IDL> plot,num,line,linestyle=1

28 Winter Quarter 2003Rolando V. Raqueño Labeling IDL Plots IDL> plot,num,line,xrange=[0,360],$ ytitle='Sin(x)',Title='Sine Plot'

29 Winter Quarter 2003Rolando V. Raqueño Other Plot Facilities plot IDL> plot,num,line,xrange=[0,360],$ ytitle='Sin(x)',Title='Sine Plot' IDL> plots,[0,360],[0,0]

30 Winter Quarter 2003Rolando V. Raqueño Polygon Filling IDL> loadct, 5 IDL> polyfill,num(0:18),line(0:18),color=120 IDL> polyfill,num(18:36),line(18:36),color=50

31 Winter Quarter 2003Rolando V. Raqueño Data File Inputs Copy the following files from ~rvrpci/pub/IDL/training surface.dat ctscan.dat

32 Winter Quarter 2003Rolando V. Raqueño Three-Dimensional Plotting Displaying Three-Dimensional Graphics –To get the data into IDL, you will need to open a file and read it into an array using the following commands (N.B. this is specific for this particular data set) IDL> file=‘surface.dat’ IDL> openr,lun,file,/get_lun IDL> peak=fltarr(40,40) IDL> readf,lun,peak IDL> free_lun, lun

33 Winter Quarter 2003Rolando V. Raqueño Surface Plots Displaying Three-Dimensional Graphics IDL> print, max(peak), min(peak) IDL> surface,peak

34 Winter Quarter 2003Rolando V. Raqueño Surface Plots IDL> x = findgen(40)*2.5 & y=findgen(40)+50 IDL> surface,peak,x,y

35 Winter Quarter 2003Rolando V. Raqueño Color Look-up Tables –The following command lets you view the current colors loaded into the color look-up tables IDL> cindex

36 Winter Quarter 2003Rolando V. Raqueño Background/Foreground Colors –The following surface command lets you manipulate the background and foreground colors IDL> surface,peak,background=200,color=45, title='Surface Projection',charsize=2.0

37 Winter Quarter 2003Rolando V. Raqueño Shaded Surface Plotting IDL> shade_surf, peak

38 Winter Quarter 2003Rolando V. Raqueño Draping Data Over a Surface –We can drape a given surface over another one by the following command (we read in the data snow the same manner as peak) IDL>shade_surf,peak,$ shade=snow

39 Winter Quarter 2003Rolando V. Raqueño Surface Plot Colored by Altitude –We can generate a simple elevation color map. IDL> shade_surf, peak, shade=bytscl(peak)

40 Winter Quarter 2003Rolando V. Raqueño Simple Contour Plots –We can generate a simple contour map. IDL> contour,peak

41 Winter Quarter 2003Rolando V. Raqueño Contour Plots Spacing –We can generate a simple contour map and adjust spacing. IDL> contour, peak, nlevels=10

42 Winter Quarter 2003Rolando V. Raqueño Contour Plots Labelling –We can generate a simple contour map and label them IDL> contour, peak, nlevels=10, /follow

43 Winter Quarter 2003Rolando V. Raqueño Contour Plots Spacing Adjustment –We can generate a simple contour map and adjust spacing along with line styles. IDL> contour, peak, nlevels=10, c_linestyle = indgen(5)

44 Winter Quarter 2003Rolando V. Raqueño Colored Contour Plots –We can generate a simple contour map and adjust spacing along with line color. IDL> contour, peak, nlevels=10, c_colors = indgen(5)*20+80

45 Winter Quarter 2003Rolando V. Raqueño Images Data Displaying Image Data –You can read in image data in a manner similar to other forms of two-dimensional data. You will need to ascertain whether the data is an ASCII file or a binary file IDL> openr, lun,’ctscan.dat’,/get_lun IDL> scan=bytarr(256,256) IDL> readu, lun, scan IDL> free_lun, lun

46 Winter Quarter 2003Rolando V. Raqueño Image Data Displaying Image Data IDL> window, /free, xsize=256, ysize=256 IDL> tvscl, scan

47 Winter Quarter 2003Rolando V. Raqueño Image Data Displaying Image Data IDL> window, /free, xsize=256, ysize=256 IDL> tvscl, scan IDL> tvscl,hist_equal(scan)

48 Winter Quarter 2003Rolando V. Raqueño Image Processing Displaying Image Data IDL> window, /free, xsize=256, ysize=256 IDL> tvscl, scan IDL> tvscl, sobel(scan)

49 Winter Quarter 2003Rolando V. Raqueño XLOADCT Routine Displaying Image Data IDL> xloadct IDL> tvscl, scan

50 Winter Quarter 2003Rolando V. Raqueño Writing IDL Programs

51 Winter Quarter 2003Rolando V. Raqueño General Form of an IDL Program Parts of an IDL program pro program_name [, arg1, arg2,..., argn] IDL statement #1 IDL statement #2. IDL statement #n end

52 Winter Quarter 2003Rolando V. Raqueño Compiling an IDL Program Create a program to take celsius arguments and print out fahrenheit values pro celsius_to_fahrenheit, celsius print, 9/5*celsius+32 end To compile: IDL>.compile celsius_to_fahrenheit.pro

53 Winter Quarter 2003Rolando V. Raqueño Executing an IDL Program To use the program in scalar mode: IDL> c = IDL> celsius_to_fahrenheit, c To use the program in array mode: IDL> c = findgen(201)/2 IDL> celsius_to_fahrenheit, c

54 Winter Quarter 2003Rolando V. Raqueño General Form of an IDL Function Parts of an IDL function function program_name [, arg1, arg2,..., argn] IDL statement #1 IDL statement #2. IDL statement #n return, answer end

55 Winter Quarter 2003Rolando V. Raqueño Compiling an IDL Function Create a function to take celsius arguments and print out fahrenheit values function celsius_to_fahrenheit, celsius answer=9/5*celsius+32 return, answer end To compile: IDL>.compile celsius_to_fahrenheit.pro

56 Winter Quarter 2003Rolando V. Raqueño Executing an IDL Function To use the program: IDL> c = findgen(201)/2 IDL> f = celsius_to_fahrenheit(c) IDL> print, f IDL> plot, c, f Equivalently: IDL> print, celsius_to_fahrenheit(c) IDL> plot, c, celsius_to_fahrenheit(c)

57 Winter Quarter 2003Rolando V. Raqueño Program Design program file vs. function file Use functions in case of mathematical functions to allow composition of functions IDL> k=celsius_to_kelvin(fahrenheit_to_celsius(f)) Use program file in case of process not requiring the return of data IDL> write_to_file,’temperature.dat’,k

58 Winter Quarter 2003Rolando V. Raqueño Parameter Passing in IDL IDL passes parameters into functions and programs by reference This means parameters can be modified through “side effect” pro celsius_to_fahrenheit, celsius celsius =9/5*celsius+32 end

59 Winter Quarter 2003Rolando V. Raqueño Problems with “Side Effect” Parameter Passing IDL> a=32.0 IDL> celsius_to_fahrenheit,a % Compiled module: CELSIUS_TO_FAHRENHEIT. IDL> print,a

60 Winter Quarter 2003Rolando V. Raqueño A Debugging Exercise The IDL function and program examples celsius_to_fahrenheit all compile, but generate incorrect answers in some cases. This is left as a debugging exercise

61 Winter Quarter 2003Rolando V. Raqueño Hints for Statistics Problem Study the IDL functions n_elements() size() Try to reuse as many of the functions as possible. Do not be concerned with efficiency at this point.