Skip to content
Snippets Groups Projects
Commit 7e11286d authored by Bruce Allen's avatar Bruce Allen
Browse files

Split this into library and main with header file as interface

parent b6c993f6
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,36 @@ ...@@ -11,6 +11,36 @@
#include <stdlib.h> #include <stdlib.h>
#include <strings.h> #include <strings.h>
// Structure for passing information about the GW source and detectors
struct InputStruct {
// orbital orientation in degrees, 0 to 180. Zero degrees has
// orbital angular momentum pointing to the earth
double iota;
// orientation of long axis of ellipse, 0 to 360, in degrees CCW
// from North
double psi;
// orientation of detector arms away from actual, 0 to 360, in
// degrees CCW when viewed from directly overhead
// Ordering is LLO, LHO, VIRGO
double orientation[3];
};
// Structure for returning information about the response. The array
// elements are in the order LLO, LHO, VIRGO
struct OutputStruct {
// amplitude of sin function, dimensionless
double amp[3];
// phase of sin function, in degrees from 0 to 360
double phase[3];
// time delays, in milliseconds
double dt[3];
};
// Global variables for passing information. Ugly style but doesn't
// matter for this!
struct InputStruct inputdata;
// For converting degrees to radians // For converting degrees to radians
const double deg_to_rad = M_PI/180.0; const double deg_to_rad = M_PI/180.0;
...@@ -184,21 +214,21 @@ void populate_detectors(){ ...@@ -184,21 +214,21 @@ void populate_detectors(){
strcpy(detectors[0].name, " LLO "); strcpy(detectors[0].name, " LLO ");
detectors[0].location[0] = 30.56*deg_to_rad; detectors[0].location[0] = 30.56*deg_to_rad;
detectors[0].location[1] = -90.77*deg_to_rad; detectors[0].location[1] = -90.77*deg_to_rad;
detectors[0].orientation = 198.0*deg_to_rad; detectors[0].orientation = (198.0+inputdata.orientation[0])*deg_to_rad;
// LHO // LHO
// Sanity checked using Google Earth! // Sanity checked using Google Earth!
strcpy(detectors[1].name, " LHO "); strcpy(detectors[1].name, " LHO ");
detectors[1].location[0] = 46.45*deg_to_rad; detectors[1].location[0] = 46.45*deg_to_rad;
detectors[1].location[1] = -119.41*deg_to_rad; detectors[1].location[1] = -119.41*deg_to_rad;
detectors[1].orientation = 126.8*deg_to_rad; detectors[1].orientation = (126.8+inputdata.orientation[1])*deg_to_rad;
// VIRGO // VIRGO
// Sanity checked using Google Earth! // Sanity checked using Google Earth!
strcpy(detectors[2].name, "VIRGO"); strcpy(detectors[2].name, "VIRGO");
detectors[2].location[0] = 43.63*deg_to_rad; detectors[2].location[0] = 43.63*deg_to_rad;
detectors[2].location[1] = 10.5*deg_to_rad; detectors[2].location[1] = 10.5*deg_to_rad;
detectors[2].orientation = 71.5*deg_to_rad; detectors[2].orientation = (71.5+inputdata.orientation[2])*deg_to_rad;
int i; int i;
...@@ -282,34 +312,23 @@ void get_UV_combinations(int det, double *alpha, double *beta, double *rdotn) { ...@@ -282,34 +312,23 @@ void get_UV_combinations(int det, double *alpha, double *beta, double *rdotn) {
*rdotn = dot; *rdotn = dot;
} }
// This function requires two floating point arguments on the command
// line, iota and psi, angles in degrees.
int main(int argc, char *argv[]) { // library function that can be called either from the GUI code or
// to loop over detectors // from a stand-alone terminal program. This function does not modify
// the input struct, but does populate/modify the output strut!
void get_antenna(struct OutputStruct *out, struct InputStruct *in) {
int i; int i;
// set up the source and detectors
// check syntax crudely, issue usage message inputdata=*in;
if (argc != 3) {
fprintf(stderr,
"Wrong argument count! Correct usage:\n"
"%s float_iota_in_degrees float_psi_in_degrees\n",
argv[0]);
exit(1);
}
// setup and test
// print_galaxy_coordinates();
populate_source(); populate_source();
// print_source();
populate_detectors(); populate_detectors();
// for (i=0; i<3; i++) print_detector(i);
// get inclination angle, polarization axis
double iota = atof(argv[1]); double iota = inputdata.iota;
double psi = atof(argv[2]); double psi = inputdata.psi;
printf("Iota = %f degrees\nPsi = %f degrees\n", iota, psi); #ifdef DEBUG
fprintf(stderror, "Iota = %f degrees\nPsi = %f degrees\n", iota, psi);
#endif
iota *= deg_to_rad; iota *= deg_to_rad;
psi *= deg_to_rad; psi *= deg_to_rad;
...@@ -348,10 +367,56 @@ int main(int argc, char *argv[]) { ...@@ -348,10 +367,56 @@ int main(int argc, char *argv[]) {
double amp = sqrt(X*X + Y*Y); double amp = sqrt(X*X + Y*Y);
double ang = 180.0*atan2(Y, X)/M_PI; double ang = 180.0*atan2(Y, X)/M_PI;
// pass outputs
out->amp[i]= amp;
out->phase[i] = ang;
out->dt[i] = dt;
#ifdef DEBUG
// degree character in UTF-8 character set (most likely terminal type!) // degree character in UTF-8 character set (most likely terminal type!)
int deg1=0xC2, deg2=0xB0; int deg1=0xC2, deg2=0xB0;
fprintf(stderr, "For detector %s the waveform is %.3f w^2 sin(2w[t%+.1f ms]%+.1f%c%c)\n", detectors[i].name, amp, dt, ang, deg1, deg2);
#endif
}
return;
}
printf("For detector %s the waveform is %.3f w^2 sin(2w[t%+.1f ms]%+.1f%c%c)\n", detectors[i].name, amp, dt, ang, deg1, deg2);
// This function requires two floating point arguments on the command
// line, iota and psi, angles in degrees.
int main(int argc, char *argv[]) {
// to loop over detectors
int i;
// to pass data in and out
struct InputStruct myinput;
struct OutputStruct myoutput;
// check syntax crudely, issue usage message
if (argc != 3) {
fprintf(stderr,
"Wrong argument count! Correct usage:\n"
"%s float_iota_in_degrees float_psi_in_degrees\n",
argv[0]);
exit(1);
} }
// pass inclination angle, polarization axis, orientation offsets
myinput.iota = atof(argv[1]);
myinput.psi = atof(argv[2]);
for (i=0;i<3;i++) myinput.orientation[i]=0.0;
printf("Iota = %f degrees\nPsi = %f degrees\n", myinput.iota, myinput.psi);
// now compute responses
get_antenna(&myoutput, &myinput);
// degree character in UTF-8 character set (most likely terminal type!)
int deg1=0xC2, deg2=0xB0;
// Now display waveforms
for (i=0; i<3; i++)
printf("For detector %s the waveform is %.3f w^2 sin(2w[t%+.1f ms]%+.1f%c%c)\n", detectors[i].name, myoutput.amp[i], myoutput.dt[i], myoutput.phase[i], deg1, deg2);
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment