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

Tidy initial docs PR #2

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
df53cdc
supress current borders spinner
edwardchalstrey1 May 24, 2024
0a37c30
stop loading wheel after one year loaded
edwardchalstrey1 May 24, 2024
70c2eb4
bring back loading indicator when adjusting the year if not all polit…
edwardchalstrey1 May 24, 2024
b3c4732
reload world_map_one_year multiple times
edwardchalstrey1 May 24, 2024
ae5fbfc
made the option to add suc and prec pols more userfriendly
MajidBenam May 28, 2024
07503fb
update gitignore to allow notebooks
edwardchalstrey1 May 31, 2024
c658042
initial setup
edwardchalstrey1 May 31, 2024
ddd9d50
note
edwardchalstrey1 Jun 3, 2024
e4ca9ba
specify 3.11
edwardchalstrey1 Jun 3, 2024
2550efa
jupyter kernel instructions
edwardchalstrey1 Jun 3, 2024
ba76735
basic notebook works
edwardchalstrey1 Jun 3, 2024
4a86dad
colours
edwardchalstrey1 Jun 3, 2024
725437d
remove extra cells
edwardchalstrey1 Jun 3, 2024
59ddce9
translucent fill
edwardchalstrey1 Jun 3, 2024
f113e92
add end years
edwardchalstrey1 Jun 3, 2024
eb64d49
load shapes for a particular year
edwardchalstrey1 Jun 3, 2024
90c4ea3
map function
edwardchalstrey1 Jun 3, 2024
daef20f
use whole world map limits
edwardchalstrey1 Jun 3, 2024
a64d349
finish prev commit
edwardchalstrey1 Jun 3, 2024
041ce53
add gadm
edwardchalstrey1 Jun 3, 2024
fa01014
use cartodb basemap
edwardchalstrey1 Jun 3, 2024
9041fbd
adjust coordinates properly for basemap
edwardchalstrey1 Jun 3, 2024
c8dd5e4
use folium
edwardchalstrey1 Jun 3, 2024
47661b2
zoom folium map correctly
edwardchalstrey1 Jun 3, 2024
0061b49
separate by colours properly
edwardchalstrey1 Jun 3, 2024
9e65ff6
add a widget for the year
edwardchalstrey1 Jun 3, 2024
cb0f8f4
add slider
edwardchalstrey1 Jun 3, 2024
c02f98f
made the insertion of descriptions more user friendly
MajidBenam Jun 3, 2024
8543b70
add play button non functional
edwardchalstrey1 Jun 3, 2024
63b2e97
play button works
edwardchalstrey1 Jun 3, 2024
3c04f11
create python functions script
edwardchalstrey1 Jun 3, 2024
ed95c89
move create_map to script
edwardchalstrey1 Jun 3, 2024
76acff4
remove play button bits for now
edwardchalstrey1 Jun 3, 2024
53769c6
accept duplicate plots for now
edwardchalstrey1 Jun 3, 2024
18dd38a
add popup
edwardchalstrey1 Jun 4, 2024
aa4cab8
use same logic as populate_videodata
edwardchalstrey1 Jun 4, 2024
d9fc1d0
remove unused import
edwardchalstrey1 Jun 4, 2024
d0c5f70
separate out the convert_name func
edwardchalstrey1 Jun 4, 2024
4fe4401
update comment
edwardchalstrey1 Jun 4, 2024
6e2a2e3
combine style_function into create_map
edwardchalstrey1 Jun 4, 2024
22d18b1
restore style_function
edwardchalstrey1 Jun 4, 2024
d0c9d01
add DisplayName to the gdf
edwardchalstrey1 Jun 4, 2024
c51378c
remove gadm and play/pause bits
edwardchalstrey1 Jun 4, 2024
aed92d3
create display_map function
edwardchalstrey1 Jun 4, 2024
e81869c
speed up get_polity_shape_content for loop
edwardchalstrey1 Jun 5, 2024
87f4c4d
ignore deprecated simplified_geom
edwardchalstrey1 Jun 5, 2024
fe28a12
big processing speedup but breaks personal union code
edwardchalstrey1 Jun 5, 2024
3b8ba62
remove prints
edwardchalstrey1 Jun 5, 2024
aae22b0
change geom to geom_json in tests
edwardchalstrey1 Jun 5, 2024
f087eac
temp disable hanging test
edwardchalstrey1 Jun 5, 2024
52b8884
create self.geo_square string manually
edwardchalstrey1 Jun 5, 2024
ef399c6
do things the old way for gadm
edwardchalstrey1 Jun 5, 2024
4fe8c49
speed assign_variables_to_shapes from 3.38 to 2.88 s
edwardchalstrey1 Jun 5, 2024
5d7be8a
dont run random_polity_shape when testing
edwardchalstrey1 Jun 6, 2024
47ccace
remove console logs
edwardchalstrey1 Jun 6, 2024
7411a21
Merge branch 'adjust-loading-2' into processing-speedups
edwardchalstrey1 Jun 6, 2024
d716ab5
dont load variables for first set of shapes for one year - but this m…
edwardchalstrey1 Jun 6, 2024
39a8d4b
Revert "dont load variables for first set of shapes for one year - bu…
edwardchalstrey1 Jun 6, 2024
4c2c07e
better way to handle unions
edwardchalstrey1 Jun 6, 2024
27be8b3
remove timers
edwardchalstrey1 Jun 6, 2024
1b81c26
Merge pull request #159 from edwardchalstrey1/processing-speedups
edwardchalstrey1 Jun 6, 2024
2ad9489
Fix `multipass` setup in docs
kallewesterling Jun 6, 2024
23d6c18
Switch from pg_restore to psql in macOS instructions
kallewesterling Jun 6, 2024
7aa32a6
added the new religion tolerance lis_all style and the description ad…
MajidBenam Jun 7, 2024
8963fa9
Merge pull request #161 from kallewesterling/kallewesterling/issue158
edwardchalstrey1 Jun 18, 2024
830f81c
Merge pull request #162 from kallewesterling/kallewesterling/issue160
edwardchalstrey1 Jun 18, 2024
56bdbfa
Merge branch 'dev' into clio-notebook
edwardchalstrey1 Jun 18, 2024
ba19701
Area not Area_Km2
edwardchalstrey1 Jun 18, 2024
88bf793
only simplify if you want to
edwardchalstrey1 Jun 18, 2024
b6b31c1
works with geopandas==0.13.2
edwardchalstrey1 Jun 18, 2024
828f000
geopandas instructions
edwardchalstrey1 Jun 18, 2024
c129011
Merge pull request #167 from edwardchalstrey1/clio-notebook
edwardchalstrey1 Jun 18, 2024
e5d65b5
use duration when start or end year missing for absent present vars
edwardchalstrey1 Jun 19, 2024
7182987
rename var
edwardchalstrey1 Jun 19, 2024
9f7e513
format BCE/CE correctly
edwardchalstrey1 Jun 19, 2024
10ecec7
make uncoded and no seshat page the same colour
edwardchalstrey1 Jun 19, 2024
434f886
make switch variable button consistent
edwardchalstrey1 Jun 19, 2024
dbbbc13
add speed in y/s
edwardchalstrey1 Jun 19, 2024
0e662f3
simplify instructions
edwardchalstrey1 Jun 19, 2024
a03693f
update polity map playRate to be same as world map
edwardchalstrey1 Jun 19, 2024
6066bb1
set minZoom
edwardchalstrey1 Jun 19, 2024
cfb886e
restrict map bounds
edwardchalstrey1 Jun 19, 2024
3dba145
move year slider to bottom of polity map
edwardchalstrey1 Jun 19, 2024
d276b4f
add tickmarks
edwardchalstrey1 Jun 19, 2024
b48fbcf
Revert "add tickmarks"
edwardchalstrey1 Jun 19, 2024
61f6441
add a middle year to tickmarks
edwardchalstrey1 Jun 19, 2024
8e84a83
restore 10 tickmarks
edwardchalstrey1 Jun 19, 2024
9ee279a
added ticks badly positioned
edwardchalstrey1 Jun 19, 2024
dc3c90a
correct number of tickmarks
edwardchalstrey1 Jun 19, 2024
27cfaf4
tickmarks are accurate but labels don't line up neatly
edwardchalstrey1 Jun 21, 2024
6bfc52b
center tick values
edwardchalstrey1 Jun 21, 2024
3840371
ticks perfect
edwardchalstrey1 Jun 21, 2024
910cb12
move year controls to left
edwardchalstrey1 Jun 21, 2024
b48c45f
adjust header and year
edwardchalstrey1 Jun 21, 2024
389641e
rearrange controls
edwardchalstrey1 Jun 21, 2024
6f1566f
move year into fieldset
edwardchalstrey1 Jun 21, 2024
187a7c1
put slider below map
edwardchalstrey1 Jun 21, 2024
1df3aa2
fix width issues
edwardchalstrey1 Jun 21, 2024
2675b8e
create setSliderTicks func
edwardchalstrey1 Jun 21, 2024
dc02dd8
works for world map all years but not initial
edwardchalstrey1 Jun 21, 2024
dd3cfd2
put slider at bottom of world map
edwardchalstrey1 Jun 24, 2024
d7a13b9
add tick_number as an arg
edwardchalstrey1 Jun 24, 2024
9b3c8fd
update tests to include tick_years
edwardchalstrey1 Jun 24, 2024
858d3ee
remove print
edwardchalstrey1 Jun 24, 2024
5aae546
use tick_years from django
edwardchalstrey1 Jun 24, 2024
2cd74ff
set default tick_number to 20, but 10 for polity map
edwardchalstrey1 Jun 24, 2024
fde5b2c
set slider ticks in world map
edwardchalstrey1 Jun 24, 2024
e604491
update ticks once everything loaded
edwardchalstrey1 Jun 24, 2024
40f3d26
add override_latest_year
edwardchalstrey1 Jun 24, 2024
a0760b5
show initial ticks
edwardchalstrey1 Jun 24, 2024
bbaa7d7
add comment
edwardchalstrey1 Jun 24, 2024
38f9c17
hide slider before all polities loaded
edwardchalstrey1 Jun 24, 2024
5e8f302
fix display year
edwardchalstrey1 Jun 24, 2024
bdf39f7
restore slider initially
edwardchalstrey1 Jun 24, 2024
82a6b95
improve text
edwardchalstrey1 Jun 24, 2024
4c2598d
make previous variable button smaller
edwardchalstrey1 Jun 24, 2024
3c537bc
reduce side panel width
edwardchalstrey1 Jun 24, 2024
623168d
put year at top
edwardchalstrey1 Jun 24, 2024
f6a4063
move speed to centre
edwardchalstrey1 Jun 24, 2024
4c53760
increase size of polity map window
edwardchalstrey1 Jun 24, 2024
919c706
Merge pull request #170 from edwardchalstrey1/aesthetics-19-June
edwardchalstrey1 Jun 24, 2024
6b593c3
change gadm fill colour to white
edwardchalstrey1 Jun 25, 2024
9f1fcaa
Merge branch 'Qing' into Qing-merge-25june
edwardchalstrey1 Jun 25, 2024
509f316
Merge pull request #174 from edwardchalstrey1/Qing-merge-25june
edwardchalstrey1 Jun 25, 2024
4eedf06
link to pulumi docs
edwardchalstrey1 Jun 26, 2024
63a01a4
refactor pulumi stack setup doc
edwardchalstrey1 Jun 26, 2024
48c03f0
de-duplicate pulumi stack info
edwardchalstrey1 Jun 26, 2024
21ead0a
improve virtual env suggestion
edwardchalstrey1 Jun 26, 2024
305ecf3
fix rst link
edwardchalstrey1 Jun 26, 2024
caf3f61
remove hint as link wasn't working
edwardchalstrey1 Jun 26, 2024
1a1b90d
update spatialdb link again
edwardchalstrey1 Jun 26, 2024
09d519f
restore hint and fix link by adding underscore
edwardchalstrey1 Jun 26, 2024
7eb62c1
Merge branch 'dev' into adding-docstrings
edwardchalstrey1 Jun 26, 2024
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
74 changes: 40 additions & 34 deletions docs/source/getting-started/setup/cloud/pulumi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following instructions assume you have the following software installed:

