Making friends with IDL IDL is an interpreted rather than a compiled language. This means that large IDL programs can execute less rapidly than equivalent.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Introduction to Matlab
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Introduction to MATLAB The language of Technical Computing.
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
The Web Warrior Guide to Web Design Technologies
Introduction to IDL Lecture 2. ITT: solutions for data visualization and image analysis   IDL, programming.
Introduction to GTECH 201 Session 13. What is R? Statistics package A GNU project based on the S language Statistical environment Graphics package Programming.
IDL Tutorials: Day 4 Goal: Learn some programming techniques: Relational operators, conditional statements, boolean operators, loops Angela Des Jardins.
Programming Cheng-Ling Kuo
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Scalar Variables Start the file with: #! /usr/bin/perl –w No spaces or newlines before the the #! “#!” is sometimes called a “shebang”. It is a signal.
Introduction to MATLAB
Guide To UNIX Using Linux Third Edition
SPSS 1: An Introduction to the Statistical Package SPSS Suzie Cro MRC Clinical Trials Unit.
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.
Chapter 2 Software Tools and Assembly Language Syntax.
What is MATLAB ? MATrix LABratory –Originally, it was a front-end to FORTRAN matrix routines developed in the U. of New Mexico and Stanford –Today.
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
You can make this in matlab!. Matlab Introduction and Matrices.
Practical Extraction & Report Language PERL Joseph Beltran.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
IE 212: Computational Methods for Industrial Engineering
Introduction to MATLAB
Lists in Python.
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Piotr Wolski Introduction to R. Topics What is R? Sample session How to install R? Minimum you have to know to work in R Data objects in R and how to.
INTRODUCTION TO MATLAB LAB# 01
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Rolando V. RaqueñoWednesday, October 21, Special Function Implementation in IDL A Case Study.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2010.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Geog Basic Skills in Scientific Programming Syllabus, Introduction, Fundamentals of IDL Syntax.
Chapter 10: BASH Shell Scripting Fun with fi. In this chapter … Control structures File descriptors Variables.
IDL Tutorial Day 1 Goals: 1) Introduce IDL basics 2) Describe fundamental IDL structures Angela Des Jardins
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Introduction to MATLAB. CSPP58001 MATLAB MATLAB is is a matrix-based language well suited for carrying out numerical analysis. It has many, many high-
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display.
IDL Tutorials: Day 4 Goal: Learn some programming techniques: Relational operators, conditional statements, boolean operators, loops Maria Kazachenko
Recap Saving Plots Summary of Chapter 5 Introduction of Chapter 6.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Digital Image Processing Introduction to M-function Programming.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
Arrays. Review of last lecture Overview of computer languages Overview of IDL Strength of IDL: (1) Interactive/compiled modes; (2) Array-oriented; (3)
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
CSE 455 : Computer Vision MATLAB 101 Getting Started with MATLAB.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
Arrays. Review of last lecture Overview of IDL Strength of IDL: (1) Interactive/compiled modes; (2) Array-oriented; (3) Variables easily redefined; (4)
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
IDL Tutorials Day 1 Henry (Trae) Winter Room 235
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to Programming
National Scientific Library at Tbilisi State University
Use of Mathematics using Technology (Maltlab)
Introduction to Programming
Statistics Function Implementation
Introduction to Programming
Presentation transcript:

Making friends with IDL IDL is an interpreted rather than a compiled language. This means that large IDL programs can execute less rapidly than equivalent compiled programs written in FORTRAN or C. IDL LIMITATIONS: IDL is a proprietary system (need licence) interactive environment excellent for visualizing, analyzing, editing, and displaying numerical data sets immediate access to all variables optimized array operations versatile built-in plotting and graphics routines data structures possible interface with C and Fortran routines on line help (?) IDL = interactive data language

Making friends with IDL create variables > name = ‘Maxwell’ creates a string > z = 1.0e-8 creates a scalar > testdata = fltarr(512,512) creates a 512x512 2-D array with zero entries > a = [1,2,3] creates a vector > a = [a,4] expands a vector Warning: If you redefine a variables during your work, you lose the previous values Avoid operation with different variables types. For example using float and integer these could be different > print, * 1 > print, * 1.

Variables Variable names can have letters, numbers and underscores in them. They are NOT case-sensitive: aaa, Aaa and AAA are all the same variable. IDL> a=[3, 5, 6, 2.5, 100, 27.7] IDL> a= [[ 2,3,4],[10,20,30]] IDL> a=float(b) IDL> a=fltarr(n_elements(b),4,2)‏ Array index START FROM 0!!!! Array of 2 rows and 3 columns = Array[3,2] One dimension array of 6 elements = Array[6]

Array manipulations INVERT - Computes the inverse of a square array. MAX - Returns the value of the largest element of Array. MEDIAN - Returns the median value of Array or applies a median filter. MEAN – Return the mean value (also first element of MOMENT). MIN - Returns the value of the smallest element of an array. MOMENT – compute the first 4 moments (mean, variance…) REFORM - Changes array dimensions without changing the total number of elements. REVERSE- Reverses the order of one dimension of an array. SIZE- Returns array size and type information. TOTAL - Sums of the elements of an array. TRANSPOSE - Transposes an array. WHERE- Returns subscripts of nonzero array elements. (a b c)## (g h) = (ag+bi+ck ah+bj+cl) (d e f) (i j) (dg+ei+fk dh+ej+fl) (k l) (a b c)# (g h) = (ag+dh bg+ch cg+fh) (d e f) (i j) (ai+dj bi+ej ci+fj) (k l) (cg+fh ci+fj ck+fl) > a = [1,2,3] > b = [4,5] > print, a#b > print, b#a > print, a##b > print,a*b > print,a+1 > print,b*2 > print,a+b Warning!!! Try to avoid loops t=0 for i=0,n_elements(a)-1 do t=t+a(i) t=total(a)

