1 """
2 Package: Astrolib Pysynphot
3
4 Purpose:
5 ========
6
7 Object-oriented replacement for STSDAS synphot package.
8
9 This __init__ file is used to expose the desired elements of the user
10 interface for interactive use.
11
12
13 Dependencies:
14 =============
15 - numpy 1.0 or greater
16 - pyfits 1.1 or greater
17 - spark (syntax parser) (included in package tho; really dependency?)
18
19 Environment:
20 ============
21 The environment variable PYSYN_CDBS must be set.
22
23 Example:
24 ========
25
26 In the examples below, items which may be installation- or platform-
27 specific are commented out so as to be excluded from doctest. However
28 users are still encouraged to try these examples.
29
30 A tutorial containing further examples and other documentation can be found at
31 U{http://incubator.stsci.edu/mediawiki/index.php/Telescopedia:pysynphot}.
32
33
34 >>> import pysynphot as S
35 >>> import os
36 >>> print S.__version__
37 0.45
38 >>> #Read a spectrum from a file
39 >>> vega=S.FileSpectrum(S.locations.VegaFile)
40
41
42
43 ##>>> print vega
44 ##/user/laidler/pyinstall/pysynphot/data/alpha_lyr_stis_003.fits
45 ## >>> vega.wave
46 ## array([ 9.00452026e+02, 9.01354004e+02, 9.02257996e+02, ...,
47 ## 2.99353200e+06, 2.99653275e+06, 2.99953700e+06], dtype=float32)
48 ## >>> vega.flux
49 ## array([ 1.23810534e-17, 1.67559564e-17, 1.78002369e-17, ...,
50 ## 1.40140738e-19, 1.38734357e-19, 1.26490663e-19])
51
52
53 >>> bb=S.BlackBody(40000)
54 >>> print bb
55 BB(T=40000)
56
57 ## >>> print bb.wave
58 ## [ 500. 500.19760122 500.39528054 ..., 25969.1985582
59 ## 25979.46164894 25989.72879567]
60 ## >>> print bb.flux
61 ## [ 1.1523018 1.15375884 1.15521644 ..., 0.00141824 0.0014166
62 ## 0.00141496]
63
64
65 >>> pl=S.PowerLaw(10000,-2)
66 >>> print pl
67 Power law: refwave 10000.000000, index -2.000000
68
69 ## >>> print pl.wave
70 ## [ 500. 500.19760122 500.39528054 ..., 25969.1985582
71 ## 25979.46164894 25989.72879567]
72 ## >>> print pl.flux
73 ## [ 4.00000000e+02 3.99684025e+02 3.99368300e+02 ..., 1.48280112e-01
74 ## 1.48162980e-01 1.48045941e-01]
75
76 >>> g1=S.GaussianSource(18.3,18000,2000,fluxunits='abmag')
77 >>> print g1
78 Gaussian: mu=18000.000000,fwhm=2000.000000,flux=18.300000 abmag
79
80 >>> unitflux=S.FlatSpectrum(18,fluxunits='abmag')
81 >>> print unitflux
82 Unit spectrum of 18.000000 abmag
83
84 >>> bp1=S.ObsBandpass('acs,hrc,f555w')
85 >>> print bp1
86 acs,hrc,f555w
87 >>> print bp1.wave
88 [ 500. 1000. 1010. ..., 11999. 30000. 30010.]
89 >>> print bp1.throughput
90 [ 0. 0. 0. ..., 0. 0. 0.]
91
92 ## >>> bp1.showfiles()
93 ## /grp/hst/cdbs/comp/ota/hst_ota_007_syn.fits
94 ## /grp/hst/cdbs/comp/acs/acs_hrc_m12_005_syn.fits
95 ## /grp/hst/cdbs/comp/acs/acs_hrc_m3_005_syn.fits
96 ## /grp/hst/cdbs/comp/acs/acs_f555w_003_syn.fits
97 ## /grp/hst/cdbs/comp/acs/acs_hrc_win_005_syn.fits
98 ## /grp/hst/cdbs/comp/acs/acs_hrc_ccd_013_syn.fits
99
100 >>> len(bp1)
101 6
102
103 ## >>> sp1=S.FileSpectrum('/grp/hst/cdbs/calspec/feige66_002.fits')
104 >>> print bp1.waveunits
105 angstrom
106
107 ##>>> obs1=S.Observation(sp1,bp1)
108
109 >>> obs1=S.Observation(vega,bp1)
110
111 ## >>> print obs1
112 ## /grp/hst/cdbs/calspec/feige66_002.fits * acs,hrc,f555w
113
114
115 ##>>> print obs1.wave
116 ##[ 500. 1000. 1010. ..., 11999. 30000. 30010.]
117
118 ## >>> print obs1.flux.max()
119 ## 7.51179802362e-14
120
121 >>> print obs1.waveunits
122 angstrom
123 >>> print obs1.fluxunits
124 flam
125
126 """
127
128
129 __version__ = '0.45'
130 __revstring__ = '$Rev: 569 $'
131
132
133
134 from spectrum import BlackBody, GaussianSource, FlatSpectrum
135 from spectrum import Powerlaw as PowerLaw
136
137 from spectrum import FileSourceSpectrum as FileSpectrum
138 from spectrum import ArraySourceSpectrum as ArraySpectrum
139 from catalog import Icat
140
141 from spectrum import Box, UniformTransmission
142
143 from spectrum import FileSpectralElement as FileBandpass
144 from spectrum import ArraySpectralElement as ArrayBandpass
145
146 from obsbandpass import ObsBandpass
147 from extinction import Extinction
148
149 from observation import Observation
150
151 from observationmode import ObservationMode as Obsmode
152 from numpy import arange as Waveset
153
154 from spectrum import Vega
155
157 "Runs doctest on the examples in this file"
158 import doctest
159 nfail,ntest=doctest.testfile('__init__.py')
160 return nfail,ntest
161
162 if __name__ == '__main__':
163 nfail,ntest=_test()
164