Skip to content

Commit

Permalink
resolving issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mmann1123 committed Aug 2, 2023
1 parent 405fcd6 commit 6281863
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 301 deletions.
19 changes: 17 additions & 2 deletions pygis/docs/b_about_py.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ Python is free and open source, with development coordinated through the
Python has experienced rapid adoption in the last decade and is now one
of the most commonly used programming languages.

Popular textbooks on Python programming include {cite}`guttag2016introduction` and {cite}`matthes2019python`.
Popular textbooks on Python programming include:

Introduction to Computation and Programming Using Python, Second Edition
With Application to Understanding Data
By John V. Guttag

Python Crash Course, 3rd Edition
A Hands-On, Project-Based Introduction to Programming
by Eric Matthes


### Common Uses

Expand Down Expand Up @@ -60,6 +69,9 @@ measure of the relative popularity of Python

```{figure} /_static/lecture_specific/about_py/python_vs_matlab.png
:scale: 72%
:name: python_vs_matlab
:alt: plot showing increasing popularity of python relative to matlab
:caption: Python's increasing popularity over time.
```

The figure indicates not only that Python is widely used but also that
Expand All @@ -75,6 +87,9 @@ library for data analysis with Python has exploded, as seen here.

```{figure} /_static/lecture_specific/about_py/pandas_vs_matlab.png
:scale: 23%
:name: pandas_vs_matlab
:alt: plot showing increasing popularity of pandas relative to matlab
:caption: Pandas increasing popularity over time.
```

