Introduction to Linux & IDL
Chia-Hsien Lin
2021 Spring (1092)
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 1 / 12
Linux
Remote connection (IP: 140.115.120.39 port 77) (IP: 192.168.1.105 port 10000)
I Two ways for remote connection from Windows:
F mobaXterm: can do ssh and sftp
https://mobaxterm.mobatek.net/download-home-edition.html
F Xmin and putty: can only do ssh
http://www.geo.mtu.edu/geoschem/docs/putty install.html
I Connection steps:
1 use mobaXterm to connect to tiny
2 use ssh to connect to project2
transfer files:
I from project2 to your computer:
1 put the files to tiny:
sftp -P77
[email protected] and then put the files
2 drag the files from the mobaxterm side column to your computer
I from your computer to project2:
1 drag the files from your computer to the mobaxterm side column
2 put the files to project2:
sftp -P10000
[email protected] and then put the files
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 2 / 12
Linux
A good on-line guide for Linux: http://linux.vbird.org/
directory operation:
commands to do the following operations on directory:
I to create a new directory:mkdir;
I to go to a directory: cd;
I to move a directory mv);
I to remove a directory (The directory must be empty) rmdir;
I to copy an entire directory cp -rf;
I to check content: ls
file operation: create, edit, move, copy
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 3 / 12
Linux
path:
I The symbol / at the beginning of a path means the root directory
e.g., cd / means go to the root directory
cd /home means go to a directory called home which is below the root
directory
I The symbol / is also used to separate mother directory and its
subordinate directory
e.g., cd /user/local means go to a directory local which is under
the directory user which is under the root directory
I go to a directory below the current directory:
I go back to a directory above the current directory
I return to your home directory: simply type cd and enter
I the symbol ∼ represents your home directory
I the symbol .. represents the mother directory of the current one
I the symbol . represents the current directory
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 4 / 12
IDL
We will be using SSWIDL, which is IDL plus special packages designed to
process solar data.
On-line IDL course:
http://www.astro.ufl.edu/∼warner/IDL5220/
Helpful on-line IDL guide and help pages:
A Guide to IDL for Astronomers’ (U Virginia)
http://www.astro.virginia.edu/class/oconnell/astr511/IDLguide.html
Coyote’s Guide to IDL Programming:
www.idlcoyote.com
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 5 / 12
IDL basics
command syntax: <command>, <inputs>, <keywords>
compilation: .r <procedure name>
program format: (IDL programs: ***.pro)
Three types of IDL programs:
I procedure:
pro name of program, [list of input and output variables, keywords]
; comment lines are marked by ; in the beginning of the line
content (a collection of IDL commands)
end
I script:
lines of commands
end
I function:
function name of program, [list of input variables, keywords]
content of the funcion
end
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 6 / 12
IDL basics
How to look for help
I standard IDL command/procedures: ?name of procedure
I SSWIDL command/procedures: xdoc
I Use keyword: tftd, keyword
Command to type whenever you get error messages: retall
save your stuff:
save, [variables you want to save], filename, /compress
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 7 / 12
How to save something in IDL?
save it as an IDL save file:
save, <variable names>, description=description, $
filename=’<your filename>’, /compress
I how to restore an IDL save file:
restore,filename=’<your filename>’
save it as a FITS file:
writefits, filename=’<your filename>’, <variable name>
I how to read a FITS file in IDL:
<variable name> = readfits(’<your filename>’)
save it as a generic file
savegen, <variable names>, file=’<your filename>’, $
names = names, text = text
I how to restore an IDL generic file
restgen, <variable names>, file=’<your filename>’
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 8 / 12
IDL basics
data types
How to create arrays of different data types:
intarr,fltarr,strarr,dblarr,indgen
Loops (for ... endfor), selections (if ... endif)
Output plots to a postscript file
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 9 / 12
Exercises
Image Filtering
1 read one image
2 filter out the pixels with intensity < some threshold:
Set their intensity fo NAN
a=where(abs(img lt thresh))
b=array indices(img, a)
img[b[0,*], b[1,*]] = !VALUES.F NAN
3 plot the filtered image
plot image, img
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 10 / 12
Exercises
Image Cropping
1 read one image
2 cut a region of interest:
xrange: xl to xr
yrange: yl to yu
img2 = image[xl:xr, yl:yu]
3 plot the cropped region
plot image, img2
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 11 / 12
Exercises
2D image → 3D array
1 create an empty 3D array
Nx = xr-xl+1 & Ny = yu - yl + 1 & Nf =
imgarr = fltarr(Nx, Ny, Nf)
2 Use a for loop to do the following:
for i=0, Nf-1 do begin
1 read in each image from a list of images
2 cut a region of interest (must be of same size)
img2 = image[xl:xr, yl:yu]
3 put the cropped region in the 3D array sequentially
imgarr[*,*,i] = img2
endfor
Chia-Hsien Lin Introduction to Linux & IDL 2021 Spring (1092) 12 / 12