mirror of
https://github.com/AllenDowney/AstronomicalData.git
synced 2025-12-05 20:40:17 -08:00
Updating the setup notebook
This commit is contained in:
169
test_setup.ipynb
169
test_setup.ipynb
@@ -6,16 +6,128 @@
|
||||
"source": [
|
||||
"# Data Carpentry Astronomy Workshop\n",
|
||||
"\n",
|
||||
"This notebook imports the libraries we need for the workshop.\n",
|
||||
"Please run this notebook before the workshop. There are three sections:\n",
|
||||
"\n",
|
||||
"If any of them are missing, you'll get an error message.\n",
|
||||
"1. A short introduction to Jupyter, with pointers to more resources.\n",
|
||||
"\n",
|
||||
"2. `import` statements to check whether you have everything installed that we need.\n",
|
||||
"\n",
|
||||
"3. A cell where you will paste a line of code you copy from Slack, to check for a potential problem with \"smart\" quotes."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Introduction to Jupyter\n",
|
||||
"\n",
|
||||
"This is a Jupyter notebook, which is a computational document that contains text, code, and results.\n",
|
||||
"\n",
|
||||
"There are several development environments you can use to work with notebooks. Currently the two most common are:\n",
|
||||
"\n",
|
||||
"* Jupyter Classic Notebook, and\n",
|
||||
"\n",
|
||||
"* JupyterLab, which is a newer environment with some improved features, but also some limitations. \n",
|
||||
"\n",
|
||||
"During the workshop, we will use the Classic Notebook environment. If you are new to Jupyter, we suggest you should, too.\n",
|
||||
"\n",
|
||||
"If you are familiar with JupyterLab and you would rather use it for the workshop, that's fine. Just be aware that there will be differences between your environment and ours.\n",
|
||||
"\n",
|
||||
"If you are new to Jupyter, you can [read about it here](https://jupyter.org/try) and follow the tutorial called \"Try Classic Notebook\".\n",
|
||||
"\n",
|
||||
"You also might like [this tutorial from DataQuest](https://www.dataquest.io/blog/jupyter-notebook-tutorial/).\n",
|
||||
"\n",
|
||||
"The following sections introduce the features you will need for the workshop."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Selecting and running cells\n",
|
||||
"\n",
|
||||
"Notebooks are divided into cells that contain either text or code.\n",
|
||||
"\n",
|
||||
"This cell is text; the following cell is code:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print('Hello')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"To select a cell, click in the left margin next to the cell. You should see a blue frame surrounding the selected cell.\n",
|
||||
"\n",
|
||||
"To edit a code cell, click inside the cell. You should see a green frame around the selected cell, and you should see a cursor inside the cell.\n",
|
||||
"\n",
|
||||
"To edit a text cell, double-click inside the cell. Again, you should see a green frame around the selected cell, and you should see a cursor inside the cell.\n",
|
||||
"\n",
|
||||
"Text cells use the Markdown typesetting language, which [you can read about here](https://www.markdownguide.org/).\n",
|
||||
"\n",
|
||||
"To run a cell, hold down Shift and press Enter.\n",
|
||||
"\n",
|
||||
"* If you run a text cell, Jupyter formats the text and displays the result.\n",
|
||||
"\n",
|
||||
"* If you run a code cell, Jupyter runs the code in the cell and displays the result, if any.\n",
|
||||
"\n",
|
||||
"To try it out, select the previous code cell and press Shift-Enter. It should run the code and print `Hello`.\n",
|
||||
"\n",
|
||||
"Then edit this cell, change some of the text, and press Shift-Enter to format it."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Adding and removing cells\n",
|
||||
"\n",
|
||||
"You can add and remove cells from a notebook using the menu at the top of the page and the tool bar below the menu.\n",
|
||||
"\n",
|
||||
"Try the following exercises:\n",
|
||||
"\n",
|
||||
"1. From the Insert menu select \"Insert cell below\" to add a cell below this one. By default, you get a code cell, as you can see in the pull-down menu that says \"Code\".\n",
|
||||
"\n",
|
||||
"2. In the new cell, add a line of Python code and run it.\n",
|
||||
"\n",
|
||||
"3. Add another cell, select the new cell, and then click on the pull-down menu that says \"Code\". Select \"Markdown\". This makes the new cell a text cell.\n",
|
||||
"\n",
|
||||
"4. In the new cell, type some text and format it.\n",
|
||||
"\n",
|
||||
"5. Use the arrow buttons in the tool bar to move cells up and down.\n",
|
||||
"\n",
|
||||
"6. Use the cut, copy, and paste buttons to delete, add, and move cells.\n",
|
||||
"\n",
|
||||
"As you make changes, Jupyter saves your notebook automatically, but if you want to make sure, you can press the save button, which looks like a floppy disk from the 1990s.\n",
|
||||
"\n",
|
||||
"Finally, when you are done with a notebook, select \"Close and Halt\" from the File menu."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Check your installation\n",
|
||||
"\n",
|
||||
"Run the following cells to import the libraries we need for the workshop.\n",
|
||||
"\n",
|
||||
"If any of the libraries are missing, you'll get an error message.\n",
|
||||
"\n",
|
||||
"If you don't get any error messages, you are all set."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -24,7 +136,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -32,9 +144,27 @@
|
||||
"import numpy as np"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Let's make sure you have a recent version of Pandas.\n",
|
||||
"\n",
|
||||
"If the following cell causes an error, you probably have an old version of Pandas. Please update it before the workshop."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pd.Series([0]).to_numpy()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -46,7 +176,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -57,7 +187,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -66,26 +196,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Created TAP+ (v1.2.1) - Connection:\n",
|
||||
"\tHost: gea.esac.esa.int\n",
|
||||
"\tUse HTTPS: True\n",
|
||||
"\tPort: 443\n",
|
||||
"\tSSL Port: 443\n",
|
||||
"Created TAP+ (v1.2.1) - Connection:\n",
|
||||
"\tHost: geadata.esac.esa.int\n",
|
||||
"\tUse HTTPS: True\n",
|
||||
"\tPort: 443\n",
|
||||
"\tSSL Port: 443\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Note: running this import statement opens a connection\n",
|
||||
"# to a Gaia server, so it will fail if you are not connected\n",
|
||||
@@ -98,11 +211,13 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Check for code-pasting problems\n",
|
||||
"\n",
|
||||
"During the workshop, we might put code on Slack and ask you to cut and paste it into the notebook.\n",
|
||||
"\n",
|
||||
"If you are on a Mac, you might encounter a problem with smart quotes.\n",
|
||||
"\n",
|
||||
"To check, following this link to [our Slack workspace](https://app.slack.com/client/T01DJHEP8Q1/C01D2TZA8SH/details/pins) and find the pinned message with the setup instructions.\n",
|
||||
"To check, following this link to [our Slack workspace](https://app.slack.com/client/T01GF8N96TD/C01G8AS0QBG/details/pins) and find the pinned message with the setup instructions.\n",
|
||||
"It contains a line of Python code.\n",
|
||||
"\n",
|
||||
"Copy the code from Slack and paste it in the cell below.\n",
|
||||
|
||||
Reference in New Issue
Block a user