SlideShare a Scribd company logo
1 of 11
• Interactive tool, but also full programming language on its own:
• structured programming (functions and procedures)
• array oriented:
• operations on arrays faster and easier than doing a loop
• many numeric types; strings
• flow control constructs
• Semi automatically quasi compiled
• garbage collection to reclaim memory
• program structure workarounds: system variables, common blocks
• structures, objects
• Three graphic models in IDL 8.x
• direct graphics: 2d, 3d
• plots (contours, images, surface plots, points, volumes),
• cursor interaction, lots of ways to customize IDL> plot, x, y
• direct graphics plot objects: IDL> p = plot(x,y)
• object graphics (more advanced, not really for individual use)
IDL features
IDL Workbench
IDL command line
• Enter commands directly at the IDL prompt
• Add a $ or &$ at the end of each line of text for multi-line command.
Batch files
• Can run a text file containing a list of commands
• Execute by entering @filename at the IDL prompt
Script files
• Very similar to a batch file
• A text file containing a list of commands
• Execute by entering .run filename
• Script file must end with the end command on its last line
• Handles multi-line commands without entering $
• Procedures and Functions
IDL Interface
Constants, variables, math
● Number types
– a = 1 integer: 16 bits, 32767 to +32767
– a = 1L long: 32 bits, 2147483647L to 2147483647L
– a = 1.0 float: 32 bits, sig decimal digits, magnitude 1e38 to 1e38
– a = 1.d double: 64 bits, ~16 decimal digits, magnitude 1d308
● Math operators + * / ^ mod < >
– Watch out for integer arithmetic: 2 / 3 is zero
● Math functions exp alog alog10 ...
● IDL's variables are dynamic
– IDL> a = 30
– IDL> b = a
– IDL> a = “Al Capone”
IDL as a calculator
Some examples:
IDL> print, 13 * 15
IDL> print, 23. / 2
IDL> print, 6.626e27 * 3.29e15
IDL> print, exp(10.)
IDL> print, alog10(30.0)
A couple ways to do a sum:
IDL> print, 1 + 2 + 3 + 4 + 5
IDL> print, total( [ 1, 2, 3, 4, 5 ] )
Arrays
● Array = bunch of numbers treated as single expression
● To make arrays:
x = [0,3,7,2]
intarr or indgen for integer
fltarr or findgen for float
intarr form gives array filled with zeros;
indgen form gives [0,1,2,3...]
● Can use operators on arrays
a = [1,3,5] b = [4,6,8] c = a + b
● Important: first element is a[0] not a[1]
● Many useful array related routines: min max where sort
● Multidimensional arrays too
More on arrays
● Basic subscripting
– print, a[0:2] first three elements
– print, a[3:*] fourth to end
– print, a[*,0] all elements of a's first row
– print, a[1,*] all elements of a's second column
● Subscripting with variables
– a = findgen(10)+10
– set = [3,4,5]
– print, a[set]
● The all important “where” function
– set = where(a gt 4.5)
● Basic plot: given arrays x, y
plot, x, y
● Many aspects of plots customized by keywords
plot, sin(d/10), psym=4, ytitle='Response (keV)'
● Shorthand for log/linear axes:
plot_io, x, y
plot_oi, x, y
plot_oo, x, y
● Shorthand for overplotting
oplot, x, y or oplot, x, y, psym=5, col=!blue
● Plots written to “devices”
– X for screen plot
– PS for postscript file
– help, /device tells which device we're in
– many device details customizable: color options, paper size...
2D plotting
Functions and Procedures
● Many functions and procedures built in but you can add your own
● Using these promotes code reuse,helps debugging, saves sanity of
yourself and others
● Functions:
– Declare this way: function circumference, radius
– Invoke this way: c = circumference(radius)
– Must return a value return, 2.*!dpi*radius
● Procedures:
– Declare this way: pro dostuff, a
– Invoke this way: dostuff, a
– Don't return a value (but can return things through argument list)
● Either one can modify any variables you send as arguments
Statement Description/Usage
IF If a statement is true – execute a statement
FOR Repeat statements for a specified number of times
WHILE Repeat statements while a condition is true
RETURN Return a variable from a function or procedure
CASE Select an option (case) form a list depending on the input
SWITCH Return to a case in a list of cases
REPEAT Repeat statements until a condition is true
GOTO Go to a certain label
BREAK Break out of the loop or statement
CONTINUE Continue the program and allow the next iteration of the loop
IDL few statements

