Repository: ESSS/barril

Issue:
Review units to use traditional Petroleum Engineering format
### Description

In the unit database, there are several units with the following format:

- `1000ft3/d`, `1000m3/d`, etc.
- `M(ft3)/d`, `M(m3)/d`, etc.

But the conventional format used in the petroleum industry is:

- `Mcf/d`, `Mm3/d`, etc.
- `MMcf/d`, `MMm3/d`, etc.

where the prefix `M` is equivalent to multiplying by `1000`.

The idea of this task is to convert the legacy format to the conventional one. This should be as transparent as possible for `barril` users in the sense that they should not be affected when working with the legacy format.

Discussion:
prusse-martin: Do not forget to run black to fix the lint problems.
codecov[bot]: # [Codecov](https://codecov.io/gh/ESSS/barril/pull/30?src=pr&el=h1) Report
> Merging [#30](https://codecov.io/gh/ESSS/barril/pull/30?src=pr&el=desc) into [master](https://codecov.io/gh/ESSS/barril/commit/6d62e7c9b938d51261d4fb6c044b66544cec3e88?src=pr&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `96.59%`.


```diff
@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
+ Coverage    97.3%   97.32%   +0.01%     
==========================================
  Files          56       57       +1     
  Lines        9441     9500      +59     
==========================================
+ Hits         9187     9246      +59     
  Misses        254      254
```

nicoddemus: Great work!
prusse-martin: > 
> 
> What do you mean?

Return `None` was the old behavior?
Or is a new option?

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 309e284..875c151 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,6 +4,8 @@ UNRELEASED
 * ``_foundation`` has been renamed to ``_util``, and a lot of functions which were not being
   used anymore have been removed.
 * Add new unit category mass temperature per mol (``kg.K/mol``).
+* Some units have been renamed as they were deemed out-of-place in the oil industry to something more usual (for example, ``1000ft3/d`` became ``Mcf/d``).
+  The old representation of those units is still supported, but they will be automatically translated during ``Quantity`` creation, so this change should not affect users much.
 
 1.7.1 (2019-10-03)
 ------------------
diff --git a/src/barril/curve/curve.py b/src/barril/curve/curve.py
index 935acbb..1ce3dbd 100644
--- a/src/barril/curve/curve.py
+++ b/src/barril/curve/curve.py
@@ -80,7 +80,7 @@ class Curve:
         """
         :rtype: int
         :returns:
-            The lenght of the curve
+            The length of the curve
         """
         return len(self._image.GetValues())
 
diff --git a/src/barril/units/_quantity.py b/src/barril/units/_quantity.py
index 0c54020..c754ea0 100644
--- a/src/barril/units/_quantity.py
+++ b/src/barril/units/_quantity.py
@@ -4,11 +4,16 @@ This module provides the implementation of an Quantity object.
 
 from collections import OrderedDict
 from barril.units.exceptions import QuantityValidationError
-from barril.units.unit_database import UnitDatabase, UnitsError
+from barril.units.unit_database import (
+    InvalidUnitError,
+    UnitDatabase,
+    UnitsError,
+    FixUnitIfIsLegacy,
+)
 from oop_ext.interface._interface import ImplementsInterface
 
-from .interfaces import IQuantity, IQuantity2, IQuantity3, IQuantity6
 from ._unit_constants import UNKNOWN_UNIT
+from .interfaces import IQuantity, IQuantity2, IQuantity3, IQuantity6
 
 __all__ = ["Quantity"]
 
@@ -97,7 +102,11 @@ def ObtainQuantity(unit, category=None, unknown_unit_caption=None):
     elif category is None:
         category = unit_database.GetDefaultCategory(unit)
         if not category:
-            raise UnitsError(f"Unable to get default category for: {unit}")
+            is_legacy, unit = FixUnitIfIsLegacy(unit)
+            if is_legacy:
+                category = unit_database.GetDefaultCategory(unit)
+            else:
+                raise UnitsError(f"Unable to get default category for: {unit}")
 
         key_with_resolved_category = (category, unit, unknown_unit_caption)
         try:
@@ -393,7 +402,15 @@ class _Quantity(Quantity):
         else:
             if unit.__class__ != str:
                 raise TypeError("Only str is accepted. %s is not." % unit.__class__)
-            unit_database.CheckCategoryUnit(category, unit)
+
+            try:
+                unit_database.CheckCategoryUnit(category, unit)
+            except InvalidUnitError as e:
+                is_legacy, unit = FixUnitIfIsLegacy(unit)
+                if is_legacy:
+                    unit_database.CheckCategoryUnit(category, unit)
+                else:
+                    raise e
 
         # store it as odict so that we can have a decent order when creating a string from
         # an operation.
diff --git a/src/barril/units/_scalar.py b/src/barril/units/_scalar.py
index ce4387a..34bd1eb 100644
--- a/src/barril/units/_scalar.py
+++ b/src/barril/units/_scalar.py
@@ -8,8 +8,8 @@ from barril._util.types_ import IsNumber
 from oop_ext.interface._interface import ImplementsInterface
 
 from ._abstractvaluewithquantity import AbstractValueWithQuantityObject
-from .interfaces import IQuantity, IScalar
 from ._quantity import ObtainQuantity, Quantity
+from .interfaces import IQuantity, IScalar
 from .unit_database import UnitDatabase
 
 __all__ = ["Scalar"]
diff --git a/src/barril/units/posc.py b/src/barril/units/posc.py
index b7b3cb7..3edc069 100644
--- a/src/barril/units/posc.py
+++ b/src/barril/units/posc.py
@@ -686,7 +686,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume",
         "thousand cubic feet",
-        "1000ft3",
+        "Mcf",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -696,27 +696,17 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "dimensionless",
         "thousand cubic feet per barrel",
-        "1000ft3/bbl",
+        "Mcf/bbl",
         f_base_to_unit,
         f_unit_to_base,
         default_category="volume per volume",
     )
