Skip to content

Commit

Permalink
Tiying up format
Browse files Browse the repository at this point in the history
  • Loading branch information
gvwilson committed Aug 14, 2016
1 parent bbfc3a9 commit 20b1421
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
22 changes: 13 additions & 9 deletions _episodes/01-getdata.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ keypoints:
- "FIXME"
---

A growing number of organizations make data sets available on the web in a style called [REST](reference.html#rest),
A growing number of organizations make data sets available on the web in a style called [REST]({{ site.github.url }}/reference#rest),
which stands for REpresentational State Transfer.
The details (and ideology) aren't important;
what matters is that when REST is used,
every data set is identified by a URL
and can be accessed through a set of functions
called an [application programming interface](reference.html#api) (API).
called an [application programming interface]({{ site.github.url }}/reference/#api) (API).

For example,
the World Bank's [Climate Data API](http://data.worldbank.org/developers/climate-data-api)
the World Bank's [Climate Data API][climate-api]
provides data generated by 15 global circulation models.
According to the API's [home page](http://data.worldbank.org/developers/climate-data-api),
According to the API's [home page][climate-api],
the data sets containing yearly averages for various values are identified by URLs of the form:

<code>http://climatedataapi.worldbank.org/climateweb/rest/v1/country/cru/<u><em>var</em></u>/year/<u><em>iso3</em></u>.<u><em>ext</em></u></code>
Expand All @@ -30,12 +30,12 @@ where:

* *var* is either `pr` (for precipitation) or `tas` (for "temperature at surface");
* *iso3* is the International Standards Organization (ISO)
[3-letter code for a country](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3),
[3-letter code for a country][wikipedia-iso-country],
such as "CAN" for Canada or "BRA" for Brazil;
and
* *ext* (short for "extension") specifies the format we want the data in.
There are several choices for format,
but the simplest is [comma-separated values](reference.html#csv) (CSV),
but the simplest is [comma-separated values]({{ site.github.url }}/reference/#csv) (CSV),
in which each record is a row,
and the values in each row are separated by commas.
(CSV is frequently used for spreadsheet data.)
Expand Down Expand Up @@ -85,7 +85,7 @@ so we should write a program.

Python has a library called `urllib2` for working with URLs.
It is clumsy to use, though, so many people (including us) prefer
a newer library called [Requests](http://docs.python-requests.org).
a newer library called [Requests][requests].
To install it, run the command:

~~~
Expand Down Expand Up @@ -158,7 +158,7 @@ but assigning it to a variable makes it easier to find.
* assigns a number to that object's `status_code` member variable to tell us whether the request succeeded or not; and
* assigns the data sent back by the web server to the object's `text` member variable.

The server can return many different [status codes](reference.html#http-status-code);
The server can return many different [status codes]({{ site.github.url }}/reference#http-status-code);
the most common are:

|Code|Name |Meaning |
Expand Down Expand Up @@ -201,6 +201,10 @@ if we get anything else, the response probably doesn't contain actual data

> ## How Hot is Afghanistan?
>
> Read the [documentation](http://data.worldbank.org/developers/climate-data-api) for the Climate Data API,
> Read the [documentation][climate-api] for the Climate Data API,
> and then write URLs to find the annual average temperature for Afghanistan between 1980 and 1999.
{: .challenge}

[climate-api]: http://data.worldbank.org/developers/climate-data-api
[requests]: http://docs.python-requests.org
[wikipedia-iso-country]: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
4 changes: 2 additions & 2 deletions _episodes/02-csv.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ with open('test01.csv', 'r') as reader:

The dates are correct,
but the values all end with `\n`.
This is an [escape sequence](reference.html#escape-sequence) that represents
This is an [escape sequence]({{ site.github.url }}/reference/#escape-sequence) that represents
the newline character at the end of each line.
To get rid of it,
we should strip leading and trailing whitespace from each line before splitting it on commas:
Expand Down Expand Up @@ -110,7 +110,7 @@ with open('test01.csv', 'r') as raw:

Here,
`raw` reads data in the normal way,
while `cooked` is a [wrapper](reference.html#wrapper)
while `cooked` is a [wrapper]({{ site.github.url }}/reference#wrapper)
that takes a line of text and turns it into a list of fields.

We can equally well give a `csv.reader` a list of strings rather than a file:
Expand Down
2 changes: 1 addition & 1 deletion _episodes/03-generalize.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ while the third crashes because we're using `left` to determine the number of re
but `right` doesn't have that many.

The first two problems are actually worse than the third
because they are [silent failures](reference.html#silent-failure):
because they are [silent failures]({{ site.github.url }}/reference/#silent-failure):
the function does the wrong thing, but doesn't indicate that in any way.
Let's fix that:

Expand Down
4 changes: 2 additions & 2 deletions _episodes/04-visualize.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plt.show()
~~~
{: .python}

![First Plot](fig/plot-01.png)
![First Plot]({{ site.github.url }}/fig/plot-01.png)

That's not what we want:
pyplot has interpreted the list of pairs returned by `annual_mean_temp`
Expand All @@ -45,7 +45,7 @@ plt.show()
~~~
{: .python}

![Second Plot](fig/plot-02.png)
![Second Plot]({{ site.github.url }}/fig/plot-02.png)

It looks like the difference is slowly decreasing, but the signal is very noisy.
At this point, if we wanted to do some real science,
Expand Down
2 changes: 1 addition & 1 deletion _episodes/06-findable.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ It's not enough to tell people what the rule is for creating filenames,
since that doesn't tell them what data sets we've actually generated.
The final step in this lesson is therefoore
to make the data we generate findable
by creating an [index](reference.html#index) to tell people what files exist.
by creating an [index]({{ site.github.url }}/reference/#index) to tell people what files exist.

Here's the format we will use:

Expand Down

0 comments on commit 20b1421

Please sign in to comment.