Commit 4e216d1d authored by Laura Schreiber's avatar Laura Schreiber
Browse files

First commit

parent 03c5dd1e
Loading
Loading
Loading
Loading

add_overlap.pro

0 → 100644
+42 −0
Original line number Original line Diff line number Diff line
; $Id: add_overlap.pro, v 1.0 Aug 1999 e.d. $
;
;+
; NAME:
;	ADD_OVERLAP
;
; PURPOSE:
;	Find the overlap region of two 2D arrays, after ideally superposing the
;	relative positions of a reference point, and add the overlap region of
;	the second array to the overlap region of the first one.
;
; CATEGORY:
;	Array manipulation.
;
; CALLING SEQUENCE:
;	ADD_OVERLAP, Array1, Array2, R1, R2
;
; INPUTS:
;	Array1, Array2:	Input arrays
;
;	R1:	2-components vector of coordinates of reference point in Array1
;
;	R2:	2-components vector of coordinates of reference point in Array2
;
; OUTPUTS:
;	Array1:	Input Array1 + overlap region of Array2
;
; SIDE EFFECTS:
;	Array1 is overwritten.
;
; MODIFICATION HISTORY:
; 	Written by:	Emiliano Diolaiti, August 1999.
;-

PRO add_overlap, array1, array2, r1, r2

	on_error, 2
	array_overlap, size52(array1, /DIM), size52(array2, /DIM), r1, r2, $
   				   lx1, ux1, ly1, uy1, lx2, ux2, ly2, uy2
	array1[lx1,ly1] = array1[lx1:ux1,ly1:uy1] + array2[lx2:ux2,ly2:uy2]
	return
end

add_subscript.pro

0 → 100644
+36 −0
Original line number Original line Diff line number Diff line
; $Id: add_subscript.pro, v 1.1 Mar 2012 e.d. $
;
;+
; NAME:
;	ADD_SUBSCRIPT
;
; PURPOSE:
;	Add new subscript to subscript vector.
;
; CATEGORY:
;	STARFINDER auxiliary procedures.
;
; CALLING SEQUENCE:
;	Result = ADD_SUBSCRIPT(Subscripts, S)
;
; INPUTS:
;	Subscripts:	1D vector of subscripts.
;
;	S:	new subscripts to append to Subscripts
;
; OUTPUTS:
;	Return appended vector of subscripts.
;	If input vector Subscripts is not valid, return S.
;
; MODIFICATION HISTORY:
; 	Written by:	Emiliano Diolaiti, June 2001.
;   1) Created this file (E. D., March 2012).
;-

FUNCTION add_subscript, subscripts, s

    on_error, 2
    if  subscripts[0] lt 0  then $
       w = s  else  w = [subscripts, s]
    return, w
end

airy_pattern.pro

0 → 100644
+52 −0
Original line number Original line Diff line number Diff line
; $Id: airy_pattern.pro, v 1.0 Aug 1999 e.d. $
;
;+
; NAME:
;	AIRY_PATTERN
;
; PURPOSE:
;	Compute Airy pattern.
;
; CATEGORY:
;	Models.
;
; CALLING SEQUENCE:
;	Result = AIRY_PATTERN(X_size, Y_size, X_center, Y_center, Sampling_factor)
;
; INPUTS:
;	X_size, Y_size:	X- and y_ size of output array
;
;	X_center, Y_center:	Coordinates of center, not necessarily integer
;
; OPTIONAL INPUTS:
;	Sampling_factor:	Ratio of actual sampling factor to critical sampling
;		step for the optical system producing the Airy pattern.
;		The default is Sampling_factor = 1, i.e. critical sampling
;
; OUTPUTS:
;	Result:	2D array containing Airy pattern normalized to maximum = 1
;
; PROCEDURE:
;	Compute Airy pattern as defined in
;	Born, Wolf, "Principles of Optics", Pergamon Press, 2nd revised edition.
;	Suitably adjust sampling step.
;
; MODIFICATION HISTORY:
; 	Written by:	Emiliano Diolaiti, August 1999.
;-

FUNCTION airy_pattern, x_size, y_size, x_center, y_center, sampling_factor

	if  n_elements(sampling_factor) eq 0  then $
	   sampling_factor = 1			; critical sampling
	scale = !pi / 2
	; define 2D array of radial distances
	r = radial_dist(x_size, y_size, x_center, y_center)
	r = temporary(r) * scale * sampling_factor
	; compute diffraction pattern
	w = where(r ne 0)
	d = r  &  d[w] = 2 * (beselj(r, 1))[w] / r[w]
	w = where(r eq 0, n)  &  if  n ne 0  then  d[w] = 1
	d = temporary(d)^2
	return, d
