Skip to content

Commit

Permalink
Merge pull request #19 from ClimateImpactLab/bump_dscimv0.2.1
Browse files Browse the repository at this point in the history
Update directory_setup.py to download most recent dscim inputs
  • Loading branch information
kemccusker authored Sep 29, 2022
2 parents 2c0d783 + b9eec4e commit fa73001
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/directory_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def makedir(path):

# Download inputs from internet
print("Downloading input files...")
url = 'https://storage.googleapis.com/climateimpactlab-scc-tool/dscim-epa_input_data/dscim_v0.1.0_inputs.zip'
name = 'dscim_v0.1.0_inputs.zip'
name = 'dscim_v20220929_inputs.zip'
url = 'https://storage.googleapis.com/climateimpactlab-scc-tool/dscim-epa_input_data/' + name
with requests.get(url, stream = True) as r:
r.raise_for_status()
with open(name, 'wb') as f:
Expand All @@ -53,17 +53,17 @@ def makedir(path):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
pbar.update(len(chunk))

print("")
print("Unzipping input files...")
with zipfile.ZipFile('./dscim_v0.1.0_inputs.zip', 'r') as zip_ref:
with zipfile.ZipFile(Path(base) / name, 'r') as zip_ref:
for member in tqdm(zip_ref.infolist()):
try:
zip_ref.extract(member, './')
zip_ref.extract(member, Path(base))
except zipfile.error as e:
pass

if os.path.exists("./dscim_v0.1.0_inputs.zip"):
os.remove("./dscim_v0.1.0_inputs.zip")
if os.path.exists(Path(base) / name):
os.remove(Path(base) / name)
else:
print("Download Failed")

Expand Down

0 comments on commit fa73001

Please sign in to comment.