If you need to install Homebrew, you can find instructions on how to do so on `Homebrew's website <https://brew.sh/>`_.

If you don't have Pulumi installed, you can install it using Homebrew.
If you don't have Pulumi installed, follow the `documentation <https://www.pulumi.com/docs/install/>`_ e.g. on a Mac:

.. code-block:: bash

Expand All @@ -65,81 +65,87 @@ Ensure that you are correctly logged in and that the subscription you will use c
$ az account set --subscription "<subscription-id>"


Step 2: Activate Pulumi environment and install relevant packages
Step 2: Create a virtual environment for Pulumi
-----------------------------------------------------------------

.. admonition:: Setting up a Pulumi environment from scratch
:class: dropdown
You can use either Conda or Python's built-in ``venv`` module to create a virtual environment (you could also re-use the environment you set up for Seshat development and install the requirements there).

We assume here that you'll use our provided Pulumi setup (located in the ``/pulumi`` directory in this repository).
.. tabs::

If you're setting up from scratch, you can follow the below steps to set up the Pulumi environment:
.. tab:: Conda example

1. Create a new Python virtual environment:
Create the environment:

.. code-block:: bash
.. code-block:: bash

$ python3 -m venv venv
$ conda create --name seshat_pulumi

2. Activate the virtual environment and install the required packages:
Activate the environment:

