Exemplo n.º 1
0
def main():
    season_to_months = get_default_season_to_months_dict()

    # var_names = ["TT", "HU", "PR", "AV", "STFL"]
    # var_names = ["TRAF", "STFL", "TRAF+TDRA"]
    # var_names = ["TT", "PR", "STFL"]
    # var_names = ["TT", "PR", "I5", "STFL", "AV", "AH"]

    var_names = ["TT", ]

    levels = [0, ] * len(var_names)
    multipliers = {
        "PR": 1.0,
        "TRAF+TDRA": 24 * 60 * 60
    }
    name_to_units = {
        "TRAF": "mm/day", "I1": "mm", "PR": "mm/day", "TRAF+TDRA": "mm/day",
        "I5": "mm", "AV": r"${\rm W/m^2}$"
    }

    base_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
                        "quebec_0.1_crcm5-r-cc-canesm2-1980-2010.hdf5"
    base_label = "CanESM2-CRCM5-NL"

    modif_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
                         "quebec_0.1_crcm5-hcd-rl-cc-canesm2-1980-2010.hdf5"
    modif_label = "CanESM2-CRCM5-L"

    plot_cc_only_for = modif_label

    # plot_cc_only_for = None

    start_year_c = 1980
    end_year_c = 2010

    future_shift_years = 90

    params = dict(
        data_path=base_current_path, start_year=start_year_c, end_year=end_year_c, label=base_label
    )

    base_config_c = RunConfig(**params)
    base_config_f = base_config_c.get_shifted_config(future_shift_years)

    params.update(
        dict(data_path=modif_current_path, label=modif_label)
    )

    modif_config_c = RunConfig(**params)
    modif_config_f = modif_config_c.get_shifted_config(future_shift_years)

    config_dict = OrderedDict([
        ("Current", OrderedDict([(base_label, base_config_c), (modif_label, modif_config_c)])),
        ("Future", OrderedDict([(base_label, base_config_f), (modif_label, modif_config_f)]))
    ])

    # Changes global plot properties mainly figure size and font size
    plot_utils.apply_plot_params(font_size=12, width_cm=25, height_cm=10)


    # Plot the differences
    fig = plt.figure()
    gs = GridSpec(len(var_names), len(season_to_months) + 1, width_ratios=[1., ] * len(season_to_months) + [0.05, ])

    config_dict.fig = fig
    config_dict.gs = gs
    config_dict.label_modif = modif_config_c.label
    config_dict.label_base = base_config_c.label
    config_dict.season_to_months = season_to_months
    config_dict.multipliers = multipliers

    lons, lats, bmp = analysis.get_basemap_from_hdf(base_current_path)
    config_dict.lons = lons
    config_dict.lats = lats
    config_dict.basemap = bmp

    config_dict.name_to_units = name_to_units

    # Calculate and plot seasonal means
    for vname, level, the_row in zip(var_names, levels, list(range(len(levels)))):
        config_dict.the_row = the_row

        _plot_row(vname=vname, level=level, config_dict=config_dict, plot_cc_only_for=plot_cc_only_for, mark_significance=False)

    # Save the image to the file
    if plot_cc_only_for is None:
        img_path = get_image_path(base_config_c, base_config_f, modif_config_c, season_to_months=season_to_months)
    else:

        config_c = base_config_c if base_config_c.label == plot_cc_only_for else modif_config_c
        config_f = base_config_f if base_config_f.label == plot_cc_only_for else modif_config_f

        img_path = get_image_path(config_c, config_f, config_c, season_to_months=season_to_months)
    fig.savefig(img_path, bbox_inches="tight", transparent=True, dpi=common_plot_params.FIG_SAVE_DPI)
    print("saving the plot to: {}".format(img_path))
    plt.close(fig)
