From 330714b08532de905f17f009b7f09f0e1c6d5b6e Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Sun, 10 Jul 2022 18:00:02 -0400 Subject: [PATCH] fix typos (#20) * fix typos * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- 01-Introduction/01-Introduction.ipynb | 7 ++--- 02_Working_With_ASDF_Files/02-Solutions.ipynb | 12 +++++++-- .../03-Creating_ASDF_Files.ipynb | 27 ++++++++++++------- 03-Creating_ASDF_Files/03-Solutions.ipynb | 21 +++++++++++---- .../05-Custom-Extensions.ipynb | 2 +- 5 files changed, 49 insertions(+), 20 deletions(-) diff --git a/01-Introduction/01-Introduction.ipynb b/01-Introduction/01-Introduction.ipynb index 011bb07..bf3c874 100644 --- a/01-Introduction/01-Introduction.ipynb +++ b/01-Introduction/01-Introduction.ipynb @@ -55,6 +55,7 @@ "metadata": {}, "source": [ "We looked at the well known existing ones but none were suitable to our requirements\n", + "\n", "Our requirements:\n", "\n", "- Suitable as an archival format (FITS satisfies that).\n", @@ -65,7 +66,7 @@ "- Leverage existing formats and tools to the extent possible\n", "- Easily extensible for:\n", " - The standard itself\n", - " - Specific science and and engineering domains\n", + " - Specific science and engineering domains\n", " - Local or private usage\n", "- Schemas to support validation\n", "- Clear versioning\n", @@ -173,7 +174,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -187,7 +188,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/02_Working_With_ASDF_Files/02-Solutions.ipynb b/02_Working_With_ASDF_Files/02-Solutions.ipynb index 7fbaf50..af7887d 100644 --- a/02_Working_With_ASDF_Files/02-Solutions.ipynb +++ b/02_Working_With_ASDF_Files/02-Solutions.ipynb @@ -16,7 +16,7 @@ "**Exercise 1:**\n", "\n", "- Open the file `jwst.asdf` in the `02_Working_With_ASDF_Files` directory. Look at the `info` method's help and display the file using some of the arguments to show more contents.\n", - "- Search for a few attributes - `wcs`, `data`\n", + "- Search for a few attributes - `wcs`, `data`, (WCS stands for World Coordinate System. In astronomy it represents the transform from pixel coordinates to sky coordinates or some physical system.)\n", "- Retrieve the `wcs` object following the path showed by the `search` method\n", "- Look at the `wcs` object and print `wcs.forward_transform`\n", "- Use matplotlib to display the data array\n", @@ -151,6 +151,14 @@ "af[\"data\"][0, 0] = 999" ] }, + { + "cell_type": "markdown", + "id": "db4f1963", + "metadata": {}, + "source": [ + "Files are opened in `readonly` mode by default. Pass `mode=rw` to the `open` function to be able to modify them." + ] + }, { "cell_type": "markdown", "id": "9a281209", @@ -403,7 +411,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.5" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/03-Creating_ASDF_Files/03-Creating_ASDF_Files.ipynb b/03-Creating_ASDF_Files/03-Creating_ASDF_Files.ipynb index 12c3555..0d268ae 100644 --- a/03-Creating_ASDF_Files/03-Creating_ASDF_Files.ipynb +++ b/03-Creating_ASDF_Files/03-Creating_ASDF_Files.ipynb @@ -34,7 +34,7 @@ "\n", "All of which are stored using `yaml`. Note that more complex structures (ones not directly supported\n", "by `yaml`) are denoted using `yaml` tags. However, those tagged \"sub-trees\" are still comprised of the\n", - "above basic structures and other tagged sub-trees. Additional tagged tagged objects are supported via\n", + "above basic structures and other tagged sub-trees. Additional tagged objects are supported via\n", "ASDF extensions.\n", "\n", "The Python analogs for these types are:\n", @@ -127,7 +127,7 @@ "## Creating ASDF files with `np.ndarray`\n", "\n", "Beyond the maps, lists, strings, and numbers built into Python, ASDF can save arrays, in particular\n", - "numpy arrays (`nd.array`). Indeed, much of ASDF is dedicated to efficiently saving arrays.\n", + "numpy arrays (`np.array`). Indeed, much of ASDF is dedicated to efficiently saving arrays.\n", "\n", "For example if suppose we want to save a random 8x8 numpy array:" ] @@ -168,7 +168,7 @@ "id": "b386f241", "metadata": {}, "source": [ - "Observe that at the end of the file that there is apparently some binary data. This binary data contains the information\n", + "Observe that at the end of the file there is apparently some binary data. This binary data contains the information\n", "in the random array we wrote. Indeed, when ASDF writes arrays to the file it stores them as binary data in a block after\n", "the YAML section of the file rather in the section itself. Note that `random_array` in the YAML section stores some\n", "information about the nature of the array and includes the `source` key. This `source` value references which binary block \n", @@ -252,8 +252,8 @@ "id": "3096c0b6", "metadata": {}, "source": [ - "Notice how no additional effort was need to write the ASDF file since `asdf-astropy` was installed \n", - "already. Now lets perform a cursory inspection of the `gaussian.asdf` file:" + "Notice how no additional effort was needed to write the ASDF file since `asdf-astropy` was installed \n", + "already. Now lets perform a cursory inspection of the `table.asdf` file:" ] }, { @@ -276,9 +276,18 @@ "\n", "Write an ASDF file containing the following `astropy` objects:\n", "1. `Quantity`\n", - "2. A different model\n", + "2. A `model`\n", + "\n", + " Hint: The `astropy.modeling` package provides a framework for representing models and performing model evaluation and fitting. Models are initialized using their parameters\n", + " ```\n", + " from astropy.modeling import models\n", + " gauss = models.Gaussian1D(amplitude=10, mean=3, stddev=1.2)\n", + " ```\n", "3. A `Time` object\n", - "4. A coordinate object." + "\n", + " Hint: The `astropy.time` package provides functionality for manipulating times and dates. To initialize it supply a string and a format, or supply a datetime object.\n", + " \n", + "4. A Celestial coordinate object (astronomy specific)." ] }, { @@ -290,7 +299,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3.10.4", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -304,7 +313,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.4" + "version": "3.9.12" }, "vscode": { "interpreter": { diff --git a/03-Creating_ASDF_Files/03-Solutions.ipynb b/03-Creating_ASDF_Files/03-Solutions.ipynb index 3417796..79f36a0 100644 --- a/03-Creating_ASDF_Files/03-Solutions.ipynb +++ b/03-Creating_ASDF_Files/03-Solutions.ipynb @@ -127,10 +127,21 @@ "source": [ "import astropy\n", "\n", + "# Create a quantity with an array value and units of meters.\n", "quantity = np.random.rand(8, 8) * astropy.units.m\n", - "model = astropy.modeling.models.Gaussian2D(quantity, 2, 3, 4, 5)\n", - "time = astropy.time.Time(\"J2000\")\n", - "coord = astropy.coordinates.ICRS(ra=1 * astropy.units.deg, dec=2 * astropy.units.deg)\n", + "\n", + "# Create a 2D Gaussian model\n", + "model = astropy.modeling.models.Gaussian2D(\n", + " amplitude=12.4 * astropy.units.m, x_mean=2, y_mean=3, x_stddev=4, y_stddev=5\n", + ")\n", + "\n", + "# Cretae a Time object in `iso` format\n", + "time = astropy.time.Time(\"2021-07-11 00:00:00\", format=\"iso\")\n", + "\n", + "# Create a celestial coordinate\n", + "coord = astropy.coordinates.ICRS(\n", + " ra=5.67 * astropy.units.deg, dec=23.5 * astropy.units.deg\n", + ")\n", "\n", "tree = {\n", " \"quantity\": quantity,\n", @@ -165,7 +176,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3.10.5", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -179,7 +190,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.5" + "version": "3.9.12" }, "vscode": { "interpreter": { diff --git a/05-Custom_ASDF_Extensions/05-Custom-Extensions.ipynb b/05-Custom_ASDF_Extensions/05-Custom-Extensions.ipynb index 52801be..5d3ffd9 100644 --- a/05-Custom_ASDF_Extensions/05-Custom-Extensions.ipynb +++ b/05-Custom_ASDF_Extensions/05-Custom-Extensions.ipynb @@ -1029,7 +1029,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.5" + "version": "3.9.12" }, "vscode": { "interpreter": {