/source/getRayParameters.c

https://github.com/EyNuel/cTraceo · C · 80 lines · 22 code · 7 blank · 51 comment · 2 complexity · 05da06ca2279e16a96947f3b30400041 MD5 · raw file

  1. /****************************************************************************************
  2. * getRayParameters.c *
  3. * (formerly "grayp.for") *
  4. * interpolates ray parameters *
  5. * *
  6. * ------------------------------------------------------------------------------------ *
  7. * Website: *
  8. * https://github.com/EyNuel/cTraceo/wiki *
  9. * *
  10. * License: This file is part of the cTraceo Raytracing Model and is released under the *
  11. * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License *
  12. * http://creativecommons.org/licenses/by-nc-sa/3.0/ *
  13. * *
  14. * NOTE: cTraceo is research code under active development. *
  15. * The code may contain bugs and updates are possible in the future. *
  16. * *
  17. * Written for project SENSOCEAN by: *
  18. * Emanuel Ey *
  19. * emanuel.ey@gmail.com *
  20. * Copyright (C) 2011 - 2013 *
  21. * Signal Processing Laboratory *
  22. * Universidade do Algarve *
  23. * *
  24. * cTraceo is the C port of the FORTRAN 77 TRACEO code written by: *
  25. * Orlando Camargo Rodriguez: *
  26. * Copyright (C) 2010 *
  27. * Orlando Camargo Rodriguez *
  28. * orodrig@ualg.pt *
  29. * Universidade do Algarve *
  30. * Physics Department *
  31. * Signal Processing Laboratory *
  32. * *
  33. * ------------------------------------------------------------------------------------ *
  34. * Inputs: *
  35. * ray: Pointer to structure containing a ray. *
  36. * iHyd: Index at which to interpolate. *
  37. * q0: TODO *
  38. * rHyd: Range of hydrophone. *
  39. * *
  40. * Outputs: *
  41. * dzdr: Derivative of z in order to r (i.e. its Slope). *
  42. * tauRay: The ray's propagation delay at hydrophone. *
  43. * zRay: The ray's depth. *
  44. * ampRay: The ray's complex Amplitude. *
  45. * qRay: TODO *
  46. * width: Width of the beam. *
  47. * *
  48. * Return Value: *
  49. * None *
  50. * *
  51. ****************************************************************************************/
  52. #pragma once
  53. #include "globals.h"
  54. #include "interpolation.h"
  55. #include <complex.h>
  56. #include "tools.h"
  57. void getRayParameters(ray_t*, uintptr_t, double, double, double*, double*, double*, double complex*, double*, double*);
  58. void getRayParameters(ray_t* ray, uintptr_t iHyd, double q0, double rHyd, double* dzdr, double* tauRay, double* zRay, double complex* ampRay, double* qRay, double* width){
  59. complex double junkComplex;
  60. double junkDouble;
  61. double theta;
  62. if( ray->iRefl[iHyd+1] == true){
  63. iHyd = iHyd - 1;
  64. }
  65. intLinear1D( &ray->r[iHyd], &ray->z[iHyd], rHyd, zRay, dzdr);
  66. intLinear1D( &ray->r[iHyd], &ray->tau[iHyd], rHyd, tauRay, &junkDouble);
  67. DEBUG(7, "iHyd = %u: ampRay = %e + j*%e\n", (uint32_t)iHyd, creal(ray->amp[iHyd]), cimag(ray->amp[iHyd]));
  68. intComplexLinear1D( &ray->r[iHyd], &ray->amp[iHyd], rHyd, ampRay, &junkComplex);
  69. intLinear1D( &ray->r[iHyd], &ray->q[iHyd], rHyd, qRay, &junkDouble);
  70. theta = atan( *dzdr );
  71. *width = max( fabs( ray->q[iHyd] ), fabs( ray->q[iHyd+1]) );
  72. *width = *width / ((q0) * cos(theta));
  73. }