More Related Content

Similar to 10-IDL.pptx

Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Things to Remember When Developing 64-bit Software
Things to Remember When Developing 64-bit SoftwareThings to Remember When Developing 64-bit Software
Things to Remember When Developing 64-bit Software
Andrey Karpov
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
ActiveState
 
Cs1123 11 pointers
Cs1123 11 pointersCs1123 11 pointers
Cs1123 11 pointers
TAlha MAlik
 

Similar to 10-IDL.pptx (20)

Learning python
Learning pythonLearning python
Learning python
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
Things to Remember When Developing 64-bit Software
Things to Remember When Developing 64-bit SoftwareThings to Remember When Developing 64-bit Software
Things to Remember When Developing 64-bit Software
 
if, while and for in Python
if, while and for in Pythonif, while and for in Python
if, while and for in Python
 
C++
C++C++
C++
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Introduction to programming - class 2
Introduction to programming - class 2Introduction to programming - class 2
Introduction to programming - class 2
 
sonam Kumari python.ppt
sonam Kumari python.pptsonam Kumari python.ppt
sonam Kumari python.ppt
 
Python for web security - beginner
Python for web security - beginnerPython for web security - beginner
Python for web security - beginner
 
Golang
GolangGolang
Golang
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
 
Cs1123 11 pointers
Cs1123 11 pointersCs1123 11 pointers
Cs1123 11 pointers
 
ppt_pspp.pdf
ppt_pspp.pdfppt_pspp.pdf
ppt_pspp.pdf
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++2 BytesC++ course_2014_c1_basicsc++
2 BytesC++ course_2014_c1_basicsc++
 
program#include iostreamusing namespace std;void calculatio.pdf
program#include iostreamusing namespace std;void calculatio.pdfprogram#include iostreamusing namespace std;void calculatio.pdf
program#include iostreamusing namespace std;void calculatio.pdf
 
About the C Libraries which are essential
About the C Libraries which are essentialAbout the C Libraries which are essential
About the C Libraries which are essential
 
COA Chapter 1.pdf
COA Chapter 1.pdfCOA Chapter 1.pdf
COA Chapter 1.pdf
 

Recently uploaded

zidauu _business communication.pptx /pdf
zidauu _business  communication.pptx /pdfzidauu _business  communication.pptx /pdf
zidauu _business communication.pptx /pdf
zukhrafshabbir
 
NewBase 24 May 2024 Energy News issue - 1727 by Khaled Al Awadi_compresse...
NewBase   24 May  2024  Energy News issue - 1727 by Khaled Al Awadi_compresse...NewBase   24 May  2024  Energy News issue - 1727 by Khaled Al Awadi_compresse...
NewBase 24 May 2024 Energy News issue - 1727 by Khaled Al Awadi_compresse...
Khaled Al Awadi
 

Recently uploaded (20)

Creative Ideas for Interactive Team Presentations
Creative Ideas for Interactive Team PresentationsCreative Ideas for Interactive Team Presentations
Creative Ideas for Interactive Team Presentations
 
Copyright: What Creators and Users of Art Need to Know
Copyright: What Creators and Users of Art Need to KnowCopyright: What Creators and Users of Art Need to Know
Copyright: What Creators and Users of Art Need to Know
 
Unveiling Gemini: Traits and Personality of the Twins
Unveiling Gemini: Traits and Personality of the TwinsUnveiling Gemini: Traits and Personality of the Twins
Unveiling Gemini: Traits and Personality of the Twins
 
