Package pylal :: Module antenna
[hide private]
[frames] | no frames]

Source Code for Module pylal.antenna

  1  # Copyright (C) 2007   Alexander Dietz 
  2  # 
  3  # This program is free software; you can redistribute it and/or modify it 
  4  # under the terms of the GNU General Public License as published by the 
  5  # Free Software Foundation; either version 2 of the License, or (at your 
  6  # option) any later version. 
  7  # 
  8  # This program is distributed in the hope that it will be useful, but 
  9  # WITHOUT ANY WARRANTY; without even the implied warranty of 
 10  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
 11  # Public License for more details. 
 12  # 
 13  # You should have received a copy of the GNU General Public License along 
 14  # with this program; if not, write to the Free Software Foundation, Inc., 
 15  # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
 16   
 17   
 18  # 
 19  # ============================================================================= 
 20  # 
 21  #                                   Preamble 
 22  # 
 23  # ============================================================================= 
 24  # 
 25   
 26   
 27  """ 
 28  This module provides functions to calculate antenna factors for a given time, a given sky location and a given detector 
 29  """ 
 30  import sys 
 31  from math import * 
 32  import lal 
 33  from pylal import inject 
 34   
 35   
 36  __author__ = "Alexander Dietz <Alexander.Dietz@astro.cf.ac.uk>" 
 37   
38 -def response( gpsTime, rightAscension, declination, inclination, 39 polarization, unit, det ):
40 41 """ 42 response( gpsTime, rightAscension, declination, inclination, 43 polarization, unit, detector ) 44 45 Calculates the antenna factors for a detector 'detector' (e.g. 'H1') 46 at a given gps time (as integer) for a given sky location 47 (rightAscension, declination) in some unit (degree/radians). 48 This computation also takes into account a specific inclination 49 and polarization. 50 51 The returned values are: (f-plus, f-cross, f-average, q-value). 52 53 Example: antenna.response( 854378604.780, 11.089, 42.308, 0, 0, 'radians', 'H1' ) 54 """ 55 56 # check the input arguments 57 if unit =='radians': 58 ra_rad = rightAscension 59 de_rad = declination 60 psi_rad = polarization 61 iota_rad = inclination 62 elif unit =='degree': 63 ra_rad = rightAscension/180.0*pi 64 de_rad = declination/180.0*pi 65 psi_rad = polarization/180.0*pi 66 iota_rad = inclination/180.0*pi 67 else: 68 raise ValueError, "Unknown unit %s" % unit 69 70 # calculate GMST if the GPS time 71 gps = lal.LIGOTimeGPS( gpsTime ) 72 gmst_rad = lal.GreenwichMeanSiderealTime(gps) 73 74 # create detector-name map 75 detMap = {'H1': 'LHO_4k', 'H2': 'LHO_2k', 'L1': 'LLO_4k', 76 'G1': 'GEO_600', 'V1': 'VIRGO', 'T1': 'TAMA_300'} 77 try: 78 detector=detMap[det] 79 except KeyError: 80 raise ValueError, "ERROR. Key %s is not a valid detector name."\ 81 % (det) 82 83 # get detector 84 if detector not in inject.cached_detector.keys(): 85 raise ValueError, "%s is not a cached detector. "\ 86 "Cached detectors are: %s" \ 87 % (det, inject.cached_detector.keys()) 88 89 # get the correct response data 90 response = inject.cached_detector[detector].response 91 92 # actual computation of antenna factors 93 f_plus, f_cross = lal.ComputeDetAMResponse(response, ra_rad, de_rad, 94 psi_rad, gmst_rad) 95 96 f_ave=sqrt( (f_plus*f_plus + f_cross*f_cross)/2.0 ); 97 ci=cos( iota_rad ); 98 cc=ci*ci; 99 100 # calculate q-value, e.g. ratio of effective to real distance 101 # ref: Duncans PhD, eq. (4.3) on page 57 102 f_q=sqrt( f_plus*f_plus*(1+cc)*(1+cc)/4.0 + f_cross*f_cross*cc ); 103 104 # output 105 return f_plus, f_cross, f_ave, f_q
106 107 108
109 -def timeDelay( gpsTime, rightAscension, declination, unit, det1, det2 ):
110 """ 111 timeDelay( gpsTime, rightAscension, declination, unit, det1, det2 ) 112 113 Calculates the time delay in seconds between the detectors 114 'det1' and 'det2' (e.g. 'H1') for a sky location at (rightAscension 115 and declination) which must be given in certain units 116 ('radians' or 'degree'). The time is passes as GPS time. 117 A positive time delay means the GW arrives first at 'det2', then at 'det1'. 118 119 Example: 120 antenna.timeDelay( 877320548.000, 355.084,31.757, 'degree','H1','L1') 121 0.0011604683260994519 122 123 Given these values, the signal arrives first at detector L1, 124 and 1.16 ms later at H2 125 """ 126 127 # check the input arguments 128 if unit =='radians': 129 ra_rad = rightAscension 130 de_rad = declination 131 elif unit =='degree': 132 ra_rad = rightAscension/180.0*pi 133 de_rad = declination/180.0*pi 134 else: 135 raise ValueError, "Unknown unit %s" % unit 136 137 # check input values 138 if ra_rad<0.0 or ra_rad> 2*pi: 139 raise ValueError, "ERROR. right ascension=%f "\ 140 "not within reasonable range."\ 141 % (rightAscension) 142 143 if de_rad<-pi or de_rad> pi: 144 raise ValueError, "ERROR. declination=%f not within reasonable range."\ 145 % (declination) 146 147 if det1 == det2: 148 return 0.0 149 150 gps = lal.LIGOTimeGPS( gpsTime ) 151 152 # create detector-name map 153 detMap = {'H1': 'LHO_4k', 'H2': 'LHO_2k', 'L1': 'LLO_4k', 154 'G1': 'GEO_600', 'V1': 'VIRGO', 'T1': 'TAMA_300'} 155 156 x1 = inject.cached_detector[detMap[det1]].location 157 x2 = inject.cached_detector[detMap[det2]].location 158 timedelay = lal.ArrivalTimeDiff(list(x1), list(x2), ra_rad, de_rad, gps) 159 160 return timedelay
161