forked from MajidBenam/seshat
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from edwardchalstrey1/adding-docstrings
Tidy initial docs PR
- Loading branch information
Showing
41 changed files
with
5,556 additions
and
726 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Visualise Cliopatria shape dataset | ||
|
||
Cliopatria is the shape dataset used by the Seshat Global History Databank website. It can also be explored in a local Jupyter notebook running on your local machine by following these instructions. | ||
|
||
1. Ensure you have a working installation of Python 3 and Conda. If not, [download Anaconda](https://docs.anaconda.com/free/anaconda/install/index.html), which should give you both | ||
- Note: you can use a different tool for creating a Python virtual environment than conda (e.g. venv) if you prefer | ||
|
||
2. Set up the required virtual environment, install packages into it and create a jupyter kernel. | ||
- Conda example: | ||
``` | ||
conda create --name cliopatria python=3.11 | ||
conda activate cliopatria | ||
pip install -r requirements.txt | ||
python -m ipykernel install --user --name=cliopatria --display-name="Python (cliopatria)" | ||
``` | ||
- Note: This will install Geopandas 0.13.2, but if you [install from source](https://geopandas.org/en/stable/getting_started/install.html#installing-from-source) it's much faster with version 1.0.0 (unreleased on pip as of 18th June 2024) | ||
3. Open the `cliopatria.ipynb` notebook with Jupyter (or another application that can run notebooks such as VSCode). | ||
- `jupyter lab` (or `jupyter notebook`) | ||
- Note: make sure the notebook Python kernel is using the virtual environment you created (click top right) | ||
4. Follow the instructions in the notebook. |
This file contains 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 |
---|---|---|
@@ -0,0 +1,144 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Cliopatria viewer\n", | ||
"\n", | ||
"1. To get started, download a copy of the Cliopatria dataset from here: `[INSERT LINK]`\n", | ||
"2. Move the downloaded dataset to an appropriate location on your machine and pass in the paths in the code cell below and run\n", | ||
"3. Run the subsequent cells of the notebook\n", | ||
"4. Play around with both the GeoDataFrame (gdf) and the rendered map\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cliopatria_geojson_path = \"../data/cliopatria_composite_unique_nonsimplified.geojson_06052024/cliopatria_composite_unique_nonsimplified.geojson\"\n", | ||
"cliopatria_json_path = \"../data/cliopatria_composite_unique_nonsimplified.geojson_06052024/cliopatria_composite_unique_nonsimplified_name_years.json\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from map_functions import cliopatria_gdf, display_map" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Load the Cliopatria data to a GeoDataFrame including end years for each shape\n", | ||
"gdf = cliopatria_gdf(cliopatria_geojson_path, cliopatria_json_path)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Play with the data on the map\n", | ||
"\n", | ||
"**Notes**\n", | ||
"- The slider is a bit buggy, the best way to change year is to enter a year in the box and hit enter. Use minus numbers for BCE.\n", | ||
"- The map is also displayed thrice for some reason!\n", | ||
"- Initial attempts to implement a play button similar to the website code failed, but that may not be needed here.\n", | ||
"- Click the shapes to reveal the polity display names, using the same logic used in the website code - see `map_functions.py`" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "a95aced3593446ceb228a171178f978b", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"IntText(value=0, description='Year:')" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "80c96982f4a34628b3026e9f853a6af9", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"IntSlider(value=0, description='Year:', max=2024, min=-3400)" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "44078fdd8e91499bad99d7fd38b76a65", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"Output()" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/Users/echalstrey/.pyenv/versions/3.11.4/lib/python3.11/site-packages/geopandas/geodataframe.py:1538: SettingWithCopyWarning: \n", | ||
"A value is trying to be set on a copy of a slice from a DataFrame.\n", | ||
"Try using .loc[row_indexer,col_indexer] = value instead\n", | ||
"\n", | ||
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", | ||
" super().__setitem__(key, value)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"display_year = 0\n", | ||
"display_map(gdf, display_year)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python (cliopatria1)", | ||
"language": "python", | ||
"name": "cliopatria1" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.