Repository: yt-project/yt

Issue:
BUG: noisy warnings when setting a custom colorbar norm for fields with take_log=False 
### Bug report

**Bug summary**

The logger filters out immediate repetitions, but when 2 different warnings are hit in a loop, it can quickly get pretty noisy.
The class reponsible for handling colorbar norms (`NormHandler`) emits warnings when it receives a new constraint that forces dropping of previously set ones (this is by design and still desired). Now, this warning *assumes* all previous constraint were either set by the user or inherited from a previous rendering of the plot, but there's one place where this rule is violated and we set norm constraint internally ahead of rendering:

https://github.com/yt-project/yt/blob/cfdf7edaf4a85c8856a185f7778d7c4ce8191536/yt/visualization/plot_window.py#L258-L264

Within the right conditions, this combination of factors generates a lot of noisy and frankly useless warnings.

**Code for reproduction**

```python
import yt
from yt.testing import fake_amr_ds
from matplotlib.colors import SymLogNorm

yt.set_log_level("warning")
def fake_field(field, data):
    return data["Density"]

field = ("gas", "fake_density")
for _ in range(5):
    ds = fake_amr_ds()
    ds.add_field(
        field,
        function=fake_field,
        sampling_type="cell",
        take_log=False,
    )
    p = yt.SlicePlot(ds, "z", field)
    p.set_norm(field, SymLogNorm(linthresh=1, base=2))
    p.save("/tmp/")
```

**Actual outcome**


```
yt : [WARNING  ] 2023-06-12 17:38:17,408 Field ('gas', 'fake_density') was added without specifying units or dimensions, auto setting units to 'g/cm**3'
yt : [WARNING  ] 2023-06-12 17:38:17,927 Dropping norm constraints (norm_type=<class 'matplotlib.colors.Normalize'>)
yt : [WARNING  ] 2023-06-12 17:38:18,698 Field ('gas', 'fake_density') was added without specifying units or dimensions, auto setting units to 'g/cm**3'
yt : [WARNING  ] 2023-06-12 17:38:18,871 Dropping norm constraints (norm_type=<class 'matplotlib.colors.Normalize'>)
yt : [WARNING  ] 2023-06-12 17:38:19,472 Field ('gas', 'fake_density') was added without specifying units or dimensions, auto setting units to 'g/cm**3'
yt : [WARNING  ] 2023-06-12 17:38:19,707 Dropping norm constraints (norm_type=<class 'matplotlib.colors.Normalize'>)
yt : [WARNING  ] 2023-06-12 17:38:20,313 Field ('gas', 'fake_density') was added without specifying units or dimensions, auto setting units to 'g/cm**3'
yt : [WARNING  ] 2023-06-12 17:38:20,482 Dropping norm constraints (norm_type=<class 'matplotlib.colors.Normalize'>)
yt : [WARNING  ] 2023-06-12 17:38:21,079 Field ('gas', 'fake_density') was added without specifying units or dimensions, auto setting units to 'g/cm**3'
yt : [WARNING  ] 2023-06-12 17:38:21,308 Dropping norm constraints (norm_type=<class 'matplotlib.colors.Normalize'>)
```

**Expected outcome**

The log should be limited to the first warning
```
yt : [WARNING  ] 2023-06-12 17:38:17,408 Field ('gas', 'fake_density') was added without specifying units or dimensions, auto setting units to 'g/cm**3'
```

**Version Information**
  * Operating System: macOS
  * Python Version: 3.11.4
  * yt version: 4.2.0
  * Other Libraries (if applicable): 



Discussion:

Resolving patch:
diff --git a/yt/visualization/_handlers.py b/yt/visualization/_handlers.py
--- a/yt/visualization/_handlers.py
+++ b/yt/visualization/_handlers.py
@@ -39,6 +39,7 @@ class NormHandler:
         "_linthresh",
         "_norm_type",
         "_norm",
+        "prefer_log",
     )
     _constraint_attrs: List[str] = [
         "vmin",
@@ -70,6 +71,7 @@ def __init__(
         self._dynamic_range = dynamic_range
         self._norm_type = norm_type
         self._linthresh = linthresh
+        self.prefer_log = True
 
         if self.has_norm and self.has_constraints:
             raise TypeError(
@@ -319,7 +321,11 @@ def get_norm(self, data: np.ndarray, *args, **kw) -> Normalize:
             # allowing to toggle between lin and log scaling without detailed user input
             norm_type = self.norm_type
         else:
-            if kw["vmin"] == kw["vmax"] or not np.any(finite_values_mask):
+            if (
+                not self.prefer_log
+                or kw["vmin"] == kw["vmax"]
+                or not np.any(finite_values_mask)
+            ):
                 norm_type = Normalize
             elif kw["vmin"] <= 0:
                 # note: see issue 3944 (and PRs and issues linked therein) for a
diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -5,7 +5,6 @@
 
 import matplotlib
 import numpy as np
-from matplotlib.colors import Normalize
 from more_itertools import always_iterable
 from unyt.exceptions import UnitConversionError
 
@@ -255,13 +254,9 @@ def __init__(
         for field in self.data_source._determine_fields(self.fields):
             finfo = self.data_source.ds._get_field_info(field)
             pnh = self.plots[field].norm_handler
-            if finfo.take_log is False:
-                # take_log can be `None` so we explicitly compare against a boolean
-                pnh.norm_type = Normalize
-            else:
-                # do nothing, the norm handler is responsible for
-                # determining a viable norm, and defaults to LogNorm/SymLogNorm
-                pass
+
+            # take_log can be `None` so we explicitly compare against a boolean
+            pnh.prefer_log = finfo.take_log is not False
 
             # override from user configuration if any
             log, linthresh = get_default_from_config(


Test patch: