Skip to content

Commit

Permalink
updated from /home/ucfalew/geog0111:t
Browse files Browse the repository at this point in the history
  • Loading branch information
profLewis committed Oct 2, 2020
1 parent d42413b commit 9737cc2
Show file tree
Hide file tree
Showing 735 changed files with 20,825 additions and 636,813 deletions.
1 change: 1 addition & 0 deletions Docker/small_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ dependencies:
- sphinx-typlog-theme
- mkdocs-rtd-dropdown
- mkdocs-material
- mkdocs-GEOG0111
1 change: 1 addition & 0 deletions bin
21 changes: 11 additions & 10 deletions config/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ nav:
- 015_Python_control.md
- 016_Python_for.md
- 017_Functions.md
- 018_Python_files.md
- 018_Running_Python.md
- 019_Plotting.md
- 200_NASA_MODIS_Earthdata.md
- 201_GoogleEarthEngine.md
plugins:
- git-revision-date-localized
- exclude:
Expand All @@ -40,23 +35,29 @@ plugins:
- "*.nc"
- "*.zip"
- "*.npz"
- "data/ucl/*"
- "*.vrt"
- search
- mkdocs-jupyter:
include_source: true
#- mkdocs-jupyter:
# include_source: true

repo_url: https://github.com/UCL-EO/geog0111
site_author: Prof P. Lewis
site_name: GEOG0111
site_url: https://ucl-eo.github.io/geog0111
theme:
name: readthedocs
favicon: images/ucl.png