-    f_unit_to_base = MakeCustomaryToBase(0.0, 28.31685, 86400, 0.0)
-    f_base_to_unit = MakeBaseToCustomary(0.0, 28.31685, 86400, 0.0)
-    db.AddUnit(
-        "volume flow rate",
-        "thousand cubic feet per day",
-        "1000ft3/d",
-        f_base_to_unit,
-        f_unit_to_base,
-        default_category=None,
-    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 92.90304, 86400, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 92.90304, 86400, 0.0)
     db.AddUnit(
         "volume per time per length",
         "thousand cubic feet per day per foot",
-        "1000ft3/d.ft",
+        "Mcf/d.ft",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -726,7 +716,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "productivity index",
         "thousand cubic feet per day per psi",
-        "1000ft3/psi.d",
+        "Mcf/psi.d",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -736,7 +726,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume flow rate",
         "thousand cubic metres per day",
-        "1000m3/d",
+        "Mm3/d",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -746,7 +736,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume per time per length",
         "thousand cubic meter per day per meter",
-        "1000m3/d.m",
+        "Mm3/d.m",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -756,7 +746,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume flow rate",
         "thousand cubic metres per hour",
-        "1000m3/h",
+        "Mm3/h",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -766,7 +756,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume per time per length",
         "thousand cubic meters per hour per meter",
-        "1000m3/h.m",
+        "Mm3/h.m",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -996,6 +986,16 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "pressure", "bar", "bar", f_base_to_unit, f_unit_to_base, default_category=None
     )
+    f_unit_to_base = MakeCustomaryToBase(101325.0, 100000.0, 1.0, 0.0)
+    f_base_to_unit = MakeBaseToCustomary(101325.0, 100000.0, 1.0, 0.0)
+    db.AddUnit(
+        "pressure",
+        "bar gauge",
+        "bar(g)",
+        f_base_to_unit,
+        f_unit_to_base,
+        default_category=None,
+    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 100000, 3600, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 100000, 3600, 0.0)
     db.AddUnit(
@@ -1211,16 +1211,6 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         f_unit_to_base,
         default_category="volume per length",
     )
