Exemplo n.º 1
0
def model_diff(parameter_set_nr, data_kind='WOA', path='/tmp', normalize_with_deviation=False, y_max=(None, None)):
    from simulation.model.constants import DATABASE_OUTPUT_DIR, DATABASE_MODEL_DIRNAME, DATABASE_TIME_STEP_DIRNAME, DATABASE_PARAMETERS_SET_DIRNAME, DATABASE_PARAMETERS_FILENAME
    from simulation.model.constants import (METOS_X_DIM as X_DIM, METOS_Y_DIM as Y_DIM, METOS_Z_LEFT as Z_VALUES_LEFT)

    logger.debug('Plotting model output for parameter set {}'.format(parameter_set_nr))

    ## load parameters
    parameter_set_dirname = DATABASE_PARAMETERS_SET_DIRNAME.format(parameter_set_nr)
    p_file = os.path.join(DATABASE_OUTPUT_DIR, DATABASE_MODEL_DIRNAME.format('dop_po4'), DATABASE_TIME_STEP_DIRNAME.format(1), parameter_set_dirname, DATABASE_PARAMETERS_FILENAME)
    p = np.loadtxt(p_file)

    ## init data base
    data_base = simulation.util.data_base.init_data_base(data_kind)
    if not normalize_with_deviation:
        file = os.path.join(path, 'model_diff_-_{}_-_' + parameter_set_dirname + '_-_{}.png')
    else:
        file = os.path.join(path, 'model_diff_normalized_with_deviation_-_{}_-_' + parameter_set_dirname + '_-_{}.png')

    ## print for WOA
    if data_kind.upper() == 'WOA':
        diff_boxes = np.abs(data_base.diff_boxes(p, normalize_with_deviation=normalize_with_deviation))
    ## print for WOD
    elif data_kind.upper() == 'WOD':
        diff = np.abs(data_base.diff(p, normalize_with_deviation=normalize_with_deviation))
        diff_boxes = data_base.convert_to_boxes(diff, no_data_value=np.inf)
    else:
        raise ValueError('Data_kind {} unknown. Must be "WOA" or "WOD".'.format(data_kind))


    def plot_tracer_diff(diff, file, y_max=None):
        util.plot.data(np.abs(diff), file, land_value=np.nan, no_data_value=np.inf, v_min=0, v_max=y_max)

    plot_tracer_diff(diff_boxes[0], file.format(data_kind, 'dop'), y_max=y_max[0])
    plot_tracer_diff(diff_boxes[1], file.format(data_kind, 'po4'), y_max=y_max[1])
Exemplo n.º 2
0
def model_diff(parameter_set_nr, data_kind='WOA', path='/tmp', normalize_with_deviation=False, y_max=(None, None)):
    from simulation.model.constants import DATABASE_OUTPUT_DIR, DATABASE_MODEL_DIRNAME, DATABASE_TIME_STEP_DIRNAME, DATABASE_PARAMETERS_DIRNAME, DATABASE_PARAMETERS_FILENAME
    from simulation.model.constants import (METOS_X_DIM as X_DIM, METOS_Y_DIM as Y_DIM, METOS_Z_LEFT as Z_VALUES_LEFT)

    logger.debug('Plotting model output for parameter set {}'.format(parameter_set_nr))

    ## load parameters
    parameter_set_dirname = DATABASE_PARAMETERS_DIRNAME.format(parameter_set_nr)
    p_file = os.path.join(DATABASE_OUTPUT_DIR, DATABASE_MODEL_DIRNAME.format('dop_po4'), DATABASE_TIME_STEP_DIRNAME.format(1), parameter_set_dirname, DATABASE_PARAMETERS_FILENAME)
    p = np.loadtxt(p_file)

    ## init data base
    data_base = simulation.util.data_base.init_data_base(data_kind)
    if not normalize_with_deviation:
        file = os.path.join(path, 'model_diff_-_{}_-_' + parameter_set_dirname + '_-_{}.png')
    else:
        file = os.path.join(path, 'model_diff_normalized_with_deviation_-_{}_-_' + parameter_set_dirname + '_-_{}.png')

    ## print for WOA
    if data_kind.upper() == 'WOA':
        diff_boxes = np.abs(data_base.diff_boxes(p, normalize_with_deviation=normalize_with_deviation))
    ## print for WOD
    elif data_kind.upper() == 'WOD':
        diff = np.abs(data_base.diff(p, normalize_with_deviation=normalize_with_deviation))
        diff_boxes = data_base.convert_to_boxes(diff, no_data_value=np.inf)
    else:
        raise ValueError('Data_kind {} unknown. Must be "WOA" or "WOD".'.format(data_kind))


    def plot_tracer_diff(diff, file, y_max=None):
        util.plot.data(np.abs(diff), file, land_value=np.nan, no_data_value=np.inf, v_min=0, v_max=y_max)

    plot_tracer_diff(diff_boxes[0], file.format(data_kind, 'dop'), y_max=y_max[0])
    plot_tracer_diff(diff_boxes[1], file.format(data_kind, 'po4'), y_max=y_max[1])
