Beispiel #1
0
def plot(args):
    """
    Setup a project directory

    Args:
        :args: (obj) Instance of form 'ArgsPlot'
    """

    for infile in args.files:
        data_fields = load_json_def_fields(infile)
        plot_all(data_fields, density=args.percent / 100)
Beispiel #2
0
def test_json_dump(example_def_field):
    """
    Test that JSON serialisation is lossless
    """

    tmp_file = tempfile.mkstemp()[1]

    s.dump_json_def_fields(tmp_file, example_def_field)
    deserialised_def_fields = s.load_json_def_fields(tmp_file)
    check_if_def_fields_same(deserialised_def_fields, example_def_field)

    os.remove(tmp_file)
Beispiel #3
0
def load(aircraft, settings):
    """
    Loads the aircraft deformation file if it exitsts.

    Args:
        :aircraft: (obj) aircraft
        :settings: (obj) settings
    """

    filepath = settings.paths('f_deformation')
    logger.info(
        f"Reading deformation from file '{truncate_filepath(filepath)}'")

    if not os.path.exists(filepath):
        raise IOError(f"file '{filepath}' not found")
    # File is empty or as good as (this also catches empty JSON file: '{}')
    elif os.stat(filepath).st_size < 10:
        logger.warning(
            f"Empty deformation file. No deformations are modelled.")
        return

    def_fields = load_json_def_fields(filepath)
    for wing_uid, def_field in def_fields.items():
        ####
        # Convention: Deformation fields starting with '_' will be ignore by CFD
        if wing_uid.startswith('_'):
            continue
        ####

        # Convention: Deformation fields ending with '_m' belongs to a 'mirrored' component
        if wing_uid.endswith('_m'):
            aircraft.wings[wing_uid.replace('_m',
                                            '')].def_field_mirror = def_field
            continue

        aircraft.wings[wing_uid].def_field = def_field
Beispiel #4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from aeroframe.fileio.serialise import load_json_def_fields
from aeroframe.plot.makeplot import plot_all

def_fields = load_json_def_fields('def_fields.json')
plot_all(def_fields)