Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding unit test notebooks for calwebb_detector1 #63

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"title_ID\"></a>\n",
"# JWST Pipeline Validation Notebook: \n",
"# calwebb_detector1, dark_current unit tests\n",
"\n",
"<span style=\"color:red\"> **Instruments Affected**</span>: NIRCam, NIRISS, NIRSpec, MIRI, FGS\n",
"\n",
"### Table of Contents\n",
"\n",
"<div style=\"text-align: left\"> \n",
" \n",
"<br> [Introduction](#intro)\n",
"<br> [JWST Unit Tests](#unit)\n",
"<br> [Defining Terms](#terms)\n",
"<br> [Test Description](#description)\n",
"<br> [Data Description](#data_descr)\n",
"<br> [Imports](#imports)\n",
"<br> [Convenience Functions](#functions)\n",
"<br> [Perform Tests](#testing) \n",
"<br> [About This Notebook](#about)\n",
"<br> \n",
"\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"intro\"></a>\n",
"# Introduction\n",
"\n",
"This is the validation notebook that displays the unit tests for the Dark Current step in calwebb_detector1. This notebook runs and displays the unit tests that are performed as a part of the normal software continuous integration process. For more information on the pipeline visit the links below. \n",
"\n",
"* Pipeline description: https://jwst-pipeline.readthedocs.io/en/latest/jwst/dark_current/index.html\n",
"\n",
"* Pipeline code: https://github.com/spacetelescope/jwst/tree/master/jwst/\n",
"\n",
"[Top of Page](#title_ID)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"unit\"></a>\n",
"# JWST Unit Tests\n",
"\n",
"JWST unit tests are located in the \"tests\" folder for each pipeline step within the [GitHub repository](https://github.com/spacetelescope/jwst/tree/master/jwst/), e.g., ```jwst/dark_current/tests```.\n",
"\n",
"* Unit test README: https://github.com/spacetelescope/jwst#unit-tests\n",
"\n",
"\n",
"[Top of Page](#title_ID)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"terms\"></a>\n",
"# Defining Terms\n",
"\n",
"These are terms or acronymns used in this notebook that may not be known a general audience.\n",
"\n",
"* JWST: James Webb Space Telescope\n",
"\n",
"* NIRCam: Near-Infrared Camera\n",
"\n",
"\n",
"[Top of Page](#title_ID)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"description\"></a>\n",
"# Test Description\n",
"\n",
"Unit testing is a software testing method by which individual units of source code are tested to determine whether they are working sufficiently well. Unit tests do not require a separate data file; the test creates the necessary test data and parameters as a part of the test code. \n",
"\n",
"\n",
"[Top of Page](#title_ID)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"data_descr\"></a>\n",
"# Data Description\n",
"\n",
"Data used for unit tests is created on the fly within the test itself, and is typically an array in the expected format of JWST data with added metadata needed to run through the pipeline. \n",
"\n",
"\n",
"[Top of Page](#title_ID)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"imports\"></a>\n",
"# Imports\n",
"\n",
"* tempfile for creating temporary output products\n",
"* pytest for unit test functions\n",
"* jwst for the JWST Pipeline\n",
"* IPython.display for display pytest reports\n",
"\n",
"[Top of Page](#title_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import tempfile\n",
"import pytest\n",
"import jwst\n",
"from IPython.display import IFrame"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"functions\"></a>\n",
"# Convenience Functions\n",
"\n",
"Here we define any convenience functions to help with running the unit tests. \n",
"\n",
"[Top of Page](#title_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def display_report(fname):\n",
" '''Convenience function to display pytest report.'''\n",
" \n",
" return IFrame(src=fname, width=700, height=600)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"testing\"></a>\n",
"# Perform Tests\n",
"\n",
"Below we run the unit tests for the Dark Current step. \n",
"\n",
"[Top of Page](#title_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"with tempfile.TemporaryDirectory() as tmpdir:\n",
" !pytest jwst/dark_current -v --ignore=jwst/associations --ignore=jwst/datamodels --ignore=jwst/stpipe --ignore=jwst/regtest --html=tmpdir/unit_report.html --self-contained-html\n",
" report = display_report('tmpdir/unit_report.html')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"report"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a id=\"about\"></a>\n",
"## About This Notebook\n",
"**Author:** Alicia Canipe, Staff Scientist, NIRCam\n",
"<br>**Updated On:** 01/07/2021"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Top of Page](#title_ID)\n",
"<img style=\"float: right;\" src=\"./stsci_pri_combo_mark_horizonal_white_bkgd.png\" alt=\"stsci_pri_combo_mark_horizonal_white_bkgd\" width=\"200px\"/> "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Loading