Exemplo n.º 3
0
def model_output(parameter_set_nr, kind='BOXES', path='/tmp', y_max=(None, None), average_in_time=False):
    from simulation.model.constants import DATABASE_OUTPUT_DIR, DATABASE_MODEL_DIRNAME, DATABASE_TIME_STEP_DIRNAME, DATABASE_PARAMETERS_SET_DIRNAME, DATABASE_PARAMETERS_FILENAME
    from simulation.util.constants import CACHE_DIRNAME, BOXES_F_FILENAME, WOD_F_FILENAME

    logger.debug('Plotting model output for parameter set {}'.format(parameter_set_nr))

    ## load parameters
    parameter_set_dirname = DATABASE_PARAMETERS_SET_DIRNAME.format(parameter_set_nr)
    p_file = os.path.join(DATABASE_OUTPUT_DIR, DATABASE_MODEL_DIRNAME.format('dop_po4'), DATABASE_TIME_STEP_DIRNAME.format(1), parameter_set_dirname, DATABASE_PARAMETERS_FILENAME)
    p = np.loadtxt(p_file)

    ## init data base
    if kind.upper() == 'BOXES':
        data_base = simulation.util.data_base.init_data_base('WOA')
        f = data_base.f_boxes(p)
        f[f < 0] = 0
        if average_in_time:
            f = f.mean(axis=1)
    else:
        data_base = simulation.util.data_base.init_data_base('WOD')
        f = data_base.f(p)
        f = data_base.convert_to_boxes(f, no_data_value=np.inf)

    file = os.path.join(path, 'model_output_-_' + kind + '_-_' + parameter_set_dirname + '_-_{tracer}.png')
    tracers = ('dop', 'po4')
    for i in range(len(tracers)):
        util.plot.data(f[i], file.format(tracer=tracers[i]), land_value=np.nan, no_data_value=np.inf, v_min=0, v_max=y_max[i], contours=True, colorbar=False)
Exemplo n.º 4
0
def model_output(parameter_set_nr, kind='BOXES', path='/tmp', y_max=(None, None), average_in_time=False):
    from simulation.model.constants import DATABASE_OUTPUT_DIR, DATABASE_MODEL_DIRNAME, DATABASE_TIME_STEP_DIRNAME, DATABASE_PARAMETERS_DIRNAME, DATABASE_PARAMETERS_FILENAME
    from simulation.util.constants import CACHE_DIRNAME, BOXES_F_FILENAME, WOD_F_FILENAME

    logger.debug('Plotting model output for parameter set {}'.format(parameter_set_nr))

    ## load parameters
    parameter_set_dirname = DATABASE_PARAMETERS_DIRNAME.format(parameter_set_nr)
    p_file = os.path.join(DATABASE_OUTPUT_DIR, DATABASE_MODEL_DIRNAME.format('dop_po4'), DATABASE_TIME_STEP_DIRNAME.format(1), parameter_set_dirname, DATABASE_PARAMETERS_FILENAME)
    p = np.loadtxt(p_file)

    ## init data base
    if kind.upper() == 'BOXES':
        data_base = simulation.util.data_base.init_data_base('WOA')
        f = data_base.f_boxes(p)
        f[f < 0] = 0
        if average_in_time:
            f = f.mean(axis=1)
    else:
        data_base = simulation.util.data_base.init_data_base('WOD')
        f = data_base.f(p)
        f = data_base.convert_to_boxes(f, no_data_value=np.inf)

    file = os.path.join(path, 'model_output_-_' + kind + '_-_' + parameter_set_dirname + '_-_{tracer}.png')
    tracers = ('dop', 'po4')
    for i in range(len(tracers)):
        util.plot.data(f[i], file.format(tracer=tracers[i]), land_value=np.nan, no_data_value=np.inf, v_min=0, v_max=y_max[i], contours=True, colorbar=False)