Skip to content

Commit

Permalink
check if cnnected
Browse files Browse the repository at this point in the history
  • Loading branch information
jdebacker committed Aug 3, 2024
1 parent 0d55f44 commit 41d507c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
8 changes: 5 additions & 3 deletions examples/run_og_zaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ogcore import output_plots as op
from ogcore.execute import runner
from ogcore.utils import safe_read_pickle
from ogzaf.utils import is_connected

# Use a custom matplotlib style file for plots
plt.style.use("ogcore.OGcorePlots")
Expand Down Expand Up @@ -50,9 +51,10 @@ def main():
defaults = json.load(file)
p.update_specifications(defaults)
# Update parameters from calibrate.py Calibration class
c = Calibration(p)
updated_params = c.get_dict()
p.update_specifications(updated_params)
if is_connected(): # only update if connected to internet
c = Calibration(p)
updated_params = c.get_dict()
p.update_specifications(updated_params)

# Run model
start_time = time.time()
Expand Down
18 changes: 11 additions & 7 deletions ogzaf/input_output.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
import numpy as np
from ogzaf.utils import is_connected
from ogzaf.constants import CONS_DICT, PROD_DICT

"""
Expand All @@ -8,13 +9,16 @@
# Read in SAM file
storage_options = {"User-Agent": "Mozilla/5.0"}
SAM_path = "https://www.wider.unu.edu/sites/default/files/Data/SASAM-2015-Data-Resource.xlsx"
SAM = pd.read_excel(
SAM_path,
sheet_name="Micro SAM 2015",
skiprows=6,
index_col=0,
storage_options=storage_options,
)
if is_connected():
SAM = pd.read_excel(
SAM_path,
sheet_name="Micro SAM 2015",
skiprows=6,
index_col=0,
storage_options=storage_options,
)
else:
SAM = None


def get_alpha_c(sam=SAM, cons_dict=CONS_DICT):
Expand Down

0 comments on commit 41d507c

Please sign in to comment.