;+
; NAME:
;	LOCAL_COORD
;
;
; PURPOSE:
;	Convert a "local" NDC coordinate to a global one
;
;
; CATEGORY:
;	Utils
;
;
; CALLING SEQUENCE:
;	gc = local_coord(lc, origin, size)
;
;
; INPUTS:
;	lc	float	The "local" NDC position
;	origin	float	The origin of the local coordinates in cm.
;	size	float	The size of the local system in cm.
;
;
; KEYWORD PARAMETERS:
;	/x	If set then this is an X coordinate (default)
;	/y	If set, then this is a Y coordinate.
;
;
; OUTPUTS:
;	gc	Float	The real NDC position
;
;
; RESTRICTIONS:
;	Only works if the current device is PS
;
;
; MODIFICATION HISTORY:
;	Original: 16/5/03; SJT
;-

function local_coord, lc, origin, size, x = x, y = y

if !d.name ne 'PS' then return, 0.0

lsys = [origin, origin+size]
if keyword_set(y) then $
  lsys = lsys*float(!d.y_px_cm)/float(!d.y_size) $
else lsys = lsys*float(!d.x_px_cm)/float(!d.x_size)

return, total([1.-lc, lc]*lsys)

end
