1515from __future__ import annotations
1616
1717from abc import ABC
18+ from logging import getLogger
1819from typing import TYPE_CHECKING
1920
2021import numpy as np
2930if TYPE_CHECKING :
3031 from simpeg_drivers .driver import InversionDriver
3132
33+ logger = getLogger (__name__ )
34+
3235
3336class DirectivesFactory :
3437 def __init__ (self , driver : InversionDriver ):
@@ -263,7 +266,15 @@ def scale_misfits(self):
263266 def update_irls_directive (self ):
264267 """Directive to update IRLS."""
265268 if self ._update_irls_directive is None :
266- has_chi_start = self .params .starting_chi_factor is not None
269+ start_chi_fact = self .params .starting_chi_factor
270+
271+ if start_chi_fact is not None and self .params .chi_factor > start_chi_fact :
272+ logger .warning (
273+ "Starting chi factor is greater than target chi factor.\n "
274+ "Setting the target chi factor to the starting chi factor."
275+ )
276+ start_chi_fact = self .params .chi_factor
277+
267278 self ._update_irls_directive = directives .UpdateIRLS (
268279 f_min_change = self .params .f_min_change ,
269280 max_irls_iterations = self .params .max_irls_iterations ,
@@ -272,11 +283,7 @@ def update_irls_directive(self):
272283 cooling_rate = self .params .cooling_rate ,
273284 cooling_factor = self .params .cooling_factor ,
274285 irls_cooling_factor = self .params .epsilon_cooling_factor ,
275- chifact_start = (
276- self .params .starting_chi_factor
277- if has_chi_start
278- else self .params .chi_factor
279- ),
286+ chifact_start = start_chi_fact or self .params .chi_factor ,
280287 chifact_target = self .params .chi_factor ,
281288 )
282289 return self ._update_irls_directive
0 commit comments