A Brief Introduction About Jacob Badgett
A Brief Introduction About Jacob BadgettA Brief Introduction About Jacob Badgett
A Brief Introduction About Jacob Badgett
 
Powers and Functions of CPCB - The Water Act 1974.pdf
Powers and Functions of CPCB - The Water Act 1974.pdfPowers and Functions of CPCB - The Water Act 1974.pdf
Powers and Functions of CPCB - The Water Act 1974.pdf
 
TriStar Gold Corporate Presentation May 2024
TriStar Gold Corporate Presentation May 2024TriStar Gold Corporate Presentation May 2024
TriStar Gold Corporate Presentation May 2024
 
Elevate Your Online Presence with SEO Services
Elevate Your Online Presence with SEO ServicesElevate Your Online Presence with SEO Services
Elevate Your Online Presence with SEO Services
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
zidauu _business communication.pptx /pdf
zidauu _business  communication.pptx /pdfzidauu _business  communication.pptx /pdf
zidauu _business communication.pptx /pdf
 
Toyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & TransformationsToyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & Transformations
 
Stages of Startup Funding - An Explainer
Stages of Startup Funding - An ExplainerStages of Startup Funding - An Explainer
Stages of Startup Funding - An Explainer
 
Potato Flakes Manufacturing Plant Project Report.pdf
Potato Flakes Manufacturing Plant Project Report.pdfPotato Flakes Manufacturing Plant Project Report.pdf
Potato Flakes Manufacturing Plant Project Report.pdf
 
NewBase 24 May 2024 Energy News issue - 1727 by Khaled Al Awadi_compresse...
NewBase   24 May  2024  Energy News issue - 1727 by Khaled Al Awadi_compresse...NewBase   24 May  2024  Energy News issue - 1727 by Khaled Al Awadi_compresse...
NewBase 24 May 2024 Energy News issue - 1727 by Khaled Al Awadi_compresse...
 
How to refresh to be fit for the future world
How to refresh to be fit for the future worldHow to refresh to be fit for the future world
How to refresh to be fit for the future world
 
Sedex Members Ethical Trade Audit (SMETA) Measurement Criteria
Sedex Members Ethical Trade Audit (SMETA) Measurement CriteriaSedex Members Ethical Trade Audit (SMETA) Measurement Criteria
Sedex Members Ethical Trade Audit (SMETA) Measurement Criteria
 
Raising Seed Capital by Steve Schlafman at RRE Ventures
Raising Seed Capital by Steve Schlafman at RRE VenturesRaising Seed Capital by Steve Schlafman at RRE Ventures
Raising Seed Capital by Steve Schlafman at RRE Ventures
 
Special Purpose Vehicle (Purpose, Formation & examples)
Special Purpose Vehicle (Purpose, Formation & examples)Special Purpose Vehicle (Purpose, Formation & examples)
Special Purpose Vehicle (Purpose, Formation & examples)
 
HAL Financial Performance Analysis and Future Prospects
HAL Financial Performance Analysis and Future ProspectsHAL Financial Performance Analysis and Future Prospects
HAL Financial Performance Analysis and Future Prospects
 
Falcon Invoice Discounting Setup for Small Businesses
Falcon Invoice Discounting Setup for Small BusinessesFalcon Invoice Discounting Setup for Small Businesses
Falcon Invoice Discounting Setup for Small Businesses
 
Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)
 