-    f_unit_to_base = MakeCustomaryToBase(0.0, 0.1589873, 28.31685, 0.0)
-    f_base_to_unit = MakeBaseToCustomary(0.0, 0.1589873, 28.31685, 0.0)
-    db.AddUnit(
-        "dimensionless",
-        "barrel per thousand cubic feet",
-        "bbl/k(ft3)",
-        f_base_to_unit,
-        f_unit_to_base,
-        default_category="volume per volume",
-    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 0.1589873, 86400000, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 0.1589873, 86400000, 0.0)
     db.AddUnit(
@@ -1236,7 +1226,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "dimensionless",
         "barrel per million cubic feet",
-        "bbl/M(ft3)",
+        "bbl/MMcf",
         f_base_to_unit,
         f_unit_to_base,
         default_category="volume per volume",
@@ -2341,7 +2331,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "time per volume",
         "day per thousand cubic feet",
-        "d/k(ft3)",
+        "d/Mcf",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -6941,7 +6931,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume",
         "million cubic feet",
-        "M(ft3)",
+        "MMcf",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -6951,7 +6941,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "dimensionless",
         "million cubic feet per acre-foot",
-        "M(ft3)/acre.ft",
+        "MMcf/acre.ft",
         f_base_to_unit,
         f_unit_to_base,
         default_category="volume per volume",
@@ -6961,7 +6951,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume flow rate",
         "million cubic feet per day",
-        "M(ft3)/d",
+        "MMcf/d",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -6971,7 +6961,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume",
         "million cubic meters",
-        "M(m3)",
+        "MMm3",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -6981,7 +6971,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume flow rate",
         "million cubic metres per day",
-        "M(m3)/d",
+        "MMm3/d",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -7601,16 +7591,6 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         f_unit_to_base,
         default_category=None,
     )
-    f_unit_to_base = MakeCustomaryToBase(0.0, 28.316846592, 1.0, 0.0)
-    f_base_to_unit = MakeBaseToCustomary(0.0, 28.316846592, 1.0, 0.0)
-    db.AddUnit(
-        "volume",
-        "thousand cubic feet",
-        "Mcf",
-        f_base_to_unit,
-        f_unit_to_base,
-        default_category=None,
-    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 37000000, 1.0, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 37000000, 1.0, 0.0)
     db.AddUnit(
@@ -8441,16 +8421,6 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         f_unit_to_base,
         default_category="volume per volume",
     )
-    f_unit_to_base = MakeCustomaryToBase(0.0, 28316.85, 1.0, 0.0)
-    f_base_to_unit = MakeBaseToCustomary(0.0, 28316.85, 1.0, 0.0)
-    db.AddUnit(
-        "volume",
-        "million cubic feet",
-        "MMcf",
-        f_base_to_unit,
-        f_unit_to_base,
-        default_category=None,
-    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 133.3224, 1.0, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 133.3224, 1.0, 0.0)
     db.AddUnit(
@@ -9121,6 +9091,36 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         f_unit_to_base,
         default_category=None,
     )
+    f_unit_to_base = MakeCustomaryToBase(0.0, 1, 86400, 0.0)
+    f_base_to_unit = MakeBaseToCustomary(0.0, 1, 86400, 0.0)
+    db.AddUnit(
+        "standard volume per time",
+        "std cubic metres/day",
+        "sm3/d",
+        f_base_to_unit,
+        f_unit_to_base,
+        default_category=None,
+    )
+    f_unit_to_base = MakeCustomaryToBase(0.0, 1000, 86400, 0.0)
+    f_base_to_unit = MakeBaseToCustomary(0.0, 1000, 86400, 0.0)
+    db.AddUnit(
+        "standard volume per time",
+        "thousand std cubic metres/day",
+        "Msm3/d",
+        f_base_to_unit,
+        f_unit_to_base,
+        default_category=None,
+    )
+    f_unit_to_base = MakeCustomaryToBase(0.0, 1000000, 86400, 0.0)
+    f_base_to_unit = MakeBaseToCustomary(0.0, 1000000, 86400, 0.0)
+    db.AddUnit(
+        "standard volume per time",
+        "million std cubic metres/day",
+        "MMsm3/d",
+        f_base_to_unit,
+        f_unit_to_base,
+        default_category=None,
+    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 0.00000000484814, 1.0, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 0.00000000484814, 1.0, 0.0)
     db.AddUnit(
@@ -11690,7 +11690,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "dimensionless",
         "cubic meter per million cubic feet",
-        "m3/M(ft3)",
+        "m3/MMcf",
         f_base_to_unit,
         f_unit_to_base,
         default_category="volume per volume",
@@ -11700,7 +11700,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "dimensionless",
         "million cubic feet per barrel",
-        "M(ft3)/bbl",
+        "MMcf/bbl",
         f_base_to_unit,
         f_unit_to_base,
         default_category="volume per volume",
@@ -11815,6 +11815,26 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         f_unit_to_base,
         default_category=None,
     )