looking for help ? name help print help,variable : print variable informations. help,A,/str : print structure info help,/rou : prints list for all compiled procedures. Lists procedure and functions separately. help,/sy : prints current values of all "system variables", which are special variables known to all routines. Names of these begin with a "!", e.g. !dir, !path, etc. help,/rec : prints contents of command recall buffer in reverse order help,/dev : prints parameter settings for current graphics device help,/mem : lists current memory usage print,max(a); print,min(a); print,max(a); print,mean(a); print,variance(a); print,median(a); print,moment(a): print various statistical properties of image array. (moment prints first four moments.) Open a help on line windows and search for ‘name’

Saving data (and time!) save restore Safety idea: save your data!!! Be prepared: 99% of time you will have to redo plots. Usual sequence: 1) Make plot 2) Save data (and exit from idl) 3) Meeting 4) Restore data 5) Redo plot It will help also have your code saved in a routines. > save,variable1,variable2,variable3,filename=‘~elisa/idl/data.sav’ Keyword: ALL => save all common block, system variable and local variable from the current IDL session. > save,/all,filename=‘datatemp.sav’’  restore, filename=‘~elisa/idl/data.sav’ > restore,filename=‘datatmp.sav’ make a routine!

main routine procedures or subroutines functions As you type, each line is interpreted and immediately executed for (loop), if, case... parameters and keywords IDL routines (.pro) One of the best ways to learn how to write and use IDL programs is to look the existing IDL programs... end pro NAME, VARIABLES... end function NAME,VARIABLES... return,VALUE end >.r filename > name, variables > a = name (variables) NAME,input1,input2...output1,output2...keyword1=value1,$ keyword2=value2, /Keyword3.... optional and can be in any order.pro file requirement How to call it without.pro OR

Program execution (and other) all IDL procedures/functions are assumed to be in files with the explicit extension '.pro'. compiles the IDL procedure(s) or function(s) in the file [name].pro. If this is a main program, also executes it. IDL will locate the first file with this name in the IDL path or current directoryWARNING!!!! stop>.c ; comment Values of keywords are usually determined by assignment statements: PROCEDURE_NAME,parm1,parm2.....KEYWORD1=100.,KEYWORD2='dumbo',... in the case of switches, keywords can be set to a value of 1 by using the following syntax: NAME,parm1,parm2...../KEYWORD1,..... > retall Run from IDL prompt Inside a file.pro Compile the file_name.pro Useful if the file mane is different from the procedure name >.r or.run [name] Don’t forget the comments!!! Comments begin with ‘;’ for debugging!!... print... plot... to continue if you wont to come back to the first level

Structures A structure can be thought of as a user-defined data type or groups of different data IDL allows you to put lots of variables into a single ‘structure’ dsat={aod550:aot,$; mean AOD stdaod550:sigma,$; standard deviation n:num,$; number of points latc:latitude,$; central lat of the boxes lonc:longitude}; central longitude of the boxes For example satellite data can be load as a structure containing: Instrument name, data and time, pixels radiances, coordinates and observing angles of the pixels Define a structure: A structure (e.g. dsat) is an ensamble of other, previously defined, variables (and structures) > help, dsat,/str AOD550 DOUBLE Array[720, 360] STDAOD550 DOUBLE Array[720, 360] N LONG Array[720, 360] LATC DOUBLE Array[360] LONC DOUBLE Array[720] > print,dsat.aod550(good) To access the variables of a structure Use: mone_str.nome_var Routine that read satellite data usually load a structure for any image/orbit keep related variables together pass/return a lot of variables with only one name

Basic plots window,0,xsize=300,ysize=200 x=findgen(10)‏ IDL> print,x IDL> plot,sin(x2) x2=2*!PI/100*findgen(100)‏ seed=1l n=32 x=randomu(seed,n)‏ y=randomu(seed,n)‏ y2=randomu(seed,n)‏ plot,x,y,psym=1,title='Random XY Points' oplot,x,y2,psym=2,colour=2

Others useful things cut of data where good = where (time eq 1000.,count) if (count eq 1 ) then begin... If (count gt 1) then begin plot, x(good), y(good) endif and ; and... or ; or gt ; greater than (similarly lt) ge ; gt or equal to (similarly le) eq ; equal to ne ; not equal to Logical operator a = tvrd(true=3) write_jpeg, 'namefile.jpg',a,true=3 save a window like.jpg print on postscript.ps file set_plot, 'ps' device, filename='filename.ps‘ … close, /device set_plot, 'x' Smaller file, good to make presentations and movies, NOT good for reports and papers !!! ‘comp_map_'+sat1+'_vsall.jpg’ plotting commands png?

routines at AOPP mappoints,data,lat,lon,centre=[0,0],/nogrey,nlevels=100 loadxy loadxyz colour_ps /home/crun/eodg/idl/ tvdata ncol=4 nrow=4 !P.MULTI= [0,ncol,nrow,0,0] mappoints,dayav.AOD550,lat,lon,centre=[0,0],/nogrey,$ Nlevels=100,range=range,symsize=0.6,$ title='AOD all daset average '+strcompress(i+1)+' March 2006' avgrid,lat,lon,aod imagepoints,data,lat,lon fitexy,px,py,A,B,X_SIG=X_SIG,Y_SIG=Y_SIG Linear fit when both x and y have errors (y = A + B x) Plots data points, with defined latitudes and longitudes Interpolate data (with the associated lat,lon) onto a regular lat lon grid, and plot the image Using the same some fast regridding code (RAL) Load txt file in columns Set colour bar + several routine to load different type of data ASK!!!