1010
1111from utils import block_diag
1212
13+ class NoHessianMethod (Exception ):
14+ """An exception triggered when the forward model isn't able to provide an
15+ estimation of the Hessian"""
16+ def __init__ (self , message ):
17+ self .message = message
1318
1419def band_selecta (band ):
1520 if band == 0 :
@@ -33,6 +38,10 @@ def hessian_correction(gp, x0, R_mat, innovation, mask, state_mask, band,
3338 nparams ):
3439 """Calculates higher order Hessian correction for the likelihood term.
3540 Needs the GP, the Observational uncertainty, the mask...."""
41+ if not hasattr (gp , "hessian" ):
42+ # The observation operator does not provide a Hessian method. We just
43+ # return 0, meaning no Hessian correction.
44+ return 0.
3645 C_obs_inv = R_mat .diagonal ()[state_mask .flatten ()]
3746 mask = mask [state_mask ].flatten ()
3847 little_hess = []
@@ -59,12 +68,13 @@ def tip_prior():
5968 Returns
6069 -------
6170 The mean prior vector, covariance and inverse covariance matrices."""
62- sigma = np .array ([0.12 , 0.7 , 0.0959 , 0.15 , 1.5 , 0.2 , 0.5 ]) # broadly TLAI 0->7 for 1sigma
71+ # broadly TLAI 0->7 for 1sigma
72+ sigma = np .array ([0.12 , 0.7 , 0.0959 , 0.15 , 1.5 , 0.2 , 0.5 ])
6373 x0 = np .array ([0.17 , 1.0 , 0.1 , 0.7 , 2.0 , 0.18 , np .exp (- 0.5 * 1.5 )])
6474 # The individual covariance matrix
65- little_p = np .diag ( sigma ** 2 ).astype (np .float32 )
66- little_p [5 ,2 ] = 0.8862 * 0.0959 * 0.2
67- little_p [2 ,5 ] = 0.8862 * 0.0959 * 0.2
75+ little_p = np .diag ( sigma ** 2 ).astype (np .float32 )
76+ little_p [5 , 2 ] = 0.8862 * 0.0959 * 0.2
77+ little_p [2 , 5 ] = 0.8862 * 0.0959 * 0.2
6878
6979 inv_p = np .linalg .inv (little_p )
7080 return x0 , little_p , inv_p
0 commit comments