Exemple #1
0
def main_no_copybuf(data_file):
    s = Sequence(
        ReadData(),
        Split(
            [
                (
                    lambda vec: vec[0],
                    Histogram(mesh((-10, 10), 10)),
                    MakeFilename("x"),
                ),
                (
                    lambda vec: vec[1],
                    Histogram(mesh((-10, 10), 10)),
                    MakeFilename("y"),
                ),
                (
                    lambda vec: vec[2],
                    Histogram(mesh((-10, 10), 10)),
                    MakeFilename("z"),
                ),
            ],
            copy_buf=False,
        ),
        MakeFilename("{{variable.name}}"),
        ToCSV(),
    )
    results = s.run([data_file])
    for res in results:
        print(res)
Exemple #2
0
def main_copybuf(data_file):
    write = Write("output")
    s = Sequence(
        ReadData(),
        Split([
            (
                Variable("x", lambda vec: vec[0]),
                Histogram(mesh((-10, 10), 10)),
            ),
            (
                Variable("y", lambda vec: vec[1]),
                Histogram(mesh((-10, 10), 10)),
            ),
            (
                Variable("z", lambda vec: vec[2]),
                Histogram(mesh((-10, 10), 10)),
            ),
        ]),
        MakeFilename("{{variable.name}}"),
        ToCSV(),
        # write,
        # RenderLaTeX("histogram_1d.tex", "templates"),
        # write,
        # LaTeXToPDF(),
        # PDFToPNG(),
    )
    results = s.run([data_file])
    for res in results:
        print(res)
Exemple #3
0
def main():
    data_file = os.path.join("..", "data", "normal_3d.csv")
    s = Sequence(
        ReadData(),
        Split([
            (
                lambda vec: vec[0],
                Histogram(mesh((-10, 10), 10)),
                ToCSV(),
                Print(),
                Write("output", "x"),
            ),
            (
                lambda vec: vec[1],
                Histogram(mesh((-10, 10), 10)),
                ToCSV(),
                Write("output", "y"),
            ),
            # (
            #     lambda vec: vec[2],
            #     Histogram(mesh((-10, 10), 10)),
            #     ToCSV(),
            #     Write("output", ("z", "csv")),
            # ),
        ]),
        RenderLaTeX("histogram_1d.tex", "templates"),
        Write("output"),
        LaTeXToPDF(),
        PDFToPNG(),
    )
    results = s.run([data_file])
    for res in results:
        print(res)
Exemple #4
0
def main():
    data_file = os.path.join("..", "data", "normal_3d.csv")
    write = Write("output")
    s = Sequence(
        ReadData(),
        Split([
            (
                Variable("x", lambda vec: vec[0]),
                Histogram(mesh((-10, 10), 10)),
            ),
            (
                Variable("y", lambda vec: vec[1]),
                Histogram(mesh((-10, 10), 10)),
            ),
            (
                Variable("z", lambda vec: vec[2]),
                Histogram(mesh((-10, 10), 10)),
            ),
        ]),
        MakeFilename("{{variable.name}}"),
        ToCSV(),
        write,
        RenderLaTeX("histogram_1d.tex", "templates"),
        write,
        LaTeXToPDF(),
        PDFToPNG(),
    )
    results = s.run([data_file])
    for res in results:
        print(res)
Exemple #5
0
def main():
    data_file = os.path.join("..", "data", "normal_3d.csv")
    s = Sequence(
        ReadData(),
        lambda dt: (dt[0][0], dt[1]),
        Histogram(mesh((-10, 10), 10)),
        ToCSV(),
        MakeFilename("x"),
        Write("output"),
        RenderLaTeX("histogram_1d.tex"),
        Write("output"),
        LaTeXToPDF(),
        PDFToPNG(),
    )
    results = s.run([data_file])
    print(list(results))
Exemple #6
0
def main():
    data_file = os.path.join("..", "data", "double_ev.csv")
    write = Write("output")
    s = Sequence(
        ReadDoubleEvents(),
        Split(coordinates_1d + [(
            particle,
            Combine(x, y, name="xy"),
            Histogram(mesh(((-10, 10), (-10, 10)), (10, 10))),
            MakeFilename("{{variable.particle}}/{{variable.name}}"),
        ) for particle in (positron, neutron)]),
        MakeFilename("{{variable.particle}}/{{variable.coordinate}}"),
        ToCSV(),
        write,
        RenderLaTeX(select_template, template_dir="templates"),
        write,
        LaTeXToPDF(),
        PDFToPNG(),
    )
    results = s.run([data_file])
    for res in results:
        print(res)
Exemple #7
0
             unit="cm",
             type="coordinate")
y = Variable("y",
             lambda vec: vec[1],
             latex_name="y",
             unit="cm",
             type="coordinate")
z = Variable("z",
             lambda vec: vec[2],
             latex_name="z",
             unit="cm",
             type="coordinate")

coordinates_1d = [(
    coordinate,
    Histogram(mesh((-10, 10), 10)),
) for coordinate in [
    Compose(particle, coord) for coord in (x, y, z)
    for particle in (positron, neutron)
]]


def select_template(val):
    data, context = lena.flow.get_data_context(val)
    if lena.context.get_recursively(context, "histogram.dim", None) == 2:
        return "histogram_2d.tex"
    else:
        return "histogram_1d.tex"


def main():