diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py
index 60876ea0c3b80be464f1d3e6c3ae559c722c5d3b..f70db74f9d11cf4c88ee34487aa13aa9b002759b 100644
--- a/binarycpython/utils/functions.py
+++ b/binarycpython/utils/functions.py
@@ -2268,3 +2268,35 @@ def load_ensemble(filename):
     else:
         jfile = open(filename)
     return json.load(jfile)
+
+def ensemble_setting(ensemble,parameter_name):
+    """
+    Function to get the setting of parameter_name in the given ensemble, or return the default value.
+    """
+    value = None
+
+    try:
+        value = ensemble['metadata']['settings']['population_settings']['bse_options'][parameter_name]
+    except KeyError:
+        value = None
+
+    if value is None:
+        try:
+            value = ensemble['metadata']['settings']['population_settings']['grid_options'][parameter_name]
+        except KeyError:
+            value = None
+
+    if value is None:
+        try:
+            value = ensemble['metadata']['settings']['population_settings']['custom_options'][parameter_name]
+        except KeyError:
+            value = None
+
+    # not found, try the default
+    if value is None:
+        try:
+            value = ensemble['metadata']['settings']['binary_c_defaults'][parameter_name]
+        except KeyError:
+            value = None
+
+    return value