#theme:
# favicon: images/ucl.png
# features:
# - search.highlight
# - header.hide
# name: material
theme:
favicon: images/ucl.png
name: material
#theme:
# favicon: images/ucl.png
# name: material
# features:
# - search.highlight
# - header.hide
1 change: 1 addition & 0 deletions config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ sphinx-markdown-tables
sphinx-typlog-theme
mkdocs-rtd-dropdown
mkdocs-material
mkdocs-GEOG0111
1 change: 1 addition & 0 deletions copy
1 change: 1 addition & 0 deletions data
Binary file removed data/Hydrologic_Units.zip
Binary file not shown.
21 changes: 15 additions & 6 deletions docs/001_Notebook_use.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ You will find full, up to date information on this course GEOG0111 on the [UCL c

#### Course load

This course is intended to be 25 % of your course load for the term. You will find fuller information on the [GEOG0111 course moodle page](https://moodle.ucl.ac.uk/course/view.php?id=21495), but that percentage should give you some idea of the amount of effort we are expecting you to put in (on average) per week.
This course is intended to be 25 % of your course load for the term, which equates to at lesast 9 hours per week. This is the typiocal average of effort you should be putting in each week of the course.

You will find fuller information on the [GEOG0111 course moodle page](https://moodle.ucl.ac.uk/course/view.php?id=21495), but that percentage should give you some idea of the amount of effort we are expecting you to put in (on average) per week.

#### Learning

Expand Down Expand Up @@ -47,14 +49,21 @@ There is a useful [cheatsheet](https://www.anaconda.com/wp-content/uploads/2019/

## How we will be using notebooks

We will be using Jupyter notebooks to present course notes and view and run exercises.
We will be using Jupyter notebooks to present course notes and view and run exercises. These will run on the [UCL notebook server](https://jupyter.data-science.rc.ucl.ac.uk/). To connect, you need either:

* a [UCL VPN connection](https://www.ucl.ac.uk/isd/services/get-connected/ucl-virtual-private-network-vpn)
* use [Desktop@UCL](https://www.ucl.ac.uk/isd/services/computers/remote-access/desktopucl-anywhere), open a browser in there, and connect to the server.

In either case, you will need to provide your UCL ISD login and password for both the access method ([UCL VPN connection](https://www.ucl.ac.uk/isd/services/get-connected/ucl-virtual-private-network-vpn) or [Desktop@UCL](https://www.ucl.ac.uk/isd/services/computers/remote-access/desktopucl-anywhere)) and for the Jupyter notebook server.


## Use of Notebooks

### Saving your work

The first thing we want you to do when you open a new notebook is to **make a copy of it in the [`work`](work) folder**.
We recommend that you use the 'traditional' Jupyter notebooks for this course, rather than Jupyter Lab. Both are viable options, but the notebooks, in the folder `notebooks` have features that will not work properly in Jupyter Lab. In essence, if you use the notebooks in the folder `notebooks` Jupyter Lab, the exercise answers will be exposed to you as you go through the notes, whereas they should be hidden. For example:

**You should make a copy of each new notebook when you start.** If you don't, then any work you do may not be there the next time you run the notebook. When you come back to run a notebook again, in a new session, you should run the saved notebook (unless you want to start afresh).
In notebooks, there will be a green button that you have to press to reveal the answer, but in Jupyter Lab, the answer will be directly on show.

## Notebooks


### Cells
Expand Down
8 changes: 8 additions & 0 deletions docs/001_Notebook_use_answers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# 001 Use of Jupyter notebooks : Answers to exercises

#### Exercse 1
This is a test exercise


```python
# and this is a test answer
```

#### Exercise 1

We can add new cells to this document via the `Insert -> Insert Cell Below` menu in the menu bar at the top of this document.
Expand Down
1 change: 1 addition & 0 deletions docs/002_Unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ In this section, we have learned the following `unix` commands and symbols:
|---|---|--|
| `~` | twiddle / tilde - home | `cd ~/geog0111` |
| `.` | dot - current directory | `cd .` |
| `..` | dot dot - one level up directory | `cd ..` |
| `*` | wildcard | `ls R*` |
| `cd` | change directory | `cd ~/geog0111` |
| `pwd` | print working directory | `pwd` |
Expand Down
23 changes: 13 additions & 10 deletions docs/004_Accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ l = Cylog(sites)
test = l.login()
```

### Test

You can run a test on your login to NASA Earthdata using the information you have stored this using `cylog` for the site `https://e4ftl01.cr.usgs.gov`. We can test this with the following code if you set do_test to True:


```python
from geog0111.modis import test_login
do_test=False
assert test_login(do_test)
```

## Reset password

If you are interested, you can see the help page for `Cylog`. It shows, for instance, how to over-ride the current entry (e.g. if you have changed your password), by using `force=True`).


Expand Down Expand Up @@ -60,16 +73,6 @@ help(Cylog.login)

You should be aware that the NASA servers this connects you to go down for maintenance on Wednesdays. You can ping the servers with the follwoing code:

### Test

You can run a test on your login to NASA Earthdata using the information you have stored this using `cylog` according to [004_Accounts](004_Accounts.md) for the site `https://e4ftl01.cr.usgs.gov`. We can test this with the following code if you set do_test to True:


```python
from geog0111.modis import test_login
assert test_login(do_test)
```

If this fails, you may have entered your account information incorrectly for `https://e4ftl01.cr.usgs.gov` (or it could just be Wednesday, in which case, don't run this again).

If you want to force the code to let you re-enter your credentials (e.g. you got it wrong before, or have changed them, or the test fails), then change the call to:
Expand Down
77 changes: 2 additions & 75 deletions docs/005_Packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

### Purpose

In this session, we will learn about importing packages into our code. We will also learn how to install `conda` and `pip` packages.

In this session, we will learn about importing packages into our code.

### Prerequisites

Expand Down Expand Up @@ -62,78 +61,6 @@ The class `Path` is now available directly as `Path`, whereas if we had imported

we would have needed to refer to it as `pathlib.Path`. This will over-ride any current definition of the class `Path` in the current code, so be careful not to over-ride things you don't mean to.

## `conda` and `pip`


The Python code you are using is from the [Anaconda](https://docs.anaconda.com/) distribution, and has a package manager [`conda`](https://docs.conda.io/en/latest/).


You can access `conda` commands in the notebook with the `%conda` directive. For example, to list the environments available to you, run:


```python
%conda env list
```

# conda environments:
#
david /shared/groups/jrole001/david/envs/david
geog0111 * /shared/groups/jrole001/geog0111/envs/geog0111
base /shared/ucl/apps/miniconda-jhub/4.8.3
jhubcode /shared/ucl/apps/miniconda-jhub/4.8.3/envs/jhubcode


Note: you may need to restart the kernel to use updated packages.


The environment you are using will be given with a `*`, along with its location on the file system. It may be either user-owned, in which case it will be somewhere in your own file space, or system-wide. If it is user-owned

If you want to see if a particular package and particular version exists in your distribution, e.g. `gdal`, you can check with:


```python
%conda search -f gdal=3.0.2
```

Loading channels: done
# Name Version Build Channel
gdal 3.0.2 py27hbb2a789_0 pkgs/main
gdal 3.0.2 py36hbb2a789_0 pkgs/main
gdal 3.0.2 py37hbb2a789_0 pkgs/main
gdal 3.0.2 py38hbb2a789_0 pkgs/main

Note: you may need to restart the kernel to use updated packages.


If you don't want to specify the version, just leave off the `=3.0.2` part.

If a package you need doesn't exist, you can [search for it on the anaconda site](https://anaconda.org/search?q=gdal).
If it exists as a conda package, you can install it with `conda install`:

%conda install gdal

We will not run this now, as it can take some time to complete, but be aware that this is how to install `conda` packages. In any case, if you are using a system-wide environment, you will not be able to modify the distribution.

Some packages only exist as [`pip` distributions](https://pypi.org/). Before taking a `pip` package, you should make sure that no equivalent anaconda package exists. But in case you need to, you can use:

%pip install urlpath

to install a pip package. You should check that the package will be suitable for your operating system before installing. Use `--user` to do a user install.


```python
%pip install urlpath --user
```

Requirement already satisfied: urlpath in /shared/groups/jrole001/geog0111/envs/geog0111/lib/python3.7/site-packages (1.1.7)
Requirement already satisfied: requests in /shared/groups/jrole001/geog0111/envs/geog0111/lib/python3.7/site-packages (from urlpath) (2.24.0)
Requirement already satisfied: idna<3,>=2.5 in /shared/groups/jrole001/geog0111/envs/geog0111/lib/python3.7/site-packages (from requests->urlpath) (2.10)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /shared/groups/jrole001/geog0111/envs/geog0111/lib/python3.7/site-packages (from requests->urlpath) (1.25.10)
Requirement already satisfied: certifi>=2017.4.17 in /shared/groups/jrole001/geog0111/envs/geog0111/lib/python3.7/site-packages (from requests->urlpath) (2020.6.20)
Requirement already satisfied: chardet<4,>=3.0.2 in /shared/groups/jrole001/geog0111/envs/geog0111/lib/python3.7/site-packages (from requests->urlpath) (3.0.4)
Note: you may need to restart the kernel to use updated packages.


## Summary

In this section, we have learned how to import packages using `import` and `from`. We have seen how to check if a package exists in our conda distribution, and how we can install `conda` and `pip` packages if we need to.
In this section, we have learned how to import packages using `import` and `from`.
12 changes: 3 additions & 9 deletions docs/014_Python_groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,9 @@ print(a)
{'one': 1, 'two': 2, 'three': 3, 'four': 4}


#### Exercise 5

* create a list called `months` with the names of the months of the year
* create a list called `ndays` with the number of days in each month (for this year)
* confirm that the two lists have the same length (12)
* Use these two lists to make a dictionary called `days_in_month` with the key as month name and value as the number of days in that month.
* print out the dictionary and confirm it is as expected
* set a variable `m` to be the name of a month
* using `m` and your dictionary, print out the number of days in month `m`
## Formative assessment

To get some feedback on how you are doing, you should complete and submit the formative assessment [A01 Groups](A01_Groups.md).

## Summary

Expand Down
42 changes: 0 additions & 42 deletions docs/014_Python_groups_answers.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,45 +156,3 @@ print(msg)
then -2 corresponds to the +ve index 6-2 = 4



#### Exercise 5

* create a list called `months` with the names of the months of the year
* create a list called `ndays` with the number of days in each month (for this year)
* confirm that the two lists have the same length (12)
* Use these two lists to make a dictionary called `days_in_month` with the key as month name and value as the number of days in that month.
* print out the dictionary and confirm it is as expected
* set a variable `m` to be the name of a month
* using `m` and your dictionary, print out the number of days in month `m`


```python
# ANSWER
# create a list called `months` with the names of the months of the year
months = ["January","February","March","April","May",\
"June","July","August","September","October",\
"November","December"]
# create a list called `ndays` with the number of days in each month (for this year)
ndays = [31,29,31,30,31,30,31,31,30,31,30,31]

# confirm that the two lists have the same length (12)
print(f'length of months: {len(months)}')
print(f'length of ndays: {len(ndays)}')

# Use these two lists to make a dictionary called `days_in_month`
# with the key as month name and value as the number of days in that month.
days_in_month = dict(zip(months,ndays))

# print out the dictionary and confirm it is as expected
print(days_in_month)

# set a variable `m` to be the name of a month
m = 'January'
print(f'The number of days in {m} is {days_in_month[m]}')
```

length of months: 12
length of ndays: 12
{'January': 31, 'February': 29, 'March': 31, 'April': 30, 'May': 31, 'June': 30, 'July': 31, 'August': 31, 'September': 30, 'October': 31, 'November': 30, 'December': 31}
The number of days in January is 31

40 changes: 3 additions & 37 deletions docs/018_Running_Python.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ To change the permissions on the file from JupyterLab, open a shell (e.g. using

### Jupyter notebook

You can open a text editor from a Jupyter notebook server from the menu on the right hand side of the window:

[geog0111/helloWorld.py](http://localhost:8888/edit/notebooks/geog0111/helloWorld.py)
![](images/te.png)


### Use a text editor
Expand Down Expand Up @@ -540,42 +541,7 @@ We see that running the script:

work/test.py Hermione

means trhat `sys.argv` inside the script contains the liust `['work/test.py', 'Hermione']`.

### Exercise: Submitted Practical

Although we provide access to answers for this exercise, we want you to submit the codes you generate via Moodle, so that we can provide feedback. You should avoid looking at the answers before you submit your work. This submitted work does not count towards your course assessment, it is purely to allow us to provide some rapid feedback to you on how you are doing. You will need to put together a few elements from the notes so far to do all prts of this practical, but yoiu should all be capable of doing it well. Pay attention to writing tidy code, with useful, clear comments and document strings.

* Create a Python code in a file called `work/greet.py` that does the following:
- define a function `greet(name)` that prints out a greeting from the name in the argument `name`
- define a function `main() that passes a string from the script command line to a function `greet(name)`
- calls `main()` if the file is run as a Python script
- show a test of the script working
- has plentiful commenting and document strings

- As a test, when you run the script:

%run work/greet.py Fred

you would expect to get a response of the form:

greetings from Fred

and if you run:
%run work/greet.py Hermione

then
greetings from Hermione

* To go further with this exercise, you might test to see that the length of `sys.argv` is as long as you expect it to be, so you can tell the user when they forget toi include the name
* To go even further with this exercise, you might attempt to make the script function so that if you run it as:

%run work/greet.py Fred Hermione

it responds:

greetings from Fred
greetings from Hermione
means that `sys.argv` inside the script contains the liust `['work/test.py', 'Hermione']`.

## Summary

Expand Down
Loading

0 comments on commit 9737cc2

Please sign in to comment.