TNO Intern

Commit 085be140 authored by Arjo Segers's avatar Arjo Segers
Browse files

Merged updates from master branch.

parent aba71ba5
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -14,6 +14,9 @@
# 2025-04, Arjo Segers
#   Changed imports for python packaging.
#
# 2026-01, Arjo Segers
#   Fixed escape characters in (document) strings.
#


########################################################################
@@ -282,7 +285,7 @@ class CSO_CoLocate(utopya.UtopyaRc):
        loc_lat = self.GetSetting("locations.latitude")
        # read:
        locations = pandas.read_csv(
            locations_file, sep="\s*" + sep + "\s*", engine="python", comment=comment
            locations_file, sep=f"\\s*{sep}\\s*", engine="python", comment=comment
        )
        # count:
        nloc = len(locations)

src/cso/cso_gridded.py

deleted100644 → 0
+0 −1495

File deleted.

Preview size limit exceeded, changes collapsed.

+9 −6
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
# 2026-01, Arjo Segers
#   Changed imports for python packaging.
#
# 2026-01, Arjo Segers
#   Fixed escape characters in (document) strings.
#

########################################################################
###
@@ -165,13 +168,13 @@ def LonLatTrianglesArea(xx, yy):
     Using the radius :math:`R` of Earth (m) the area is:

     .. math::
         A ~=~ R^2 \int\limits_{x,y} \cos(y)\ dx\ dy
         A ~=~ R^2 \\int\\limits_{x,y} \\cos(y)\\ dx\\ dy

    Approximate this by first computing the area in degrees2
    and use the average latitude:

     .. math::
         A ~=~ R^2 \int\limits_{x,y} dx\ dy\ \cos(y_{aver})
         A ~=~ R^2 \\int\\limits_{x,y} dx\\ dy\\ \\cos(y_{aver})

    """

@@ -279,9 +282,9 @@ def LonLatPolygonCentroids(xx, yy, maxlevel=5, _level=0, indent=""):
    from with the sides of the polygon as base and the centroid as top::

          o---o
          |\ /|
          |\\ /|
          | * |
          |/ \|
          |/ \\|
          o---o

    Each triangle is devided into 2 new triangles with the middle of the longest side as their top
@@ -289,8 +292,8 @@ def LonLatPolygonCentroids(xx, yy, maxlevel=5, _level=0, indent=""):

              2
              o
          0 / | \ 2
          /   |   \
          0 / | \\ 2
          /   |   \\
        o-----*-----o
        0    1    1

+6 −3
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@
# 2025-04, Arjo Segers
#   Changed imports for python packaging.
#
# 2026-01, Arjo Segers
#   Fixed seperation argument when reading csv file.
#

########################################################################
###
@@ -1306,7 +1309,7 @@ class RegionMap(object):
        # endif
        # read:
        df_to = pandas.read_csv(
            tonew, sep="\s*;", skipinitialspace=True, comment="#", na_filter=False, engine="python"
            tonew, sep="\\s+;", skipinitialspace=True, comment="#", na_filter=False, engine="python"
        )
        # check ..
        for key in ["code", "newcode"]:
@@ -1345,7 +1348,7 @@ class RegionMap(object):
        # endif
        # read:
        df_new = pandas.read_csv(
            new, sep="\s*;", skipinitialspace=True, comment="#", na_filter=False, engine="python"
            new, sep="\\s+;", skipinitialspace=True, comment="#", na_filter=False, engine="python"
        )
        # check ..
        for key in ["code", "name"]:
@@ -2738,7 +2741,7 @@ class CSO_Statistics_RegionsTables(utopya.UtopyaRc):
            ctab_file = self.GetSetting("ctab.file")
            # read:
            ctab = pandas.read_csv(
                ctab_file, sep="\s*;", skipinitialspace=True, na_filter=False, engine="python"
                ctab_file, sep="\\s+;", skipinitialspace=True, na_filter=False, engine="python"
            )

            # info ..
+6 −3
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@
# 2026-01, Alessandro D'ausilio
#   Trap case that no pixels are selected.
#
# 2026-01, Arjo Segers
#   Fixed escape characters in (document) strings.
#


########################################################################
@@ -101,15 +104,15 @@ class CSO_SuperObs(utopya.UtopyaRc):
    using the total overlapping area:

    .. math::
        x(i_k,j_k) ~=~ \left(\ \sum\limits_{p\in P_k} y_p\ w_{p,k}\ \\right)\ /\ \sum\limits_{p\in P_k}\ w_{p,k}
        x(i_k,j_k) ~=~ \\left(\\ \\sum\\limits_{p\\in P_k} y_p\\ w_{p,k}\\ \\right)\\ /\\ \\sum\\limits_{p\\in P_k}\\ w_{p,k}

    where:

    * :math:`i_k,j_k` are the indices of grid cell :math:`k`;
    * :math:`P_k` is the set of pixels that overlap with cell :math:`k`;
    * :math:`y_p` is the data value of pixel :math:`p`;
    * :math:`w_p` is the footprint area [m\ :sup:`2`] of pixel :math:`p`
    * :math:`w_{p,k}` is the area [m\ :sup:`2`] of pixel :math:`p` that overlaps with the cell :math:`k`.
    * :math:`w_p` is the footprint area [m\\ :sup:`2`] of pixel :math:`p`
    * :math:`w_{p,k}` is the area [m\\ :sup:`2`] of pixel :math:`p` that overlaps with the cell :math:`k`.

    The overlapping area is computed using the :py:meth:`LonLatPolygonCentroids <cso_mapping.LonLatPolygonCentroids>` method.
    This fractions a footprint area into a large number of triangles, and returns
Loading