.. code-block:: bash

$ source venv/bin/activate
$ pip install -r requirements.txt
.. code-block:: bash

3. Set up a Pulumi stack:

.. code-block:: bash
$ conda activate seshat_pulumi

$ pulumi new azure-python
.. tab:: venv example

.. important::
Create the environment:

In the provided set up in the ``/pulumi`` directory, we have already set up the Pulumi environment and stack for you.
.. code-block:: bash

In the included set up, we:
$ python3 -m venv seshat_pulumi

- Chose a sensible project name: `seshat-dev`
- Chose default stack name
- Chose ``UKSouth`` location
- Made custom edits to the config files for the Seshat app
Activate the environment:

.. code-block:: bash

To activate the provided Pulumi environment and install the required packages, run the following commands:
$ source seshat_pulumi/bin/activate

Install the requirements:

.. code-block:: bash

$ cd pulumi
$ source venv/bin/activate
$ pip install -r requirements.txt
$ pip install -r pulumi/requirements.txt

Step 3: Set up a Pulumi stack
------------------------------

We assume here that you'll use our provided Pulumi setup (located in the ``/pulumi`` directory in this repository).

.. admonition:: Setting up a Pulumi stack from scratch
:class: dropdown

If you're setting up a Pulumi stack from scratch, you can follow the below steps:

