Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates argument in load_regions utility from bool to region name #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion notebooks/05_aggregate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
},
"outputs": [],
"source": [
"regions_df = load_regions(extension=True)\n",
"regions_df = load_regions(extension='se-europe')\n",
"# use an area-preserving projection\n",
"buffer = (\n",
" 0.5 # padding to expand bounds to ensure you grab the data covering each region\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/06_bias_correction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
},
"outputs": [],
"source": [
"regions_df = load_regions(extension=True)"
"regions_df = load_regions(extension='se-europe')"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/07_solar_radiation_wind.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"metadata": {},
"outputs": [],
"source": [
"regions_df = load_regions(extension=True)\n",
"regions_df = load_regions(extension='se-europe')\n",
"buffer = (\n",
" 0.5 # padding to expand bounds to ensure you grab the data covering each region\n",
")\n",
Expand Down
25 changes: 22 additions & 3 deletions notebooks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ def calc_sparse_weights(
weights_sparse = ds_weights.unstack(sparse=True, fill_value=0.0).weights
return weights_sparse

from typing import Optional, Literal

def load_regions(extension=False):
def load_regions(extension: Literal['all', 'se-europe', 'central-asia'] = 'all'):
"""
Load in the city and regions that to use for aggregation.
"""
Expand All @@ -293,14 +294,32 @@ def load_regions(extension=False):
# use an area-preserving projection
crs_area = "ESRI:53034"
regions_df = regions_df.to_crs(crs_area)
if extension:

if extension == 'all': # should this be 'in'
return regions_df
elif extension == 'central-asia':
extension_cities = pd.read_csv(
"s3://carbonplan-climate-impacts/extreme-heat-extension/v1.0/inputs/<_______TODO_____ADD_PATH_TO_CENTRAL_ASIAN_CITIES_______>.csv"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orianac once we get the list of cities for central Asia, we can update this line.

)
regions_df = regions_df[
regions_df["ID_HDC_G0"].isin(extension_cities["ID_HDC_G0"].values)
]
return regions_df
elif extension == 'se-europe':
extension_cities = pd.read_csv(
"s3://carbonplan-climate-impacts/extreme-heat-extension/v1.0/inputs/SE_Europe_city_selection.csv"
)
regions_df = regions_df[
regions_df["ID_HDC_G0"].isin(extension_cities["ID_HDC_G0"].values)
]
return regions_df

return regions_df
else:
raise ValueError(f"extension: {extension} not in ['all', 'se-europe', 'central-asia']")






def remove_360_longitudes(ds):
Expand Down