Exemplo n.º 2
0
def main():
    """

    """

    season_to_months = get_default_season_to_months_dict()

    # season_to_months = OrderedDict([("April", [4, ]), ("May", [5, ]), ("June", [6, ]), ("July", [7, ])])

    var_names = ["TT", "HU", "PR", "AV", "AH", "STFL", "TRAF", "I5", "I0"]

    # var_names = ["TT", "PR"]

    levels = [
        0,
    ] * len(var_names)
    multipliers = {"PR": 1.0e3 * 24.0 * 3600., "TRAF": 24 * 3600.0}

    base_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
                        "quebec_0.1_crcm5-r-cc-canesm2-1980-2010.hdf5"
    base_label = "CanESM2-CRCM5-NL"

    modif_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
                         "quebec_0.1_crcm5-hcd-rl-cc-canesm2-1980-2010.hdf5"
    modif_label = "CanESM2-CRCM5-L"

    # base_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
    # "quebec_0.1_crcm5-hcd-rl-cc-canesm2-1980-2010.hdf5"
    # base_label = "CRCM5-L"
    #
    # modif_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
    # "quebec_0.1_crcm5-hcd-rl-intfl-cc-canesm2-1980-2010.hdf5"
    # modif_label = "CRCM5-LI"

    start_year_c = 1980
    end_year_c = 2010

    future_shift_years = 90

    params = dict(data_path=base_current_path,
                  start_year=start_year_c,
                  end_year=end_year_c,
                  label=base_label)

    base_config_c = RunConfig(**params)
    base_config_f = base_config_c.get_shifted_config(future_shift_years)

    params.update(dict(data_path=modif_current_path, label=modif_label))

    modif_config_c = RunConfig(**params)
    modif_config_f = modif_config_c.get_shifted_config(future_shift_years)

    config_dict = OrderedDict([("Current",
                                OrderedDict([(base_label, base_config_c),
                                             (modif_label, modif_config_c)])),
                               ("Future",
                                OrderedDict([(base_label, base_config_f),
                                             (modif_label, modif_config_f)]))])

    # Plot the differences
    config_dict.label_modif = modif_config_c.label
    config_dict.label_base = base_config_c.label
    config_dict.season_to_months = season_to_months
    config_dict.multipliers = multipliers

    lons, lats, bmp = analysis.get_basemap_from_hdf(base_current_path)
    config_dict.lons = lons
    config_dict.lats = lats
    config_dict.basemap = bmp

    # Calculate and plot seasonal means
    for vname, level in zip(var_names, levels):
        data = get_data(vname=vname, level=level, config_dict=config_dict)
        _plot_var(vname=vname,
                  level=level,
                  config_dict=config_dict,
                  data_dict=data)
Exemplo n.º 3
0
def main_interflow():
    # Changes global plot properties mainly figure size and font size
    plot_utils.apply_plot_params(font_size=12, width_cm=20)

    # season_to_months = get_default_season_to_months_dict()
    season_to_months = OrderedDict([("January", [1, ]), ("February", [2, ]), ("March", [3, ]), ])

    var_names = ["TT", "HU", "PR", "AV", "TRAF", "I1", "STFL"]

    levels = [0, ] * len(var_names)

    plot_utils.apply_plot_params(font_size=10, width_pt=None, width_cm=20 * len(season_to_months) / 4.0,
                                 height_cm=20 * len(var_names) / 5.0)

    multipliers = {
        "PR": 1.,
        "TRAF": 1.,
        "I1": infovar.soil_layer_widths_26_to_60[0] * 1000.0,
        "TRAF+TDRA": 24 * 60 * 60
    }

    name_to_units = {
        "TRAF": "mm/day", "I1": "mm", "PR": "mm/day", "TRAF+TDRA": "mm/day"
    }

    base_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
                        "quebec_0.1_crcm5-hcd-rl-cc-canesm2-1980-2010.hdf5"
    base_label = "CanESM2-CRCM5-L"

    modif_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
                         "quebec_0.1_crcm5-hcd-rl-intfl-cc-canesm2-1980-2010.hdf5"
    modif_label = "CanESM2-CRCM5-LI"

    start_year_c = 1980
    end_year_c = 2010

    future_shift_years = 90

    params = dict(
        data_path=base_current_path, start_year=start_year_c, end_year=end_year_c, label=base_label
    )

    base_config_c = RunConfig(**params)
    base_config_f = base_config_c.get_shifted_config(future_shift_years)

    params.update(
        dict(data_path=modif_current_path, label=modif_label)
    )

    modif_config_c = RunConfig(**params)
    modif_config_f = modif_config_c.get_shifted_config(future_shift_years)

    config_dict = OrderedDict([
        ("Current", OrderedDict([(base_label, base_config_c), (modif_label, modif_config_c)])),
        ("Future", OrderedDict([(base_label, base_config_f), (modif_label, modif_config_f)]))
    ])


    # Plot the differences
    fig = plt.figure()
    gs = GridSpec(len(var_names), len(season_to_months) + 1, width_ratios=[1., ] * len(season_to_months) + [0.05, ])
    config_dict.fig = fig
    config_dict.gs = gs
    config_dict.label_modif = modif_config_c.label
    config_dict.label_base = base_config_c.label
    config_dict.season_to_months = season_to_months
    config_dict.multipliers = multipliers

    lons, lats, bmp = analysis.get_basemap_from_hdf(base_current_path)
    config_dict.lons = lons
    config_dict.lats = lats
    config_dict.basemap = bmp
    config_dict.name_to_units = name_to_units

    # Calculate and plot seasonal means
    for vname, level, the_row in zip(var_names, levels, list(range(len(levels)))):
        config_dict.the_row = the_row

        _plot_row(vname=vname, level=level, config_dict=config_dict)

    # Save the image to the file
    img_path = get_image_path(base_config_c, base_config_f, modif_config_c, season_to_months=season_to_months)
    fig.savefig(img_path, bbox_inches="tight")
