From 93f5896ee79f189273313bd8589de9440408ee35 Mon Sep 17 00:00:00 2001
From: Charlotte Bond <czb@star.sr.bham.ac.uk>
Date: Tue, 29 Apr 2014 15:32:18 +0100
Subject: [PATCH] function compatible with other uses

---
 src/new/IFOs/FT_GW_sidebands.m | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/new/IFOs/FT_GW_sidebands.m b/src/new/IFOs/FT_GW_sidebands.m
index 9085e28..0ad61b1 100644
--- a/src/new/IFOs/FT_GW_sidebands.m
+++ b/src/new/IFOs/FT_GW_sidebands.m
@@ -1,5 +1,5 @@
 %--------------------------------------------------------------------------
-% function [Abs] = FT_GW_sidebands(lambda,h0,fsig,L,n)
+% function [Abs] = FT_GW_sidebands(lambda,h0,fsig,L,n,sb_sign)
 %
 % A function for Matlab which calculates the amplitude of the sidebands
 % created when a light beam travels along a path modulated by a
@@ -10,6 +10,9 @@
 % fsig:     Frequency of the gravitational wave [Hz]
 % L:        Length of the path [m]
 % n:        Index refection of the medium through which the beam travels
+% sb_sign:  Sign of the sideband
+%           1:  upper sideband
+%           -1: lower sideband
 %
 % Asb:      Amplitude of the sidebands [sqrt(W)]
 %
@@ -18,8 +21,17 @@
 %--------------------------------------------------------------------------
 %
 
-function [Asb] = FT_GW_sidebands(lambda,h0,fsig,L,n)
+function [Asb] = FT_GW_sidebands(lambda,h0,fsig,L,n,sb_sign)
     
+    baseid = 'GW_sidebands';
+    
+    % Error meesgaes
+    if sb_sign~=1 && sb_sign~=-1
+        result='Invalid sideband sign: must be -1 (lower) or +1 (upper)';
+        msgid=[baseid,':checkarguments']
+        error(msgid,result);
+    end
+
     % Carrier light parameters
     c = 299792458;
     f0 = c/lambda;
@@ -30,6 +42,12 @@ function [Asb] = FT_GW_sidebands(lambda,h0,fsig,L,n)
  
     % Sideband amplitude
     Asb = (w0*h0./(2*wsig)) .* sin(wsig*L*n/(2*c));
+    
+    % Phase
+    phi_sb = pi/2 - w0*L*n/c - sb_sign * wsig*L*n/(2*c);
+    
+    % Final sideband amplitude and phase
+    Asb = Asb.*exp(1i*phi_sb);
 
 end
 
-- 
GitLab