10-IDL.pptx

  • 1.
  • 2. • Interactive tool, but also full programming language on its own: • structured programming (functions and procedures) • array oriented: • operations on arrays faster and easier than doing a loop • many numeric types; strings • flow control constructs • Semi automatically quasi compiled • garbage collection to reclaim memory • program structure workarounds: system variables, common blocks • structures, objects • Three graphic models in IDL 8.x • direct graphics: 2d, 3d • plots (contours, images, surface plots, points, volumes), • cursor interaction, lots of ways to customize IDL> plot, x, y • direct graphics plot objects: IDL> p = plot(x,y) • object graphics (more advanced, not really for individual use) IDL features
  • 4. IDL command line • Enter commands directly at the IDL prompt • Add a $ or &$ at the end of each line of text for multi-line command. Batch files • Can run a text file containing a list of commands • Execute by entering @filename at the IDL prompt Script files • Very similar to a batch file • A text file containing a list of commands • Execute by entering .run filename • Script file must end with the end command on its last line • Handles multi-line commands without entering $ • Procedures and Functions IDL Interface
  • 5. Constants, variables, math ● Number types – a = 1 integer: 16 bits, 32767 to +32767 – a = 1L long: 32 bits, 2147483647L to 2147483647L – a = 1.0 float: 32 bits, sig decimal digits, magnitude 1e38 to 1e38 – a = 1.d double: 64 bits, ~16 decimal digits, magnitude 1d308 ● Math operators + * / ^ mod < > – Watch out for integer arithmetic: 2 / 3 is zero ● Math functions exp alog alog10 ... ● IDL's variables are dynamic – IDL> a = 30 – IDL> b = a – IDL> a = “Al Capone”
  • 6. IDL as a calculator Some examples: IDL> print, 13 * 15 IDL> print, 23. / 2 IDL> print, 6.626e27 * 3.29e15 IDL> print, exp(10.) IDL> print, alog10(30.0) A couple ways to do a sum: IDL> print, 1 + 2 + 3 + 4 + 5 IDL> print, total( [ 1, 2, 3, 4, 5 ] )
  • 7. Arrays ● Array = bunch of numbers treated as single expression ● To make arrays: x = [0,3,7,2] intarr or indgen for integer fltarr or findgen for float intarr form gives array filled with zeros; indgen form gives [0,1,2,3...] ● Can use operators on arrays a = [1,3,5] b = [4,6,8] c = a + b ● Important: first element is a[0] not a[1] ● Many useful array related routines: min max where sort ● Multidimensional arrays too
  • 8. More on arrays ● Basic subscripting – print, a[0:2] first three elements – print, a[3:*] fourth to end – print, a[*,0] all elements of a's first row – print, a[1,*] all elements of a's second column ● Subscripting with variables – a = findgen(10)+10 – set = [3,4,5] – print, a[set] ● The all important “where” function – set = where(a gt 4.5)
  • 9. ● Basic plot: given arrays x, y plot, x, y ● Many aspects of plots customized by keywords plot, sin(d/10), psym=4, ytitle='Response (keV)' ● Shorthand for log/linear axes: plot_io, x, y plot_oi, x, y plot_oo, x, y ● Shorthand for overplotting oplot, x, y or oplot, x, y, psym=5, col=!blue ● Plots written to “devices” – X for screen plot – PS for postscript file – help, /device tells which device we're in – many device details customizable: color options, paper size... 2D plotting
  • 10. Functions and Procedures ● Many functions and procedures built in but you can add your own ● Using these promotes code reuse,helps debugging, saves sanity of yourself and others ● Functions: – Declare this way: function circumference, radius – Invoke this way: c = circumference(radius) – Must return a value return, 2.*!dpi*radius ● Procedures: – Declare this way: pro dostuff, a – Invoke this way: dostuff, a – Don't return a value (but can return things through argument list) ● Either one can modify any variables you send as arguments
  • 11. Statement Description/Usage IF If a statement is true – execute a statement FOR Repeat statements for a specified number of times WHILE Repeat statements while a condition is true RETURN Return a variable from a function or procedure CASE Select an option (case) form a list depending on the input SWITCH Return to a case in a list of cases REPEAT Repeat statements until a condition is true GOTO Go to a certain label BREAK Break out of the loop or statement CONTINUE Continue the program and allow the next iteration of the loop IDL few statements