end
 No newline at end of file

all_max.pro

0 → 100644
+61 −0
Original line number Original line Diff line number Diff line
; $Id: all_max.pro, v 1.1 Sep 2001 e.d. $
;
;+
; NAME:
;	ALL_MAX
;
; PURPOSE:
;	Find relative maxima in a 2D array.
;	A given pixel is considered a relative maximum if it is brighter
;	than its 8-neighbors or 4-neighbors.
;
; CATEGORY:
;	Signal processing.
;
; CALLING SEQUENCE:
;	ALL_MAX, Array, X, Y, N
;
; INPUTS:
;	Array:	2D array to be searched
;
; KEYWORD PARAMETERS:
;	BOX:	Size of sub-regions where the local maxima are defined.
;		The default is 3, i.e. each returned peak is the relative
;		maximum in a 3x3 sub-array.
;
;	FOUR:	Set this keyword to identify relative maxima as pixels
;		brighter than their 4-neighbors. The default is to use
;		8-neighbors.
;
; OUTPUTS:
;	X, Y:	Coordinates of detected maxima
;
;	N:	Number of detected maxima
;
; MODIFICATION HISTORY:
; 	Written by:	Emiliano Diolaiti, August 1999.
;	1) Added BOX keyword (Emiliano Diolaiti, September 2001).
;-

PRO all_max, array, x, y, n, BOX = box, FOUR = four

	on_error, 2
	if  n_elements(box) eq 0  then  box  = 3
	siz = size52(array, /DIM)  &  sx = siz[0]  &  sy = siz[1]
	xedge = box/2  &  yedge = box/2
	ext_array = extend_array(array, sx + 2*xedge, sy + 2*yedge)
	m = make_array(sx + 2*xedge, sy + 2*yedge, /BYTE, VALUE = 1B)
	for  dx = -box/2, box/2  do  for  dy = -box/2, box/2  do begin
	   if  keyword_set(four)  then $
	      check = abs(dx) ne abs(dy)  else $	; 4-neighbors
	      check = dx ne 0 or dy ne 0		     	; 8-neighbors
	   if  check  then $
	      m = temporary(m) and ext_array gt shift(ext_array, dx, dy)
	endfor
   w = where(m[xedge:xedge+sx-1,yedge:yedge+sy-1] eq 1, n)
   if  n ne 0  then  subs_to_coord, w, sx, x, y
   if  n eq 1  then begin
	   x = x[0]  &  y = y[0]
	endif
	return
end

angle.pro

0 → 100644
+49 −0
Original line number Original line Diff line number Diff line
; $Id: angle.pro, v 1.0 Aug 1999 e.d. $
;
;+
; NAME:
;	ANGLE
;
; PURPOSE:
;	Compute the position angles of a set of points on a plane with
;	respect to the horizontal axis of a reference frame passing through
;	a fixed origin. The angles are measured counter-clockwise in radians
;	and belong to the interval [0, 2*pi[.
;	The computations are performed in floating-point arithmethic.
;
; CATEGORY:
;	Mathematics.
;
; CALLING SEQUENCE:
;	Result = ANGLE(X0, Y0, X, Y)
;
; INPUTS:
;	X0, Y0:	Couple of scalars, representing coordinates of the origin
;
;	X, Y:	Coordinates of the points for which the position angle
;		must be computed
;
; OUTPUTS:
;	Result:	Array of position angles, with the same size as the input
;		arrays X and Y.
;
; MODIFICATION HISTORY:
; 	Written by:	Emiliano Diolaiti, August 1999.
;-

FUNCTION angle, x0, y0, x, y

	on_error, 2
	a = float(x) - x  &  dx = x - float(x0[0])  &  dy = y - float(y0[0])
	w = where(dx eq 0 and dy ne 0, n)
	if  n ne 0  then  a[w] = !pi/2
	w = where(dx ne 0, n)
	if  n ne 0  then  a[w] = atan(dy[w] / dx[w])
	w = ((dx lt 0) or ((dx eq 0) and (dy lt 0))) and 1B
	a = a + w * !pi
	w = where(a lt 0, n)
	if  n ne 0  then  a[w] = a[w] + 2*!pi
	w = where(a eq 2*!pi, n)
	if  n ne 0  then  a[w] = 0
 	return, a
end
Loading