Пример #1
0
def sim_frame_beamAnimation(frame_args):
    data = simulation_db.read_json(
        run_dir.join(template_common.INPUT_BASE_NAME))
    model = data.models.beamAnimation
    model.update(frame_args)
    beam_info = hellweg_dump_reader.beam_info(_dump_file(run_dir),
                                              frame_args.frameIndex)
    x, y = frame_args.reportType.split('-')
    values = [
        hellweg_dump_reader.get_points(beam_info, x),
        hellweg_dump_reader.get_points(beam_info, y),
    ]
    model['x'] = x
    model['y'] = y
    # see issue #872
    if not np.any(values):
        values = [[], []]
    return template_common.heatmap(
        values, model, {
            'x_label':
            hellweg_dump_reader.get_label(x),
            'y_label':
            hellweg_dump_reader.get_label(y),
            'title':
            _report_title(frame_args.reportType, 'BeamReportType', beam_info),
            'z_label':
            'Number of Particles',
            'summaryData':
            _summary_text(run_dir),
        })
Пример #2
0
def extract_beam_histrogram(report, run_dir, frame):
    beam_info = hellweg_dump_reader.beam_info(_dump_file(run_dir), frame)
    points = hellweg_dump_reader.get_points(beam_info, report.reportType)
    hist, edges = np.histogram(points, template_common.histogram_bins(report.histogramBins))
    return {
        'title': _report_title(report.reportType, 'BeamHistogramReportType', beam_info),
        'x_range': [edges[0], edges[-1]],
        'y_label': 'Number of Particles',
        'x_label': hellweg_dump_reader.get_label(report.reportType),
        'points': hist.T.tolist(),
    }
Пример #3
0
def sim_frame_beamHistogramAnimation(frame_args):
    beam_info = hellweg_dump_reader.beam_info(_dump_file(run_dir))
    points = hellweg_dump_reader.get_points(beam_info, frame_args.reportType)
    hist, edges = np.histogram(
        points, template_common.histogram_bins(frame_args.histogramBins))
    return {
        'title':
        _report_title(frame_args.reportType, 'BeamHistogramReportType',
                      beam_info),
        'x_range': [edges[0], edges[-1]],
        'y_label':
        'Number of Particles',
        'x_label':
        hellweg_dump_reader.get_label(frame_args.reportType),
        'points':
        hist.T.tolist(),
    }
Пример #4
0
def extract_beam_report(report, run_dir, frame):
    data = simulation_db.read_json(run_dir.join(template_common.INPUT_BASE_NAME))
    model = data.models.beamAnimation
    model.update(report)
    beam_info = hellweg_dump_reader.beam_info(_dump_file(run_dir), frame)
    x, y = report.reportType.split('-')
    values = [
        hellweg_dump_reader.get_points(beam_info, x),
        hellweg_dump_reader.get_points(beam_info, y),
    ]
    model['x'] = x
    model['y'] = y
    return template_common.heatmap(values, model, {
        'x_label': hellweg_dump_reader.get_label(x),
        'y_label': hellweg_dump_reader.get_label(y),
        'title': _report_title(report.reportType, 'BeamReportType', beam_info),
        'z_label': 'Number of Particles',
        'summaryData': _summary_text(run_dir),
    })
Пример #5
0
def _compute_range_across_files(run_dir, data):
    res = {}
    for v in _SCHEMA.enum.BeamReportType:
        x, y = v[0].split('-')
        res[x] = []
        res[y] = []
    dump_file = _dump_file(run_dir)
    if not os.path.exists(dump_file):
        return res
    beam_header = hellweg_dump_reader.beam_header(dump_file)
    for frame in xrange(beam_header.NPoints):
        beam_info = hellweg_dump_reader.beam_info(dump_file, frame)
        for field in res:
            values = hellweg_dump_reader.get_points(beam_info, field)
            if not len(values):
                pass
            elif len(res[field]):
                res[field][0] = min(min(values), res[field][0])
                res[field][1] = max(max(values), res[field][1])
            else:
                res[field] = [min(values), max(values)]
    return res
Пример #6
0
def extract_beam_report(report, run_dir, frame):
    beam_info = hellweg_dump_reader.beam_info(_dump_file(run_dir), frame)
    x, y = report.reportType.split('-')
    data_list = [
        hellweg_dump_reader.get_points(beam_info, x),
        hellweg_dump_reader.get_points(beam_info, y),
    ]
    hist, edges = numpy.histogramdd(
        data_list, template_common.histogram_bins(report.histogramBins))
    return {
        'x_range': [float(edges[0][0]),
                    float(edges[0][-1]),
                    len(hist)],
        'y_range': [float(edges[1][0]),
                    float(edges[1][-1]),
                    len(hist[0])],
        'x_label': hellweg_dump_reader.get_label(x),
        'y_label': hellweg_dump_reader.get_label(y),
        'title': _report_title(report.reportType, 'BeamReportType', beam_info),
        'z_matrix': hist.T.tolist(),
        'z_label': 'Number of Particles',
        'summaryData': _summary_text(run_dir),
    }