Skip to content

Commit 923c98d

Browse files
authored
Merge pull request #330 from kakirastern/fixing-units-and-integration
Fixing bugs in units-and-integration notebook
2 parents 58e537e + 677345f commit 923c98d

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

quarantine/FITS-cubes/FITS-cubes.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"# Downloads the HI data in a fits file format\n",
9191
"hi_datafile = download_file(\n",
9292
" 'http://cdsarc.u-strasbg.fr/vizier/ftp/cats/J/A+A/594/A116/CUBES/GAL/TAN/TAN_C14.fits',\n",
93-
" cache=True, show_progress = True)"
93+
" cache= False, show_progress = True)"
9494
]
9595
},
9696
{

tutorials/notebooks/quantities/quantities.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,8 @@
634634
},
635635
"outputs": [],
636636
"source": [
637-
"nu13 = lambda13.to(u.Hz)"
637+
"nu13 = lambda13.to(u.Hz)\n",
638+
"nu18 = lambda18.to(u.Hz)"
638639
]
639640
},
640641
{
@@ -671,6 +672,8 @@
671672
"metadata": {},
672673
"outputs": [],
673674
"source": [
675+
"nu13 = 115271096910.13396 * u.Hz\n",
676+
"nu18 = 109782318669.689 * u.Hz\n",
674677
"A13 = 7.4e-8 / u.s\n",
675678
"A18 = 8.8e-8 / u.s\n",
676679
"\n",

tutorials/notebooks/units-and-integration/units-and-integration.ipynb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,16 @@
3333
{
3434
"cell_type": "code",
3535
"execution_count": null,
36-
"metadata": {
37-
"collapsed": true
38-
},
36+
"metadata": {},
3937
"outputs": [],
4038
"source": [
41-
"%matplotlib inline\n",
42-
"\n",
4339
"import numpy as np\n",
4440
"from scipy import integrate\n",
4541
"from astropy.modeling.blackbody import blackbody_lambda, blackbody_nu, BlackBody1D\n",
4642
"from astropy import units as u, constants as c\n",
47-
"import matplotlib.pyplot as plt"
43+
"import matplotlib.pyplot as plt\n",
44+
"\n",
45+
"%matplotlib inline"
4846
]
4947
},
5048
{
@@ -159,7 +157,7 @@
159157
"source": [
160158
"### How to simulate actual observations\n",
161159
"\n",
162-
"As of Fall 2017, `astropy` does not explicitly support constructing synthetic observations of models like black-body curves. The [`synphot`](https://synphot.readthedocs.io/en/latest/) library does allow this. You can use `synphot` to perform tasks like turning spectra into visual magnitudes by convolving with a filter curve."
160+
"As of Fall 2017, `astropy` does not explicitly support constructing synthetic observations of models like black-body curves. The [synphot library](https://synphot.readthedocs.io/en/latest/) does allow this. You can use `synphot` to perform tasks like turning spectra into visual magnitudes by convolving with a filter curve."
163161
]
164162
},
165163
{
@@ -208,7 +206,7 @@
208206
"source": [
209207
"## Integrating using Gaussian quadrature\n",
210208
"\n",
211-
"In this section, we'll explore a method of numerical integration that does not require having your sampling grid set-up already. [`scipy.integrate.quad`](https://docs.scipy.org/doc/scipy-0.19.1/reference/generated/scipy.integrate.quad.html) takes a function and both a lower and upper bound, and our `PowerLawPDF` class takes care of this just fine.\n",
209+
"In this section, we'll explore a method of numerical integration that does not require having your sampling grid set-up already. `scipy.integrate.quad` with reference [here](https://docs.scipy.org/doc/scipy-0.19.1/reference/generated/scipy.integrate.quad.html) takes a function and both a lower and upper bound, and our `PowerLawPDF` class takes care of this just fine.\n",
212210
"\n",
213211
"Now we can use our new class to normalize our IMF given the mass bounds. This amounts to normalizing a probability density function. We'll use Gaussian quadrature (`quad`) to find the integral. `quad` returns the numerical value of the integral and its uncertainty. We only care about the numerical value, so we'll pack the uncertainty into `_` (a placeholder variable). We immediately throw the integral into our IMF object and use it for normalizing!\n",
214212
"\n",
@@ -328,10 +326,14 @@
328326
"\n",
329327
"* Right now, we aren't worried about the bounds of the power law, but the IMF should drop off to zero probability at masses below .01 solar masses and above 100 solar masses. Modify `PowerLawPDF` in a way that allows both `float` and `numpy.ndarray` inputs.\n",
330328
"* Modify the `PowerLawPDF` class to explicitly use `astropy`'s `units` constructs.\n",
331-
"* Derive a relationship between recent star-formation rate and $H\\alpha$ luminosity. In other words, for the function $ {\\rm SFR \\, [\\frac{M_{\\odot}}{yr}]} = C \\, L_{H\\alpha} \\, [{\\rm \\frac{erg}{s}}]$, find a value of $C$. How does this depend on the slope and endpoints of the IMF?\n",
332-
" * take a look at Appendix B of [Hunter & Elmegreen 2004, AJ, 128, 2170](http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:astro-ph/0408229)\n",
333-
" * what effect does changing the power-law index or upper mass limit of the IMF have on the value of $C$?\n",
334-
" * predict the effect on the value of $C$ of using a different form of the IMF, like Kroupa or Chabrier (both are lighter on the low-mass end). If you're not tired of IMFs yet, try defining a new class that implements a broken-power-law (Kroupa) or log-parabola (Chabrier) IMF. Perform the same calculations as above."
329+
"* Derive a relationship between recent star-formation rate and $H\\alpha$ luminosity. In other words, for the function\n",
330+
"\n",
331+
"$${\\rm SFR \\, [\\frac{M_{\\odot}}{yr}]} = {\\rm C \\, L_{H\\alpha} \\, [\\frac{erg}{s}]} \\, ,$$\n",
332+
"\n",
333+
"find a value of $C$. How does this depend on the slope and endpoints of the IMF?\n",
334+
" * Take a look at Appendix B of [Hunter & Elmegreen 2004, AJ, 128, 2170](http://adsabs.harvard.edu/cgi-bin/bib_query?arXiv:astro-ph/0408229)\n",
335+
" * What effect does changing the power-law index or upper mass limit of the IMF have on the value of $C$?\n",
336+
" * Predict the effect on the value of $C$ of using a different form of the IMF, like Kroupa or Chabrier (both are lighter on the low-mass end). If you're not tired of IMFs yet, try defining a new class that implements a broken-power-law (Kroupa) or log-parabola (Chabrier) IMF. Perform the same calculations as above."
335337
]
336338
}
337339
],

0 commit comments

Comments
 (0)