Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pygem/bin/op/compress_gdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from oggm import utils, workflow

# pygem imports
import pygem.setup.config as config
from pygem.setup.config import ConfigManager

# check for config
config.ensure_config()
# instantiate ConfigManager
config_manager = ConfigManager()
# read the config
pygem_prms = config.read_config()
pygem_prms = config_manager.read_config()

# Initialize OGGM subprocess
cfg.initialize(logging_level='WARNING')
Expand Down
8 changes: 4 additions & 4 deletions pygem/bin/run/run_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import pandas as pd

# pygem imports
import pygem.setup.config as config
from pygem.setup.config import ConfigManager

# check for config
config.ensure_config()
# instantiate ConfigManager
config_manager = ConfigManager()
# read the config
pygem_prms = config.read_config()
pygem_prms = config_manager.read_config()
from oggm import cfg, tasks, workflow

import pygem.pygem_modelsetup as modelsetup
Expand Down
42 changes: 28 additions & 14 deletions pygem/bin/run/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import os
import sys
import time
import warnings

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -457,6 +458,7 @@ def run(list_packed_vars):
gcm_elev_adj = gcm_elev
gcm_temp_adj = gcm_temp[:, sim_idx_start:]
gcm_prec_adj = gcm_prec[:, sim_idx_start:]
gcm_prec_biasadj_frac = np.ones(gcm_prec_adj.shape[0])
# Bias correct based on reference climate data
else:
# OPTION 1: Adjust temp using Huss and Hock (2015), prec similar but addresses for variance and outliers
Expand All @@ -472,14 +474,16 @@ def run(list_packed_vars):
args.ref_startyear,
)
# Precipitation bias correction
gcm_prec_adj, gcm_elev_adj = gcmbiasadj.prec_biasadj_opt1(
ref_prec,
ref_elev,
gcm_prec,
dates_table_ref,
dates_table_full,
args.sim_startyear,
args.ref_startyear,
gcm_prec_adj, gcm_elev_adj, gcm_prec_biasadj_frac = (
gcmbiasadj.prec_biasadj_opt1(
ref_prec,
ref_elev,
gcm_prec,
dates_table_ref,
dates_table_full,
args.sim_startyear,
args.ref_startyear,
)
)
# OPTION 2: Adjust temp and prec using Huss and Hock (2015)
elif args.option_bias_adjustment == 2:
Expand All @@ -494,12 +498,14 @@ def run(list_packed_vars):
args.ref_startyear,
)
# Precipitation bias correction
gcm_prec_adj, gcm_elev_adj = gcmbiasadj.prec_biasadj_HH2015(
ref_prec,
ref_elev,
gcm_prec,
dates_table_ref,
dates_table_full,
gcm_prec_adj, gcm_elev_adj, gcm_prec_biasadj_frac = (
gcmbiasadj.prec_biasadj_HH2015(
ref_prec,
ref_elev,
gcm_prec,
dates_table_ref,
dates_table_full,
)
)
# OPTION 3: Adjust temp and prec using quantile delta mapping, Cannon et al. (2015)
elif args.option_bias_adjustment == 3:
Expand All @@ -524,6 +530,7 @@ def run(list_packed_vars):
args.sim_startyear,
args.ref_startyear,
)
gcm_prec_biasadj_frac = np.ones(gcm_prec_adj.shape[0])

# assert that the gcm_elev_adj is not None
assert gcm_elev_adj is not None, 'No GCM elevation data'
Expand Down Expand Up @@ -640,6 +647,13 @@ def run(list_packed_vars):
'prec': gcm_prec_adj[glac, :],
'lr': gcm_lr[glac, :],
}
fact = gcm_prec_biasadj_frac[glac]
if fact < 0.5 or fact > 2:
warnings.warn(
f'Bias-adjusted GCM precipitation for {glacier_str} differs from that of the refernce climate data by a factor greater than 2x ({round(fact, 2)})',
Warning,
stacklevel=2,
)
gdir.dates_table = dates_table

glacier_area_km2 = fls[0].widths_m * fls[0].dx_meter / 1e6
Expand Down
8 changes: 4 additions & 4 deletions pygem/bin/run/run_spinup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import pandas as pd

# pygem imports
import pygem.setup.config as config
from pygem.setup.config import ConfigManager

# check for config
config.ensure_config()
# instantiate ConfigManager
config_manager = ConfigManager()
# read the config
pygem_prms = config.read_config()
pygem_prms = config_manager.read_config()
from oggm import tasks, workflow

import pygem.pygem_modelsetup as modelsetup
Expand Down
Loading