-
Notifications
You must be signed in to change notification settings - Fork 2
Update download link and remove unnecessary cell #17
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
Open
sanika-vaze
wants to merge
3
commits into
ClimateImpactLab:main
Choose a base branch
from
sanika-vaze:update-download-link-and-remove-cell
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,20 +97,78 @@ | |
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "dbff1f30-3dd4-4666-9df2-5358f456f5eb", | ||
| "id": "3207b1e9-62fd-43b1-8265-a923d4ab8eb7", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the same changes made in #16 (moving the GADM cell) are repeated in this PR, and I don't see the removal of the mangroves section. |
||
| "metadata": {}, | ||
| "source": [ | ||
| "## Get country codes from GADM" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 9, | ||
| "id": "994246ad-0616-43c7-a4b8-675c2a2e1d65", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "## Mangroves" | ||
| "ccode_mapping = (\n", | ||
| " read_shapefile(sset.PATH_GADM, layer=0)\n", | ||
| " .set_index(\"COUNTRY\")\n", | ||
| " .GID_0.rename(\"ccode\")\n", | ||
| " .rename_axis(\"name\")\n", | ||
| ")\n", | ||
| "# drop numerical china/india/pakistan GID_0's\n", | ||
| "ccode_mapping = ccode_mapping[ccode_mapping.str[1] != \"0\"]\n", | ||
| "\n", | ||
| "# add on manaully added segments (which account for uninhabited areas not in GADM)\n", | ||
| "ccode_mapping = pd.concat(\n", | ||
| " (ccode_mapping, pd.read_parquet(sset.PATH_SEG_PTS_MANUAL).ccode)\n", | ||
| ")\n", | ||
| "\n", | ||
| "# add some manual mappers\n", | ||
| "# Netherlands Antilles in CIA WFB corresponds to these three (not ABW)\n", | ||
| "manual = sset.CCODE_MANUAL.copy()\n", | ||
| "manual[\"Netherlands Antilles\"] = \"BES+CUW+SXM\"\n", | ||
| "ccode_mapping = pd.concat([ccode_mapping, manual]).sort_index()\n", | ||
| "\n", | ||
| "# Handle no-accent names\n", | ||
| "alt_index = (\n", | ||
| " ccode_mapping.index.str.normalize(\"NFKD\")\n", | ||
| " .str.encode(\"ascii\", errors=\"ignore\")\n", | ||
| " .astype(str)\n", | ||
| ")\n", | ||
| "alt = pd.Series(ccode_mapping.values, index=alt_index, name=\"ccode\")\n", | ||
| "ccode_mapping = (\n", | ||
| " pd.concat((ccode_mapping, alt))\n", | ||
| " .reset_index()\n", | ||
| " .drop_duplicates()\n", | ||
| " .set_index(\"name\")\n", | ||
| " .ccode.sort_index()\n", | ||
| ")\n", | ||
| "\n", | ||
| "# getting list of valid ccodes including some previously uncaptured mixtures (i.e.\n", | ||
| "# France + overseas depts)\n", | ||
| "valid_ccodes = np.setdiff1d(\n", | ||
| " np.unique(\n", | ||
| " np.concatenate(\n", | ||
| " (\n", | ||
| " ccode_mapping.unique(),\n", | ||
| " [k for v in sset.PPP_CCODE_IF_MSNG.values() for k in v],\n", | ||
| " )\n", | ||
| " )\n", | ||
| " ),\n", | ||
| " sset.EXCLUDED_ISOS,\n", | ||
| ")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "1bc40d4b-ab6f-40de-b37f-cef0b2cffe6c", | ||
| "execution_count": 12, | ||
| "id": "f0525373-d81a-4710-b729-de857effa1ef", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "this = gpd.GeoDataFrame(geometry=[read_shapefile(sset.PATH_GLOBAL_MANGROVES_RAW).make_valid().unary_union], crs=4326).to_parquet(sset.PATH_GLOBAL_MANGROVES_INT)" | ||
| "save(pd.DataFrame({\"ccode\": valid_ccodes}), sset.PATH_ALL_VALID_HIST_CCODES)\n", | ||
| "save(ccode_mapping.to_frame(), sset.PATH_HIST_CCODE_MAPPING)" | ||
| ] | ||
| }, | ||
| { | ||
|
|
@@ -242,82 +300,6 @@ | |
| "save_geoparquet(adm1, sset.PATH_GADM_ADM1_INT)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "3207b1e9-62fd-43b1-8265-a923d4ab8eb7", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Get country codes from GADM" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 9, | ||
| "id": "994246ad-0616-43c7-a4b8-675c2a2e1d65", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "ccode_mapping = (\n", | ||
| " read_shapefile(sset.PATH_GADM, layer=0)\n", | ||
| " .set_index(\"COUNTRY\")\n", | ||
| " .GID_0.rename(\"ccode\")\n", | ||
| " .rename_axis(\"name\")\n", | ||
| ")\n", | ||
| "# drop numerical china/india/pakistan GID_0's\n", | ||
| "ccode_mapping = ccode_mapping[ccode_mapping.str[1] != \"0\"]\n", | ||
| "\n", | ||
| "# add on manaully added segments (which account for uninhabited areas not in GADM)\n", | ||
| "ccode_mapping = pd.concat(\n", | ||
| " (ccode_mapping, pd.read_parquet(sset.PATH_SEG_PTS_MANUAL).ccode)\n", | ||
| ")\n", | ||
| "\n", | ||
| "# add some manual mappers\n", | ||
| "# Netherlands Antilles in CIA WFB corresponds to these three (not ABW)\n", | ||
| "manual = sset.CCODE_MANUAL.copy()\n", | ||
| "manual[\"Netherlands Antilles\"] = \"BES+CUW+SXM\"\n", | ||
| "ccode_mapping = pd.concat([ccode_mapping, manual]).sort_index()\n", | ||
| "\n", | ||
| "# Handle no-accent names\n", | ||
| "alt_index = (\n", | ||
| " ccode_mapping.index.str.normalize(\"NFKD\")\n", | ||
| " .str.encode(\"ascii\", errors=\"ignore\")\n", | ||
| " .astype(str)\n", | ||
| ")\n", | ||
| "alt = pd.Series(ccode_mapping.values, index=alt_index, name=\"ccode\")\n", | ||
| "ccode_mapping = (\n", | ||
| " pd.concat((ccode_mapping, alt))\n", | ||
| " .reset_index()\n", | ||
| " .drop_duplicates()\n", | ||
| " .set_index(\"name\")\n", | ||
| " .ccode.sort_index()\n", | ||
| ")\n", | ||
| "\n", | ||
| "# getting list of valid ccodes including some previously uncaptured mixtures (i.e.\n", | ||
| "# France + overseas depts)\n", | ||
| "valid_ccodes = np.setdiff1d(\n", | ||
| " np.unique(\n", | ||
| " np.concatenate(\n", | ||
| " (\n", | ||
| " ccode_mapping.unique(),\n", | ||
| " [k for v in sset.PPP_CCODE_IF_MSNG.values() for k in v],\n", | ||
| " )\n", | ||
| " )\n", | ||
| " ),\n", | ||
| " sset.EXCLUDED_ISOS,\n", | ||
| ")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 12, | ||
| "id": "f0525373-d81a-4710-b729-de857effa1ef", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "save(pd.DataFrame({\"ccode\": valid_ccodes}), sset.PATH_ALL_VALID_HIST_CCODES)\n", | ||
| "save(ccode_mapping.to_frame(), sset.PATH_HIST_CCODE_MAPPING)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "647b195b", | ||
|
|
@@ -1471,7 +1453,7 @@ | |
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython3", | ||
| "version": "3.11.7" | ||
| "version": "3.12.2" | ||
| }, | ||
| "widgets": { | ||
| "application/vnd.jupyter.widget-state+json": { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked this link and it looks like it's not correct - sorry for sending you the wrong one. If you use this link, you'd see that it goes to the "report" rather than the "databook". Here's a link to the databook:
https://rev01ution.red/wp-content/uploads/2024/03/global-wealth-databook-2023-ubs.pdf
Also, the "urldefense" part of the URL is just something that comes through on email clients so can be removed. But let's use the link above, otherwise it will be downloading the wrong thing (which is why you didn't see Table 2-1 or Table 2-2 when you looked at it)