diff --git a/.gitignore b/.gitignore index 4b5a0be17..d372337d1 100644 --- a/.gitignore +++ b/.gitignore @@ -220,7 +220,6 @@ pulumi/logs pulumi/Pulumi.seshat.yaml scripts .DS_Store -*.ipynb docs/source/api/seshat/ docs/source/api/custom_filters/ \ No newline at end of file diff --git a/notebooks/README.md b/cliopatria/README.md similarity index 96% rename from notebooks/README.md rename to cliopatria/README.md index 7c3275dee..4225ef17d 100644 --- a/notebooks/README.md +++ b/cliopatria/README.md @@ -2,6 +2,8 @@ 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 diff --git a/cliopatria/cliopatria.ipynb b/cliopatria/cliopatria.ipynb new file mode 100644 index 000000000..56b0dcca5 --- /dev/null +++ b/cliopatria/cliopatria.ipynb @@ -0,0 +1,94 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Cliopatria viewer\n", + "\n", + "1. Download and unzip the Cliopatria dataset.\n", + "2. Update the Cliopatria GeoJSON file with colours and other properties required by Seshat:\n", + " ```\n", + " python cliopatria/convert_data.py /path/to/cliopatria.geojson\n", + " ```\n", + " Note: this will create a new file with the same name but with the suffix \"_seshat_processed.geojson\"\n", + "3. Run the subsequent cells of this notebook\n", + "4. Play around with both the GeoDataFrame (gdf) and the rendered map\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Note: update this path to the location of the cliopatria data\n", + "cliopatria_geojson_path = \"../data/cliopatria_07052024/cliopatria_composite_unique_simplified_seshat_processed.geojson\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Import necessary libraries\n", + "from map_functions import display_map\n", + "import geopandas as gpd" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Load the processed Cliopatria data to a GeoDataFrame with geopandas\n", + "gdf = gpd.read_file(cliopatria_geojson_path)\n", + "gdf.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Play with the data on the map\n", + "\n", + "**Notes**\n", + "- Use minus numbers for BCE.\n", + "- Click the shapes to reveal the polity display names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "display_year = 1217\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 +} diff --git a/notebooks/map_functions.py b/cliopatria/map_functions.py similarity index 100% rename from notebooks/map_functions.py rename to cliopatria/map_functions.py diff --git a/notebooks/requirements.txt b/cliopatria/requirements.txt similarity index 100% rename from notebooks/requirements.txt rename to cliopatria/requirements.txt diff --git a/docs/source/getting-started/setup/cloud/pulumi.rst b/docs/source/getting-started/setup/cloud/pulumi.rst index c9c4f6e38..c87c1f12e 100644 --- a/docs/source/getting-started/setup/cloud/pulumi.rst +++ b/docs/source/getting-started/setup/cloud/pulumi.rst @@ -294,6 +294,18 @@ In order to restore the database from the dump, run the following command: $ sudo psql -U postgres < ~/seshat.dump +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +[Optional] manual step 4.1: Update the database with the latest shape data +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you need to update the database with the latest shape datasets, you can do so by following the instructions in `spatialdb.rst <../spatialdb.rst>`_. + +You can first upload the data files required to the VM using ``scp``: + +.. code-block:: bash + + $ scp -i ~/.ssh/id_rsa path/to/datafile webadmin@:location_on_vm/datafile + Manual step 5: Run the Django app ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/source/getting-started/setup/local/ubuntu.rst b/docs/source/getting-started/setup/local/ubuntu.rst index 3025dc530..25556f514 100644 --- a/docs/source/getting-started/setup/local/ubuntu.rst +++ b/docs/source/getting-started/setup/local/ubuntu.rst @@ -248,11 +248,11 @@ The file should look like this: .. code-block:: - NAME= - USER=postgres - HOST=localhost - PORT=5432 - PASSWORD= + DB_NAME= + DB_USER=postgres + DB_HOST=localhost + DB_PORT=5432 + DB_PASSWORD= Step 10: Migrate the database diff --git a/notebooks/cliopatria.ipynb b/notebooks/cliopatria.ipynb deleted file mode 100644 index d5ae751eb..000000000 --- a/notebooks/cliopatria.ipynb +++ /dev/null @@ -1,314 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Cliopatria viewer\n", - "\n", - "1. Download and unzip the Cliopatria dataset.\n", - "2. Update the Cliopatria GeoJSON file with colours and other properties required by Seshat:\n", - " ```\n", - " python cliopatria/convert_data.py /path/to/cliopatria.geojson\n", - " ```\n", - " Note: this will create a new file with the same name but with the suffix \"_seshat_processed.geojson\"\n", - "3. Run the subsequent cells of this notebook\n", - "4. Play around with both the GeoDataFrame (gdf) and the rendered map\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "# Note: update this path to the location of the cliopatria data\n", - "cliopatria_geojson_path = \"../data/cliopatria_07052024/cliopatria_composite_unique_simplified_seshat_processed.geojson\"\n", - "cliopatria_geojson_path_unprocessed = \"../data/cliopatria_07052024/cliopatria_composite_unique_simplified.geojson\"" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "# Import necessary libraries\n", - "from map_functions import display_map\n", - "import geopandas as gpd" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
NameFromYearToYearAreaTypeWikipediaSeshatIDMemberOfComponentsDisplayNameColorPolityStartYearPolityEndYeargeometry
0Sumerian City-States-3400-320122083.609657POLITYHistory of SumerSumerian City-States#08fd2a-3400-1761POLYGON ((46.58681 31.27192, 46.43482 31.27192...
1Sumerian City-States-3200-300135508.841506POLITYHistory of SumerSumerian City-States#08fd2a-3400-1761POLYGON ((46.87564 31.14338, 46.55646 31.65753...
2Elam-3200-27014919.440675POLITYElamElam#ff00ff-3200-601POLYGON ((48.65172 32.55735, 48.34636 32.55735...
3Sumerian City-States-3000-270145135.556672POLITYHistory of SumerSumerian City-States#08fd2a-3400-1761POLYGON ((46.47702 30.30789, 46.62852 30.30789...
4Early Dynastic Period of Egypt-3000-270192480.979261POLITYEarly Dynastic Period (Egypt)eg_dynasty_1Early Dynastic Period of Egypt#0971fa-3000-2501POLYGON ((32.90918 30.17935, 32.92628 30.43643...
\n", - "
" - ], - "text/plain": [ - " Name FromYear ToYear Area Type \\\n", - "0 Sumerian City-States -3400 -3201 22083.609657 POLITY \n", - "1 Sumerian City-States -3200 -3001 35508.841506 POLITY \n", - "2 Elam -3200 -2701 4919.440675 POLITY \n", - "3 Sumerian City-States -3000 -2701 45135.556672 POLITY \n", - "4 Early Dynastic Period of Egypt -3000 -2701 92480.979261 POLITY \n", - "\n", - " Wikipedia SeshatID MemberOf Components \\\n", - "0 History of Sumer \n", - "1 History of Sumer \n", - "2 Elam \n", - "3 History of Sumer \n", - "4 Early Dynastic Period (Egypt) eg_dynasty_1 \n", - "\n", - " DisplayName Color PolityStartYear PolityEndYear \\\n", - "0 Sumerian City-States #08fd2a -3400 -1761 \n", - "1 Sumerian City-States #08fd2a -3400 -1761 \n", - "2 Elam #ff00ff -3200 -601 \n", - "3 Sumerian City-States #08fd2a -3400 -1761 \n", - "4 Early Dynastic Period of Egypt #0971fa -3000 -2501 \n", - "\n", - " geometry \n", - "0 POLYGON ((46.58681 31.27192, 46.43482 31.27192... \n", - "1 POLYGON ((46.87564 31.14338, 46.55646 31.65753... \n", - "2 POLYGON ((48.65172 32.55735, 48.34636 32.55735... \n", - "3 POLYGON ((46.47702 30.30789, 46.62852 30.30789... \n", - "4 POLYGON ((32.90918 30.17935, 32.92628 30.43643... " - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Load the processed Cliopatria data to a GeoDataFrame with geopandas\n", - "gdf = gpd.read_file(cliopatria_geojson_path)\n", - "gdf.head()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Play with the data on the map\n", - "\n", - "**Notes**\n", - "- Use minus numbers for BCE.\n", - "- Click the shapes to reveal the polity display names" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "d7f432ca0bd7414da4a85447ca5c1e9c", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "IntText(value=1217, description='Year:')" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "68a32e22a5a34bf1a32c06257b673c63", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "IntSlider(value=1217, description='Year:', max=2024, min=-3400)" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "f6835bbb5f014eed913fb6a1cba5dc6f", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "RadioButtons(description='Display:', options=('Polities', 'Components'), value='Polities')" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "32671fb04ee24993b4d299e0ecb7df5b", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Output()" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display_year = 1217\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 -}