﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
502	Update ropp_1dvar_add_refrac_error to handle missing data better	Ian Culverwell	Johannes K. Nielsen	"Joe Nielsen (DMI) found some problems with '''ropp_1dvar_add_refrac_error''' when using missing data:
{{{
My impression is that the obs%weights variable is supposed to handle 
this, but if the missing values are passed to 
ropp_1dvar_add_refrac_error it produces a 247x247 correlation file 
which is not positive definite.  
}}}
(He's referring to the reduction of levels to accommodate missing data, as is/was done in 1DV.)

By using the following patch, he managed to get consistent output between ropp_1dvar and DMI 1DV:
{{{
===================================================================
--- ropp_1dvar/errors/ropp_1dvar_add_refrac_error.f90   (revision 5460)
+++ ropp_1dvar/errors/ropp_1dvar_add_refrac_error.f90   (working copy)
@@ -82,6 +82,7 @@

  ! For TP formula
    REAL(wp), DIMENSION(:), ALLOCATABLE   :: grad_T
+  LOGICAL,  DIMENSION(:), ALLOCATABLE   :: weight
    REAL(wp)                              :: trop

+ ALLOCATE(weight(ro_data%Lev2a%Npoints))

+
+          WHERE( (ro_data%lev2a%refrac      < ropp_MDTV) .OR. &
+               (ro_data%lev2a%geop_refrac < ropp_MDTV) )
+             ro_data%Lev2a%refrac_sigma = ropp_MDFV
+             weight=.FALSE.
+          ELSEWHERE
+             weight=.TRUE.
+          END WHERE
+
+

+
         DO j=1,ro_data%Lev2a%Npoints
           DO k=1, ro_data%Lev2a%Npoints
-           Ocorr(j,k) = EXP(-ABS(RO_data%Lev2a%geop_refrac(j) -    &
-              RO_data%Lev2a%geop_refrac(k))/3000.0_wp)
+
+            IF ((weight(j).AND.weight(k)).OR.(j.EQ.k)) THEN
+               Ocorr(j,k) = &
+                    EXP(-ABS(RO_data%Lev2a%geop_refrac(j) - &
+                    RO_data%Lev2a%geop_refrac(k))/3000.0_wp)
+            ELSE
+               Ocorr(j,k)= 0.0_wp
+            ENDIF
           ENDDO
         ENDDO

===================================================================
--- ropp_fm/refrac_1d/ropp_fm_refrac_1d_grad.f90        (revision 5460)
+++ ropp_fm/refrac_1d/ropp_fm_refrac_1d_grad.f90        (working copy)

-     K(:,i) = grad
+     K(:,i) = grad*y%weights
}}}

We should consider this for inclusion in ROPP, but not urgently.
"	enhancement	closed	normal	DMI ROPP developments	ropp_1dvar	9.0	fixed	add errors, missing data	