Note that pandas takes off in 2012, which is the same year that we see
Expand All @@ -91,7 +106,7 @@ Overall, it\'s clear that
Python is a [high-level language](https://en.wikipedia.org/wiki/High-level_programming_language)
suitable for rapid development.

It has a relatively small core language supported by many libraries.
It has a relatively small core language supported by many libraries. For instance run the following [The Zen of Python (poem)](https://www.online-python.com/4MW2mnxufk) online.

Multiple programming styles are supported (procedural, object-oriented, functional, etc.)

Expand Down
93 changes: 90 additions & 3 deletions pygis/docs/b_getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ in a Jupyter notebook
```{figure} /_static/lecture_specific/getting_started/jp_demo.png
:scale: 50%
:name: jp_demo
A Jupyter notebook viewed in the browser
:alt: A Jupyter notebook viewed in the browser
:caption: A Jupyter notebook viewed in the browser
```

While Jupyter isn\'t the only way to code in Python, it\'s great for
Expand All @@ -136,6 +136,8 @@ If you use the second option, you will see something like this

```{figure} /_static/lecture_specific/getting_started/starting_nb.png
:scale: 50%
:caption: Terminal window
:alt: image of an empty terminal window
```

The output tells us the notebook is running at `http://localhost:8888/`
Expand All @@ -152,6 +154,8 @@ looks something like this

```{figure} /_static/lecture_specific/getting_started/nb.png
:scale: 50%
:caption: Jupyter notebook file browser
:alt: image of a web browser with a jupyter notebook file browser
```

What you see here is called the Jupyter *dashboard*.
Expand All @@ -166,6 +170,8 @@ Here\'s what shows up on our machine:

```{figure} /_static/lecture_specific/getting_started/nb2.png
:scale: 50%
:caption: Jupyter notebook cell
:alt: image of a jupyter notebook cell
```

The notebook displays an *active cell*, into which you can type Python
Expand All @@ -190,6 +196,8 @@ instead of the usual `Enter`.

```{figure} /_static/lecture_specific/getting_started/nb3.png
:scale: 50%
:caption: Running a cell
:alt: image of a jupyter notebook cell with a green border and executed cells
```

(Note: There are also menu and button options for running code in a cell
Expand Down Expand Up @@ -289,6 +297,8 @@ For example, here we type `np.ran` and hit Tab

```{figure} /_static/lecture_specific/getting_started/nb6.png
:scale: 50%
:caption: Tab completion in a notebook
:alt: image of a jupyter notebook cell demonstrating tab completion
```

Jupyter offers up the two possible completions, `random` and `rank`.
Expand All @@ -306,6 +316,8 @@ Documentation appears in a split window of the browser, like so

```{figure} /_static/lecture_specific/getting_started/nb6a.png
:scale: 50%
:caption: On-line help in a notebook
:alt: image of a jupyter notebook cell demonstrating on-line help
```

Clicking on the top right of the lower split closes the on-line help.
Expand All @@ -320,6 +332,9 @@ code

```{figure} /_static/lecture_specific/getting_started/nb7.png
:scale: 50%
:caption: Markdown in a notebook
:alt: image of a jupyter notebook cell demonstrating markdown using latex equations
```

Next we `Esc` to enter command mode and then type `m` to indicate that
Expand All @@ -333,8 +348,11 @@ Now we `Shift+Enter` to produce this

```{figure} /_static/lecture_specific/getting_started/nb8.png
:scale: 50%
:caption: Markdown rendered in a notebook
:alt: image of a jupyter notebook cell demonstrating markdown rendered using latex equations
```


### Sharing Notebooks

Notebook files are just text files structured in
Expand All @@ -353,5 +371,74 @@ Save it somewhere, navigate to it from the Jupyter dashboard and then
run as discussed above.


Sure! Let's add a section using Myst Markdown to explain how to access and use Google Colab.



# Using Google Colab

## Overview

Google Colab is a cloud-based Jupyter notebook environment provided by Google. It allows you to write and execute Python code, similar to Jupyter Notebooks, but without the need for local installations. Google Colab provides free access to computing resources, including GPUs and TPUs, which can be beneficial for resource-intensive tasks.

## Accessing Google Colab

To access Google Colab, follow these steps:

1. Open a web browser and navigate to [Google Colab](https://colab.research.google.com/).
2. Sign in to your Google account or create one if you don't have it already.

## Creating a New Colab Notebook

Once you are signed in, you can create a new Colab notebook:

1. Click on the "NEW NOTEBOOK" button on the left sidebar or go to "File" > "New notebook."

## Running Code in Colab

Running code in Google Colab is similar to Jupyter Notebooks. You can create code cells and execute them using Shift+Enter or by clicking the "Play" button in the top left of each cell.

```{code-cell} ipython3
print("Hello, Google Colab!")
```

```{code-cell} ipython3
# Basic Python code example
for i in range(5):
print("Count:", i)
```

## Saving and Sharing Your Colab Notebook

Google Colab automatically saves your notebook in your Google Drive. To save a copy to your local machine or share the notebook with others, go to "File" > "Download" or "File" > "Share."

## GPU and TPU Support

Google Colab provides free access to GPUs and TPUs (Tensor Processing Units) to accelerate computations. To use GPU or TPU, go to "Runtime" > "Change runtime type" and select the desired hardware accelerator.

## Accessing External Data

You can access external data from Google Drive, GitHub, or other online sources directly from a Colab notebook. For instance, you can mount your Google Drive and access files using the following code:

```{code-cell} ipython3
from google.colab import drive
drive.mount('/content/drive')
```

## Installing Additional Libraries

Most popular Python libraries come pre-installed in Google Colab. However, if you need to install additional libraries, you can use the pip package manager directly in a code cell:

```{code-cell} ipython3
!pip install pandas
```

## Limitations

While Google Colab is a powerful tool, it does have some limitations. Colab sessions may disconnect after a period of inactivity, and resources like GPU/TPU availability might be limited during peak usage.

**Importantly** some libraries used in this textbook, for instance `geowombat` are not easily installed on google colabs.


## Attribution
The above lesson was pulled directly from work by [Thomas J. Sargent & John Stachurski](https://python-programming.quantecon.org/about_py.html)
The above lesson was pulled and adapted from work by [Thomas J. Sargent & John Stachurski](https://python-programming.quantecon.org/about_py.html)
6 changes: 5 additions & 1 deletion pygis/docs/b_intro_py.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ kernelspec:

# Welcome - Let's get started

This section is an introduction to spatial Python, starting with the basics of Python programming. It covers the setup of a standard Python environment and provides an introductory example to help learners get acquainted with Python concepts. The section encourages learners to explore further and learn more about spatial Python methods beyond the basics.

This section will answer a few basic questions about python:
- What is python?
- How do we use it?
- How can we extend its functionality?
- Utilize and extend the programming language python


11 changes: 7 additions & 4 deletions pygis/docs/b_learn_more.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ kernelspec:

# Learn More

We're about ready to wrap up this brief course on Python for scientific
computing.

In this last lecture we give some pointers to the major scientific libraries
In this last introductory section we give some pointers to the major scientific libraries
and suggestions for further reading.


Expand Down Expand Up @@ -93,18 +90,24 @@ Example 2D plot with embedded LaTeX annotations

```{figure} /_static/lecture_specific/about_py/qs.png
:scale: 55%
:caption: Histogram plot
:alt: Image three histograms demonstrating different distributions
```

Example contour plot

```{figure} /_static/lecture_specific/about_py/bn_density1.png
:scale: 55%
:caption: Contour plot
:alt: Image of a contour plot indicating 3 dimensions of data
```

Example 3D plot

```{figure} /_static/lecture_specific/about_py/career_vf.png
:scale: 80%
:caption: 3D plot
:alt: Image of a 3D plot with a surface
```

More examples can be found in the [Matplotlib thumbnail
Expand Down
Loading

0 comments on commit 6281863

Please sign in to comment.