1. Initialize a new Pulumi stack:
1. Set up a Pulumi stack for Azure Python:

.. code-block:: bash

$ pulumi new azure-python

2. Initialize a new Pulumi stack:

.. code-block:: bash

$ pulumi stack init <stack-name>

2. Select the stack:
3. Select the stack:

.. code-block:: bash

$ pulumi stack select <stack-name>

.. important::

In the provided set up in the ``/pulumi`` directory, we have already set up the Pulumi stack for you.
In the provided set up in the ``/pulumi`` directory, we have already set up the Pulumi stack for you.

In the included set up, we:

In the included set up, we chose the stack name `seshat`.
- Chose a sensible project name: `seshat-dev`
- Chose the stack name `seshat`
- Chose ``UKSouth`` location
- Made custom edits to the config files for the Seshat app

To set up the Pulumi stack, run the following command:
To set up this Pulumi stack, run the following commands:

.. code-block:: bash

Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting-started/setup/local/macos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Ensure that all Django database migrations have run:
Step 11: Load the shape data
----------------------------

If the shape data tables are not yet populated in your copy of the Seshat core database and you have access to source data, populate one or more of them with the instructions in [spatialdb.rst](../spatialdb.rst).
If the shape data tables are not yet populated in your copy of the Seshat core database and you have access to source data, populate one or more of them with the instructions `here <../spatialdb.rst>`_.


Step 12: Run Django
Expand Down
5 changes: 2 additions & 3 deletions docs/source/getting-started/setup/local/ubuntu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ Setting up Seshat in a local Ubuntu environment
===============================================

.. hint::

Local setup steps have been tested on an M1 Mac and on an Ubuntu VM running on the Mac. Instructions for setting up an Ubuntu VM on a Mac can be found :doc:`here </getting-started/setup/local/macos-ubuntu.rst>`.
Local setup steps have been tested on an M1 Mac and on an Ubuntu VM running on the Mac. Instructions for setting up an Ubuntu VM on a Mac can be found `here <../getting-started/setup/local/macos-ubuntu.rst>`_.


Prerequisites
Expand Down Expand Up @@ -269,7 +268,7 @@ Ensure that all Django database migrations have run:
Step 11: Load the shape data
----------------------------

If the shape data tables are not yet populated in your copy of the Seshat core database and you have access to source data, populate one or more of them with the instructions in [spatialdb.rst](../spatialdb.rst).
If the shape data tables are not yet populated in your copy of the Seshat core database and you have access to source data, populate one or more of them with the instructions `here <../spatialdb.rst>`_.


Step 12: Run Django
Expand Down
21 changes: 21 additions & 0 deletions notebooks/README.md
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.
144 changes: 144 additions & 0 deletions notebooks/cliopatria.ipynb
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
}
Loading