Basics of Scientific Computing
Bruce Grossan
- B. Grossan. Use requires attribution of all sources -
Your Digital Professional Life in 3 parts:
2
- B. Grossan. Use requires attribution of all sources -
Part I: Your Information
3
- B. Grossan. Use requires attribution of all sources -
Plan to find everything useful 5 years from now��
4
- B. Grossan. Use requires attribution of all sources -
...find everything useful 5 years from now (cont)��
5
- B. Grossan. Use requires attribution of all sources -
Part II. Software Projects
- B. Grossan. Use requires attribution of all sources -
Hint 1: Write programs for re-use
- B. Grossan. Use requires attribution of all sources -
Hint 2: Go from simple to complex
8
; DATA IN COLUMNS ____ _____ ______
____ _____ ______
____ _____ ______
____ _____ ______
____ _____ ______
Program
; OUTPUT IN COLUMNS ____ _____ ______
____ _____ ______
____ _____ ______
____ _____ ______
____ _____ ______
List of images
____ _____
____ _____
____ _____
____ _____
co-adder
; OUTPUT list of images, star positions
____ _____ ______
____ _____ ______
____ _____ ______
sex-tractor
; OUTPUT list of images, photometry
____ _____ ______
____ _____ ______
____ _____ ______
- B. Grossan. Use requires attribution of all sources -
Technique: Parameter/”control” files
- B. Grossan. Use requires attribution of all sources -
Technique: Name-per-run
WHY BOTHER? �
Two years later, you can still figure out what you did:�
>ls phot/GRB251013C
photrun5.params (starts: ; this run no coadds)
photinlist5.coldat
photoutlist5.coldat
photrun8.params (;coadds ≤ 180s; standard stars 13-17mag; skip cloudy time)
photinlist8.coldat
photoutlist8.coldat
….this way you can know PRECISELY what you did those 2 years ago!
- B. Grossan. Use requires attribution of all sources -
Software is unpredictable: Deep Reasons
11
- B. Grossan. Use requires attribution of all sources -
Software is unpredictable: TEST THOROUGHLY
12
- B. Grossan. Use requires attribution of all sources -
Hint 4: Document as you go
-helps you not forget what you did, why
13
- B. Grossan. Use requires attribution of all sources -
Technique: abstract paths (for portability)
-easily made runs on any computer, setup of data files, directories, etc.
14
- B. Grossan. Use requires attribution of all sources -
Part III: Scientific Computing Techniques
15
IDL> ii=12000 & help,ii
II INT = 12000
IDL> print,'what is 4*12k?’ & print,4*ii
what is 4*12k?
-17536 integer overflow.
IDL> ff=12000.0 & print,4.*ff, 2.^65.*ff
48000.0 4.42722e+23 Inf <-float overflow
Example from Image Reduction
co-add, 25 images, you will get overflow because images are integers. In python, convert to FLOAT:
import numpy as np
rows = 1025
cols = 1024
float_zeros_array = np.zeros((rows, cols), dtype=np.float64) # or np.float32, etc.
(In IDL, just newimage=float(firstimagearray)
For really big numbers, type double is usually 10^302.
- B. Grossan. Use requires attribution of all sources -
Technique: calculate mantissa, put exp in name
16
- B. Grossan. Use requires attribution of all sources -
Data Vectors, Vectorization
17
Tutorials on Tools and Methods using High Performance Computing resources for Big Data, Sodani+2016
- B. Grossan. Use requires attribution of all sources -
Matrix Operations
Example: X’ = R X where R is a rotation matrix
IDL> xprime=r # X <- Weird “#” operator�
python:
import numpy as np
xprime= R@X or <-Special “@” operator
xprime=np.dot(R,X) <-Special Function np.dot()
�
18
- B. Grossan. Use requires attribution of all sources -
Computer Image Manipulation
- B. Grossan. Use requires attribution of all sources -
Image Convolution
20
taken from IDL Convol manual page
wikipedia
- B. Grossan. Use requires attribution of all sources -
Simulating Stars for Photometry 1
21
airy disk by Ben Waterman
- B. Grossan. Use requires attribution of all sources -
Simulating Stars for Photometry 2
22
airy disk by Ben Waterman
Airy Disk
NUTTelA PSF
- B. Grossan. Use requires attribution of all sources -
Simulating Stars for Photometry-3
23
IDL:
; copy bright star at xbrt,ybrt (; denotes comment)
star = realimage[xbrt-2*FWHM:xbt+28FWHM, ybrt-2*FWHM:ybrt+2*FWHM]
star = star/total(star) ; normalize
; place star on simulated image at xstar, ystar
simulated_im[xstar-2*FHWM:xstar+2*FHWM, ystar 2*FHWM:ystar+2*FHWM]=star*flux
…. ; place all the test stars you want, then add background noise:
noiseim=randomn(seed,xsize,ysize) & simulated_im=simulated_im+noiseim
- B. Grossan. Use requires attribution of all sources -