def main():
    """

    """

    season_to_months = get_default_season_to_months_dict()

    # season_to_months = OrderedDict([("April", [4, ]), ("May", [5, ]), ("June", [6, ]), ("July", [7, ])])

    var_names = ["TT", "HU", "PR", "AV", "AH", "STFL", "TRAF", "I5", "I0"]

    # var_names = ["TT", "PR"]

    levels = [0, ] * len(var_names)
    multipliers = {
        "PR": 1.0e3 * 24.0 * 3600.,
        "TRAF": 24 * 3600.0
    }

    base_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
                        "quebec_0.1_crcm5-r-cc-canesm2-1980-2010.hdf5"
    base_label = "CanESM2-CRCM5-NL"

    modif_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
                         "quebec_0.1_crcm5-hcd-rl-cc-canesm2-1980-2010.hdf5"
    modif_label = "CanESM2-CRCM5-L"

    # base_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
    # "quebec_0.1_crcm5-hcd-rl-cc-canesm2-1980-2010.hdf5"
    # base_label = "CRCM5-L"
    #
    # modif_current_path = "/skynet3_rech1/huziy/hdf_store/cc-canesm2-driven/" \
    # "quebec_0.1_crcm5-hcd-rl-intfl-cc-canesm2-1980-2010.hdf5"
    # modif_label = "CRCM5-LI"

    start_year_c = 1980
    end_year_c = 2010

    future_shift_years = 90

    params = dict(
        data_path=base_current_path, start_year=start_year_c, end_year=end_year_c, label=base_label
    )

    base_config_c = RunConfig(**params)
    base_config_f = base_config_c.get_shifted_config(future_shift_years)

    params.update(
        dict(data_path=modif_current_path, label=modif_label)
    )

    modif_config_c = RunConfig(**params)
    modif_config_f = modif_config_c.get_shifted_config(future_shift_years)

    config_dict = OrderedDict([
        ("Current", OrderedDict([(base_label, base_config_c), (modif_label, modif_config_c)])),
        ("Future", OrderedDict([(base_label, base_config_f), (modif_label, modif_config_f)]))
    ])

    # Plot the differences
    config_dict.label_modif = modif_config_c.label
    config_dict.label_base = base_config_c.label
    config_dict.season_to_months = season_to_months
    config_dict.multipliers = multipliers

    lons, lats, bmp = analysis.get_basemap_from_hdf(base_current_path)
    config_dict.lons = lons
    config_dict.lats = lats
    config_dict.basemap = bmp

    # Calculate and plot seasonal means
    for vname, level in zip(var_names, levels):
        data = get_data(vname=vname, level=level, config_dict=config_dict)
        _plot_var(vname=vname, level=level, config_dict=config_dict, data_dict=data)