Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#577 closed task (fixed)

Do a proper average of SNRs (via I and Q) [1 d]

Reported by: Ian Culverwell Owned by: Ian Culverwell
Priority: normal Milestone: ROPP9.1 carry over
Component: ropp_io Version: 9.0
Keywords: Cc:

Description

Change history (6)

comment:1 by Ian Culverwell, 5 years ago

This change is described at r5344. There are two aspects to this that I don't like/understand.

  • i_ca_avr is allocated a size of n_olrs. But as far as I can see, if n_rs is >/~ 20*n_olrs then the loop that defines i_ca_avr could take it out of bounds, couldn't it?
  • There's a check on dtime(j+1)-dtime(j) > 0.00105_wp. Might it be safer to check the ABS value of this, as in other parts of SUBROUTINE ropp_io_read_eumdata?

Ask Stig for advice.

comment:2 by Ian Culverwell, 5 years ago

It turns out that #584 includes a line

              IF (j1==n_olrs) EXIT 

in the loop over j1, which addresses the first concern. Second concern remains.

comment:3 by Ian Culverwell, 5 years ago

Commit change at r5945. Note that I had to change

          IF (sampling_mode .EQ. '/open_loop/') THEN

to

          IF (sampling_mode .EQ. 'open_loop') THEN

since the official code doesn't use /s for these variables. (It also contains an info message if the data are missing, which the dmi_trunk code has somehow omitted.)

comment:4 by Ian Culverwell, 5 years ago

Resolution: fixed
Status: newclosed

Checks out OK in tests - because, as before, there's no rs data in the test file. Take this one on trust. Close ticket.

comment:5 by Ian Culverwell, 5 years ago

(Forget the issue of the sign of dtime(j+1) - dtime(j).)

comment:6 by Ian Culverwell, 5 years ago

(I'm not sure, incidentally, that we need

            angle_iq=ATAN2(q_ca(j),i_ca(j)+TINY(1.0_wp))
            i_ca_sum=i_ca_sum+snr_ca(j)*COS(angle_iq)
            q_ca_sum=q_ca_sum+snr_ca(j)*SIN(angle_iq)

. I think COS(ATAN2(y, x+TINY(1.0_wp))) = x/SQRT(x**2+y**2), and sim for SIN. See

real(KIND(1.d0)) :: theta, theta1, x, x1, y, y1
integer :: i

do i=-4,4

  theta = i * atan(1.d0) ! -pi to pi in steps of pi/4 

  x = COS(theta)
  y = SIN(theta)

  theta1 = atan2(y, x+tiny(1.d0))

  x1 = COS(theta1)
  y1 = SIN(theta1)
  
  write(*,'(a, i2, 6es20.10)') 'i, theta, theta1, x, x1, y, y1 = ', i, theta, theta1, x, x1, y, y1

enddo

which produces

i, theta, theta1, x, x1, y, y1 = -4   -3.1415926536E+00   -3.1415926536E+00   -1.0000000000E+00   -1.0000000000E+00   -1.2246467991E-16   -1.2246467991E-16
i, theta, theta1, x, x1, y, y1 = -3   -2.3561944902E+00   -2.3561944902E+00   -7.0710678119E-01   -7.0710678119E-01   -7.0710678119E-01   -7.0710678119E-01
i, theta, theta1, x, x1, y, y1 = -2   -1.5707963268E+00   -1.5707963268E+00    6.1232339957E-17    6.1232339957E-17   -1.0000000000E+00   -1.0000000000E+00
i, theta, theta1, x, x1, y, y1 = -1   -7.8539816340E-01   -7.8539816340E-01    7.0710678119E-01    7.0710678119E-01   -7.0710678119E-01   -7.0710678119E-01
i, theta, theta1, x, x1, y, y1 =  0    0.0000000000E+00    0.0000000000E+00    1.0000000000E+00    1.0000000000E+00    0.0000000000E+00    0.0000000000E+00
i, theta, theta1, x, x1, y, y1 =  1    7.8539816340E-01    7.8539816340E-01    7.0710678119E-01    7.0710678119E-01    7.0710678119E-01    7.0710678119E-01
i, theta, theta1, x, x1, y, y1 =  2    1.5707963268E+00    1.5707963268E+00    6.1232339957E-17    6.1232339957E-17    1.0000000000E+00    1.0000000000E+00
i, theta, theta1, x, x1, y, y1 =  3    2.3561944902E+00    2.3561944902E+00   -7.0710678119E-01   -7.0710678119E-01    7.0710678119E-01    7.0710678119E-01
i, theta, theta1, x, x1, y, y1 =  4    3.1415926536E+00    3.1415926536E+00   -1.0000000000E+00   -1.0000000000E+00    1.2246467991E-16    1.2246467991E-16

In all cases, x=x1 and y=y1. The SQRT formulation might be a bit quicker. Leave it for now - this code is only a stopgap.)

Note: See TracTickets for help on using tickets.