Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:praktikum:gdl [2014/12/13 01:39] – created, Part 1 msteinke | en:praktikum:gdl [2016/06/16 01:31] (current) – rhainich | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)// | ||
====== GDL (IDL) for beginners ====== | ====== GDL (IDL) for beginners ====== | ||
Line 11: | Line 10: | ||
Now enter the GDL program code line by line and the interpreter executes it right away. | Now enter the GDL program code line by line and the interpreter executes it right away. | ||
- | However, it's more conveniant | + | However, it's more convenient |
.compile myprog.pro | .compile myprog.pro | ||
- | Depending on the name given to the program | + | The first line of the program code gives the (internal GDL) name of the program |
pro prog1 | pro prog1 | ||
- | the compiling | + | After compiling the program " |
prog1 | prog1 | ||
in GDL. | in GDL. | ||
- | |||
====== Syntax ====== | ====== Syntax ====== | ||
Line 27: | Line 25: | ||
and even | and even | ||
PrInT, "Hello World!" | PrInT, "Hello World!" | ||
- | return the same output. However, for strings and filenames | + | return the same output. However, for strings and file names it's different, as usual. |
==== Basics==== | ==== Basics==== | ||
- | | Calling the interpreter: | + | ^ |
- | | Starting GDL help: | ? | | + | | Calling the interpreter: |
- | | | + | | Starting GDL help: | |
- | | Anzeigen aller Variablen:| help | | + | | Show all variables: |
- | | Kompilieren eines eigenen Scripts: | .compile | + | | Compile a script: | |
- | | Ausführen des Scripts | + | | Execute the script |
- | | Beenden von GDL: | + | | Leave gdl: |
- | | Erste Zeile: | + | | First line of a script: |
- | | Letzte Zeile (Ende des Programms): | end | | + | | Last line of a script |
- | ==== FITS-Dateien ==== | + | (Note: Replace " |
- | Einlesen eines Fits-Files in eine Variable: | + | ==== FITS files ==== |
- | bild1 = readfits(' | + | |
- | Liegt das Bild nicht im aktuellen Verzeichnis muss man hier den ganzen (relativen) Pfad vor dem Dateinamen angeben. | + | |
- | Je nach interner Rechnerarchitektur werden Daten, die mehr als ein Byte umfassen entweder in High- oder Lowbyteordnung abgespeichert. In seltenen Faellen kann es passieren, dass die Standardordnung zwischen Quellsystem und Auswertesystem nicht identisch ist, was sich in (scheinbar) unsinnigen Werten ausdrückt und sich leicht mit einem Blick auf das Bild der FITS-Datei ermitteln laesst. In solchen Faellen muss die Byteordnung konvertiert werden mittels: | + | Read the content of a fits file into the variable |
- | byteorder, bild1 | + | |
- | + | If the image is not in the current directory, give the full (or relative) path (i.e. ' | |
- | Abspeichern eines Arrays (hier //bild2//) als FITS-Datei: | + | |
- | | + | |
- | Beachte: Alle FITS-Befehle benoetigen die (frei verfügbare) Astrolib fuer GDL/IDL. | + | Depending on the internal computer architecture, |
+ | byteorder, image1 | ||
- | ==== Ein- und Ausgabe ==== | + | Save an array (e.g. //image2//) as fits file: |
+ | writefits, ' | ||
- | Schreiben auf die Konsole | + | Note: All FITS commands require the (freely distributed) [[http:// |
- | | + | ==== Input/ |
+ | |||
+ | If the variable //namevar// has a content (e.g. namevar=' | ||
+ | |||
+ | | ||
| | ||
- | Mittels Komma getrennt koennen beliebig viele weitere Werte oder Variablen angehaengt werden. Es erfolgt an Ende ein Zeilenumbruch. | + | Any number of values/ |
- | Schreiben in eine Datei: | + | Write into a file: |
- | openw, handle, 'dateiname.dat' | + | openw, handle, 'filename.dat' |
- | printf, | + | printf, |
close, handle | close, handle | ||
- | // | + | // |
- | ==== Variablen und Felder ==== | + | openw, |
+ | printf, | ||
+ | close,out | ||
+ | free_lun, | ||
- | Indizierte Variablen beginnen mit dem Index 0. Ein Array mit den Eintraegen 0, 1,... bis MMAX hat somit MMAX + 1 Eintraege | + | In this case GDL will automatically assign a //handle// (via /// |
- | + | ||
- | Dimensionierung eines zweidimensionalen Arrays fuer Integer-Zahlen durch: | + | |
- | variablenname = intarr(MMAX+1, | + | |
- | In machen Faellen werden groessere Zahlenwerte benoetigt, als der Datentyp Integer hergibt, in diesem Fall kann | + | ==== Variables and arrays ==== |
- | variablenname | + | |
- | verwendet werden. | + | |
- | Fuer Fliesskommazahlen (Float) lautet der Befehl | + | Index variables start with the index 0. Thus, an array with the indices 0,1,...,MMAX has MMAX+1 entries. |
- | variablenname = fltarr(MMAX+1,NMAX+1) | + | |
- | Die Anzahl der Eintraege eines Arrays (hier // | + | Dimensioning of a two dimensional array for integer numbers: |
- | | + | |
- | ermittelt werden. Allerdings liefert '' | + | |
- | anz = (size(arrayvar,/ | + | |
+ | In some cases lager values are required than provided by the integer type ($i> | ||
+ | variablename = lonarr(MMAX+1, | ||
+ | variablename = lon64arr(MMAX+1, | ||
+ | | ||
+ | For floating point numbers (Float) use | ||
+ | variablename = fltarr(MMAX+1, | ||
- | ==== Kontrollstrukturen ==== | + | For double-precision numbers (Double) use |
+ | variablename | ||
+ | |||
+ | For strings use | ||
+ | variablename | ||
+ | |||
+ | The number of entries in an array (e.g. // | ||
+ | size(variablename,/ | ||
+ | which returns an array itself (with data type, size, etc.). To obtain the number of entries extract the first value (index 0!) of that array: | ||
+ | number | ||
- | Schleifen-Syntax: | + | ==== Control structures ==== |
+ | |||
+ | Loop syntax: | ||
for j=n1,n2 do begin | for j=n1,n2 do begin | ||
Line 99: | Line 111: | ||
endfor | endfor | ||
+ | Conditional syntax: | ||
+ | |||
+ | if a gt b then begin | ||
+ | ... | ||
+ | endif | ||
+ | Additional information can be accessed via the help of GDL (type "?" |