-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.py
executable file
·31 lines (23 loc) · 991 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
utility functions used for permafrost use case
"""
import os
import numpy as np
# installation function
def install_api_key():
home_dir = os.path.expanduser("~")
work_dir = os.getcwd()
# create Topography API key file
topo_key = input("Enter Your OpenTopography API Key: ")
topo_config_path = os.path.join(work_dir, ".opentopography.txt")
with open(topo_config_path, "w") as topo_config_file:
topo_config_file.write(topo_key)
print("OpenTopography API Key file is created at {}.".format(topo_config_path))
# create CDS API key file
cds_key = input("Enter Your CDS API Key: ")
cds_url = "https://cds.climate.copernicus.eu/api"
cds_config_content = "url: {} \nkey: {}".format(cds_url, cds_key)
cds_config_path = os.path.join(home_dir, ".cdsapirc")
with open(cds_config_path, "w") as cds_config_file:
cds_config_file.write(cds_config_content)
print("CDS API Key file is created at {}".format(cds_config_path))