Beispiel #1
0
def combine(_path):
    """Combine and return density and flow map in _path."""

    # Read maps using non-public ways :O
    dens = DataMap(fields="dens")
    dens.path = _path["dens"]
    dens._read()
    flow = DataMap(fields="flow")
    flow.path = _path["flow"]
    flow._read()

    # Container for output
    output = DataMap()
    output.cells = []

    # Go over all density cells, ie. entire system
    i = 0
    with flow.FlatArray(flow.cells) as flow.cells:
        for cell in dens.cells:
            combined = cell.copy()

            # If cells equal, add flow and move to next flow cell
            if i < len(flow.cells) and cell["X"] == flow.cells[i]["X"] and cell["Y"] == flow.cells[i]["Y"]:
                combined.update(flow.cells[i])
                i += 1
            else:
                combined.update({"U": 0.0, "V": 0.0})

            # Append to container
            output.cells.append(combined)

    # Convert by hand to good format and save
    output.cells = np.array(output.cells)
    output._info = output.info
    output._grid()

    return output