diff --git a/docs/index.rst b/docs/index.rst index 5baa688..c1474c4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot_index: ********************************************* @@ -98,16 +96,22 @@ Below are the instructions to install: stsynphot/data_hst stsynphot/data_jwst +.. testsetup:: + + >>> # This is not marked remote data because it is essential for VEGAMAG + >>> from stsynphot.spectrum import load_vega + >>> load_vega(vegafile='http://ssb.stsci.edu/cdbs/calspec/alpha_lyr_stis_009.fits', encoding='binary') # doctest: +IGNORE_OUTPUT + To ensure consistency for all data files used, **stsynphot silently overwrites synphot data file locations within the Python session**. For example:: >>> from synphot.config import conf as syn_conf - >>> print(syn_conf.johnson_v_file) + >>> print(syn_conf.johnson_v_file) # doctest: +IGNORE_OUTPUT http://ssb.stsci.edu/cdbs/comp/nonhst/johnson_v_004_syn.fits >>> from stsynphot.config import conf - >>> print(conf.rootdir) + >>> print(conf.rootdir) # doctest: +IGNORE_OUTPUT /my/local/dir/cdbs/ - >>> print(syn_conf.johnson_v_file) + >>> print(syn_conf.johnson_v_file) # doctest: +IGNORE_OUTPUT /my/local/dir/cdbs//comp/nonhst/johnson_v_004_syn.fits You can also take advantage of @@ -154,8 +158,8 @@ before proceeding. Display the current settings for graph and component tables, telescope area (in squared centimeter), and default wavelength set (in Angstrom):: - >>> import stsynphot as STS - >>> STS.showref() + >>> import stsynphot as stsyn + >>> stsyn.showref() # doctest: +SKIP graphtable: /my/local/dir/cdbs/mtab/07r1502mm_tmg.fits comptable : /my/local/dir/cdbs/mtab/07r1502nm_tmc.fits thermtable: /my/local/dir/cdbs/mtab/tae17277m_tmt.fits @@ -168,14 +172,16 @@ consistency, as stated in :ref:`stsynphot-installation-setup` (the double slash in path name does not affect software operation):: >>> import synphot - >>> synphot.conf.vega_file - '/my/local/dir/cdbs//calspec/alpha_lyr_stis_008.fits' + >>> synphot.conf.vega_file # doctest: +IGNORE_OUTPUT + '/my/local/dir/cdbs//calspec/alpha_lyr_stis_009.fits' Plot the built-in Vega spectrum, which is used to compute VEGAMAG. This is pre-loaded at start-up for convenience:: >>> from synphot import units - >>> STS.Vega.plot(right=20000, flux_unit=units.FLAM, title='Vega spectrum') + >>> stsyn.Vega.plot( + ... right=20000, flux_unit=units.FLAM, + ... title='Vega spectrum') # doctest: +SKIP .. image:: stsynphot/images/vega_spec.png :width: 600px @@ -184,8 +190,8 @@ pre-loaded at start-up for convenience:: Construct a bandpass for HST/ACS camera using WFC1 detector and F555W filter; Then, show all the individual throughput files used in its construction:: - >>> bp = STS.band('acs,wfc1,f555w') - >>> bp.showfiles() + >>> bp = stsyn.band('acs,wfc1,f555w') # doctest: +SKIP + >>> bp.showfiles() # doctest: +SKIP INFO: #Throughput table names: /my/local/dir/cdbs/comp/ota/hst_ota_007_syn.fits /my/local/dir/cdbs/comp/acs/acs_wfc_im123_004_syn.fits @@ -198,14 +204,14 @@ star with blackbody temperature of 5770 Kelvin, at solar metallicity, and log surface gravity of 4.5, renormalized to 20 VEGAMAG in Johnson *V* filter, using IRAF SYNPHOT syntax:: - >>> sp = STS.parse_spec( - ... 'rn(icat(k93models,5770,0.0,4.5),band(johnson,v),20,vegamag)') + >>> sp = stsyn.parse_spec( + ... 'rn(icat(k93models,5770,0.0,4.5),band(johnson,v),20,vegamag)') # doctest: +SKIP Construct an extinction curve for Milky Way (diffuse) with :math:`E(B-V)` of 0.7 mag. Then, apply the extinction to the source spectrum from before:: - >>> ext = STS.ebmvx('mwavg', 0.7) - >>> sp_ext = sp * ext + >>> ext = stsyn.ebmvx('mwavg', 0.7) # doctest: +REMOTE_DATA + >>> sp_ext = sp * ext # doctest: +SKIP Construct an observation using the ACS bandpass and the extincted source spectrum. (For accurate detector binning, you can pass in the binned wavelength @@ -214,8 +220,8 @@ observation mode is stored in ``bp.binset``.) Then, compute the count rate for HST collecting area:: >>> from synphot import Observation - >>> obs = Observation(sp_ext, bp, binset=bp.binset) - >>> obs.countrate(area=STS.config.conf.area) + >>> obs = Observation(sp_ext, bp, binset=bp.binset) # doctest: +SKIP + >>> obs.countrate(area=stsyn.config.conf.area) # doctest: +SKIP To find out exactly how ``bp.binset`` was computed, you can use the following @@ -224,14 +230,15 @@ mode in use is stored in ``wavecats/acs.dat`` in the **stsynphot** software data directory (``synphot$``, which is named so for backward compatibility with ASTROLIB PYSYNPHOT):: - >>> STS.wavetable.WAVECAT['acs,wfc1,f555w'] + >>> from stsynphot import wavetable + >>> wavetable.WAVECAT['acs,wfc1,f555w'] 'synphot$wavecats/acs.dat' Calculate thermal background for a HST/WFC3 bandpass for its IR detector using F110W filter:: - >>> wfc3 = STS.band('wfc3,ir,f110w') - >>> wfc3.thermback() + >>> wfc3 = stsyn.band('wfc3,ir,f110w') # doctest: +SKIP + >>> wfc3.thermback() # doctest: +SKIP diff --git a/docs/stsynphot/appendixa.rst b/docs/stsynphot/appendixa.rst index 4b529a2..1debb18 100644 --- a/docs/stsynphot/appendixa.rst +++ b/docs/stsynphot/appendixa.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot-appendixa: Appendix A: Catalogs and Spectral Atlases @@ -82,8 +80,8 @@ The example below generates a spectrum with metallicity ``[M/H] = +0.1``, temperature :math:`T_{\text{eff}} = 10000 \text{K}`, and gravity :math:`\log g = 3.0`:: - >>> import stsynphot as STS - >>> sp = STS.grid_to_spec('ck04models', 10000, 0.1, 3.0) + >>> import stsynphot as stsyn + >>> sp = stsyn.grid_to_spec('ck04models', 10000, 0.1, 3.0) # doctest: +SKIP .. _stsynphot-appendixa-kurucz1993: @@ -125,9 +123,9 @@ columns in the file are filled with zeroes:: >>> from astropy.io import fits >>> filename = os.path.join( ... os.environ['PYSYN_CDBS'], 'grid', 'k93models', - ... 'kp00', 'kp00_8000.fits') - >>> hdr = fits.getheader(filename) - >>> hdr + ... 'kp00', 'kp00_8000.fits') # doctest: +SKIP + >>> hdr = fits.getheader(filename) # doctest: +SKIP + >>> hdr # doctest: +SKIP SIMPLE = T / file does conform to FITS standard BITPIX = 16 / number of bits per data pixel NAXIS = 0 / number of data axes @@ -166,16 +164,16 @@ means :math:`\log g = 3.0`:: >>> filename = os.path.join( ... os.environ['PYSYN_CDBS'], 'grid', 'k93models', - ... 'kp01', 'kp01_10000.fits') - >>> spec = fits.getdata(filename) - >>> wave = spec['WAVELENGTH'] - >>> flux = spec['g30'] + ... 'kp01', 'kp01_10000.fits') # doctest: +SKIP + >>> spec = fits.getdata(filename) # doctest: +SKIP + >>> wave = spec['WAVELENGTH'] # doctest: +SKIP + >>> flux = spec['g30'] # doctest: +SKIP The easier way is to use :func:`~stsynphot.catalog.grid_to_spec` (also see :ref:`stsynphot-spec-atlas`). Equivalent to the example above:: - >>> import stsynphot as STS - >>> sp = STS.grid_to_spec('k93models', 10000, 0.1, 3.0) + >>> import stsynphot as stsyn + >>> sp = stsyn.grid_to_spec('k93models', 10000, 0.1, 3.0) # doctest: +SKIP .. _stsynphot-appendixa-phoenix: @@ -205,8 +203,8 @@ The example below generates a spectrum with metallicity ``[M/H] = +0.1``, temperature :math:`T_{\text{eff}} = 10000 \text{K}`, and gravity :math:`\log g = 3.0`:: - >>> import stsynphot as STS - >>> sp = STS.grid_to_spec('phoenix', 10000, 0.1, 3.0) + >>> import stsynphot as stsyn + >>> sp = stsyn.grid_to_spec('phoenix', 10000, 0.1, 3.0) # doctest: +SKIP .. _stsynphot-appendixa-calspec: @@ -225,9 +223,9 @@ the header from G191B2B spectrum and then loads it into **stsynphot**:: >>> from astropy.io import fits >>> from synphot import SourceSpectrum >>> filename = os.path.join( - ... os.environ['PYSYN_CDBS'], 'calspec', 'g191b2b_mod_010.fits') - >>> hdr = fits.getheader(filename) - >>> hdr + ... os.environ['PYSYN_CDBS'], 'calspec', 'g191b2b_mod_010.fits') # doctest: +SKIP + >>> hdr = fits.getheader(filename) # doctest: +SKIP + >>> hdr # doctest: +SKIP SIMPLE = T / Fits standard BITPIX = 16 / Bits per pixel NAXIS = 0 / Number of axes @@ -259,7 +257,7 @@ the header from G191B2B spectrum and then loads it into **stsynphot**:: HISTORY Vega Flux(5556A)=3.44e-9 (Bohlin 2014, AJ, 147, 127) HISTORY INPUT FILE: /internal/1/wd/dat/g191.rauch59000-nlte HISTORY Written by MAKE_MOD_CALSPEC.pro 23-Dec-2014 10:20:09.00 - >>> sp = SourceSpectrum.from_file(filename) + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP Note that in some cases, the calibration spectrum is truncated in the blue or the red at wavelength longer or shorter, respectively, than the sensitivity @@ -307,8 +305,8 @@ subset of the library:: >>> from synphot import SourceSpectrum >>> filename = os.path.join( ... os.environ['PYSYN_CDBS'], 'grid', 'pickles', - ... 'dat_uvk', 'pickles_uk_27.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... 'dat_uvk', 'pickles_uk_27.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-bkmodels: @@ -340,8 +338,8 @@ The example below loads Block S (models for the Sun and Vega) with >>> import os >>> from synphot import SourceSpectrum >>> filename = os.path.join( - ... os.environ['PYSYN_CDBS'], 'grid', 'bkmodels', 'bk_s0001.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... os.environ['PYSYN_CDBS'], 'grid', 'bkmodels', 'bk_s0001.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-bz77: @@ -361,8 +359,8 @@ The example below loads a source spectrum of spectral type G5V from the atlas:: >>> import os >>> from synphot import SourceSpectrum >>> filename = os.path.join( - ... os.environ['PYSYN_CDBS'], 'grid', 'bz77', 'bz_27.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... os.environ['PYSYN_CDBS'], 'grid', 'bz77', 'bz_27.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-gs: @@ -385,8 +383,8 @@ The example below loads a source spectrum of spectral type G5V from the atlas:: >>> import os >>> from synphot import SourceSpectrum >>> filename = os.path.join( - ... os.environ['PYSYN_CDBS'], 'grid', 'gunnstryker', 'gs_44.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... os.environ['PYSYN_CDBS'], 'grid', 'gunnstryker', 'gs_44.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-bpgs: @@ -419,8 +417,8 @@ The example below loads a source spectrum of spectral type G5V from the atlas:: >>> import os >>> from synphot import SourceSpectrum >>> filename = os.path.join( - ... os.environ['PYSYN_CDBS'], 'grid', 'bpgs', 'bpgs_44.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... os.environ['PYSYN_CDBS'], 'grid', 'bpgs', 'bpgs_44.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-jacobi: @@ -444,8 +442,8 @@ The example below loads a source spectrum of spectral type G0V from the atlas:: >>> import os >>> from synphot import SourceSpectrum >>> filename = os.path.join( - ... os.environ['PYSYN_CDBS'], 'grid', 'jacobi', 'jc_43.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... os.environ['PYSYN_CDBS'], 'grid', 'jacobi', 'jc_43.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-bc95: @@ -474,8 +472,8 @@ instantaneous burst:: >>> from synphot import SourceSpectrum >>> filename = os.path.join( ... os.environ['PYSYN_CDBS'], 'grid', 'bc95', - ... 'templates', 'bc95_c_50E5.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... 'templates', 'bc95_c_50E5.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-kc96: @@ -499,8 +497,8 @@ The example below loads a galaxy spectrum from the elliptical template:: >>> from synphot import SourceSpectrum >>> filename = os.path.join( ... os.environ['PYSYN_CDBS'], 'grid', 'kc96', - ... 'elliptical_template.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... 'elliptical_template.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-agn: @@ -523,8 +521,8 @@ The example below loads a Seyfert 2 spectrum:: >>> import os >>> from synphot import SourceSpectrum >>> filename = os.path.join( - ... os.environ['PYSYN_CDBS'], 'grid', 'agn', 'seyfert2_template.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... os.environ['PYSYN_CDBS'], 'grid', 'agn', 'seyfert2_template.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-galactic: @@ -544,8 +542,8 @@ The example below loads the spectrum for Orion nebula:: >>> from synphot import SourceSpectrum >>> filename = os.path.join( ... os.environ['PYSYN_CDBS'], 'grid', 'galactic', - ... 'orion_template.fits') - >>> sp = SourceSpectrum.from_file(filename) + ... 'orion_template.fits') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP .. _stsynphot-appendixa-etcsource: @@ -563,5 +561,5 @@ The example below loads a spectrum for Gliese 229B brown dwarf:: >>> import os >>> from synphot import SourceSpectrum >>> filename = os.path.join( - ... os.environ['PYSYN_CDBS'], 'etc', 'source', 'gl229b_001.dat') - >>> sp = SourceSpectrum.from_file(filename) + ... os.environ['PYSYN_CDBS'], 'etc', 'source', 'gl229b_001.dat') # doctest: +SKIP + >>> sp = SourceSpectrum.from_file(filename) # doctest: +SKIP diff --git a/docs/stsynphot/appendixb.rst b/docs/stsynphot/appendixb.rst index 9bdca01..f5506fc 100644 --- a/docs/stsynphot/appendixb.rst +++ b/docs/stsynphot/appendixb.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. include:: appb_ref.txt .. _stsynphot-appendixb: diff --git a/docs/stsynphot/appendixb_inflight.rst b/docs/stsynphot/appendixb_inflight.rst index 8c6f6ff..58f836f 100644 --- a/docs/stsynphot/appendixb_inflight.rst +++ b/docs/stsynphot/appendixb_inflight.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. include:: appb_ref.txt .. _stsynphot-appendixb-inflight: @@ -21,8 +19,8 @@ The ACS keywords consist of a list of detectors, filters, :ref:`extraction apertures `, and |mjd_par| specifications. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('acs,wfc1,f555w') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('acs,wfc1,f555w') # doctest: +SKIP +---------------+-----------------------------------------------------------------+ |Description |Keywords | @@ -69,8 +67,8 @@ To use a ramp filter in simulations, use the keyword syntax and ``cenwave`` the desired central wavelength in Angstrom. Also see :ref:`stsynphot-parameterized` for more information. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('acs,wfc1,fr388n#3880') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('acs,wfc1,fr388n#3880') # doctest: +SKIP .. _stsynphot-appendixb-cos: @@ -97,8 +95,8 @@ Science Aperture will be included by default if neither is specified. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('cos,nuv,g185m,c1786') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('cos,nuv,g185m,c1786') # doctest: +SKIP +----------------+------------------------------------+ |Description |Keywords | @@ -147,8 +145,8 @@ axis. Some of the filter names are aliases for other filters. For instance, ``astroclear`` is an alias for F605W, ``clear`` for F583W, ``red`` for F650W, and ``yellow`` for 550W. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('fgs,f583w,y') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('fgs,f583w,y') # doctest: +SKIP +-----------+-----------------------------------------------------------+ |Description|Keywords | @@ -177,8 +175,8 @@ For thermal calculations, all component keywords, except the detector, may be For example:: - >>> import stsynphot as STS - >>> bp = STS.band('nicmos,1,f090m,dn,primary#270') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('nicmos,1,f090m,dn,primary#270') # doctest: +SKIP +-----------------+-----------------------------------------------------------------+ |Description |Keywords | @@ -241,25 +239,25 @@ units of electrons to DN. These ``obsmode`` strings are all equivalent, with 50CCD being the unobstructed full-field aperture for the CCD detector:: - >>> import stsynphot as STS - >>> bp = STS.band('stis,g430l') - >>> bp = STS.band('stis,ccd,g430l') - >>> bp = STS.band('stis,ccd,g430l,50ccd') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('stis,g430l') # doctest: +SKIP + >>> bp = stsyn.band('stis,ccd,g430l') # doctest: +SKIP + >>> bp = stsyn.band('stis,ccd,g430l,50ccd') # doctest: +SKIP This assumes that an imaging mirror is being used because the detector name is specified without a grating:: - >>> bp = STS.band('stis,ccd,f28x50lp') + >>> bp = stsyn.band('stis,ccd,f28x50lp') # doctest: +SKIP This will calculate results for the entire bandpass of the instrument because no central wavelength is specified:: - >>> bp = STS.band('stis,ccd,g430m,52X0.2') + >>> bp = stsyn.band('stis,ccd,g430m,52X0.2') # doctest: +SKIP This will only calculate results for the wavelength range covered by the specified wavelength setting:: - >>> bp = STS.band('stis,ccd,g430m,52X0.2,c4451') + >>> bp = stsyn.band('stis,ccd,g430m,52X0.2,c4451') # doctest: +SKIP +-----------+---------------------------------------------------------------------+ |Description|Keywords | @@ -311,8 +309,8 @@ The WFC3 keywords consist of a list of detectors, filters, |mjd_par|, and for each of its 2 channels (UVIS and IR), in addition to other special keyword, as tabulated below. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('wfc3,uvis1,f218w') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('wfc3,uvis1,f218w') # doctest: +SKIP +------------------------+-------------------------------------------------+ |Description |Keywords | @@ -366,5 +364,5 @@ However, the appropriate count rate for SNR calculations should be in electrons with a correction for this quantum yield effect; That is, users should specify the ``qyc`` keyword but not ``dn``. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('wfc3,uvis1,f218w,qyc') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('wfc3,uvis1,f218w,qyc') # doctest: +SKIP diff --git a/docs/stsynphot/appendixb_legacy.rst b/docs/stsynphot/appendixb_legacy.rst index 1c41e9a..626b552 100644 --- a/docs/stsynphot/appendixb_legacy.rst +++ b/docs/stsynphot/appendixb_legacy.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. include:: appb_ref.txt .. _stsynphot-appendixb-legacy: @@ -25,8 +23,8 @@ miscellaneous keywords. The ``f/48`` detector has 2 filter wheels and the The miscellaneous keywords include the :ref:`stsynphot-costar` and the occulting fingers. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('foc,costar,f/96,f410m') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('foc,costar,f/96,f410m') # doctest: +SKIP +--------------+--------------------------------------------------+ |Description |Keywords | @@ -113,25 +111,25 @@ The FOS keywords consist of a list of detectors, apertures, gratings, and polarimeter waveplates and waveplate position angles. :ref:`stsynphot-costar` keyword is also accepted. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('fos,costar,blue,g160l') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('fos,costar,blue,g160l') # doctest: +SKIP The waveplate keywords indicate whether Waveplate A or B is being used and the angle of the waveplate. The waveplate keyword syntax is ``POLpa-wp``, where ``pa`` is the position angle in degrees, and ``wp`` is the A or B waveplate:: - >>> bp = STS.band('fos,blue,g130h,pol135-a') + >>> bp = stsyn.band('fos,blue,g130h,pol135-a') # doctest: +SKIP The ``upper`` and ``lower`` aperture keywords are only recognized when used in conjunction with one of the paired apertures:: - >>> bp = STS.band('fos,blue,g130h,upper,1.0-pair') + >>> bp = stsyn.band('fos,blue,g130h,upper,1.0-pair') # doctest: +SKIP The ``order0`` keyword is only available in conjunction with the ``g160l`` grating and the ``blue`` detector:: - >>> bp = STS.band('fos,blue,g160l,order0') + >>> bp = stsyn.band('fos,blue,g160l,order0') # doctest: +SKIP +-----------+--------------------------------------------------+ |Description|Keywords | @@ -164,14 +162,14 @@ The GHRS keywords consist of a list of detectors, apertures, gratings or mirrors, and Echelle mode orders. :ref:`stsynphot-costar` keyword is also accepted. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('hrs,costar,lsa,g160m') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('hrs,costar,lsa,g160m') # doctest: +SKIP The Echelle mode orders are used with the keywords ``echa`` and ``echb``. Orders 18 to 33 are valid with Echelle mode B, while orders 33 to 53 with mode A. For example:: - >>> bp = STS.band('hrs,costar,lsa,echa,33') + >>> bp = stsyn.band('hrs,costar,lsa,echa,33') # doctest: +SKIP +-----------+--------------------------------------------------+ |Description|Keywords | @@ -200,8 +198,8 @@ with all detectors; Refer to the HSP Instrument Handbook for further information. The polarization detector also has angle and type keywords. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('hsp,uv1,f220w,c') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('hsp,uv1,f220w,c') # doctest: +SKIP +------------------+-------------------------------------------------+ |Description |Keywords | @@ -253,8 +251,8 @@ and ``pc`` is 6. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('wfpc,4,f194w,dn') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('wfpc,4,f194w,dn') # doctest: +SKIP +---------------+-------------------------------+ |Decription |Keywords | @@ -317,8 +315,8 @@ Wide Field Camera. If a detector is not specified, the default is Detector 4. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('wfpc2,2,f450w,a2d7,cont#50180') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('wfpc2,2,f450w,a2d7,cont#50180') # doctest: +SKIP +---------------+------------------------------------------------------+ |Description |Keywords | @@ -393,8 +391,8 @@ by the PC, it is necessary to rotate the quad filters as follow The nominal positions are represented as ``fquvn``, ``fqch4n``, and ``polq`` keywords. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('wfpc2,2,fqch4n') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('wfpc2,2,fqch4n') # doctest: +SKIP .. _stsynphot-wfpc2-ramp: @@ -409,5 +407,5 @@ the central wavelength. To use a WFPC2 ramp filter in simulations, use the keyword syntax ``lrf#cenwave``, where ``cenwave`` is the desired central wavelength in Angstrom. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('wfpc2,3,lrf#4861') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('wfpc2,3,lrf#4861') # doctest: +SKIP diff --git a/docs/stsynphot/appendixb_nonhst.rst b/docs/stsynphot/appendixb_nonhst.rst index 160355e..9501593 100644 --- a/docs/stsynphot/appendixb_nonhst.rst +++ b/docs/stsynphot/appendixb_nonhst.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. include:: appb_ref.txt .. _stsynphot-appendixb-nonhst: @@ -15,16 +13,16 @@ needed) are as tabulated below. Non-HST filters are specified using the name of the filter system, followed by the desired band name. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('cousins,i') - >>> bp = STS.band('stromgren,u') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('cousins,i') # doctest: +SKIP + >>> bp = stsyn.band('stromgren,u') # doctest: +SKIP If the name of the filter system is omitted for any of the common *UBVRIJHK* filters, the defaults are Johnson *UBV*, Cousins *RI*, and Bessell *JHK*. For example, the following are equivalent: - >>> bp = STS.band('v') - >>> bp = STS.band('johnson,v') + >>> bp = stsyn.band('v') # doctest: +SKIP + >>> bp = stsyn.band('johnson,v') # doctest: +SKIP +------------------+-------------+ |System Name |Band Name | @@ -121,8 +119,8 @@ The Cousins *RI* throughputs are taken from :ref:`Bessell (1983) `. They have been transformed into photon-counting form. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('cousins,i') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('cousins,i') # doctest: +SKIP .. _stsynphot-nonhst-galex: @@ -141,8 +139,8 @@ represent the true total throughput, including obscuration by the secondary mirror, reflectivity of the mirrors, sensitivity of the detector, and so forth. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('galex,fuv') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('galex,fuv') # doctest: +SKIP .. _stsynphot-nonhst-johnson: @@ -154,8 +152,8 @@ The throughput data for the Johnson *UBV* bands were obtained from :ref:`Maiz Apellaniz (2006) `, while the *RIJK* bands from :ref:`Johnson (1965) `. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('johnson,v') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('johnson,v') # doctest: +SKIP .. _stsynphot-nonhst-landolt: @@ -167,8 +165,8 @@ The :ref:`Landolt (1983) ` *UBVRI* system is made up of the :ref:`stsynphot-nonhst-johnson` *UBV* and the :ref:`stsynphot-nonhst-cousins` *RI* bandpass. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('landolt,v') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('landolt,v') # doctest: +SKIP .. _stsynphot-nonhst-sdss: @@ -182,8 +180,8 @@ as described in :ref:`Gunn et al. (2001) `. The filter curves are shown in the `SDSS filter response plot `_. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('sdss,g') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('sdss,g') # doctest: +SKIP The throughput data give the system photon response to point sources of the 2.5-m SDSS survey telescope, including extinction through an airmass of 1.3 at @@ -245,8 +243,8 @@ Stromgren The Stromgren *uvby* throughputs are taken from :ref:`Maiz Apellaniz (2006) `. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('stromgren,y') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('stromgren,y') # doctest: +SKIP .. _stsynphot-nonhst-deprecated: @@ -292,8 +290,8 @@ The Astronomical Netherlands Satellite (ANS) system is a set of UV filters used by the satellite, as described in :ref:`van Duinen et al. (1975) `. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('ans,1550') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('ans,1550') # doctest: +SKIP .. _stsynphot-nonhst-baum: @@ -310,8 +308,8 @@ by the spectral response curve of the ground-based CCD (measured in the laboratory) and twice by the spectral reflectance of aluminum (:ref:`Harris et al. 1991 `). For example:: - >>> import stsynphot as STS - >>> bp = STS.band('baum,f336w') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('baum,f336w') # doctest: +SKIP .. _stsynphot-nonhst-bessell: @@ -325,8 +323,8 @@ These curves include the mean atmospheric transmission equivalent to 1.2 air masses of a standard `KPNO `_ atmosphere. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('bessell,k') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('bessell,k') # doctest: +SKIP .. _stsynphot-nonhst-eso: @@ -337,8 +335,8 @@ ESO The 530 ESO band throughput tables were received from Jan Koornneef in 1990. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('eso,198') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('eso,198') # doctest: +SKIP .. _stsynphot-nonhst-kpno: @@ -351,8 +349,8 @@ filter curves are taken from the tracings of the Simultaneous Quad Infrared Image Device (SQIID) filter set, which were provided by Richard Joyce from the observatory. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('kpno,k') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('kpno,k') # doctest: +SKIP .. _stsynphot-nonhst-steward: @@ -364,8 +362,8 @@ The `Steward Observatory `_ *JHK* filter curves are from data provided by Marcia Rieke from the observatory. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('steward,k') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('steward,k') # doctest: +SKIP .. _stsynphot-nonhst-walraven: @@ -376,5 +374,5 @@ Walraven The throughput data for the Walraven *VBLUW* bands are from :ref:`Lub & Pel (1977) `, Table 6. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('walraven,v') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('walraven,v') # doctest: +SKIP diff --git a/docs/stsynphot/appendixb_specialkey.rst b/docs/stsynphot/appendixb_specialkey.rst index 2ae06db..ac4d8d5 100644 --- a/docs/stsynphot/appendixb_specialkey.rst +++ b/docs/stsynphot/appendixb_specialkey.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. include:: appb_ref.txt .. _stsynphot-appendixb-special-keywords: @@ -19,8 +17,8 @@ The HST OTA transmissivity is included by default in the calculation of all HST-related observation modes. It can be included or excluded explicitly by adding the keywords ``ota`` or ``noota``, respectively; For example:: - >>> import stsynphot as STS - >>> bp = STS.band('stis,ccd,f25srf2,noota') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('stis,ccd,f25srf2,noota') # doctest: +SKIP .. _stsynphot-costar: @@ -44,8 +42,8 @@ versions of the graph table, ``nocostar`` is the default. To explicitly include or exclude COSTAR, use the keywords ``costar`` and ``nocostar``, respectively, anywhere within your observation mode string; For example:: - >>> import stsynphot as STS - >>> bp = STS.band('fos,red,4.3,g270h,costar') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('fos,red,4.3,g270h,costar') # doctest: +SKIP All current HST instruments (except :ref:`stsynphot-appendixb-fgs`) have built-in corrective optics to compensate for the spherical aberration of the @@ -70,8 +68,8 @@ value, which could be an integer or a floating point. to arrive at an estimate of the throughput on the requested date (see :ref:`stsynphot-parameterized`). For example:: - >>> import stsynphot as STS - >>> bp = STS.band('acs,wfc1,f555w,mjd#49486') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('acs,wfc1,f555w,mjd#49486') # doctest: +SKIP If not specified, the default is to use the latest set of throughput values in the ``THROUGHPUT`` column without any @@ -134,8 +132,8 @@ When "aper#0" is specified, the user will obtain the number of counts in the brightest pixel (i.e., the peak counts of the source centered at that pixel). For example:: - >>> import stsynphot as STS - >>> bp = STS.band('acs,wfc1,f850lp,aper#0.2') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('acs,wfc1,f850lp,aper#0.2') # doctest: +SKIP .. _stsynphot-parameterized-temperature: @@ -160,8 +158,8 @@ table is used to correctly compute the detected signal from a background spectrum, which gives the transmission of the grism over its entire bandpass. The ``bkg`` keyword cannot be used with non-grism observations. For example:: - >>> import stsynphot as STS - >>> bp = STS.band('wfc3,ir,g102,bkg') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('wfc3,ir,g102,bkg') # doctest: +SKIP For NICMOS, all keywords except the detector are parameterized for temperature. This includes OTA components that are opaque but thermally @@ -172,8 +170,8 @@ not enforce this, so the user must specify any non-default temperature for each component individually. For example, to specify a primary mirror temperature of 290 K and then calculate the thermal background: - >>> bp = STS.band('nicmos,3,f222m,primary#290.0') - >>> bp.thermback() + >>> bp = stsyn.band('nicmos,3,f222m,primary#290.0') # doctest: +SKIP + >>> bp.thermback() # doctest: +SKIP @@ -197,5 +195,5 @@ in intervals of approximately 30 days. to arrive at an estimate of the throughput on the requested date (see :ref:`stsynphot-parameterized`). For example:: - >>> import stsynphot as STS - >>> bp = STS.band('wfpc2,3,f555w,cont#49800') + >>> import stsynphot as stsyn + >>> bp = stsyn.band('wfpc2,3,f555w,cont#49800') # doctest: +SKIP diff --git a/docs/stsynphot/appendixc.rst b/docs/stsynphot/appendixc.rst index 78d03d7..584add4 100644 --- a/docs/stsynphot/appendixc.rst +++ b/docs/stsynphot/appendixc.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot-appendixc: Appendix C: TMG, TMC, and TMT Files @@ -400,9 +398,9 @@ The example below displays the header keywords mentioned above:: >>> from astropy.io import fits >>> filename = os.path.join( ... os.environ['PYSYN_CDBS'], 'comp', 'nicmos', - ... 'nic2_f110w_002_th.fits') - >>> with fits.open(filename) as pf: - ... print(pf[1].header) + ... 'nic2_f110w_002_th.fits') # doctest: +SKIP + >>> with fits.open(filename) as pf: # doctest: +SKIP + ... print(pf[1].header) # doctest: +SKIP ... BEAMFILL= 1. / Fraction of beam filled by this component DEFT = 77.1 / Default temperature in kelvins diff --git a/docs/stsynphot/commissioning.rst b/docs/stsynphot/commissioning.rst index 9a11dca..aefe9d0 100644 --- a/docs/stsynphot/commissioning.rst +++ b/docs/stsynphot/commissioning.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot_comm_report: Commissioning Report diff --git a/docs/stsynphot/data_atlas.rst b/docs/stsynphot/data_atlas.rst index 844d900..5e2f4e0 100644 --- a/docs/stsynphot/data_atlas.rst +++ b/docs/stsynphot/data_atlas.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _atlas_data_files: Atlases and calibration spectra files diff --git a/docs/stsynphot/data_hst.rst b/docs/stsynphot/data_hst.rst index 1912611..9d135d6 100644 --- a/docs/stsynphot/data_hst.rst +++ b/docs/stsynphot/data_hst.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _hst_data_files: HST data files diff --git a/docs/stsynphot/data_jwst.rst b/docs/stsynphot/data_jwst.rst index 640dc87..29dc27d 100644 --- a/docs/stsynphot/data_jwst.rst +++ b/docs/stsynphot/data_jwst.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _jwst_data_files: JWST data files (coming soon) diff --git a/docs/stsynphot/from_pysyn_iraf.rst b/docs/stsynphot/from_pysyn_iraf.rst index ca9caa3..f4fe97d 100644 --- a/docs/stsynphot/from_pysyn_iraf.rst +++ b/docs/stsynphot/from_pysyn_iraf.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot-switcher: Switching from Legacy Software @@ -164,7 +162,7 @@ IRAF setup:: Python imports:: >>> import os - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from synphot import units, SourceSpectrum, Observation >>> from synphot.models import BlackBodyNorm1D @@ -184,13 +182,13 @@ The blackbody spectrum is normalized to be 18.6 VEGAMAG in *V*-band:: .. code-block:: python >>> rnbb = SourceSpectrum(BlackBodyNorm1D, temperature=5000).normalize( - ... 18.6 * units.VEGAMAG, band=STS.band('v'), vegaspec=STS.Vega) - >>> obs = Observation(rnbb, STS.band('wfpc,f555w')) + ... 18.6 * units.VEGAMAG, band=stsyn.band('v'), vegaspec=stsyn.Vega) # doctest: +SKIP + >>> obs = Observation(rnbb, stsyn.band('wfpc,f555w')) # doctest: +SKIP >>> print('Pivot Wavelength: {:.3f}\n' ... 'Equiv Gaussian FWHM: {:.3f}\n' ... 'Countrate: {:.4f}'.format( ... obs.bandpass.pivot(), obs.bandpass.fwhm(), - ... obs.countrate(STS.conf.area))) + ... obs.countrate(stsyn.conf.area))) # doctest: +SKIP Pivot Wavelength: 5467.651 Angstrom Equiv Gaussian FWHM: 1200.923 Angstrom Countrate: 416.4439 ct / s @@ -213,13 +211,13 @@ WFC1 F555W bandpass for :math:`E(B-V)` values of 0.0, 0.25, and 0.5:: >>> law = 'mwavg' # stsynphot has no obsolete ebmv(), so use this instead >>> sp = SourceSpectrum(BlackBodyNorm1D, temperature=5000) - >>> bp = STS.band('acs,wfc1,f555w') - >>> for ebv in (0.0, 0.25, 0.5): + >>> bp = stsyn.band('acs,wfc1,f555w') # doctest: +SKIP + >>> for ebv in (0.0, 0.25, 0.5): # doctest: +SKIP ... if ebv == 0: ... print('VZERO\tOBMAG') # Header - ... obs = Observation(sp * STS.ebmvx(law, ebv), bp) + ... obs = Observation(sp * stsyn.ebmvx(law, ebv), bp) ... print('{}\t{:.4f}'.format( - ... ebv, obs.effstim(units.OBMAG, area=STS.conf.area))) + ... ebv, obs.effstim(units.OBMAG, area=stsyn.conf.area))) VZERO OBMAG 0.0 -10.0118 OBMAG 0.25 -9.2167 OBMAG @@ -240,11 +238,11 @@ proper magnitude of 9.5 VEGAMAG in *U*-band:: .. code-block:: python >>> filename = os.path.join( - ... os.environ['PYSYN_CDBS'], 'calspec', 'bd_75d325_stis_003.fits') + ... os.environ['PYSYN_CDBS'], 'calspec', 'bd_75d325_stis_003.fits') # doctest: +SKIP >>> sp = SourceSpectrum.from_file(filename).normalize( - ... 9.5 * units.VEGAMAG, band=STS.band('u'), vegaspec=STS.Vega) - >>> obs = Observation(sp, STS.band('acs,sbc,f125lp')) - >>> obs.plot(flux_unit=units.FLAM, left=1200, right=2000) + ... 9.5 * units.VEGAMAG, band=stsyn.band('u'), vegaspec=stsyn.Vega) # doctest: +SKIP + >>> obs = Observation(sp, stsyn.band('acs,sbc,f125lp')) # doctest: +SKIP + >>> obs.plot(flux_unit=units.FLAM, left=1200, right=2000) # doctest: +SKIP .. image:: images/bd75325_plspec_ex2.png :width: 600px @@ -328,11 +326,11 @@ These are the reddening laws (``law``) recognized by the parser for the This example shows how a blackbody can be generated using both the parser and the Pythonic command. It also shows that they are equivalent:: - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from synphot import SourceSpectrum >>> from synphot.models import BlackBodyNorm1D >>> from numpy.testing import assert_allclose - >>> bb1 = STS.parse_spec('bb(5000)') + >>> bb1 = stsyn.parse_spec('bb(5000)') >>> bb2 = SourceSpectrum(BlackBodyNorm1D, temperature=5000) >>> assert_allclose(bb1.integrate(), bb2.integrate()) @@ -343,11 +341,11 @@ Even though the Pythonic way takes more lines of codes to accomplish, one might also argue that it is more readable:: >>> from astropy import units as u - >>> sp1 = STS.parse_spec( + >>> sp1 = stsyn.parse_spec( ... 'ebmvx(0.1, lmcavg) * z(rn(icat(k93models, 5000, -0.5, 4.4), ' - ... 'band(johnson,v), 18, abmag), 0.01)') - >>> rnsp = STS.grid_to_spec('k93models', 5000, -0.5, 4.4).normalize( - ... 18 * u.ABmag, band=STS.band('johnson,v')) - >>> rnsp.z = 0.01 - >>> sp2 = STS.ebmvx('lmcavg', 0.1) * rnsp - >>> assert_allclose(sp1.integrate(), sp2.integrate()) + ... 'band(johnson,v), 18, abmag), 0.01)') # doctest: +SKIP + >>> rnsp = stsyn.grid_to_spec('k93models', 5000, -0.5, 4.4).normalize( + ... 18 * u.ABmag, band=stsyn.band('johnson,v')) # doctest: +SKIP + >>> rnsp.z = 0.01 # doctest: +SKIP + >>> sp2 = stsyn.ebmvx('lmcavg', 0.1) * rnsp # doctest: +SKIP + >>> assert_allclose(sp1.integrate(), sp2.integrate()) # doctest: +SKIP diff --git a/docs/stsynphot/obsmode.rst b/docs/stsynphot/obsmode.rst index aaebfa7..81407fb 100644 --- a/docs/stsynphot/obsmode.rst +++ b/docs/stsynphot/obsmode.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot-obsmode: Observation Modes @@ -37,12 +35,12 @@ Examples Create a bandpass for HST/ACS instrument with its WFC1 detector and F555W filter:: - >>> import stsynphot as STS - >>> bp_acs = STS.band('acs,wfc1,f555w') + >>> import stsynphot as stsyn + >>> bp_acs = stsyn.band('acs,wfc1,f555w') # doctest: +SKIP To see which throughput tables are being used, as set by CRDS:: - >>> bp_acs.showfiles() + >>> bp_acs.showfiles() # doctest: +SKIP /my/local/dir/cdbs/comp/ota/hst_ota_007_syn.fits /my/local/dir/cdbs/comp/acs/acs_wfc_im123_004_syn.fits /my/local/dir/cdbs/comp/acs/acs_f555w_wfc_005_syn.fits @@ -51,17 +49,17 @@ To see which throughput tables are being used, as set by CRDS:: Create a bandpass for Johnson *V*:: - >>> bp_v = STS.band('johnson,v') + >>> bp_v = stsyn.band('johnson,v') # doctest: +SKIP Compare them in a plot:: - >>> import matplotlib.pyplot as plt + >>> import matplotlib.pyplot as plt # doctest: +SKIP >>> from astropy.visualization import quantity_support - >>> quantity_support() + >>> quantity_support() # doctest: +SKIP >>> plt.plot(bp_acs.waveset, bp_acs(bp_acs.waveset), 'b', - ... bp_v.waveset, bp_v(bp_v.waveset), 'g--') - >>> plt.xlim(4000, 7000) - >>> plt.legend([bp_acs.obsmode, bp_v.obsmode], loc='best') + ... bp_v.waveset, bp_v(bp_v.waveset), 'g--') # doctest: +SKIP + >>> plt.xlim(4000, 7000) # doctest: +SKIP + >>> plt.legend([bp_acs.obsmode, bp_v.obsmode], loc='best') # doctest: +SKIP .. image:: images/acs_v_bp_ex1.png :width: 600px @@ -72,15 +70,15 @@ Then plot the actual bandpass and overlay those components:: >>> from synphot import SpectralElement >>> ota = SpectralElement.from_file( - ... '/my/local/dir/cdbs/comp/ota/hst_ota_007_syn.fits') + ... '/my/local/dir/cdbs/comp/ota/hst_ota_007_syn.fits') # doctest: +SKIP >>> ccd = SpectralElement.from_file( - ... '/my/local/dir/cdbs/comp/acs/acs_wfc_ccd1_mjd_021_syn.fits') - >>> bp_partial = ota * ccd - >>> w = bp_acs.binset # waveset that is optimal for binning - >>> plt.plot(w, ota(w), 'b--', w, ccd(w), 'r--', w, bp_partial(w), 'g', w, bp_acs(w), 'k') - >>> plt.xlim(w[0], w[-1]) - >>> plt.ylim(0, 1.1) - >>> plt.legend(['ota', 'ccd', 'ota*ccd', bp_acs.obsmode], loc='upper left', fontsize=12) + ... '/my/local/dir/cdbs/comp/acs/acs_wfc_ccd1_mjd_021_syn.fits') # doctest: +SKIP + >>> bp_partial = ota * ccd # doctest: +SKIP + >>> w = bp_acs.binset # waveset that is optimal for binning # doctest: +SKIP + >>> plt.plot(w, ota(w), 'b--', w, ccd(w), 'r--', w, bp_partial(w), 'g', w, bp_acs(w), 'k') # doctest: +SKIP + >>> plt.xlim(w[0], w[-1]) # doctest: +SKIP + >>> plt.ylim(0, 1.1) # doctest: +SKIP + >>> plt.legend(['ota', 'ccd', 'ota*ccd', bp_acs.obsmode], loc='upper left', fontsize=12) # doctest: +SKIP .. image:: images/acs_wfc1_f555w_comp_ex1.png :width: 600px @@ -103,12 +101,12 @@ The example below calculates the number of pixels covered from 8600.5 to 12400.5 Angstrom. Then, it calculates the starting and ending wavelengths covered by 3800 pixels centered at 10500 Angstrom:: - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from astropy import units as u - >>> bp = STS.band('wfc3,ir,f105w') - >>> bp.binned_pixelrange([8600.5, 12400.5] * u.AA) + >>> bp = stsyn.band('wfc3,ir,f105w') # doctest: +SKIP + >>> bp.binned_pixelrange([8600.5, 12400.5] * u.AA) # doctest: +SKIP 3800 - >>> bp.binned_waverange(10500 * u.AA, 3800) + >>> bp.binned_waverange(10500 * u.AA, 3800) # doctest: +SKIP @@ -125,19 +123,19 @@ For non-IR detectors, calling this method will raise ``NotImplementedError``. For example:: - >>> import stsynphot as STS - >>> bp_wfc3 = STS.band('wfc3,ir,f105w') - >>> bp_wfc3.thermback() + >>> import stsynphot as stsyn + >>> bp_wfc3 = stsyn.band('wfc3,ir,f105w') # doctest: +SKIP + >>> bp_wfc3.thermback() # doctest: +SKIP - >>> bp_acs = STS.band('acs,wfc1,f555w') - >>> bp_acs.thermback() + >>> bp_acs = stsyn.band('acs,wfc1,f555w') # doctest: +SKIP + >>> bp_acs.thermback() # doctest: +SKIP ... NotImplementedError: No thermal support provided for acs,wfc1,f555w To plot the thermal spectrum for WFC3/IR bandpass above:: - >>> thsp = bp_wfc3.obsmode.thermal_spectrum() - >>> thsp.plot(left=14000, right=18500) + >>> thsp = bp_wfc3.obsmode.thermal_spectrum() # doctest: +SKIP + >>> thsp.plot(left=14000, right=18500) # doctest: +SKIP .. image:: images/wfc3_ir_therm_spec.png :width: 600px @@ -180,20 +178,19 @@ The example below (adapted from an example in the documentation of IRAF SYNPHOT ``calcphot`` task) shows you how to calculate the color indices of a 2500 K blackbody in Cousins *I* and HST/WFC3 UVIS1 F814W bandpasses:: - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from synphot import SourceSpectrum, Observation >>> from synphot.models import BlackBodyNorm1D >>> # Create the blackbody >>> bb = SourceSpectrum(BlackBodyNorm1D, temperature=2500) >>> # Create WFC3 observation - >>> obs_wfc3 = Observation(bb, STS.band('wfc3,uvis1,f814w')) + >>> obs_wfc3 = Observation(bb, stsyn.band('wfc3,uvis1,f814w')) # doctest: +SKIP >>> # Create Cousins I observation using WFC3 binning for consistency - >>> obs_i = Observation(bb, STS.band('i'), binset=obs_wfc3.binset) + >>> obs_i = Observation(bb, stsyn.band('i'), binset=obs_wfc3.binset) # doctest: +SKIP >>> # Color index in instrumental magnitude - >>> area = STS.conf.area - >>> obs_i.effstim('obmag', area=area) - \ - ... obs_wfc3.effstim('obmag', area=area) + >>> area = stsyn.conf.area + >>> obs_i.effstim('obmag', area=area) - obs_wfc3.effstim('obmag', area=area) # doctest: +SKIP >>> # Color index in FLA - >>> obs_i.effstim('flam') / obs_wfc3.effstim('flam') - >>> + >>> obs_i.effstim('flam') / obs_wfc3.effstim('flam') # doctest: +SKIP + diff --git a/docs/stsynphot/overview.rst b/docs/stsynphot/overview.rst index e3be618..a360cd7 100644 --- a/docs/stsynphot/overview.rst +++ b/docs/stsynphot/overview.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot_overview: Overview diff --git a/docs/stsynphot/refdata.rst b/docs/stsynphot/refdata.rst index 1766596..d2b26f8 100644 --- a/docs/stsynphot/refdata.rst +++ b/docs/stsynphot/refdata.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot-refdata: Reference Data @@ -47,15 +45,15 @@ can also set them to specific filenames. It is also possible to For backward compatibilty, :func:`~stsynphot.config.showref` and :func:`~stsynphot.config.getref` convenience functions are provided:: - >>> import stsynphot as STS - >>> STS.showref() + >>> import stsynphot as stsyn + >>> stsyn.showref() # doctest: +SKIP graphtable: /my/local/dir/cdbs/mtab/0bf2050hm_tmg.fits comptable : /my/local/dir/cdbs/mtab/0ac1951am_tmc.fits thermtable: /my/local/dir/cdbs/mtab/tae17277m_tmt.fits area : 45238.93416 waveset : Min: 500, Max: 26000, Num: 10000, Delta: None, Log: True [stsynphot.config] - >>> STS.getref() + >>> stsyn.getref() # doctest: +SKIP {'area': 45238.93416, 'comptable': '/my/local/dir/cdbs/mtab/0ac1951am_tmc.fits', 'graphtable': '/my/local/dir/cdbs/mtab/0bf2050hm_tmg.fits', @@ -67,12 +65,12 @@ To change a configurable item's value, use the machinery of Examples shown are only for ``graphtable`` but they are similar for others (in fact, usually all the graph and component tables are changed together):: - >>> STS.conf.graphtable = '/path/to/my_new_tmg.fits' # Entire session - >>> STS.conf.reload('graphtable') # Reload from stsynphot.cfg - >>> STS.conf.reload() # Reload everything - >>> STS.conf.reset('graphtable') # Reset to software default - >>> STS.conf.reset() # Reset everything - >>> with STS.conf.set_temp('graphtable', '/path/to/my_new_tmg.fits'): + >>> stsyn.conf.graphtable = '/path/to/my_new_tmg.fits' # Entire session + >>> stsyn.conf.reload('graphtable') # Reload from stsynphot.cfg + >>> stsyn.conf.reload() # Reload everything + >>> stsyn.conf.reset('graphtable') # Reset to software default + >>> stsyn.conf.reset() # Reset everything + >>> with stsyn.conf.set_temp('graphtable', '/path/to/my_new_tmg.fits'): ... pass # graphtable will only change inside this block @@ -92,8 +90,8 @@ observation mode. They can be displayed using A bandpass that does not rely on the tables does not have this feature. For example:: - >>> bp_hst = STS.band('wfc3,ir,f105w') - >>> bp_hst.showfiles() + >>> bp_hst = stsyn.band('wfc3,ir,f105w') # doctest: +SKIP + >>> bp_hst.showfiles() # doctest: +SKIP /my/local/dir/cdbs/comp/wfc3/wfc3_ir_primary_001_syn.fits /my/local/dir/cdbs/comp/wfc3/wfc3_ir_secondary_001_syn.fits /my/local/dir/cdbs/comp/wfc3/wfc3_pom_001_syn.fits @@ -109,8 +107,8 @@ For example:: /my/local/dir/cdbs/comp/wfc3/wfc3_ir_cor_004_syn.fits [...] >>> from synphot import SpectralElement - >>> bp_nonhst = SpectralElement.from_filter('johnson_v') - >>> bp_nonhst.showfiles() + >>> bp_nonhst = SpectralElement.from_filter('johnson_v') # doctest: +REMOTE_DATA + >>> bp_nonhst.showfiles() # doctest: +SKIP AttributeError: 'SpectralElement' object has no attribute 'showfiles' @@ -147,10 +145,10 @@ pre-defined wavelength catalog in ``wavecatfile`` and can be accessed via `~stsynphot.spectrum.ObservationSpectralElement.binset`. For example:: >>> from synphot import Observation - >>> obs = Observation(STS.Vega, bp_hst, binset=bp_hst.binset) - >>> bp_hst.binset + >>> obs = Observation(stsyn.Vega, bp_hst, binset=bp_hst.binset) # doctest: +SKIP + >>> bp_hst.binset # doctest: +SKIP - >>> obs.binset + >>> obs.binset # doctest: +SKIP For more details on how the catalog works, see the `~stsynphot.wavetable` diff --git a/docs/stsynphot/spectrum.rst b/docs/stsynphot/spectrum.rst index d1e2fb6..f032c76 100644 --- a/docs/stsynphot/spectrum.rst +++ b/docs/stsynphot/spectrum.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot-spec-main: Source Spectrum @@ -55,20 +53,20 @@ or :ref:`stsynphot-appendixa-kc96`. The example below plots the spectra of a starburst and a Seyfert 1 galaxies from their respective atlases:: >>> import os - >>> import matplotlib.pyplot as plt + >>> import matplotlib.pyplot as plt # doctest: +SKIP >>> from synphot import SourceSpectrum >>> starburst = SourceSpectrum.from_file(os.path.join( - ... os.environ['PYSYN_CDBS'], 'grid', 'kc96', 'starb2_template.fits')) + ... os.environ['PYSYN_CDBS'], 'grid', 'kc96', 'starb2_template.fits')) # doctest: +SKIP >>> seyfert1 = SourceSpectrum.from_file(os.path.join( - ... os.environ['PYSYN_CDBS'], 'grid', 'agn', 'seyfert1_template.fits')) + ... os.environ['PYSYN_CDBS'], 'grid', 'agn', 'seyfert1_template.fits')) # doctest: +SKIP >>> wave = range(1500, 7000) >>> plt.semilogy(wave, starburst(wave, flux_unit='flam'), 'r', - ... wave, seyfert1(wave, flux_unit='flam'), 'b') - >>> plt.xlim(1500, 7000) - >>> plt.ylim(1E-14, 2E-12) - >>> plt.xlabel('Wavelength (Angstrom)') - >>> plt.ylabel('Flux (FLAM)') - >>> plt.legend(['Starburst 2', 'Seyfert 1'], loc='upper right') + ... wave, seyfert1(wave, flux_unit='flam'), 'b') # doctest: +SKIP + >>> plt.xlim(1500, 7000) # doctest: +SKIP + >>> plt.ylim(1E-14, 2E-12) # doctest: +SKIP + >>> plt.xlabel('Wavelength (Angstrom)') # doctest: +SKIP + >>> plt.ylabel('Flux (FLAM)') # doctest: +SKIP + >>> plt.legend(['Starburst 2', 'Seyfert 1'], loc='upper right') # doctest: +SKIP .. image:: images/AGN_compare.png :width: 600px @@ -96,8 +94,8 @@ The example below obtains the spectrum for a :math:`T_{\text{eff}} = 6000 \; \text{K}`, ``[M/H] = 0``, and :math:`\log g = 4.3`:: - >>> import stsynphot as STS - >>> sp = STS.grid_to_spec('k93models', 6440, 0, 4.3) + >>> import stsynphot as stsyn + >>> sp = stsyn.grid_to_spec('k93models', 6440, 0, 4.3) # doctest: +SKIP For completeness, the Kurucz spectrum is plotted below in comparison with the Seyfert 1 from above. Note that the Kurucz spectrum has arbitrary @@ -105,11 +103,11 @@ flux values and would need to be renormalize using :meth:`~synphot.spectrum.BaseSourceSpectrum.normalize` (not done here):: >>> plt.semilogy(wave, sp(wave, flux_unit='flam'), 'r', - ... wave, seyfert1(wave, flux_unit='flam'), 'b') - >>> plt.xlim(1500, 6000) - >>> plt.xlabel('Wavelength (Angstrom)') - >>> plt.ylabel('Flux (FLAM)') - >>> plt.legend(['Kurucz', 'Seyfert 1'], loc='center right') + ... wave, seyfert1(wave, flux_unit='flam'), 'b') # doctest: +SKIP + >>> plt.xlim(1500, 6000) # doctest: +SKIP + >>> plt.xlabel('Wavelength (Angstrom)') # doctest: +SKIP + >>> plt.ylabel('Flux (FLAM)') # doctest: +SKIP + >>> plt.legend(['Kurucz', 'Seyfert 1'], loc='center right') # doctest: +SKIP .. image:: images/spec_atlas_ex.png :width: 600px diff --git a/docs/stsynphot/tutorials.rst b/docs/stsynphot/tutorials.rst index 7b0d049..7dcd7b4 100644 --- a/docs/stsynphot/tutorials.rst +++ b/docs/stsynphot/tutorials.rst @@ -1,5 +1,3 @@ -.. doctest-skip-all - .. _stsynphot-tutorials: Tutorials @@ -22,19 +20,19 @@ radius specification (see :ref:`stsynphot-appendixb`). Create two observations of Vega (renormalized to 20 STMAG in Johnson *V*) with ACS/WFC1 F555W bandpass, with 0.3 and 1.0 arcsec EE radii, respectively:: - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from astropy import units as u >>> from synphot import Observation - >>> sp = STS.Vega.normalize(20 * u.STmag, STS.band('johnson,v')) - >>> obs03 = Observation(sp, STS.band('acs,wfc1,f555w,aper#0.3')) - >>> obs10 = Observation(sp, STS.band('acs,wfc1,f555w,aper#1.0')) + >>> sp = stsyn.Vega.normalize(20 * u.STmag, stsyn.band('johnson,v')) # doctest: +SKIP + >>> obs03 = Observation(sp, stsyn.band('acs,wfc1,f555w,aper#0.3')) # doctest: +SKIP + >>> obs10 = Observation(sp, stsyn.band('acs,wfc1,f555w,aper#1.0')) # doctest: +SKIP Calculate the count rates for both and display the results:: - >>> c03 = obs03.countrate(STS.conf.area) - >>> c10 = obs10.countrate(STS.conf.area) + >>> c03 = obs03.countrate(stsyn.conf.area) # doctest: +SKIP + >>> c10 = obs10.countrate(stsyn.conf.area) # doctest: +SKIP >>> print('Count rate for 0.3" is {:.3f}\n' - ... 'Count rate for 1.0" is {:.3f}'.format(c03, c10)) + ... 'Count rate for 1.0" is {:.3f}'.format(c03, c10)) # doctest: +SKIP Count rate for 0.3" is 174.801 ct / s Count rate for 1.0" is 186.521 ct / s @@ -54,15 +52,24 @@ In this tutorial, you will learn how to calculate the STMAG zeropoint for the ACS/WFC1 F555W bandpass, which happens to be time-dependent:: >>> import numpy as np - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from astropy.time import Time >>> obsdate = Time('2017-05-30').mjd - >>> bp = STS.band('acs,wfc1,f555w,mjd#{}'.format(obsdate)) - >>> photflam = bp.unit_response(STS.conf.area) - >>> photflam + >>> obsmode = 'acs,wfc1,f555w,mjd#{}'.format(obsdate) + >>> bp = stsyn.band(obsmode) # doctest: +SKIP + >>> photflam = bp.unit_response(stsyn.conf.area) # doctest: +SKIP + >>> photflam # doctest: +SKIP + +.. testsetup:: + + >>> from synphot import units + >>> photflam = 1.9647813651514673e-19 * units.FLAM + +:: + >>> st_zpt = -2.5 * np.log10(photflam.value) - 21.1 - >>> print('STmag zeropoint for {} is {:.5f}'.format(bp.obsmode, st_zpt)) + >>> print('STmag zeropoint for {} is {:.5f}'.format(obsmode, st_zpt)) STmag zeropoint for acs,wfc1,f555w,mjd#57903.0 is 25.66671 @@ -78,17 +85,28 @@ In this tutorial, you will learn how to calculate the ABMAG zeropoint for the ACS/WFC1 F555W bandpass, which happens to be time-dependent:: >>> import numpy as np - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from astropy.time import Time >>> obsdate = Time('2017-05-30').mjd - >>> bp = STS.band('acs,wfc1,f555w,mjd#{}'.format(obsdate)) - >>> photflam = bp.unit_response(STS.conf.area) - >>> photplam = bp.pivot() - >>> photplam + >>> obsmode = 'acs,wfc1,f555w,mjd#{}'.format(obsdate) + >>> bp = stsyn.band(obsmode) # doctest: +SKIP + >>> photflam = bp.unit_response(stsyn.conf.area) # doctest: +SKIP + >>> photplam = bp.pivot() # doctest: +SKIP + >>> photplam # doctest: +SKIP + +.. testsetup:: + + >>> from astropy import units as u + >>> from synphot import units + >>> photflam = 1.96478154e-19 * units.FLAM + >>> photplam = 5360.938362432486 * u.AA + +:: + >>> ab_zpt = (-2.5 * np.log10(photflam.value) - 21.1 - ... 5 * np.log10(photplam.value) + 18.6921) - >>> print('ABmag zeropoint for {} is {:.5f}'.format(bp.obsmode, ab_zpt)) + >>> print('ABmag zeropoint for {} is {:.5f}'.format(obsmode, ab_zpt)) ABmag zeropoint for acs,wfc1,f555w,mjd#57903.0 is 25.71261 @@ -108,14 +126,14 @@ In this tutorial, you will learn how to calculate the VEGAMAG zeropoint for the ACS/WFC1 F555W bandpass, which happens to be time-dependent:: >>> import numpy as np - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from astropy.time import Time >>> from synphot import Observation >>> obsdate = Time('2017-05-30').mjd - >>> bp = STS.band('acs,wfc1,f555w,mjd#{}'.format(obsdate)) - >>> obs = Observation(STS.Vega, bp, binset=bp.binset) - >>> vega_zpt = -obs.effstim(flux_unit='obmag', area=STS.conf.area) - >>> print('VEGAMAG zeropoint for {} is {:.5f}'.format(bp.obsmode, vega_zpt)) + >>> bp = stsyn.band('acs,wfc1,f555w,mjd#{}'.format(obsdate)) # doctest: +SKIP + >>> obs = Observation(stsyn.Vega, bp, binset=bp.binset) # doctest: +SKIP + >>> vega_zpt = -obs.effstim(flux_unit='obmag', area=stsyn.conf.area) # doctest: +SKIP + >>> print('VEGAMAG zeropoint for {} is {:.5f}'.format(bp.obsmode, vega_zpt)) # doctest: +SKIP VEGAMAG zeropoint for acs,wfc1,f555w,mjd#57903.0 is 25.71235 OBMAG @@ -130,17 +148,17 @@ Sun's spectrum can be obtained from :ref:`stsynphot-appendixa-calspec` but needs to be normalized to literature value (e.g., http://www.astronomynotes.com/starprop/s4.htm):: - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from synphot import units, SourceSpectrum, SpectralElement, Observation - >>> v_band = SpectralElement.from_filter('johnson_v') + >>> v_band = SpectralElement.from_filter('johnson_v') # doctest: +REMOTE_DATA >>> sun_file = 'http://ssb.stsci.edu/cdbs/calspec/sun_reference_stis_002.fits' - >>> sun_raw = SourceSpectrum.from_file(sun_file) - >>> sun = sun_raw.normalize(4.83 * units.VEGAMAG, v_band, vegaspec=STS.Vega) + >>> sun_raw = SourceSpectrum.from_file(sun_file) # doctest: +REMOTE_DATA + >>> sun = sun_raw.normalize(4.83 * units.VEGAMAG, v_band, vegaspec=stsyn.Vega) # doctest: +REMOTE_DATA >>> for obsmode in ['acs,wfc1,f555w', 'wfc3,uvis2,f336w', 'wfc3,ir,f160w']: - ... bp = STS.band(obsmode) - ... obs = Observation(sun, bp, binset=bp.binset) - ... m = obs.effstim('vegamag', vegaspec=STS.Vega) - ... print("Sun's abs mag in {} is {:.4f}".format(bp.obsmode, m)) + ... bp = stsyn.band(obsmode) # doctest: +SKIP + ... obs = Observation(sun, bp, binset=bp.binset) # doctest: +SKIP + ... m = obs.effstim('vegamag', vegaspec=stsyn.Vega) # doctest: +SKIP + ... print("Sun's abs mag in {} is {:.4f}".format(bp.obsmode, m)) # doctest: +SKIP Sun's abs mag in acs,wfc1,f555w is 4.8395 VEGAMAG Sun's abs mag in wfc3,uvis2,f336w is 5.4864 VEGAMAG Sun's abs mag in wfc3,ir,f160w is 3.4127 VEGAMAG @@ -166,8 +184,8 @@ Create the 3 regions separately, concatenate them, and display the result:: >>> mdwave = np.arange(4950, 5010, 0.1) # [O III] >>> hiwave = np.arange(5010, 8000) >>> wave = np.concatenate([lowave, mdwave, hiwave]) - >>> wave - array([ 2000., 2001., 2002., ..., 7997., 7998., 7999.]) + >>> wave # doctest: +ELLIPSIS + array([2000., 2001., 2002., ..., 7997., 7998., 7999.]) Create an Astropy table from the concatenated array above and save it out as a FITS table:: @@ -176,23 +194,30 @@ FITS table:: >>> col = fits.Column( ... name='wavelength', unit='angstrom', format='E', array=wave) >>> tabhdu = fits.BinTableHDU.from_columns([col]) - >>> tabhdu.writeto('mywaveset.fits') + >>> tabhdu.writeto('mywaveset.fits') # doctest: +SKIP Read the custom wavelength set back in from file using Astropy table:: >>> from astropy.table import QTable - >>> tab = QTable.read('mywaveset.fits') # Ignore the UnitsWarning + >>> tab = QTable.read('mywaveset.fits') # Ignore the UnitsWarning # doctest: +SKIP WARNING: UnitsWarning: The unit 'angstrom' has been deprecated... + +.. testsetup:: + + >>> tab = QTable.read(tabhdu) + +:: + >>> wave = tab['wavelength'] - >>> wave - + >>> wave # doctest: +ELLIPSIS + Create an observation of Vega with ACS/WFC1 F555W bandpass, using the custom wavelength binning above, and then check that the binned wavelength set is indeed the given one:: - >>> import stsynphot as STS + >>> import stsynphot as stsyn >>> from synphot import Observation - >>> obs = Observation(STS.Vega, STS.band('acs,wfc1,f555w'), binset=wave) - >>> obs.binset + >>> obs = Observation(stsyn.Vega, stsyn.band('acs,wfc1,f555w'), binset=wave) # doctest: +SKIP + >>> obs.binset # doctest: +SKIP