Package pysynphot
[hide private]
[frames] | no frames]

Source Code for Package pysynphot

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