IDL Tutorials Day 4 Henry (Trae) Winter

Slides:



Advertisements
Similar presentations
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Advertisements

IDL Tutorials : Day 5 Michael Hahn
Pemrograman C Risanuri Hidayat. Why C  Compact, fast, and powerful  “Mid-level” Language  Standard for program development (wide acceptance)  It is.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
EGR 106 – Truss Design Project (cont.) Truss design programs Graphical interface tools in Matlab Saving and loading data Formatted output Project Assignment.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Homework Reading –Finish K&R Chapter 1 (if not done yet) –Start K&R Chapter 2 for next time. Programming Assignments –DON’T USE and string library functions,
The printf Method The printf method is another way to format output. It is based on the printf function of the C language. System.out.printf(,,,..., );
Homework Reading Programming Assignments
Chapter 5: Data Input and Output Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
Control Statements I: Loop. Control Statements Used to specify the order in which computations will be carried out Three types Loop: for, while, repeat.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Input and Output I: ASCII and Binary files. Data formats ASCII Binary netCDF HDF.
Khalid Rasheed Shaikh Computer Programming Theory 1.
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!)
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Input and Output.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
A.Abhari CPS1251 Topic 2: C Overview C Language Elements Variable Declaration and Data Types Statement Execution C Program Layout Formatting Output Interactive.
Simple Console Output CS 21a. What we will briefly discuss System.out.println( … ) System.out.print( … ) System.out.printf( … )
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.
Functions Commands Programming Steps Examples Printing Homework Hints.
Formatted I/O ä ä Standard Output ä ä printf() family of functions ä ä Standard Input ä ä scanf() family of functions.
File I/O. I/O Flags Flags are passed to give some information about how the file is to be used. – Read only file – flag=0x0 – Write only file – flag=0x1.
Welcome to Computer Programming II! Computer Programming II Summer 2015.
PHP using MySQL Database for Web Development (part II)
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
Input from STDIN STDIN, standard input, comes from the keyboard.
Input and Output: I/O Finish reading chapters 1 and 2 of the text
INC 161 , CPE 100 Computer Programming
Standard Input - Output
Shell Scripting March 1st, 2004 Class Meeting 7.
Introduction to C CSE 2031 Fall /3/ :33 AM.
MATLAB: Structures and File I/O
Visit for more Learning Resources
Input and Output Lecture 4.
System.out.println for console output
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Introduction to Python
C Stuff CS 2308.
Lecture 13 Input/Output Files.
I/O in C Lecture 6 Winter Quarter Engineering H192 Winter 2005
Matlab review Matlab is a numerical analysis system
Number and String Operations
Java Tutotrial for [NLP-AI] 2
PHP.
Exam 1 Material Study Guide
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
Govt. Polytechnic,Dhangar
Program Breakdown, Variables, Types, Control Flow, and Input/Output
Homework Applied for cs240? (If not, keep at it!) 8/10 Done with HW1?
Intro to PHP.
Conversion Check your class notes and given examples at class.
Homework Reading Programming Assignments Finish K&R Chapter 1
LING 388: Computers and Language
CISC101 Reminders All assignments are now posted.
Homework Finishing Chapter 2 of K&R. We will go through Chapter 3 very quickly. Not a lot is new. Questions?
EECE.2160 ECE Application Programming
C++ Programming Basics
Strings …again.
EECE.2160 ECE Application Programming
Repetition Structures
Course Outcomes of Programming In C (PIC) (17212, C203):
Introduction to C Programming
Introduction to C CSE 2031 Fall /15/2019 8:26 AM.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

IDL Tutorials Day 4 winter@physics.montana.edu Henry (Trae) Winter http://solar.physics.montana.edu/winter/idl_tutorial/2003/index.html

Today’s Topics Writing and reading to a text file Using the FORMAT keyword

Opening a Textfile First you have to open a file. This is done with some variation of the open command. openr ;Opens a file to read. openw ;Opens a file to write. openu ;Opens a file for updates. Syntax: >openw,lun,”filename.ext”, /OPTIONAL_KEYWORDS lun: A number or a variable containing a number for the “logical unit number”. Just a way for IDL to manage files Important keywords /APPEND ;Starts writing at the end of an existing file instead of overwriting the file. /GET_LUN ;IDL assigns a number for the variable lun

Writing to a Textfile Once the file is open you can write to it just like writing to the screen, except you use the printf procedure Syntax: >printf, lun, “Stuff to be printed” ,”More stuff”, FORMAT=“(2A12)” Once your finished with the file you need to close it >close, lun ;Closes the file associated with lun >close, /ALL ;Closes all open files

Using the FORMAT Keyword The FORMAT keyword allows you to format the data output Syntax: >…, FORMAT=‘(5A6)’ Formats the next 5 strings with six characters each >…, FORMAT=‘(3F7.3)’ Formats the next 3 numbers. 7 total digits (including a minus sign if needed, and decimal) and 3 digits past the decimal point. >…, FORMAT=‘(3D7.3)’ Does the same as above except with double precision >…, FORMAT=‘(2A6, 1D7.2, A5)’ The expressions in the print statement will be formatted: First two are strings, 6 characters each. Next expression is a double with 7 total characters and 2 past the decimal. The last is a string with 5 characters

Reading a Textfile Open a file using the openr procedure Ascii files can be read with a wide array of procedures and functions. Most common is readf >readf,lun,var1,var2, FORMAT=‘(some format)’ Once your finished with the file you need to close it, again.

Homework Assignment Download extract_text to your directory Rename it something uniq Put a header template on it and fill it out Make documentation notes about what each line does.