+    f_unit_to_base = MakeCustomaryToBase(0.0, 158.9873, 86400, 0.0)
+    f_base_to_unit = MakeBaseToCustomary(0.0, 158.9873, 86400, 0.0)
+    db.AddUnit(
+        "standard volume per time",
+        "thousand stock tank barrels, 60 deg F/day",
+        "Mstb/d",
+        f_base_to_unit,
+        f_unit_to_base,
+        default_category=None,
+    )
+    f_unit_to_base = MakeCustomaryToBase(0.0, 158987.3, 86400, 0.0)
+    f_base_to_unit = MakeBaseToCustomary(0.0, 158987.3, 86400, 0.0)
+    db.AddUnit(
+        "standard volume per time",
+        "million stock tank barrels, 60 deg F/day",
+        "MMstb/d",
+        f_base_to_unit,
+        f_unit_to_base,
+        default_category=None,
+    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 0.028262357, 86400, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 0.028262357, 86400, 0.0)
     db.AddUnit(
@@ -11825,6 +11845,26 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         f_unit_to_base,
         default_category=None,
     )
+    f_unit_to_base = MakeCustomaryToBase(0.0, 28.262357, 86400, 0.0)
+    f_base_to_unit = MakeBaseToCustomary(0.0, 28.262357, 86400, 0.0)
+    db.AddUnit(
+        "standard volume per time",
+        "thousand standard cubic feet/day",
+        "Mscf/d",
+        f_base_to_unit,
+        f_unit_to_base,
+        default_category=None,
+    )
+    f_unit_to_base = MakeCustomaryToBase(0.0, 28262.357, 86400, 0.0)
+    f_base_to_unit = MakeBaseToCustomary(0.0, 28262.357, 86400, 0.0)
+    db.AddUnit(
+        "standard volume per time",
+        "million standard cubic feet/day",
+        "MMscf/d",
+        f_base_to_unit,
+        f_unit_to_base,
+        default_category=None,
+    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 28.262357, 0.1589873, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 28.262357, 0.1589873, 0.0)
     db.AddUnit(
@@ -11855,16 +11895,6 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         f_unit_to_base,
         default_category=None,
     )
-    f_unit_to_base = MakeCustomaryToBase(0.0, 28.316846592, 0.1589873, 0.0)
-    f_base_to_unit = MakeBaseToCustomary(0.0, 28.316846592, 0.1589873, 0.0)
-    db.AddUnit(
-        "dimensionless",
-        "thousand cubic feet per barrel",
-        "Mcf/bbl",
-        f_base_to_unit,
-        f_unit_to_base,
-        default_category="volume per volume",
-    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 0.1589873, 28.31685, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 0.1589873, 28.31685, 0.0)
     db.AddUnit(
@@ -11875,16 +11905,6 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
         f_unit_to_base,
         default_category="volume per volume",
     )
