gwsurrogate icon indicating copy to clipboard operation
gwsurrogate copied to clipboard

handle missing modes more gently (from Bitbucket)

Open sfield17 opened this issue 5 years ago • 1 comments

This is from Richard:

  • Right now, EvaluateSurrogate accepts 'ell_m', a list of modes to load
  • Until I look at the surrogate file itself, I don't know what modes are available (e.g., single mode vs multi mode)
  • If I pass an 'ell_m' list that includes modes that aren't available in the surrogate (e.g., all modes below some lmax; modes with m<0, for a reflection-symmetric model), the code fails to find them in the .h5 file, and fails.

Would it be possible to modify 'CreateManyEvaluateSingleModeSurrogate' (old interface) to either handle requested but missing modes more gently, by taking the intersection of the modes that are requested and the modes that are available? In about line 780 in surrogate.py?

Specifically, the following

   ### compile list of available modes ###
  modes_available =[]
  for kk in fp.keys():
      splitkk = kk.split('_')
      if splitkk[0][0] == 'l' and splitkk[1][0] == 'm':
        ell = int(splitkk[0][1])
        emm = int(splitkk[1][1:])
        if not (ell, emm) in exc_modes:
          modes_available.append((ell,emm))
  if ell_m is None:
    mode_keys = modes_available
  else:
    mode_keys = []
    for i, mode in enumerate(ell_m):
      if mode in exc_modes:
        print "WARNING: Mode (%d,%d) is both included and excluded! Excluding it."%mode 
      else:
        if mode in modes_available:
          mode_keys.append(mode)

sfield17 avatar Jun 28 '20 20:06 sfield17

Suggested fix:

  • try evaluating models with missing modes and see what happens. Is the message clear? If not change it.

sfield17 avatar Apr 06 '21 15:04 sfield17