-    f_unit_to_base = MakeCustomaryToBase(0.0, 0.1589873, 28316.85, 0.0)
-    f_base_to_unit = MakeBaseToCustomary(0.0, 0.1589873, 28316.85, 0.0)
-    db.AddUnit(
-        "dimensionless",
-        "barrel per million cubic feet",
-        "bbl/MMcf",
-        f_base_to_unit,
-        f_unit_to_base,
-        default_category="volume per volume",
-    )
     f_unit_to_base = MakeCustomaryToBase(0.0, 1, 0.0001, 0.0)
     f_base_to_unit = MakeBaseToCustomary(0.0, 1, 0.0001, 0.0)
     db.AddUnit(
@@ -12474,7 +12494,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
     db.AddUnit(
         "volume",
         "thousand cubic meters",
-        "1000m3",
+        "Mm3",
         f_base_to_unit,
         f_unit_to_base,
         default_category=None,
@@ -13840,12 +13860,12 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
             "dimensionless",
             override=override_categories,
             valid_units=[
-                "1000ft3/bbl",
+                "Mcf/bbl",
                 "bbl/100bbl",
                 "bbl/bbl",
                 "bbl/ft3",
-                "bbl/k(ft3)",
-                "bbl/M(ft3)",
+                "bbl/Mcf",
+                "bbl/MMcf",
                 "cm3/cm3",
                 "cm3/m3",
                 "dm3/m3",
@@ -13860,11 +13880,8 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
                 "sm3/sm3",
                 "volpercent",
                 "volppm",
-                "m3/M(ft3)",
-                "M(ft3)/bbl",
-                "Mcf/bbl",
-                "bbl/Mcf",
-                "bbl/MMcf",
+                "m3/MMcf",
+                "MMcf/bbl",
             ],
         )
         db.AddCategory(
@@ -15387,9 +15404,9 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
             "volume per time per length",
             override=override_categories,
             valid_units=[
-                "1000ft3/d.ft",
-                "1000m3/d.m",
-                "1000m3/h.m",
+                "Mcf/d.ft",
+                "Mm3/d.m",
+                "Mm3/h.m",
                 "bbl/d.ft",
                 "galUK/hr.ft",
                 "galUK/hr.in",
@@ -15415,7 +15432,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
             override=override_categories,
             valid_units=[
                 "m3",
-                "1000ft3",
+                "Mcf",
                 "bbl",
                 "bcf",
                 "cm3",
@@ -15428,16 +15445,14 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
                 "hL",
                 "in3",
                 "L",
-                "M(ft3)",
-                "M(m3)",
+                "MMcf",
+                "MMm3",
                 "Mbbl",
-                "Mcf",
                 "mL",
                 "mm3",
                 "MMbbl",
-                "MMcf",
                 "tcf",
-                "1000m3",
+                "Mm3",
                 "um3",
             ],
         )
@@ -15540,7 +15555,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
             override=override_categories,
             valid_units=[
                 "m3/Pa.s",
-                "1000ft3/psi.d",
+                "Mcf/psi.d",
                 "bbl/d.psi",
                 "bbl/kPa.d",
                 "bbl/psi.d",
@@ -15566,9 +15581,9 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
             override=override_categories,
             valid_units=[
                 "m3/s",
-                "1000ft3/d",
-                "1000m3/d",
-                "1000m3/h",
+                "Mcf/d",
+                "Mm3/d",
+                "Mm3/h",
                 "bbl/d",
                 "bbl/hr",
                 "bbl/min",
@@ -15591,13 +15606,12 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
                 "L/h",
                 "L/min",
                 "L/s",
-                "M(ft3)/d",
-                "M(m3)/d",
+                "MMcf/d",
+                "MMm3/d",
                 "m3/d",
                 "m3/h",
                 "m3/min",
                 "Mbbl/d",
-                "Mcf/d",
                 "um3/s",
             ],
         )
@@ -15942,6 +15956,8 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
                 "ubar",
                 "uPa",
                 "upsi",
+                "Pa(g)",
+                "bar(g)",
             ],
         )
         db.AddCategory(
@@ -15984,6 +16000,8 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
                 "ubar",
                 "uPa",
                 "upsi",
+                "Pa(g)",
+                "bar(g)",
             ],
         )
         db.AddCategory(
@@ -16243,7 +16261,7 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
                 "s/m3",
                 "d/bbl",
                 "d/ft3",
-                "d/k(ft3)",
+                "d/Mcf",
                 "d/m3",
                 "h/ft3",
                 "h/m3",
@@ -16293,8 +16311,15 @@ def FillUnitDatabaseWithPosc(db=None, fill_categories=True, override_categories=
                 "scf(60F)/d",
                 "scm(15C)/d",
                 "stb(60F)/d",
-                "stb/d",
+                "MMscf/d",
+                "MMsm3/d",
+                "MMstb/d",
+                "Mscf/d",
+                "Msm3/d",
+                "Mstb/d",
                 "scf/d",
+                "sm3/d",
+                "stb/d",
             ],
         )
         db.AddCategory(
diff --git a/src/barril/units/unit_database.py b/src/barril/units/unit_database.py
index dcd371a..e58abaf 100644
--- a/src/barril/units/unit_database.py
+++ b/src/barril/units/unit_database.py
@@ -17,6 +17,25 @@ __all__ = [
 ]
 
 
+_LEGACY_TO_CURRENT = {
+    ("1000ft3", "Mcf"),
+    ("1000m3", "Mm3"),
+    ("M(ft3)", "MMcf"),
+    ("M(m3)", "MMm3"),
+    ("k(ft3)", "Mcf"),
+}
+
+
+def FixUnitIfIsLegacy(unit):
+    fixed_unit = unit
+    try:
+        for legacy, current in _LEGACY_TO_CURRENT:
+            fixed_unit = fixed_unit.replace(legacy, current)
+        return (unit != fixed_unit), fixed_unit
+    except:
+        return False, unit
+
+
 class UnitsError(RuntimeError):
     """
     Base class for errors related to units.
@@ -799,14 +818,16 @@ class UnitDatabase(Singleton):
         try:
             unit_info = self.unit_to_unit_info[unit]
         except KeyError:
-            return None
-        else:
-            category = unit_info.default_category
-            if category:
-                return category
-            category = unit_info.quantity_type
-            if category in self.categories_to_quantity_types:
-                return category
+            is_legacy, fixed_unit = FixUnitIfIsLegacy(unit)
+            if not is_legacy:
+                return None
+            unit_info = self.unit_to_unit_info[fixed_unit]
+        category = unit_info.default_category
+        if category:
+            return category
+        category = unit_info.quantity_type
+        if category in self.categories_to_quantity_types:
+            return category
 
     def GetQuantityType(self, unit):
         """
@@ -887,12 +908,16 @@ class UnitDatabase(Singleton):
         """
         return [x.name for x in self.GetInfos(quantity_type)]
 
-    def GetInfo(self, quantity_type, unit, fix_unknown=False):
+    def GetInfo(self, quantity_type, unit, fix_unknown=False, fix_legacy=True):
         """
         :param bool fix_unknown:
             If True won't raise error if quantity_type is unkwnown (and unit may be anything).
             Returns the unknown unit info in this situation.
 
+        :param bool fix_legacy:
+            If True and `unit` is in _LEGACY_TO_CURRENT, then it will return
+            the current equivalent unit info.
+
         :rtype: UnitInfo
         :returns:
             The unit object registered with the given unit
@@ -900,13 +925,23 @@ class UnitDatabase(Singleton):
         @raise InvalidQuantityTypeError
         @raise InvalidUnitError
         """
-        try:
-            # Common case: unit matches the quantity type registered.
-            unit_info = self.unit_to_unit_info[unit]
-            if quantity_type == unit_info.quantity_type:
-                return unit_info
-        except KeyError:
-            pass  # Just ignore and go through the 'uncommon' case.
+
+        def TryToGetUnitInfoFromUnit(unit):
+            """
+            This is the common case, where the unit matches the quantity type registered.
+            """
+            try:
+                # Common case: unit matches the quantity type registered.
+                unit_info = self.unit_to_unit_info[unit]
+                if quantity_type == unit_info.quantity_type:
+                    return unit_info
+            except KeyError:
+                pass  # Just ignore and go through the 'uncommon' case.
+            return None
+
+        unit_info = TryToGetUnitInfoFromUnit(unit)
+        if unit_info is not None:
+            return unit_info
 
         # First check if the quantity_type is a registered category
         try:
@@ -930,8 +965,8 @@ class UnitDatabase(Singleton):
                 if fix_unknown:
                     # Before actually triggering the error, handle the unknown case:
                     # We can have an unknown quantity type with a 'known' unit (i.e.: the reader
-                    # says it's unknwon, but we get a proper label for it in the UI, thus, it's a
-                    # known 'unkwon' quantity). So, in this case, proceed returning the unknown
+                    # says it's unknown, but we get a proper label for it in the UI, thus, it's a
+                    # known 'unknown' quantity). So, in this case, proceed returning the unknown
                     # quantity unit information.
                     from ._unit_constants import UNKNOWN_QUANTITY_TYPE, UNKNOWN_UNIT
 
@@ -941,6 +976,13 @@ class UnitDatabase(Singleton):
                             if info.unit == UNKNOWN_UNIT:
                                 return info
 
+                if fix_legacy:
+                    is_legacy, fixed_unit = FixUnitIfIsLegacy(unit)
+                    if is_legacy:
+                        unit_info = TryToGetUnitInfoFromUnit(fixed_unit)
+                        if unit_info is not None:
+                            return unit_info
+
                 raise InvalidUnitError(
                     unit,
                     quantity_type,
@@ -987,7 +1029,10 @@ class UnitDatabase(Singleton):
 
         @raise InvalidUnitError
         """
-        self.GetInfo(quantity_type, unit)
+        # NOTE: Using `fix_legacy=False` because when don't want to fix the legacy unit
+        # at this point, we actually want `InvalidUnitError` is the unit is
+        # legacy
+        self.GetInfo(quantity_type, unit, fix_legacy=False)
 
     def _ConvertWithExp(self, quantity_type, from_unit, to_unit, value):
         """


Test patch:
diff --git a/src/barril/units/_tests/test_legacy_unit.py b/src/barril/units/_tests/test_legacy_unit.py
new file mode 100644
index 0000000..a20cf6f
--- /dev/null
+++ b/src/barril/units/_tests/test_legacy_unit.py
@@ -0,0 +1,108 @@
+from barril.units import Scalar
+from pytest import approx, raises
+
+
+def testConvertLegacyUnit():
+    from barril.units.unit_database import _LEGACY_TO_CURRENT
+
+    # test creating scalar using legacy representation and default category
+    q = Scalar(1.0, "1000ft3/d")
+    assert q.GetUnit() == "Mcf/d"
+
+    # test creating scalar using legacy representation
+    q = Scalar(category="volume flow rate", value=1.0, unit="1000ft3/d")
+    assert q.GetUnit() == "Mcf/d"
+
+    # test getting value using legacy representation
+    assert approx(q.GetValue("M(ft3)/d")) == q.GetValue("MMcf/d")
+
+    q = Scalar(category="volume flow rate", value=1.0, unit="M(ft3)/d")
+    assert q.GetUnit() == "MMcf/d"
+    assert approx(q.GetValue("M(ft3)/d")) == q.GetValue("MMcf/d")
+    assert q.GetUnitName() == "million cubic feet per day"
+
+    # Test all possible legacy formats
+    for legacy, current in _LEGACY_TO_CURRENT:
+        assert Scalar(1.0, legacy).GetUnit() == current
+
+
+def testCreateScalarUnitsError():
+    from barril.units.unit_database import UnitsError
+
+    with raises(UnitsError, match="Unable to get default category for: foo/d"):
+        _ = Scalar(1.0, "foo/d")
+
+
+def testGetValueInvalidUnitError():
+    from barril.units.unit_database import InvalidUnitError
+
+    with raises(
+        InvalidUnitError,
+        match="Invalid unit for quantity_type volume flow rate: 1000ft3/foo",
+    ):
+        q = Scalar(1.0, "1000ft3/d")
+        q.GetValue("1000ft3/foo")
+
+
+def testFixUnitIfIsLegacyExcept():
+    from barril.units.unit_database import FixUnitIfIsLegacy
+
+    class SomeNonExpectedObject:
+        pass
+
+    unknown = SomeNonExpectedObject()
+    is_legacy, unit = FixUnitIfIsLegacy(unknown)
+    assert is_legacy == False
+    assert unit is unknown
+
+
+def testUnitDatabaseConvert(unit_database_posc):
+    import numpy as np
+
+    # Test against float
+    converted = unit_database_posc.Convert("volume flow rate", "1000ft3/d", "m3/d", 1.0)
+    assert approx(converted) == 28.31685
+
+    converted = unit_database_posc.Convert("volume flow rate", "M(ft3)/d", "m3/d", 1.0)
+    assert approx(converted) == 28316.85
+
+    # Test against numpy arrays
+    converted = unit_database_posc.Convert(
+        "volume flow rate", "1000ft3/d", "m3/d", np.ones(2)
+    )
+    assert approx(converted) == 28.31685
+    converted = unit_database_posc.Convert(
+        "volume flow rate", "M(ft3)/d", "m3/d", np.ones(2)
+    )
+    assert approx(converted) == 28316.85
+
+
+def testUnitDatabaseGetUnitNameLegacy(unit_database_posc):
+    assert (
+        unit_database_posc.GetUnitName(
+            quantity_type="volume flow rate", unit="M(ft3)/d"
+        )
+        == "million cubic feet per day"
+    )
+
+
+def testUnitDatabaseCheckQuantityTypeUnitLegacy(unit_database_posc):
+    from barril.units.unit_database import InvalidUnitError
+
+    with raises(
+        InvalidUnitError, match="Invalid unit for quantity_type volume flow rate"
+    ):
+        unit_database_posc.CheckQuantityTypeUnit(
+            quantity_type="volume flow rate", unit="M(ft3)/d"
+        )
+
+
+def testUnitDatabaseGetDefaultCategory(unit_database_posc):
+    category = unit_database_posc.GetDefaultCategory("1000ft3/d")
+    assert category == "volume flow rate"
+
+    class SomeNonExpectedObject:
+        pass
+
+    category = unit_database_posc.GetDefaultCategory(SomeNonExpectedObject())
+    assert category is None