index int64 | repo_name string | branch_name string | path string | content string | import_graph string |
|---|---|---|---|---|---|
67,563 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_ticket150.py | from __future__ import absolute_import, division, print_function
import os
import sys
import numpy as np
import pytest
from numpy.testing import assert_allclose
from .. import locations, refs
from ..exceptions import OverlapError
from ..obsbandpass import ObsBandpass
from ..spectrum import (ArraySpectralElement, ArraySourceSpectrum, Box,
FileSourceSpectrum, SourceSpectrum)
from ..spparser import parse_spec
old_comptable = None
old_vegafile = None
def setup_module(module):
"""
Freeze the version of the comptable so tests are not susceptible to
updates to CDBS. Also set the version of Vega for similar reasons.
"""
global old_comptable, old_vegafile
old_comptable = refs.COMPTABLE
refs.COMPTABLE = os.path.join(
os.environ['PYSYN_CDBS'], 'mtab', 'OLD_FILES', 't260548pm_tmc.fits')
old_vegafile = locations.VegaFile
locations.VegaFile = os.path.join(
os.environ['PYSYN_CDBS'], 'crcalspec', 'alpha_lyr_stis_003.fits')
def teardown_module(module):
refs.COMPTABLE = old_comptable
locations.VegaFile = old_vegafile
@pytest.mark.remote_data
class TestRenormOverlap(object):
"""Tests for strict rejection."""
def setup_class(self):
"""(re)discovery case: stis_rn_cases/stisC94"""
self.sp = FileSourceSpectrum(os.path.join(
os.environ['PYSYN_CDBS'], 'grid', 'kc96', 'starb2_template.fits'))
self.bp = ObsBandpass('cos,fuv,g130m,c1300')
self.cmd = ('rn(crgridkc96$starb2_template.fits,'
'band(cos,fuv,g130m,c1300),16.0,stmag)')
self.ref = 0.00718543 # expected renorm factor
def test_raise(self):
with pytest.raises(OverlapError):
self.sp.renorm(16.0, 'stmag', self.bp)
def test_force(self):
sp2 = self.sp.renorm(16.0, 'stmag', self.bp, force=True)
ratio = sp2.flux / self.sp.flux
assert np.all((1 - abs(ratio / self.ref)) < 0.0001)
def test_parse(self):
sp2 = parse_spec(self.cmd)
ratio = sp2.flux / self.sp.flux
assert np.all((1 - abs(ratio / self.ref)) < 0.0001)
@pytest.mark.parametrize('obsmode', ['johnson,v', 'acs,hrc,f555w'])
def test_renorm(self, obsmode):
"""
ACS: If 99% of throughput on spectrum, go ahead but print warning.
Does not yet test warning.
"""
sp2 = self.sp.renorm(17.0, 'abmag', ObsBandpass(obsmode))
assert isinstance(sp2, SourceSpectrum)
@pytest.mark.remote_data
class TestCornerCase(object):
def setup_class(self):
"""
This is deliberately constructed to have a waveset that partially
overlaps, but for which all the flux is fully contained.
"""
self.bp = ObsBandpass('acs,hrc,f555w')
w = np.arange(1000, 10000)
f = np.zeros(w.shape)
f[4000:4010] = 1.0
self.sp = ArraySourceSpectrum(wave=w, flux=f, fluxunits='flam')
def test_partial(self):
assert self.bp.check_overlap(self.sp) == 'partial'
def test_smart(self):
sp2 = self.sp.renorm(17.0, 'abmag', self.bp)
assert isinstance(sp2, SourceSpectrum)
class TestBPIntegrate(object):
def setup_class(self):
# Box 100 A wide, centered at 1000
self.bp = Box(1000, 100)
self.ref = 100.0
def test_integrate(self):
tst = self.bp.integrate()
assert_allclose(tst, self.ref, rtol=0.01)
def test_subint(self):
w = self.bp.wave
tst = self.bp.integrate(w[0:int(len(w)/2)])
# epsilon due to the nature of trapezoid integration
assert abs(self.ref / 2.0 - tst) <= 0.025
@pytest.mark.xfail(sys.version_info < (3, 0),
reason='defarrays not compatible with Python 2')
class OVBase(object):
"""
Base class to test for the variants we can imagine.
Implement all methods here.
"""
def defarrays(self):
"""Supposes that the range variables have already been set."""
w = np.arange(*self.sprange)
f = np.zeros(w.shape)
f[slice(*(self.spnonzero - w[0]))] += 1.0
self.sp = ArraySourceSpectrum(wave=w, flux=f)
w = np.arange(*self.bprange)
t = np.zeros(w.shape)
t[slice(*(self.bpnonzero - w[0]))] += 1
self.bp = ArraySpectralElement(w, t)
def test_current(self):
ans = self.bp.check_overlap(self.sp)
assert ans == self.cref
def test_sig(self):
if self.cref == 'partial':
ans = self.bp.check_sig(self.sp)
assert ans == self.sref
else:
pytest.skip('Not applicable')
class TestSpBp(OVBase):
"""SPdef fully encloses BPdef: "full" overlap. Pass."""
def setup_class(self):
self.sprange = (1000, 10000)
self.spnonzero = self.sprange
self.bprange = (5000, 6000)
self.bpnonzero = self.bprange
super(TestSpBp, self).defarrays(self)
self.cref = 'full'
self.sref = True
class TestBpSp(OVBase):
"""BPdef fully encloses SPdef: Insufficient overlap. Fail."""
def setup_class(self):
self.sprange = (5000, 6000)
self.spnonzero = self.sprange
self.bprange = (1000, 10000)
self.bpnonzero = self.bprange
super(TestBpSp, self).defarrays(self)
self.cref = 'partial'
self.sref = False
class TestSpPartial(OVBase):
"""Partial overlap: return partial, require further processing."""
def setup_class(self):
self.sprange = (1000, 8000)
self.bprange = (4000, 10000)
self.spnonzero = self.sprange
self.bpnonzero = self.bprange
super(TestSpPartial, self).defarrays(self)
self.cref = 'partial'
self.sref = False # assuming they're all ones
# Now do variants where nonzero is different from range
class TestSpBpNz(OVBase):
"""BP defined zero some places: still acceptable."""
def setup_class(self):
self.sprange = (1000, 10000)
self.spnonzero = self.sprange
self.bprange = (5000, 6000)
self.bpnonzero = (5500, 5550)
super(TestSpBpNz, self).defarrays(self)
self.cref = 'full'
self.sref = True
class TestBpSpNz(OVBase):
"""Passes per current defn that looks at bp.nonzero, sp.def."""
def setup_class(self):
self.sprange = (5000, 6000)
self.spnonzero = self.sprange
self.bprange = (1000, 10000)
self.bpnonzero = (5500, 5700)
super(TestBpSpNz, self).defarrays(self)
self.cref = 'full'
self.sref = True
class TestSpPartialNz1(OVBase):
"""Passes per current defn that looks at bp.nonzero, sp.def."""
def setup_class(self):
self.sprange = (1000, 8000)
self.spnonzero = self.sprange
self.bprange = (4000, 10000)
self.bpnonzero = (5000, 6000)
super(TestSpPartialNz1, self).defarrays(self)
self.cref = 'full'
self.sref = True
class TestSpPartialNz2(OVBase):
"""
This is still not acceptable:
the bandpass is nonzero in places where the spectrum is undefined.
"""
def setup_class(self):
self.sprange = (1000, 8000)
self.spnonzero = (5000, 6000)
self.bprange = (4000, 10000)
self.bpnonzero = self.bprange
super(TestSpPartialNz2, self).defarrays(self)
self.cref = 'partial'
self.sref = False
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,564 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_table.py | """
Test table format errors. Usually in real life these occur
in file access, but many of them apply to ArraySpectrum objects
as well & can be tested that way.
"""
from __future__ import absolute_import, division, print_function
import numpy as np
import pytest
from ..exceptions import (BadRow, DuplicateWavelength, UnsortedWavelength,
ZeroWavelength)
from ..spectrum import ArraySourceSpectrum, FileSourceSpectrum
def test_wave_exceptions():
fx = np.array([10, 20, 20, 30, 50, 100])
# No error
sp = ArraySourceSpectrum(np.array([10, 20, 30, 40, 50, 100]), fx)
assert sp(30) == 20
with pytest.raises(DuplicateWavelength) as e:
ArraySourceSpectrum(np.array([10, 20, 20, 30, 50, 100]), fx)
assert e.rows == 1
with pytest.raises(ZeroWavelength):
ArraySourceSpectrum(np.array([0, 20, 30, 40, 50, 100]), fx)
with pytest.raises(UnsortedWavelength):
ArraySourceSpectrum(np.array([10, 20, 40, 30, 50, 100]), fx)
def test_file_badrow(tmpdir):
wv = np.array([10, 20, 'grackle', 30, 50, 100])
content = ''
for w in wv:
content += "{0} {0}\n".format(w)
# pytest will only keep the last few runs and auto delete the rest
fname = tmpdir.join('grackle.dat')
fname.write(content)
with pytest.raises(BadRow) as e:
FileSourceSpectrum(str(fname))
assert e.rows == 3
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,565 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/observation.py | # It defines a new Observation class, subclassed from CompositeSourceSpectrum,
# that has some special methods and attributes and explicitly removes
# certain other methods.
"""This module handles an observation and related calculations."""
from __future__ import division
import numpy as np
import math
from . import spectrum
from . import units
from . import binning
from . import exceptions
from .obsbandpass import pixel_range, wave_range
from .spectrum import ArraySourceSpectrum
try:
import pysynphot_utils
utils_imported = True
except ImportError:
utils_imported = False
def check_overlap(a, b):
"""Check for wavelength overlap between two spectra.
.. note::
Generalized from
:meth:`pysynphot.spectrum.SpectralElement.check_overlap`.
Parameters
----------
a, b : `~pysynphot.spectrum.SourceSpectrum` or `~pysynphot.spectrum.SpectralElement`
Typically a source spectrum, spectral element, observation,
or bandpass from observation mode.
Returns
-------
result : {'full', 'partial', 'none'}
Full, partial, or no overlap.
Raises
------
AttributeError
Given spectrum does not have flux or throughput.
"""
if a.isAnalytic or b.isAnalytic:
#then it's defined everywhere
result = 'full'
else:
#get the wavelength arrays
waves = list()
for x in (a, b):
if hasattr(x,'throughput'):
wv = x.wave[np.where(x.throughput != 0)]
elif hasattr(x,'flux'):
wv = x.wave
else:
raise AttributeError("neither flux nor throughput in %s"%x)
waves.append(wv)
#get the endpoints
a1,a2 = waves[0].min(), waves[0].max()
b1,b2 = waves[1].min(), waves[1].max()
#do the comparison
if (a1>=b1 and a2<=b2):
result = 'full'
elif (a2<b1) or (b2<a1):
result = 'none'
else:
result = 'partial'
return result
def validate_overlap(comp1, comp2, force):
"""Validate the overlap between the wavelength sets
of the two given components.
Parameters
----------
comp1, comp2 : `~pysynphot.spectrum.SourceSpectrum` or `~pysynphot.spectrum.SpectralElement`
Source spectrum and bandpass of an observation.
force : {'extrap', 'taper', `None`}
If not `None`, the components may be adjusted by
extrapolation or tapering.
Returns
-------
comp1, comp2
Same as inputs. However, ``comp1`` might be tapered
if that option is selected.
warnings : dict
Maps warning keyword to its description.
Raises
------
KeyError
Invalid ``force``.
pysynphot.exceptions.DisjointError
No overlap detected when ``force`` is `None`.
pysynphot.exceptions.PartialOverlap
Partial overlap detected when ``force`` is `None`.
"""
warnings = dict()
if force is None:
stat = comp2.check_overlap(comp1)
if stat=='full':
pass
elif stat == 'partial':
raise(exceptions.PartialOverlap('Spectrum and bandpass do not fully overlap. You may use force=[extrap|taper] to force this Observation anyway.'))
elif stat == 'none':
raise(exceptions.DisjointError('Spectrum and bandpass are disjoint'))
elif force.lower() == 'taper':
try:
comp1=comp1.taper()
except AttributeError:
comp1=comp1.tabulate().taper()
warnings['PartialOverlap']=force
elif force.lower().startswith('extrap'):
#default behavior works, but check the overlap so we can set the warning
stat=comp2.check_overlap(comp1)
if stat == 'partial':
warnings['PartialOverlap']=force
else:
raise(KeyError("Illegal value force=%s; legal values=('taper','extrap')"%force))
return comp1, comp2, warnings
class Observation(spectrum.CompositeSourceSpectrum):
"""Class to handle an :ref:`observation <pysynphot-observation>`.
An observation is the end point of a chain of spectral manipulation.
Most `~pysynphot.obsbandpass.ObsBandpass` objects have a built-in
``binset`` that is optimized for use with the specified observing
mode (also see :ref:`pysynphot-wavelength-table`).
Specifying the ``binset`` here would override the built-in one.
Parameters
----------
spec : `~pysynphot.spectrum.SourceSpectrum`
Source spectrum.
band : `~pysynphot.spectrum.SpectralElement`
Bandpass.
binset : array_like or `None`
Wavelength values to be used for binning when converting to counts.
See :meth:`initbinset`.
force
See :meth:`~pysynphot.observation.Observation.validate_overlap`.
Attributes
----------
spectrum
Same as input ``spec``.
bandpass
Same as input ``band``.
binset
Same as input ``binset``.
component1, component2 : `~pysynphot.spectrum.SourceSpectrum` or `~pysynphot.spectrum.SpectralElement`
Components and sub-components that belong to the observation.
operation : str
This is always "multiply".
name : str
Short description of the observation.
warnings : dict
To store warnings, which are inherited from all inputs. If they have the same warning keyword, the one from most recently read component is used.
isAnalytic : bool
Flag to indicate whether this is an analytic spectrum. This is only `True` if both inputs are analytic.
primary_area : number or `None`
:ref:`pysynphot-area` of the telescope. This is inherited from either of the inputs, if available (not `None`). If inputs have different values, an exception is raised.
waveunits, fluxunits : `~pysynphot.units.Units`
User units inherited from source spectrum.
wave, flux : array_like
Wavelength set and associated flux in user units. This is the native dataset.
binwave, binflux : array_like
Binned dataset.
Raises
------
pysynphot.exceptions.IncompatibleSources
Input spectra have different telescope areas defined.
"""
def __init__(self,spec,band,binset=None,force=None):
self.spectrum = spec
self.bandpass = band
self.warnings={}
self.validate_overlap(force)
self.binset = binset
keep=self.warnings
spectrum.CompositeSourceSpectrum.__init__(self,
self.spectrum,
self.bandpass,
'multiply')
self.warnings.update(keep)
#The natural waveset of the observation is the merge of the
#natural waveset of the spectrum with the natural waveset of the
#bandpass. Because the Observation inherits from a
#CompositeSourceSpectrum, this will be handled correctly.
# self._binwave = None
self._binflux = None
self.initbinset(binset)
#self.initbinflux()
def validate_overlap(self,force):
"""Validate that spectrum and bandpass overlap.
Warnings are stored in ``self.warnings``.
Parameters
----------
force : {'extrap', 'taper', `None`}
If `None`, it is required that the spectrum and bandpass fully
overlap. Partial overlap is allowed if this is set to
``'extrap'`` or ``'taper'``. See :func:`validate_overlap`.
"""
#Wrap the function for convenience
self.spectrum, self.bandpass, warn = validate_overlap(self.spectrum,
self.bandpass, force)
self.warnings.update(warn)
def initbinset(self,binset=None):
"""Set ``self.binwave``.
By default, wavelength values for binning are inherited
from bandpass. If the bandpass has no binning information,
then source spectrum wavelengths are used. However, if
user provides values, then those are used without question.
Parameters
----------
binset : array_like or `None`
Wavelength values to be used for binning when converting to counts.
"""
if binset is None:
msg="(%s) does not have a defined binset in the wavecat table. The waveset of the spectrum will be used instead."%str(self.bandpass)
try:
self.binwave = self.bandpass.binset
except (KeyError, AttributeError):
self.binwave = self.spectrum.wave
print(msg)
if self.binwave is None:
self.binwave = self.spectrum.wave
print(msg)
else:
self.binwave=binset
def initbinflux(self):
"""Calculate binned flux and edges.
Flux is computed by integrating the spectrum
on the specified binned wavelength set, using
information from the natural wavelength set.
Native wave/flux arrays should be considered samples
of a continuous function, but not their binned counterparts.
Thus, it makes sense to interpolate ``(wave, flux)`` but not
``(binwave, binflux)``.
.. note::
Assumes that the wavelength values in the binned
wavelength set are the *centers* of the bins.
Uses ``pysynphot.pysynphot_utils.calcbinflux()`` C-extension,
if available, for binned flux calculation.
"""
endpoints = binning.calculate_bin_edges(self.binwave)
# merge these endpoints in with the natural waveset
spwave = spectrum.MergeWaveSets(self.wave, endpoints)
spwave = spectrum.MergeWaveSets(spwave,self.binwave)
# compute indices associated to each endpoint.
indices = np.searchsorted(spwave, endpoints)
self._indices = indices[:-1]
self._indices_last = indices[1:]
# prepare integration variables.
flux = self(spwave)
avflux = (flux[1:] + flux[:-1]) / 2.0
self._deltaw = spwave[1:] - spwave[:-1]
# sum over each bin.
if utils_imported is True:
self._binflux, self._intwave = \
pysynphot_utils.calcbinflux(len(self.binwave),
self._indices,
self._indices_last,
avflux,
self._deltaw)
else:
#Note that, like all Python striding, the range over which
#we integrate is [first:last).
self._binflux = np.empty(shape=self.binwave.shape,dtype=np.float64)
self._intwave = np.empty(shape=self.binwave.shape,dtype=np.float64)
for i in range(len(self._indices)):
first = self._indices[i]
last = self._indices_last[i]
self._binflux[i]=(avflux[first:last]*self._deltaw[first:last]).sum()/self._deltaw[first:last].sum()
self._intwave[i]=self._deltaw[first:last].sum()
#Save the endpoints for future use
self._bin_edges = endpoints
def _getBinfluxProp(self):
if self._binflux is None:
self.initbinflux()
if hasattr(self.bandpass, 'primary_area'):
area = self.bandpass.primary_area
else:
area = None
binflux = units.Photlam().Convert(self.binwave,
self._binflux,
self.fluxunits.name,
area=area)
return binflux
def _getBinwaveProp(self):
if self._binwave is None:
self.initbinset(self.binset)
return self._binwave
binflux = property(_getBinfluxProp,doc='Flux of binned wavelength set.')
# binwave = property(_getBinwaveProp,doc='Waveset for binned flux')
# Multiplication is handled by performing the operation on
# the spectral component of the Observation, and then creating a
# new Observation as the result.
#
# This is because Observation is a subclass of CompositeSourceSpectrum
# but with *a lot* of extra functionality involved in handling the
# binned wave and flux arrays. Simply inheriting the parent class's
# methods for multiplication does not return an Observation.
#
# Note that the order of operations actually implemented therefore varies
# from what is expected, which naively would be
# (self.spectrum*self.bandpass) * other
#
def __mul__(self, other):
# If the original object has partial overlap warnings, then
# the forcing behavior also needs to be propagated.
force = self.warnings.get('PartialOverlap', None)
result = Observation(self.spectrum,
self.bandpass * other,
binset=self.binwave,
force=force)
return result
def __rmul__(self, other):
return self.__mul__(other)
#Disable methods that should not be supported by this class
def __add__(self, other):
raise NotImplementedError('Observations cannot be added')
def __radd__(self, other):
raise NotImplementedError('Observations cannot be added')
def redshift(self,z):
"""Observations cannot be redshifted."""
raise NotImplementedError('Observations cannot be redshifted')
def writefits(self,fname,clobber=True, trimzero=True, binned=True,
hkeys=None):
"""Like :meth:`pysynphot.spectrum.SourceSpectrum.writefits`
but with ``binned=True`` as default.
"""
spectrum.CompositeSourceSpectrum.writefits(self,fname,
clobber=clobber,
trimzero=trimzero,
binned=binned,
hkeys=hkeys)
def countrate(self,binned=True,range=None,force=False):
"""Calculate effective stimulus in count/s.
Also see :ref:`pysynphot-formula-countrate` and
:ref:`pysynphot-formula-effstim`.
.. note::
This is the calculation performed when the ETC invokes
``countrate``.
Parameters
-----------
binned : bool
If `True` (default), use binned data.
Otherwise, use native data.
range : tuple or `None`
If not `None`, it must be a sequence with two floating-point
elements specifying the wavelength range (*inclusive*) in the
unit of ``self.waveunits`` in the form of ``(low, high)``;
This is the range over which the integration will be performed.
If the specified range does not exactly match a value in the
wavelength set:
* If ``binned=True``, the bin containing the range value will
be used. This assumes ``self.binwave`` contains bin centers.
* If ``binned=False``, native dataset will be interpolated to
the specified values. (*Not Implemented.*)
force : bool
If `False` (default), partially overlapping ranges
will raise an exception. If `True`, a partial overlap will
return the calculated value instead. Disjoint ranges raise
an exception regardless.
Returns
-------
ans : float
Count rate.
Raises
------
NotImplementedError
Wavelength range is defined for unbinned data.
pysynphot.exceptions.DisjointError
Wavelength range does not overlap with observation.
pysynphot.exceptions.PartialOverlap
Wavelength range only partially overlaps with observation.
"""
if self._binflux is None:
self.initbinflux()
myfluxunits = self.fluxunits.name
self.convert('counts')
warn=False
if binned:
#No range specified - use full range
if range is None:
lx,ux=(None,None)
#Range is disjoint from binwave
elif (range[0]>self.binwave[-1] or
range[1]<self.binwave[0]):
raise exceptions.DisjointError("%s is disjoint from obs.binwave %s"%(range,
[self.binwave[0],self.binwave[-1]]))
#Partial overlap
else:
if range[0] < self._bin_edges[0]:
warn=True
lx=None
else:
lx=np.searchsorted(self._bin_edges,range[0])-1
if range[1] > self._bin_edges[-1]:
warn=True
ux=None
else:
ux=np.searchsorted(self._bin_edges,range[1])
ans = math.fsum(self.binflux[lx:ux])
if warn and not force:
raise exceptions.PartialOverlap("%s does not fully overlap binwave range %s. Countrate in overlap area is %f"%(range,[self.binwave[0],self.binwave[-1]],ans))
else:
if range is None:
ans = math.fsum(self.flux)
else:
raise NotImplementedError("Sorry, range+binned=False not yet implemented")
self.convert(myfluxunits)
return ans
def effstim(self,fluxunits='photlam'):
"""Compute :ref:`effective stimulus <pysynphot-formula-effstim>`.
Calculations are done in given flux unit, and wavelengths
in Angstrom. Native dataset is used.
Parameters
----------
fluxunits : str
Flux unit.
Returns
-------
ans : float
Effective stimulus.
Raises
------
ValueError
Invalid integrated flux.
"""
oldunits=self.fluxunits
self.convert(fluxunits)
x=units.Units(fluxunits)
try:
if x.isDensity:
rate=self.integrate()
self._fluxcheck(rate)
if x.isMag:
ans=x.unitResponse(self.bandpass) - 2.5*math.log10(rate)
else:
ans=rate*x.unitResponse(self.bandpass)
else:
if x.isMag:
#its linear unit must be counts
self.convert('counts')
total=self.flux.sum()
self._fluxcheck(total)
ans=-2.5*math.log10(total)
else:
ans=self.flux.sum()
self._fluxcheck(ans)
finally:
self.convert(oldunits)
del x
return ans
def _fluxcheck(self,totalflux):
if totalflux <= 0.0:
raise ValueError('Integrated flux is <= 0')
if np.isnan(totalflux):
raise ValueError('Integrated flux is NaN')
if np.isinf(totalflux):
raise ValueError('Integrated flux is infinite')
def pivot(self,binned=True):
"""Calculate :ref:`pivot wavelength <pysynphot-formula-pivwv>`
of the observation.
.. note::
This is the calculation performed when ETC invokes ``calcphot``.
Parameters
----------
binned : bool
Use binned dataset for calculations. Otherwise, use native dataset.
Returns
-------
ans : float
Pivot wavelength.
"""
if binned:
wave = self.binwave
else:
wave = self.wave
countmulwave = self(wave)*wave
countdivwave = self(wave)/wave
num = self.trapezoidIntegration(wave,countmulwave)
den = self.trapezoidIntegration(wave,countdivwave)
if num == 0.0 or den == 0.0:
return 0.0
return math.sqrt(num/den)
def efflam(self,binned=True):
"""Calculate :ref:`effective wavelength <pysynphot-formula-efflam>`
of the observation.
Calculation is done in the flux unit of ``flam``.
.. note::
Similar to IRAF STSDAS SYNPHOT ``efflphot`` task.
Parameters
----------
binned : bool
Use binned dataset for calculations. Otherwise, use native dataset.
Returns
-------
ans : float
Effective wavelength.
"""
myfluxunits=self.fluxunits.name
self.convert('flam')
if binned:
wave=self.binwave
flux=self.binflux
else:
wave=self.wave
flux=self.flux
num = self.trapezoidIntegration(wave,flux*wave*wave)
den = self.trapezoidIntegration(wave,flux*wave)
self.convert(myfluxunits)
if num == 0.0 or den == 0.0:
return 0.0
return num/den
def sample(self, swave, binned=True, fluxunits='counts'):
"""Sample the observation at the given wavelength.
Also see :ref:`pysynphot-command-sample`.
Parameters
----------
swave : float
Wavelength to sample.
binned : bool
Sample binned dataset (no interpolation).
Otherwise, native (perform interpolation).
fluxunits : {'counts'}
Only the unit of counts is supported for now.
Returns
-------
ans : float
Sampled flux in given unit.
Raises
------
NotImplementedError
Flux unit is not supported or non-scalar wavelength is given.
ValueError
Given wavelength out of range.
"""
if self._binflux is None:
self.initbinflux()
if fluxunits != 'counts':
s = "Sorry, only counts are supported at this time"
raise NotImplementedError(s)
else:
#Save current fluxunits, in case they're different
saveunits = None
if not units.ismatch('counts', self.fluxunits):
saveunits = self.fluxunits
self.convert('counts')
if binned:
#Then we don't interpolate, just return the appropriate values
#from binflux
if np.isscalar(swave):
#Find the bin in which it belongs.
#_bin_edge[i] is the low edge of the bin centered
#at binwave[i].
idx = np.where(swave >= self._bin_edges)[0]
#idx[-1] is the largest edge that is still smaller
#than swave
try:
ans = self.binflux[idx[-1]]
except IndexError:
s = 'Value out of range: wavelength %g not contained in range [%g, %g]'
s = s % (swave, self.binwave[0], self.binwave[-1])
raise ValueError(s)
else:
#The logic for this case doesn't yet work on arrays
s = "Sorry, only scalar samples are supported at this time"
raise NotImplementedError(s)
else:
#Then we do interpolate on wave/flux
if np.isscalar(swave):
delta = 0.00001
wv = np.array([swave - delta, swave, swave + delta])
ans = np.interp(wv, self.wave, self.flux)[1]
else:
# This raises UnboundLocalError -- needs to be fixed!
ans = np.interp(wv, self.wave, self.flux)
#Change units back, if necessary, then return
if saveunits is not None:
self.convert(saveunits)
return ans
def pixel_range(self, waverange, waveunits=None, round='round'):
"""Calculate the number of wavelength bins within given
wavelength range.
.. note::
This calls :func:`pysynphot.obsbandpass.pixel_range` with
``self.binwave`` as the first argument.
Parameters
----------
waverange, round
See :func:`pysynphot.obsbandpass.pixel_range`.
waveunits : str, optional
The unit of the wavelength range.
If `None` (default), the wavelengths are assumed to be
in the units of ``self.waveunits``.
Returns
-------
num : int or float
Number of wavelength bins within ``waverange``.
Raises
------
pysynphot.exceptions.UndefinedBinset
No binned dataset.
"""
# make sure we have a binset to work with
if self.binwave is None:
raise exceptions.UndefinedBinset('No binset specified for this bandpass.')
# start by converting waverange to self.waveunits, if necessary
if waveunits is not None:
waveunits = units.Units(waveunits)
if not isinstance(waverange, np.ndarray):
waverange = np.array(waverange)
# convert to angstroms and then whatever self.waveunits is
waverange = waveunits.ToAngstrom(waverange)
waverange = units.Angstrom().Convert(waverange, self.waveunits.name)
return pixel_range(self.binwave, waverange, round=round)
def wave_range(self, cenwave, npix, waveunits=None, round='round'):
"""Calculate the wavelength range covered by the given
number of pixels, centered on the given wavelength.
.. note::
This calls :func:`pysynphot.obsbandpass.wave_range` with
``self.binwave`` as the first argument.
Parameters
----------
cenwave, npix, round
See :func:`pysynphot.obsbandpass.wave_range`.
waveunits : str, optional
Wavelength unit of the given and the returned wavelength values.
If `None` (default), the wavelengths are assumed to be in
the unit of ``self.waveunits``.
Returns
-------
waverange : tuple of floats
The range of wavelengths spanned by ``npix`` centered on
``cenwave``.
Raises
------
pysynphot.exceptions.UndefinedBinset
No binned dataset.
"""
# make sure we have a binset to work with
if self.binwave is None:
raise exceptions.UndefinedBinset('No binset specified for this bandpass.')
# convert cenwave from waveunits to self.waveunits, if necessary
if waveunits is not None:
waveunits = units.Units(waveunits)
# convert to angstroms and then whatever self.waveunits is
cenwave = waveunits.ToAngstrom(cenwave)
cenwave = units.Angstrom().Convert(cenwave, self.waveunits.name)
wave1, wave2 = wave_range(self.binwave, cenwave, npix, round=round)
# translate ends to waveunits, if necessary
if waveunits is not None:
# convert to angstroms
wave1 = self.waveunits.ToAngstrom(wave1)
wave2 = self.waveunits.ToAngstrom(wave2)
# then to waveunits
wave1 = units.Angstrom().Convert(wave1, waveunits.name)
wave2 = units.Angstrom().Convert(wave2, waveunits.name)
return wave1, wave2
def as_spectrum(self, binned=True):
"""Reduce the observation to a simple spectrum object.
An observation is a complex object with some restrictions on its
capabilities. At times, it would be useful to work with the
simulated observation as a simple object that is easier to
manipulate and takes up less memory.
Parameters
----------
binned : bool
If `True` (default), export binned dataset. Otherwise, native.
Returns
-------
result : `~pysynphot.spectrum.ArraySourceSpectrum`
Observation dataset as a simple spectrum object.
"""
if binned:
wave, flux = self.binwave, self.binflux
else:
wave, flux = self.wave, self.flux
result = ArraySourceSpectrum(wave, flux,
self.waveunits,
self.fluxunits,
name = self.name,
keepneg = True)
return result
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,566 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/exceptions.py | """Custom exceptions for ``pysynphot`` to raise."""
# TODO: error message about BaseException
class PysynphotError(Exception):
"""Parent class for ``pysynphot`` exceptions.
Parameters
----------
msg : str
Error message.
"""
def __init__(self,msg):
Exception.__init__(self,msg)
# Exceptions to do with table access.
class TableFormatError(PysynphotError):
"""Exception to do with table access.
Parameters
----------
msg : str
Error message.
rows : list
Rows with wrong values.
"""
def __init__(self, msg, rows=None):
PysynphotError.__init__(self, msg)
# Save rows with wrong values as an attribute so calling code
# can access it directly
self.rows = rows
# Also make this info go into the visibly displayed message in
# Python 2.7 (self.args) and Python 2.5/6 (self.message)
args = list(self.args)
args.append("Invalid entries at or about row: "+str(rows))
self.args = tuple(args)
self.message = self.args
class DuplicateWavelength(TableFormatError):
"""Exception for duplicate wavelength values in table."""
pass
class ZeroWavelength(TableFormatError):
"""Exception for wavelength values containing zero."""
pass
class UnsortedWavelength(TableFormatError):
"""Exception for wavelength values not in ascending or descending order."""
pass
class BadRow(TableFormatError):
"""Exception for invalid row in table."""
pass
# Exceptions to do with overlap checking
class OverlapError(PysynphotError):
"""Exception to do with overlap checking."""
pass
class PartialOverlap(OverlapError):
"""Exception for partial overlap between two spectra."""
pass
class DisjointError(OverlapError):
"""Exception for no overlap between two spectra."""
pass
# Exceptions to do with graph table traversal
class GraphtabError(PysynphotError):
"""Exception to do with graph table traversal."""
pass
class UnusedKeyword(GraphtabError):
"""Exception for unused keyword in graph table lookup."""
pass
class IncompleteObsmode(GraphtabError):
"""Exception for incomplete observation mode in graph table lookup."""
pass
class AmbiguousObsmode(GraphtabError):
"""Exception for ambiguous observation mode in graph table lookup."""
pass
# Exceptions for undefined optional values
class UndefinedBinset(PysynphotError):
"""Exception for undefined ``binset`` in bandpass or observation."""
pass
# Exceptions for interpolation/extrapolation
class ExtrapolationNotAllowed(PysynphotError):
"""Exception for invalid extrapolation."""
pass
# Exceptions for catalog problems
class ParameterOutOfBounds(PysynphotError):
"""Exception for invalid parameter value in a catalog."""
pass
# if two sources in Composite* spectrum shouldn't go together
class IncompatibleSources(PysynphotError):
"""Exception for operation on two incompatible spectra types."""
pass
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,567 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_ticket21.py | from __future__ import absolute_import, division, print_function
import os
import pytest
from .. import refs
from ..observationmode import ObservationMode
from ..spectrum import InterpolatedSpectralElement
old_comptable = None
def setup_module(module):
"""
Freeze the version of the comptable so tests are not susceptible to
updates to CDBS.
"""
global old_comptable
old_comptable = refs.COMPTABLE
refs.COMPTABLE = os.path.join(
os.environ['PYSYN_CDBS'], 'mtab', 'OLD_FILES', 'rcb1833hm_tmc.fits')
def teardown_module(module):
refs.COMPTABLE = old_comptable
@pytest.mark.remote_data
def test_one_param():
parkey = 'mjd'
parval = 54000
om = ObservationMode('acs,hrc,f555w,mjd#54000')
rnames = [x for x in om._throughput_filenames if (x != 'clear')]
reffile = os.path.join(os.environ['PYSYN_CDBS'], 'comp', 'acs',
'acs_hrc_ccd_mjd_013_syn.fits[mjd#]')
idx = rnames.index(reffile)
# parm# in modes
assert (parkey + '#') in om.modes
# filename has a "#"
assert reffile in om._throughput_filenames
# dict entry
assert om.pardict[parkey] == parval
# interpolated type
assert isinstance(om.components[idx].throughput,
InterpolatedSpectralElement), \
'{}\n{}'.format(len(om.components), idx)
@pytest.mark.remote_data
def test_two_params():
pardict = {'fr459m': 4610, 'aper': 0.3}
om = ObservationMode('acs,hrc,fr459m#4610,aper#0.3')
# parm# in modes
for k in pardict:
assert (k + '#') in om.modes
# dict vals
for k in pardict:
assert om.pardict[k] == pardict[k]
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,568 | spacetelescope/pysynphot | refs/heads/master | /commissioning/platform_cases.py | """These test cases are generated from reports that synphot performs
differently on different platforms:
Mode = band(acs,wfc1,f814w)
Spectrum: rn(icat(k93models,3500,0.0,4.6),band(v),18.0,vegamag)
Task: Countrate
Mode = band(acs,wfc1,f555w)
Spectrum: rn(spec(/usr/stsci/stdata/calspec/gd71_mod_005.fits),box(5125.0,1.0), 1.0e-18, flam)
Task: countrate"""
from pytools import testutil
import sys, socket
from basecase import countrateCase
class P1(countrateCase):
def setUp(self):
self.obsmode='acs,wfc1,f814w'
self.spectrum='rn(icat(k93models,3500,0.0,4.6),band(v),18.0,vegamag)'
self.setglobal(__file__)
self.tda['Hostname']=socket.gethostname()
self.runpy()
class P2(countrateCase):
def setUp(self):
self.obsmode='acs,wfc1,f555w'
self.spectrum='rn(spec(crcalspec$gd71_mod_005.fits),box(5125.0,1.0), 1.0e-18, flam)'
self.setglobal(__file__)
self.tda['Hostname']=socket.gethostname()
self.runpy()
if __name__ == '__main__':
if 'debug' in sys.argv:
testutil.debug(__name__)
else:
testutil.testall(__name__,2)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,569 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_ui.py | from __future__ import absolute_import, division, print_function
import os
import numpy as np
import pytest
from astropy.io import fits
from numpy.testing import assert_array_equal, assert_allclose
from .. import units, refs
from ..obsbandpass import ObsBandpass
from ..spectrum import (MergeWaveSets, ArraySourceSpectrum, BlackBody, Box,
FileSourceSpectrum, FlatSpectrum,
TabularSourceSpectrum)
def test_merge_wave():
"""
Demonstrate the problem described in Trac Ticket #34:
Adding two identical tabular spectra loses a pixel in the resulting
spectrum's table.
"""
foo = np.arange(10, 20, dtype=np.float64)
x = MergeWaveSets(foo, foo)
assert_array_equal(foo, x)
def test_unit():
"""
Converted to fnu, it should not be flat.
Can't test against 1.0 because there's computations & some
numerical issues.
"""
uspec = FlatSpectrum(1.0, fluxunits='flam')
uspec.convert('fnu')
assert uspec.flux.mean() != 1.0
def test_units_exceptions():
sp = BlackBody(30000)
# Make sure waveunits are really waveunits
with pytest.raises(TypeError):
ArraySourceSpectrum(sp.wave, sp.flux, 'flam')
# Make sure fluxunits are really fluxunits
with pytest.raises(TypeError):
ArraySourceSpectrum(sp.wave, sp.flux, 'angstrom', 'angstrom')
@pytest.mark.remote_data
def test_band():
"""Comparison results were computed with r1j2146sm_tmc.fits"""
old_comptable = refs.COMPTABLE
refs.COMPTABLE = os.path.join(
os.environ['PYSYN_CDBS'], 'mtab', 'OLD_FILES', 'r1j2146sm_tmc.fits')
# Tests Trac Ticket #30 -- no error
ObsBandpass('johnson,v')
# Tests SVN commit r172
bp1 = ObsBandpass('acs,hrc,f555w')
assert len(bp1) == 6
# Reset
refs.COMPTABLE = old_comptable
@pytest.mark.remote_data
class TestFile(object):
def setup_class(self):
self.fname = os.path.join(
os.environ['PYSYN_CDBS'], 'calspec', 'feige66_002.fits')
self.sp = FileSourceSpectrum(self.fname)
self.openfits = fits.open(self.fname)
def test_wave_flux(self):
fitswave = self.openfits[1].data.field('wavelength')
fitsflux = self.openfits[1].data.field('flux')
assert_array_equal(self.sp.wave, fitswave)
assert_allclose(self.sp.flux, fitsflux, rtol=1E-6)
def test_name(self):
assert str(self.sp) == self.fname
assert self.sp.name == self.fname
def test_resample(self):
sp2 = self.sp.resample(np.arange(10000, 18000, 2))
assert sp2.fluxunits is not None
def test_add(self):
sp2 = self.sp + self.sp
sumflux = self.sp.flux + self.sp.flux
assert_array_equal(sp2.flux, sumflux)
def test_mul(self):
bp = Box(3000, 50)
sp1 = self.sp * bp
sp2 = bp * self.sp
assert_array_equal(sp1.flux, sp2.flux)
def teardown_class(self):
self.openfits.close()
class TestTabular(object):
"""Test new ArraySourceSpectrum inheriting from TabularSourceSpectrum"""
def setup_class(self):
self.inwave = np.arange(1300, 1800)
self.influx = -2.5 * np.log10(self.inwave ** 2)
self.sp = ArraySourceSpectrum(wave=self.inwave, flux=self.influx,
fluxunits='abmag')
def test_arrays(self):
assert_allclose(self.inwave, self.sp.wave)
assert_allclose(self.influx, self.sp.flux, rtol=1E-3)
def test_units(self):
assert isinstance(self.sp.waveunits, units.Angstrom)
assert isinstance(self.sp.fluxunits, units.ABMag)
def test_string(self):
str(self.sp) # No error
def test_convert(self):
old_unit = self.sp.fluxunits
self.sp.convert('flam')
assert not np.allclose(self.influx, self.sp.flux)
self.sp.convert(old_unit)
class TestTab2(TestTabular):
def setup_class(self):
self.inwave = np.arange(1300, 1800)
self.influx = np.random.lognormal(size=len(self.inwave)) * 1e-15
self.sp = ArraySourceSpectrum(wave=self.inwave, flux=self.influx,
waveunits='nm', fluxunits='fnu',
name='Tab2 spectrum')
def test_units(self):
assert isinstance(self.sp.waveunits, units.Nm)
assert isinstance(self.sp.fluxunits, units.Fnu)
def test_string(self):
assert str(self.sp) == 'Tab2 spectrum'
class BaseSpecComp(object):
"""Base class for the tests to follow."""
def test_wave_flux(self):
assert_array_equal(self.new_sp.wave, self.old_sp.wave)
assert_array_equal(self.new_sp.flux, self.old_sp.flux)
assert isinstance(self.new_sp.waveunits,
self.old_sp.waveunits.__class__)
assert isinstance(self.new_sp.fluxunits,
self.old_sp.fluxunits.__class__)
assert_array_equal(self.new_sp._wavetable, self.old_sp._wavetable)
assert_array_equal(self.new_sp._fluxtable, self.old_sp._fluxtable)
def testconvertflux(self):
self.old_sp.convert('vegamag')
self.new_sp.convert('vegamag')
assert_array_equal(self.new_sp.flux, self.old_sp.flux)
@pytest.mark.remote_data
class TestTab(BaseSpecComp):
def setup_class(self):
self.fname = os.path.join(
os.environ['PYSYN_CDBS'], 'calspec', 'feige66_002.fits')
self.old_sp = FileSourceSpectrum(self.fname)
self.openfits = fits.open(self.fname)
fdata = self.openfits[1].data
self.new_sp = ArraySourceSpectrum(
wave=fdata.field('wavelength'),
flux=fdata.field('flux'),
waveunits=self.openfits[1].header['tunit1'],
fluxunits=self.openfits[1].header['tunit2'],
name='table from feige66')
def teardown_class(self):
self.openfits.close()
@pytest.mark.remote_data
class TestFSS(BaseSpecComp):
"""Test operations on a FileSource."""
def setup_class(self):
self.fname = os.path.join(
os.environ['PYSYN_CDBS'], 'calspec', 'feige66_002.fits')
self.old_sp = TabularSourceSpectrum(self.fname)
self.new_sp = FileSourceSpectrum(self.fname)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,570 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_locations.py | from __future__ import absolute_import, division, print_function
import os
import astropy
from astropy.utils.data import get_pkg_data_filename
from astropy.utils.introspection import minversion
from .. import locations
ASTROPY_LT_4_3 = not minversion(astropy, '4.3')
if ASTROPY_LT_4_3:
from astropy.utils.data import _find_pkg_data_path as get_pkg_data_path
else:
from astropy.utils.data import get_pkg_data_path
class TestGetRedLaws(object):
"""
Test the ability of pysynphot.locations to auto-gather extinction laws
from $PYSYN_CDBS/extinction/
"""
def setup_class(self):
self.old_cdbs = os.environ['PYSYN_CDBS']
locations.rootdir = get_pkg_data_path(os.path.join('data', 'cdbs'))
locations._get_RedLaws()
def teardown_class(self):
locations.rootdir = self.old_cdbs
def test_get_RedLaws(self):
redlaws = locations.RedLaws.copy()
shouldbe = {'lmc30dor': 'lmc_30dorshell_001.fits',
'lmcavg': 'lmc_diffuse_002.fits',
'mwdense': 'milkyway_dense_001.fits',
'mwavg': 'milkyway_diffuse_001.fits',
'smcbar': 'smc_bar_001.fits',
'xgalsb': 'xgal_starburst_003.fits'}
for name in shouldbe:
assert shouldbe[name] == os.path.basename(redlaws[name]), \
'actual={}'.format(redlaws[name])
def test_CONVERTDICT():
"""
Test that we can add a new conversion to the CONVERTDICT and
irafconvert will find and use it.
"""
refpath = get_pkg_data_filename(
os.path.join('data', 'cdbs', 'jref', 'empty_test_file.txt'))
locations.CONVERTDICT['testjref'] = os.path.dirname(refpath)
filename = locations.irafconvert('testjref$empty_test_file.txt')
assert refpath == filename
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,571 | spacetelescope/pysynphot | refs/heads/master | /commissioning/invalid_rn_cases.py | import unittest
from pysynphot import etc
class C1(unittest.TestCase):
def setUp(self):
self.sp="rn(icat(ck04models,41000,4.5,0),band(ACS,HRC,G800L,F220W),4.5,vegamag)"
def testinvalid(self):
self.assertRaises(ValueError,
etc.parse_spec,
self.sp)
class C2(C1):
def setUp(self):
self.sp="rn(icat(ck04models,41000,4.5,0),band(ACS,HRC,G800L,F250W),4.5,vegamag)"
class C3(C1):
def setUp(self):
self.sp="rn(icat(ck04models,41000,4.5,0),band(ACS,HRC,G800L,F330W),4.5,vegamag)"
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,572 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/refs.py | """This module handles constants and look-up tables used in calculations.
**Global Variables**
* ``pysynphot.refs._default_waveset`` - Default wavelength set to use if no
instrument-specific values found.
* ``pysynphot.refs._default_waveset_str`` - Description of the default
wavelength set above.
* ``pysynphot.refs.PRIMARY_AREA`` - Telescope collecting area, i.e., the primary
mirror, in :math:`\\mathrm{cm}^{2}`. The value for HST is 45238.93416.
These are used in `~pysynphot.observationmode` to look up throughput files for
a given bandpass:
* ``pysynphot.refs.GRAPHTABLE``
* ``pysynphot.refs.GRAPHDICT``
* ``pysynphot.refs.COMPTABLE``
* ``pysynphot.refs.COMPDICT``
* ``pysynphot.refs.THERMTABLE``
* ``pysynphot.refs.THERMDICT``
"""
from __future__ import print_function
import os.path
import warnings
import numpy as np
from .locations import irafconvert, _refTable
_default_waveset = None
_default_waveset_str = None
# Constants to hold tables.
GRAPHTABLE = ''
GRAPHDICT = {}
COMPTABLE = ''
COMPDICT = {}
THERMTABLE = ''
THERMDICT = {}
PRIMARY_AREA = 45238.93416 # cm^2 - default to HST mirror
def set_default_waveset(minwave=500, maxwave=26000, num=10000,
delta=None, log=True):
"""Set the default wavelength set, ``pysynphot.refs._default_waveset``.
Parameters
----------
minwave, maxwave : float, optional
The start (inclusive) and end (exclusive) points of the wavelength set.
Values should be given in linear space regardless of ``log``.
num : int, optional
The number of elements in the wavelength set.
Only used if ``delta=None``.
delta : float, optional
Delta between values in the wavelength set.
If ``log=True``, this defines wavelegth spacing in log space.
log : bool, optional
Determines whether the wavelength set is evenly spaced in log or linear
space.
"""
global _default_waveset
global _default_waveset_str
# Must be int for numpy>=1.12
num = int(num)
s = 'Min: %s, Max: %s, Num: %s, Delta: %s, Log: %s'
if log and not delta:
s = s % tuple([str(x) for x in (minwave, maxwave, num, None, log)])
logmin = np.log10(minwave)
logmax = np.log10(maxwave)
_default_waveset = np.logspace(logmin, logmax, num, endpoint=False)
elif log and delta:
s = s % tuple([str(x) for x in (minwave, maxwave, None, delta, log)])
logmin = np.log10(minwave)
logmax = np.log10(maxwave)
_default_waveset = 10 ** np.arange(logmin, logmax, delta)
elif not log and not delta:
s = s % tuple([str(x) for x in (minwave, maxwave, num, None, log)])
_default_waveset = np.linspace(minwave, maxwave, num, endpoint=False)
elif not log and delta:
s = s % tuple([str(x) for x in (minwave, maxwave, None, delta, log)])
_default_waveset = np.arange(minwave, maxwave, delta)
_default_waveset_str = s
def _set_default_refdata():
"""Default refdata set on import."""
global GRAPHTABLE, COMPTABLE, THERMTABLE, PRIMARY_AREA
# Component tables are defined here.
try:
GRAPHTABLE = _refTable(os.path.join('mtab','*_tmg.fits'))
COMPTABLE = _refTable(os.path.join('mtab','*_tmc.fits'))
except IOError as e:
GRAPHTABLE = None
COMPTABLE = None
warnings.warn('No graph or component tables found; '
'functionality will be SEVERELY crippled. ' + str(e))
try:
THERMTABLE = _refTable(os.path.join('mtab','*_tmt.fits'))
except IOError as e:
THERMTABLE = None
warnings.warn('No thermal tables found, '
'no thermal calculations can be performed. ' + str(e))
PRIMARY_AREA = 45238.93416 # cm^2 - default to HST mirror
set_default_waveset()
#Do this on import
_set_default_refdata()
def setref(graphtable=None, comptable=None, thermtable=None,
area=None, waveset=None):
"""Set default graph and component tables, primary area, and
wavelength set.
This is similar to setting ``refdata`` in IRAF STSDAS SYNPHOT.
If all parameters set to `None`, they are reverted to software default.
If any of the parameters are not `None`, they are set to desired
values while the rest (if any) remain at current setting.
Parameters
----------
graphtable, comptable, thermtable : str or `None`
Graph, component, and thermal table names, respectively,
for `~pysynphot.observationmode` throughput look-up.
Do not use "*" wildcard.
area : float or `None`
Telescope collecting area, i.e., the primary
mirror, in :math:`\\mathrm{cm}^{2}`.
waveset : tuple or `None`
Parameters for :func:`set_default_waveset` as follow:
* ``(minwave, maxwave, num)`` - This assumes log scale.
* ``(minwave, maxwave, num, 'log')``
* ``(minwave, maxwave, num, 'linear')``
Raises
------
ValueError
Invalid ``waveset`` parameters.
"""
global GRAPHTABLE, COMPTABLE, THERMTABLE, PRIMARY_AREA, GRAPHDICT, COMPDICT, THERMDICT
GRAPHDICT = {}
COMPDICT = {}
THERMDICT = {}
#Check for all None, which means reset
kwds=set([graphtable,comptable,thermtable,area,waveset])
if kwds == set([None]):
#then we should reset everything.
_set_default_refdata()
return
#Otherwise, check them all separately
if graphtable is not None:
GRAPHTABLE = irafconvert(graphtable)
if comptable is not None:
COMPTABLE = irafconvert(comptable)
if thermtable is not None:
THERMTABLE = irafconvert(thermtable)
#Area is a bit different:
if area is not None:
PRIMARY_AREA = area
if waveset is not None:
if len(waveset) not in (3, 4):
raise ValueError('waveset tuple must contain 3 or 4 values')
minwave = waveset[0]
maxwave = waveset[1]
num = waveset[2]
if len(waveset) == 3:
log = True
elif len(waveset) == 4:
if waveset[3].lower() == 'log':
log = True
elif waveset[3].lower() == 'linear':
log = False
else:
raise ValueError('fourth waveset option must be "log" or "linear"')
set_default_waveset(minwave,maxwave,num,log=log)
#That's it.
return
def getref():
"""Current default values for graph and component tables, primary area,
and wavelength set.
.. note::
Also see :func:`setref`.
Returns
-------
ans : dict
Mapping of parameter names to their current values.
"""
ans=dict(graphtable=GRAPHTABLE,
comptable=COMPTABLE,
thermtable=THERMTABLE,
area=PRIMARY_AREA,
waveset=_default_waveset_str)
return ans
def showref():
"""Like :func:`getref` but print results to screen instead of returning
a dictionary.
"""
refdata = getref()
for k, v in refdata.items():
print("%10s: %s" % (k,v))
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,573 | spacetelescope/pysynphot | refs/heads/master | /commissioning/acs_effstim_cases.py | from pytools import testutil
import sys
import basecase
class E1photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E1flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E1fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E1vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E1abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E1stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E1obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E1counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E2photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E2flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E2fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E2vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E2abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E2stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E2obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E2counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E3photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E3flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E3fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E3vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E3abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E3stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E3obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E3counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E4photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E4flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E4fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E4vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E4abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E4stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E4obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E4counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E5photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E5flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E5fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E5vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E5abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E5stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E5obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E5counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E6photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E6flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E6fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E6vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E6abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E6stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E6obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E6counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E7photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E7flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E7fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E7vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E7abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E7stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E7obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E7counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E8photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E8flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E8fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E8vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E8abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E8stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E8obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E8counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E9photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E9flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E9fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E9vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E9abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E9stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E9obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E9counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E10photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E10flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E10fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E10vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E10abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E10stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E10obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E10counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E11photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E11flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E11fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E11vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E11abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E11stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E11obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E11counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E12photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E12flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E12fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E12vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E12abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E12stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E12obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E12counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E13photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E13flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E13fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E13vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E13abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E13stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E13obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E13counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E14photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E14flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E14fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E14vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E14abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E14stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E14obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E14counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E15photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E15flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E15fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E15vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E15abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E15stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E15obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E15counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E16photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E16flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E16fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E16vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E16abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E16stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E16obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E16counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E17photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E17flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E17fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E17vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E17abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E17stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E17obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E17counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E18photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E18flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E18fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E18vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E18abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E18stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E18obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E18counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E19photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E19flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E19fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E19vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E19abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E19stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E19obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E19counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E20photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E20flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E20fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E20vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E20abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E20stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E20obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E20counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E21photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E21flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E21fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E21vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E21abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E21stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E21obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E21counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E22photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E22flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E22fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E22vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E22abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E22stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E22obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E22counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E23photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E23flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E23fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E23vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E23abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E23stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E23obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E23counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E24photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E24flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E24fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E24vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E24abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E24stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E24obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E24counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E25photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E25flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E25fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E25vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E25abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E25stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E25obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E25counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E26photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E26flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E26fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E26vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E26abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E26stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E26obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E26counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E27photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E27flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E27fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E27vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E27abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E27stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E27obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E27counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E28photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E28flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E28fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E28vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E28abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E28stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E28obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E28counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E29photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E29flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E29fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E29vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E29abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E29stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E29obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E29counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E30photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E30flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E30fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E30vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E30abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E30stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E30obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E30counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E31photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E31flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E31fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E31vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E31abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E31stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E31obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E31counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E32photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E32flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E32fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E32vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E32abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E32stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E32obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E32counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E33photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E33flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E33fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E33vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E33abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E33stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E33obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E33counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E34photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E34flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E34fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E34vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E34abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E34stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E34obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E34counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E35photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E35flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E35fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E35vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E35abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E35stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E35obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E35counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E36photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E36flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E36fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E36vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E36abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E36stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E36obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E36counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E37photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E37flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E37fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E37vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E37abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E37stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E37obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E37counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E38photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E38flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E38fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E38vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E38abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E38stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E38obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E38counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E39photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E39flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E39fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E39vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E39abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E39stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E39obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E39counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E40photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E40flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E40fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E40vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E40abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E40stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E40obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E40counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E41photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E41flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E41fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E41vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E41abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E41stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E41obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E41counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E42photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E42flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E42fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E42vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E42abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E42stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E42obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E42counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E43photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E43flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E43fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E43vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E43abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E43stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E43obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E43counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E44photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E44flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E44fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E44vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E44abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E44stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E44obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E44counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E45photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E45flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E45fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E45vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E45abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E45stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E45obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E45counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E46photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E46flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E46fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E46vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E46abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E46stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E46obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E46counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E47photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E47flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E47fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E47vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E47abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E47stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E47obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E47counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E48photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E48flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E48fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E48vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E48abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E48stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E48obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E48counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E49photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E49flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E49fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E49vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E49abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E49stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E49obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E49counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E50photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E50flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E50fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E50vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E50abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E50stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E50obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E50counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E51photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E51flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E51fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E51vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E51abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E51stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E51obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E51counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E52photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E52flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E52fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E52vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E52abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E52stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E52obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E52counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E53photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E53flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E53fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E53vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E53abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E53stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E53obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E53counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E54photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E54flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E54fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E54vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E54abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E54stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E54obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E54counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f435w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E55photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E55flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E55fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E55vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E55abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E55stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E55obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E55counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f475w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E56photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E56flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E56fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E56vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E56abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E56stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E56obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E56counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f555w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E57photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E57flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E57fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E57vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E57abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E57stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E57obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E57counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E58photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E58flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E58fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E58vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E58abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E58stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E58obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E58counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E59photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E59flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E59fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E59vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E59abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E59stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E59obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E59counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E60photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E60flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E60fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E60vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E60abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E60stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E60obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E60counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,wfc1,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E61photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E61flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E61fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E61vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E61abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E61stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E61obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E61counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E62photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E62flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E62fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E62vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E62abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E62stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E62obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E62counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E63photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E63flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E63fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E63vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E63abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E63stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E63obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E63counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E64photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E64flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E64fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E64vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E64abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E64stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E64obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E64counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E65photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E65flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E65fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E65vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E65abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E65stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E65obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E65counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E66photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E66flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E66fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E66vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E66abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E66stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E66obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E66counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E67photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E67flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E67fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E67vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E67abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E67stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E67obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E67counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E68photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E68flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E68fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E68vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E68abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E68stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E68obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E68counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E69photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E69flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E69fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E69vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E69abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E69stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E69obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E69counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E70photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E70flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E70fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E70vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E70abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E70stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E70obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E70counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E71photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E71flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E71fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E71vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E71abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E71stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E71obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E71counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E72photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E72flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E72fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E72vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E72abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E72stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E72obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E72counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E73photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E73flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E73fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E73vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E73abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E73stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E73obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E73counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E74photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E74flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E74fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E74vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E74abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E74stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E74obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E74counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E75photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E75flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E75fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E75vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E75abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E75stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E75obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E75counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E76photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E76flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E76fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E76vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E76abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E76stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E76obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E76counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E77photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E77flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E77fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E77vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E77abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E77stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E77obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E77counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E78photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E78flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E78fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E78vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E78abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E78stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E78obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E78counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E79photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E79flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E79fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E79vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E79abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E79stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E79obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E79counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E80photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E80flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E80fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E80vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E80abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E80stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E80obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E80counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E81photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E81flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E81fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E81vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E81abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E81stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E81obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E81counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E82photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E82flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E82fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E82vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E82abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E82stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E82obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E82counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E83photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E83flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E83fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E83vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E83abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E83stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E83obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E83counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E84photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E84flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E84fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E84vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E84abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E84stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E84obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E84counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E85photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E85flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E85fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E85vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E85abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E85stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E85obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E85counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E86photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E86flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E86fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E86vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E86abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E86stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E86obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E86counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E87photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E87flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E87fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E87vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E87abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E87stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E87obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E87counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E88photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E88flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E88fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E88vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E88abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E88stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E88obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E88counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E89photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E89flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E89fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E89vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E89abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E89stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E89obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E89counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E90photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E90flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E90fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E90vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E90abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E90stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E90obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E90counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E91photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E91flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E91fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E91vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E91abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E91stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E91obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E91counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E92photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E92flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E92fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E92vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E92abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E92stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E92obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E92counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E93photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E93flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E93fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E93vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E93abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E93stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E93obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E93counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E94photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E94flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E94fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E94vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E94abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E94stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E94obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E94counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E95photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E95flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E95fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E95vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E95abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E95stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E95obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E95counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E96photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E96flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E96fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E96vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E96abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E96stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E96obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E96counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E97photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E97flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E97fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E97vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E97abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E97stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E97obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E97counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E98photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E98flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E98fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E98vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E98abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E98stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E98obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E98counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E99photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E99flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E99fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E99vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E99abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E99stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E99obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E99counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E100photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E100flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E100fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E100vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E100abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E100stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E100obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E100counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E101photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E101flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E101fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E101vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E101abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E101stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E101obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E101counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E102photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E102flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E102fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E102vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E102abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E102stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E102obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E102counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E103photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E103flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E103fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E103vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E103abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E103stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E103obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E103counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E104photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E104flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E104fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E104vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E104abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E104stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E104obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E104counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E105photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E105flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E105fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E105vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E105abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E105stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E105obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E105counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E106photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E106flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E106fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E106vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E106abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E106stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E106obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E106counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E107photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E107flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E107fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E107vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E107abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E107stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E107obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E107counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E108photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E108flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E108fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E108vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E108abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E108stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E108obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E108counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E109photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E109flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E109fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E109vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E109abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E109stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E109obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E109counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(2000) "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E110photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E110flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E110fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E110vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E110abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E110stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E110obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E110counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E111photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E111flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E111fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E111vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E111abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E111stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E111obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E111counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E112photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E112flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E112fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E112vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E112abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E112stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E112obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E112counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E113photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E113flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E113fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E113vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E113abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E113stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E113obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E113counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(3000) "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E114photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E114flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E114fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E114vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E114abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E114stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E114obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E114counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f435w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E115photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E115flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E115fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E115vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E115abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E115stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E115obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E115counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f475w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E116photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E116flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E116fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E116vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E116abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E116stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E116obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E116counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f555w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E117photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E117flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E117fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E117vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E117abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E117stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E117obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E117counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f606w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E118photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E118flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E118fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E118vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E118abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E118stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E118obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E118counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f775w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E119photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E119flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E119fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E119vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E119abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E119stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E119obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E119counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f814w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E120photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E120flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E120fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E120vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E120abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E120stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E120obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E120counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crcalspec$alpha_lyr_stis_003.fits "
self.obsmode="acs,hrc,f850lp"
self.form="counts"
self.setglobal(__file__)
self.runpy()
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,574 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_v05_tickets.py | from __future__ import absolute_import, division, print_function
import os
import numpy as np
import pytest
from numpy.testing import assert_array_equal, assert_allclose
from .. import Cache, extinction
from ..obsbandpass import ObsBandpass
from ..reddening import Extinction, RedLaw
from ..spectrum import (ArraySourceSpectrum, ArraySpectralElement, BlackBody,
FlatSpectrum, SourceSpectrum, SpectralElement)
from ..spparser import parse_spec
@pytest.mark.remote_data
def test_0000():
"""
Some of the tests below will fail if this is not the FIRST
set of tests to be run;they probe side effects on the Cache.
"""
xt = Extinction(0.3, 'mwdense')
assert isinstance(xt, SpectralElement)
# test sideeffect of above
xt = Cache.RedLaws['mwdense']
assert isinstance(xt, RedLaw)
xt = Cache.RedLaws['smcbar']
if not xt.startswith(('http', 'ftp')):
assert os.path.isfile(xt)
xt = Extinction(0.2, Cache.RedLaws['smcbar'])
assert isinstance(xt, SpectralElement)
xt = Extinction(0.3)
assert isinstance(xt, SpectralElement)
assert 'mwavg' in xt.name.lower()
with pytest.raises(ValueError):
Extinction(0.2, '/foo/bar.fits')
@pytest.mark.remote_data
def test_smcbar():
newsmc = Extinction(0.2, 'smcbar')
tst = newsmc(np.array([5500, 5550, 5600]))
assert tst[-1] > tst[0]
assert_array_equal(newsmc.throughput, newsmc._throughputtable)
def test_integral():
sp = BlackBody(30000)
sp.convert('flam')
sp.convert('Angstrom')
wave, flux = sp.getArrays()
ang = sp.trapezoidIntegration(wave, flux)
sp.convert('fnu')
sp.convert('hz')
wave, flux = sp.getArrays()
hz = sp.trapezoidIntegration(wave, flux)
assert_allclose(ang, hz)
class TestTicket135Ordering(object):
def setup_class(self):
self.ascending = np.arange(10000, 10100, 10)
self.thru = np.arange(10) + 5
@pytest.mark.parametrize('step', [1, -1])
def test_order(self, step):
wave = self.ascending[::step]
bp = ArraySpectralElement(wave=wave, throughput=self.thru)
t = bp(wave[::-1])
assert_array_equal(bp.throughput, bp._throughputtable)
assert_array_equal(t, bp._throughputtable[::-1])
assert_array_equal(bp.throughput, bp(bp.wave))
def test_ticket135_flip_sp():
sp = BlackBody(30000)
# create a spectrum with wavelength in descending order
sp2 = ArraySourceSpectrum(wave=sp.wave[::-1],
flux=sp.flux[::-1],
waveunits=sp.waveunits,
fluxunits=sp.fluxunits)
# .flux calls __call__ calls resample
ref = sp.flux[::-1]
tst = sp2.flux
assert_allclose(ref, tst)
@pytest.mark.remote_data
def test_ticket135_flip_bp():
bp = ObsBandpass('johnson,v')
T = bp.throughput
# create a bandpass with wavelength in descending order
bp2 = ArraySpectralElement(wave=bp.wave[::-1],
throughput=T[::-1],
waveunits=bp.waveunits)
# .throughput calls __call__ calls resample
ref = bp.throughput[::-1]
tst = bp2.throughput
idxr = np.where(ref != 0)[0]
idxt = np.where(tst != 0)[0]
assert_array_equal(idxr, idxt)
assert_allclose(ref[idxr], tst[idxr])
@pytest.mark.remote_data
@pytest.mark.parametrize(
'pstr',
['rn(icat(k93models,44500,0.0,5.0),band(nicmos,2,f222m),18,vegamag)',
'rn(icat(k93models,44500,0.0,5.0),band(v),18,vegamag)',
'rn(icat(k93models,44500,0.0,5.0),band(johnson,v),18,vegamag)'])
def test_parse_spec(pstr):
sp = parse_spec(pstr)
assert isinstance(sp, SourceSpectrum)
class TestAddMag(object):
"""Ticket #122"""
def setup_class(self):
self.bright = FlatSpectrum(18.0, fluxunits='abmag')
self.faint = FlatSpectrum(21.0, fluxunits='abmag')
self.delta = 3
def test_add(self):
test = self.bright.addmag(self.delta)
assert_array_equal(test.flux, self.faint.flux)
def test_subtract(self):
test = self.faint.addmag(self.delta * -1.0)
assert_allclose(test.flux, self.bright.flux)
def testtypecatch(self):
with pytest.raises(TypeError):
self.faint.addmag(self.bright)
def test_sample():
"""Ticket #99"""
sp = FlatSpectrum(10, fluxunits='flam')
wave = np.arange(1000, 11000, 1000)
ref = ArraySourceSpectrum(wave=wave,
flux=sp.flux[0]*np.ones(wave.shape),
fluxunits=sp.fluxunits)
tst = sp.sample(wave)
assert_array_equal(tst, ref.flux)
@pytest.mark.remote_data
def test_ticket104():
"""
Use the extinction laws to test and make sure the conversion to
SpectralElements works ok.
"""
sp = Extinction(0.2, 'gal1') # Make an extinction law
sp.convert('1/um') # convert to inverse microns
refwave = extinction._buildDefaultWaveset()
testwave = sp.wave
assert_allclose(testwave, refwave)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,575 | spacetelescope/pysynphot | refs/heads/master | /commissioning/printversion.py | from __future__ import print_function
import pysynphot as S
from pysynphot import observationmode as O
print("S.__svn_revision__: %s"%S.__svn_revision__)
print(O.GRAPHTABLE)
print(O.COMPTABLE)
print(O.THERMTABLE)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,576 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_units.py | from __future__ import absolute_import, division, print_function
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_array_equal
from .. import extinction, refs
from ..binning import calculate_bin_widths, calculate_bin_edges
from ..spectrum import ArraySourceSpectrum, BlackBody, FlatSpectrum
from ..units import Angstrom, Counts, InverseMicron, OBMag, Photlam, Units
awave = refs._default_waveset.copy()[::10][0:10]
aflux = np.ones(awave.shape)
class BaseUnitStr(object):
"""Base class to test unit string."""
def test_str(self):
assert str(self.x) == self.unit_str
class TestInverseMicron(BaseUnitStr):
def setup_class(self):
self.unit_str = '1/um'
self.x = Units(self.unit_str)
self.mwave = extinction._buildDefaultWaveset()[0:10]
self.awave = awave
def test_unittoang(self):
tst = self.x.Convert(self.mwave, 'angstrom')
assert_allclose(tst, self.awave)
def test_unitfromang(self):
ang = Units('angstrom')
for s in ('1/um', 'InverseMicron', 'inversemicrons'):
tst = ang.Convert(self.awave, s)
assert_allclose(tst, self.mwave)
def test_fromang(self):
tst = ArraySourceSpectrum(wave=self.awave,
flux=aflux,
waveunits='angstrom',
fluxunits='flam')
tst.convert('1/um')
assert isinstance(tst.waveunits, InverseMicron)
assert_allclose(tst.wave, self.mwave)
def test_create(self):
tst = ArraySourceSpectrum(wave=self.mwave,
flux=aflux,
waveunits='1/um',
fluxunits='flam')
assert isinstance(tst.waveunits, InverseMicron)
assert_array_equal(tst.wave, self.mwave)
tst.convert('angstrom')
assert isinstance(tst.waveunits, Angstrom)
assert_allclose(tst.wave, self.awave)
class BasePfxJy(object):
"""Base class to test ujy and njy."""
def test_unittophotlam(self):
"""Verify that the conversion from muJy to photlam is correct."""
tst = self.x.ToPhotlam(self.awave, self.flux)
assert_allclose(self.ref_photlam, tst)
def test_fromphotlam1(self):
"""Verify that the conversion from photlam to muJy is correct."""
photlam = Units('photlam')
for s in self.aliases:
tst = photlam.Convert(self.awave, self.flux, s)
assert_allclose(tst, self.ref_val)
class TestmuJy(BasePfxJy, BaseUnitStr):
"""
Tests certain attributes of the micro Jansky (muJy)
class, including how the units are referenced, and
the conversion to and from.
Partial fulfillment of Trac Ticket #102.
"""
def setup_class(self):
self.unit_str = 'mujy'
self.aliases = (self.unit_str, 'microjy', 'ujy')
self.x = Units(self.unit_str)
# Create a 10 element array of simulated wavelength values in Angstroms
self.awave = awave
# Creates a 10 element array of ones
self.flux = aflux
# Create reference values based on Jansky class to
# be used in verifying the Micro Jansky class
self.ref_photlam = (Units('jy').ToPhotlam(self.awave, self.flux) *
(1.0e-6))
self.ref_val = Units('photlam').ToJy(self.awave, self.flux) * (1.0e6)
class TestnJy(BasePfxJy, BaseUnitStr):
"""
Tests certain attributes of the nano Jansky (nJy)
class, including how the units are referenced, and
the conversion to and from.
Partial fulfillment of Trac Ticket #102.
"""
def setup_class(self):
self.unit_str = 'njy'
self.aliases = (self.unit_str, 'nanojy')
self.x = Units(self.unit_str)
# Create a 10 element array of simulated wavelength values in Angstroms
self.awave = awave
# Creates a 10 element array of ones
self.flux = aflux
# Create reference values based on Jansky class to
# be used in verifying the Nano Jansky class
self.ref_photlam = (Units('jy').ToPhotlam(self.awave, self.flux) *
(1.0e-9))
self.ref_val = Units('photlam').ToJy(self.awave, self.flux) * (1.0e9)
class TestXJanskyTypicalUse(object):
"""
Tests normal use attributes of the muJy and nJy classes in
relation to a larger portion of the code base, to verify
output, from a broader perspective, and values as they
should appear, based on how the functions within the classes
are referenced and how they are converted.
Partial fulfillment of Trac Ticket #102.
"""
def setup_class(self):
self.bb = BlackBody(5500)
self.bb.convert('jy')
self.wave = self.bb.wave
self.flux = self.bb.flux
@pytest.mark.parametrize(
('fac', 'unit_str'),
[(1.0e6, 'mujy'),
(1.0e9, 'njy')])
def test_convert(self, fac, unit_str):
self.bb.convert(unit_str)
assert_allclose(self.bb.wave, self.wave)
assert_allclose(self.bb.flux, self.flux * fac)
@pytest.mark.parametrize(
('unit_str', 'ref_units'),
[('mujy', 'mujy'),
('microjy', 'mujy'),
('ujy', 'mujy'),
('njy', 'njy'),
('nanojy', 'njy')])
def test_unitstring1(self, unit_str, ref_units):
self.bb.convert(unit_str)
assert str(self.bb.fluxunits) == ref_units
def test_fluxattribute(self):
self.bb.convert('mujy')
mflux = self.bb.flux
self.bb.convert('njy')
nflux = self.bb.flux
assert_allclose(np.mean(nflux / mflux), 1000)
def test_flat_spectrum():
"""Test unit conversion of a FlatSpectrum."""
f = FlatSpectrum(1, fluxunits='photlam')
f.convert('counts')
delta_wave = calculate_bin_widths(calculate_bin_edges(f.wave))
assert_allclose(delta_wave * refs.PRIMARY_AREA, f.sample(f.wave))
f.primary_area = 100.0
assert_allclose(delta_wave * 100, f.sample(f.wave))
class TestConvWithArea(object):
"""Test the flux unit conversion methods that take area arguments."""
def setup_class(self):
self.wave = refs._default_waveset
self.flux = np.ones_like(self.wave)
self.delta_wave = calculate_bin_widths(calculate_bin_edges(self.wave))
@pytest.mark.parametrize(
('area', 'refs_area'),
[(1.0, 1),
(None, refs.PRIMARY_AREA)])
def test_photlam(self, area, refs_area):
p = Photlam()
ref = -1.085736 * np.log(self.flux * self.delta_wave * refs_area)
tst = p.ToOBMag(self.wave, self.flux, area=area)
assert_allclose(ref, tst)
ref = self.flux * self.delta_wave * refs_area
tst = p.ToCounts(self.wave, self.flux, area=area)
assert_allclose(ref, tst)
@pytest.mark.parametrize(
('area', 'refs_area'),
[(1.0, 1),
(None, refs.PRIMARY_AREA)])
def test_obmag(self, area, refs_area):
ob = OBMag()
ref = 10.0 ** (-0.4 * self.flux) / (self.delta_wave * refs_area)
tst = ob.ToPhotlam(self.wave, self.flux, area=area)
assert_allclose(ref, tst)
@pytest.mark.parametrize(
('area', 'refs_area'),
[(1.0, 1),
(None, refs.PRIMARY_AREA)])
def test_counts(self, area, refs_area):
counts = Counts()
ref = self.flux / (self.delta_wave * refs_area)
tst = counts.ToPhotlam(self.wave, self.flux, area=area)
assert_allclose(ref, tst)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,577 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_write.py | from __future__ import absolute_import, division, print_function
import os
import numpy as np
import pytest
from ..catalog import Icat
from ..obsbandpass import ObsBandpass
from ..spectrum import (ArraySourceSpectrum, BlackBody, Box,
FileSourceSpectrum, FileSpectralElement, FlatSpectrum,
GaussianSource, Powerlaw, UniformTransmission)
from ..spparser import interpret, parse, scan
root = os.environ['PYSYN_CDBS']
@pytest.mark.parametrize(
'obj',
[ArraySourceSpectrum(np.arange(1, 10000), np.arange(9999) * 2.5),
BlackBody(10000),
Box(7000, 13.5),
FlatSpectrum(10.0, fluxunits='flam'),
GaussianSource(1e14, 10000, 10),
Powerlaw(10000, 0.5),
UniformTransmission(0.7)])
def test_write(tmpdir, obj):
fname = tmpdir.join(os.path.basename(obj.name) + '.fits')
obj.writefits(str(fname))
@pytest.mark.remote_data
class TestWriteParse(object):
"""
pytest.mark.parametrize gives URLError for HTTP or FTP connection,
so we have to do it this way instead.
"""
def setup_class(self):
self.obj = interpret(parse(scan('ebmvx(0.5,gal1)')))
def test_write_obj(self, tmpdir):
fname = tmpdir.join(os.path.basename(self.obj.name) + '.fits')
self.obj.writefits(str(fname))
class TestWriteFeige(TestWriteParse):
def setup_class(self):
self.obj = FileSourceSpectrum(
os.path.join(root, 'calspec', 'feige66_002.fits'))
class TestWriteV(TestWriteParse):
def setup_class(self):
self.obj = FileSpectralElement(
os.path.join(root, 'comp', 'nonhst', 'johnson_v_003_syn.fits'))
class TestWriteACS(TestWriteParse):
def setup_class(self):
self.obj = ObsBandpass('acs,hrc,f555w')
class TestWriteMJD(TestWriteParse):
def setup_class(self):
self.obj = ObsBandpass('acs,hrc,f555w,mjd#54000')
class TestWriteMult(TestWriteParse):
def setup_class(self):
self.obj = BlackBody(10000) * ObsBandpass('acs,hrc,f555w')
class TestWriteIcat(TestWriteParse):
def setup_class(self):
self.obj = Icat('k93models', 3500, 0.0, 4.6)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,578 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_ticket157.py | from __future__ import absolute_import, division, print_function
import os
import astropy
import numpy as np
import pytest
from astropy.utils.data import get_pkg_data_filename
from astropy.utils.introspection import minversion
from numpy.testing import assert_allclose
from .. import locations, refs
from ..exceptions import PartialOverlap
from ..obsbandpass import ObsBandpass
from ..observation import Observation
from ..spectrum import (ArraySourceSpectrum, ArraySpectralElement, BlackBody,
Box, FileSourceSpectrum, FlatSpectrum, GaussianSource,
Powerlaw)
old_comptable = None
old_vegafile = None
ASTROPY_LT_4_3 = not minversion(astropy, '4.3')
if ASTROPY_LT_4_3:
from astropy.utils.data import _find_pkg_data_path as get_pkg_data_path
else:
from astropy.utils.data import get_pkg_data_path
def setup_module(module):
"""
Freeze the version of the comptable so tests are not susceptible to
updates to CDBS. Also set the version of Vega for similar reasons.
"""
global old_comptable, old_vegafile
old_comptable = refs.COMPTABLE
refs.COMPTABLE = os.path.join(
os.environ['PYSYN_CDBS'], 'mtab', 'OLD_FILES', '39h19082m_tmc.fits')
old_vegafile = locations.VegaFile
locations.VegaFile = get_pkg_data_filename(
os.path.join('data', 'alpha_lyr_stis_002.fits'))
def teardown_module(module):
refs.COMPTABLE = old_comptable
locations.VegaFile = old_vegafile
class TestOverlapBug(object):
def setup_class(self):
self.sp = ArraySourceSpectrum(wave=np.arange(3000, 4000),
flux=np.ones((1000, )) * 0.75,
name='Short flat')
self.bp = Box(4000, 100)
self.refwave = 4005
self.refval = 0.75
self.rtol = 1e-7
def test_overlap(self):
ans = self.bp.check_overlap(self.sp)
assert ans == 'partial'
with pytest.raises(PartialOverlap):
Observation(self.sp, self.bp)
def test_taper(self):
obs = Observation(self.sp, self.bp, force='taper')
idx = np.searchsorted(obs.wave, self.refwave)
tst = obs.flux[idx]
assert tst == 0, 'Expected 0, got {}'.format(tst)
def test_extrap(self):
obs = Observation(self.sp, self.bp, force='extrap')
idx = np.searchsorted(obs.wave, self.refwave)
tst = obs.flux[idx]
assert_allclose(tst, self.refval, rtol=self.rtol)
@pytest.mark.remote_data
class TestDiscoveryCase(TestOverlapBug):
def setup_class(self):
# rn(z(spec(data/qso_template.fits),0.03),band(johnson,v),18,vegamag)
spdat = FileSourceSpectrum(
get_pkg_data_filename(os.path.join('data', 'qso_template.fits')))
self.sp = spdat.redshift(0.03).renorm(
18, 'vegamag', ObsBandpass('johnson,v'), force=True)
self.sp.convert('photlam')
self.bp = ObsBandpass('stis,ccd,g750l,c7751,s52x02')
self.refwave = 6200
self.refval = 2.853227e-06
self.rtol = 0.01
class TestBPOverlap(object):
def setup_class(self):
self.a = Box(4000, 50)
self.disjoint = Box(6000, 100)
self.full = Box(4000, 100)
self.partial = Box(4050, 50)
def test_disjoint(self):
assert self.a.check_overlap(self.disjoint) == 'none'
def test_full(self):
assert self.a.check_overlap(self.full) == 'full'
def test_partial(self):
assert self.a.check_overlap(self.partial) == 'partial'
class TestBP03(TestBPOverlap):
def setup_class(self):
self.a = ArraySpectralElement(wave=np.arange(4000, 5000),
throughput=np.ones(1000))
self.disjoint = Box(1000, 100)
self.full = ArraySpectralElement(wave=np.arange(3000, 6000),
throughput=np.ones(3000))
self.partial = ArraySpectralElement(wave=np.arange(500, 4500),
throughput=np.ones(4000))
def test_analytic_to_file(tmpdir):
fname = str(tmpdir.join('ac_pl.fits'))
pl = Powerlaw(5000, -2)
pl.writefits(fname)
fspec = FileSourceSpectrum(fname)
assert not fspec.isAnalytic
def test_analytic_flat():
flat = FlatSpectrum(10)
x = flat * 2.6
assert x.isAnalytic
class TestAnalyticCase(object):
def setup_class(self):
self.bb = BlackBody(5000)
def test_bb_gauss(self):
em = GaussianSource(3300, 1, 1)
x = self.bb + em
assert x.isAnalytic
def test_bb_arr(self):
tspec = ArraySourceSpectrum(self.bb.wave, self.bb.flux,
fluxunits=self.bb.fluxunits)
x = self.bb + tspec
assert self.bb.isAnalytic
assert not tspec.isAnalytic
assert not x.isAnalytic
# These tests were part of the original nightly pysynphot test suite
# that began failing when #157 was implemented because they really
# did have partial overlap.
@pytest.mark.remote_data
class TestCalcphot(object):
# Loosened accuracy for r618 (no taper)
def setup_class(self):
self.sp = FileSourceSpectrum(os.path.join(
os.environ['PYSYN_CDBS'], 'calspec', 'feige66_002.fits'))
self.bandpass = ObsBandpass('acs,hrc,f555w')
def test_raises(self):
with pytest.raises(PartialOverlap):
Observation(self.sp, self.bandpass)
def test_efflam(self):
obs = Observation(self.sp, self.bandpass, force='extrap')
tst = obs.efflam()
# Answer from updated HRC throughput from Mar 2018 (Ryon et al.)
assert_allclose(tst, 5303.886864, rtol=1e-4)
def test_countrate(self):
obs = Observation(self.sp, self.bandpass, force='taper')
tst = obs.countrate()
# Answer from updated HRC throughput from Mar 2018 (Ryon et al.)
assert_allclose(tst, 833324.285116, rtol=1e-4)
@pytest.mark.remote_data
class TestETC_Imag2(object):
def setup_class(self):
# (earthshine.fits * 0.5) +
# rn(spec(Zodi.fits), band(V), 22.7, vegamag) +
# (el1215a.fits * 0.5) +
# (el1302a.fits * 0.5) +
# (el1356a.fits * 0.5) +
# (el2471a.fits * 0.5)
path = get_pkg_data_path(os.path.join('data', 'generic'),
package='pysynphot')
spz = FileSourceSpectrum(os.path.join(path, 'Zodi.fits')).renorm(
22.7, 'vegamag', ObsBandpass('V'))
self.sp = ((FileSourceSpectrum(os.path.join(path, 'earthshine.fits')) +
FileSourceSpectrum(os.path.join(path, 'el1215a.fits')) +
FileSourceSpectrum(os.path.join(path, 'el1302a.fits')) +
FileSourceSpectrum(os.path.join(path, 'el1356a.fits')) +
FileSourceSpectrum(os.path.join(path, 'el2471a.fits'))) *
0.5 + spz)
self.bp = ObsBandpass('acs,sbc,F140LP')
@pytest.mark.xfail(reason='Behavior changed, no longer raises')
def test_raises(self):
# Replaced answer for r618 (no tapering).
# The throughput files used in this case don't actually go
# all the way to zero.
with pytest.raises(PartialOverlap):
Observation(self.sp, self.bp)
def test_flux(self):
"""Moved from old ticket159.py"""
obs = Observation(self.sp, self.bp, force='taper')
assert 'PartialOverlap' in obs.warnings
class TestETC_Spec2a(TestETC_Imag2):
def setup_class(self):
self.sp = FileSourceSpectrum(os.path.join(
os.environ['PYSYN_CDBS'], 'calspec', 'grw_70d5824_stis_001.fits'))
self.bp = ObsBandpass('stis,fuvmama,g140l,s52x2')
self.refrate = 28935.7
def test_flux(self):
obs = Observation(self.sp, self.bp, force='taper')
obs.convert('counts')
assert_allclose(obs.binflux[500], 33.779645, rtol=1e-4)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,579 | spacetelescope/pysynphot | refs/heads/master | /commissioning/wfc3_ir_imaging_80_thermback.py | from pytools import testutil
import sys
import basecase
class thermbackCase1(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f140w"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0000"
self.setglobal(__file__)
self.runpy()
class thermbackCase3(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f098m"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0005"
self.setglobal(__file__)
self.runpy()
class thermbackCase4(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f105w"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0010"
self.setglobal(__file__)
self.runpy()
class thermbackCase5(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f110w"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0015"
self.setglobal(__file__)
self.runpy()
class thermbackCase6(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f125w"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0020"
self.setglobal(__file__)
self.runpy()
class thermbackCase7(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f126n"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0025"
self.setglobal(__file__)
self.runpy()
class thermbackCase8(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f127m"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0030"
self.setglobal(__file__)
self.runpy()
class thermbackCase9(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f128n"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0035"
self.setglobal(__file__)
self.runpy()
class thermbackCase10(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f130n"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0040"
self.setglobal(__file__)
self.runpy()
class thermbackCase11(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f132n"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0045"
self.setglobal(__file__)
self.runpy()
class thermbackCase12(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f139m"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0050"
self.setglobal(__file__)
self.runpy()
class thermbackCase13(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f153m"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0055"
self.setglobal(__file__)
self.runpy()
class thermbackCase14(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f160w"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0060"
self.setglobal(__file__)
self.runpy()
class thermbackCase15(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f164n"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0065"
self.setglobal(__file__)
self.runpy()
class thermbackCase16(basecase.thermbackCase):
def setUp(self):
self.obsmode="wfc3,ir,f167n"
self.spectrum="None"
self.subset=True
self.etcid="irim006.tab:0070"
self.setglobal(__file__)
self.runpy()
if __name__ == '__main__':
if 'debug' in sys.argv:
testutil.debug(__name__)
else:
testutil.testall(__name__,2)
#calcspec:0 - 0 dup =0
#thermback:16 - 1 dup =15
#calcphot:0 - 0 dup =0
#countrate:0 - 0 dup =0
#SpecSourcerateSpec:0 - 0 dup =0
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,580 | spacetelescope/pysynphot | refs/heads/master | /commissioning/doscalars.py | from __future__ import print_function
import kwfile_dict
import glob, os, sys
import numpy as N
from astropy.io import fits as pyfits
import pylab as P
import matplotlib
from pysynphot.compat import ASTROPY_LT_1_3
def getdata(dirpath,fieldname,instr,save=True):
#get the list of files
flist=glob.glob("%s/*.log"%dirpath)
#make the arrays
nfiles=len(flist)
if nfiles == 0:
raise ValueError('No files found')
val=N.zeros((nfiles,),dtype=N.float64)
obsmode=N.zeros((nfiles,),dtype=N.float64)
spectrum=N.zeros((nfiles,),dtype=N.float64)
#
# Make the dicts
olist=[]
odict={}
ocount=0
sdict={}
scount=0
namedict={}
i=0
#
# Start processing
for fname in flist:
d=kwfile_dict.read_kwfile(fname)
namedict[i]=fname
om=d['tda_obsmode']
olist.append(om)
if om not in odict:
odict[om]=ocount
ocount+=1
obsmode[i]=odict[om]
sp=d['tda_spectrum']
if sp not in sdict:
sdict[sp]=scount
scount+=1
spectrum[i]=sdict[sp]
try:
val[i]=float(d['tra_discrep'])
except KeyError:
#Cases with errors don't have results.
pass
i+=1
#Save our results as a FITS table
if save:
tmp=[len(x) for x in flist]
c1=pyfits.Column(name='logfile',format='%dA'%max(tmp),
array=N.array(flist))
tmp=[len(x) for x in olist]
c2=pyfits.Column(name='obsmode',format='%dA'%max(tmp),
array=N.array(olist))
c3=pyfits.Column(name='obscode',format='I',
array=obsmode)
c4=pyfits.Column(name='spcode',format='I',
array=spectrum)
c5=pyfits.Column(name='discrep',format='D',
array=val)
tbhdu=pyfits.BinTableHDU.from_columns(pyfits.ColDefs([c1,c2,c3,c4,c5]))
outname=os.path.join(os.path.abspath(os.path.dirname(dirpath)),
"%s_%s_table.fits"%(instr,fieldname))
if ASTROPY_LT_1_3:
tbhdu.writeto(outname, clobber=True)
else:
tbhdu.writeto(outname, overwrite=True)
#and return the values for immediate use
return namedict,odict,sdict,obsmode,spectrum,val
def reverse(d):
"""Return a reverse lookup dictionary for the input dictionary"""
r={}
for k in d:
r[d[k]]=k
return r
def plotdata(obsmode,spectrum,val,odict,sdict,
instr,fieldname,outdir,outname):
isetting=P.isinteractive()
P.ioff()
P.clf()
P.plot(obsmode,val,'.')
P.ylabel('(pysyn-syn)/syn')
P.xlabel('obsmode')
P.title("%s: %s"%(instr,fieldname))
P.savefig(os.path.join(outdir,outname+'_obsmode.ps'))
P.clf()
P.plot(spectrum,val,'.')
P.ylabel('(pysyn-syn)/syn')
P.xlabel('spectrum')
P.title("%s: %s"%(instr,fieldname))
P.savefig(os.path.join(outdir,outname+'_spectrum.ps'))
matplotlib.interactive(isetting)
def run(dirpath, fieldname, instr):
namedict,odict,sdict,obsmode,spectrum,val = getdata(dirpath,
fieldname,
instr)
outdir=os.path.abspath(os.path.dirname(dirpath))
outname="%s_%s"%(instr,fieldname)
plotdata(obsmode,spectrum,val,odict,sdict,
instr,fieldname,outdir,outname)
if __name__ == '__main__':
#dirpath, fieldname, instr=sys.argv[1:]
try:
run(*sys.argv[1:])
except TypeError as e:
print("sys.argv[1:] = ",sys.argv[1:])
raise e
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,581 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_ticket166.py | from __future__ import absolute_import, division, print_function
import numpy as np
import pytest
from numpy.testing import assert_allclose
from ..exceptions import DisjointError, PartialOverlap
from ..observation import Observation
from ..spectrum import ArraySourceSpectrum, ArraySpectralElement
class TestHandmade(object):
"""Handmade observation with well defined ranges."""
def setup_class(self):
w = np.arange(1000, 1100, 0.5)
self.sp = ArraySourceSpectrum(
wave=w, flux=(w - 1000), fluxunits='counts', name='slope1')
# Handmade box that has fewer points
self.bp = ArraySpectralElement(
wave=np.array([1000, 1009.95, 1010, 1030, 1030.05, 1100]),
throughput=np.array([0, 0, 1, 1, 0, 0]), name='HandBox')
self.obs = Observation(self.sp, self.bp, binset=np.arange(w[6], w[40]))
def test_allbin(self):
"""
Specifying the entire exact range should be identical to the
results without any such specification.
"""
ref = self.obs.countrate()
tst = self.obs.countrate(range=[self.obs.binwave[0],
self.obs.binwave[-1]])
assert_allclose(tst, ref)
@pytest.mark.parametrize(
'wrange', [[1013, 1016], [1012.8, 1016], [1013.2, 1016]])
def test_bin(self, wrange):
"""Ask for a bin with some slight offsets."""
tst = self.obs.countrate(range=wrange)
assert_allclose(tst, 116)
@pytest.mark.parametrize(
('wrange', 'ans'),
[([1016, 1026], '140'),
([1000, 1016], '172.75')])
def test_ovlphibin(self, wrange, ans):
"""Ask for something _partly_ outside the bin range."""
with pytest.raises(PartialOverlap) as e:
self.obs.countrate(range=wrange)
assert ans in str(e)
def test_disjointbin(self):
"""Ask for something outside the bin range."""
with pytest.raises(DisjointError):
self.obs.countrate(range=[1025, 1030])
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,582 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/reddening.py | """This module handles
:ref:`reddening laws and extinction <pysynphot-extinction>` calculations.
"""
from __future__ import absolute_import, division, print_function
from astropy.io import fits as pyfits
from .spectrum import ArraySpectralElement
from . import Cache
from . import extinction #temporary(?) backwards compatibility
from . import units
# https://github.com/spacetelescope/pysynphot/issues/44
class ExtinctionSpectralElement(ArraySpectralElement):
"""Like :class:`~pysynphot.spectrum.ArraySpectralElement` but
with special ``waveset`` handling.
"""
def GetWaveSet(self):
"""Extinction curve ``waveset`` should not be merged."""
return None
def _getWaveProp(self):
"""Return wavelength in user units."""
wave = units.Angstrom().Convert(self._wavetable, self.waveunits.name)
return wave
wave = property(_getWaveProp, doc="Wavelength property.")
def GetThroughput(self):
return self.__call__(self._wavetable)
throughput = property(GetThroughput, doc='Throughput property.')
class CustomRedLaw(object):
"""Class to handle reddening law.
Parameters
----------
wave : array_like
Wavelength values.
waveunits : str
Wavelength unit, as accepted by `~pysynphot.units.Units`.
By default, it is :math:`\\mu m^{-1}`.
Avscaled : array_like
Values of :math:`A(V)/E(B-V)`.
name : str
Short description of the reddening law.
litref : str
Literature reference of the reddening law.
Attributes
----------
wave, waveunits, name, litref
Same as inputs.
obscuration
Same as input ``Avscaled``.
"""
def __init__(self,
wave=None,
waveunits='InverseMicrons',
Avscaled=None,
name='Unknown Reddening Law',
litref=None):
self.wave=wave
self.waveunits=waveunits
self.obscuration=Avscaled
self.name=name
self.litref=litref
def reddening(self,extval):
"""Compute the reddening for the given extinction.
.. math::
A(V) = R(V) \\; \\times \\; E(B-V)
\\mathrm{THRU} = 10^{-0.4 \\; A(V)}
.. note::
``self.litref`` is passed into ``ans.citation``.
Parameters
----------
extval : float
Value of :math:`E(B-V)` in magnitudes.
Returns
-------
ans : `~pysynphot.spectrum.ArraySpectralElement`
Extinction curve to apply to a source spectrum.
"""
T = 10.0**(-0.4*extval*self.obscuration)
ans = ExtinctionSpectralElement(wave=self.wave,
waveunits=self.waveunits,
throughput=T,
name='%s(EBV=%g)'%(self.name, extval))
ans.citation = self.litref
return ans
class RedLaw(CustomRedLaw):
"""`CustomRedLaw` from a FITS file.
Table must be in EXT 1 and contains the following columns:
#. ``WAVELENGTH``
#. ``Av/E(B-V)``
Wavelength unit is extracted from ``TUNIT1`` keyword in EXT 1 header.
The primary header (EXT 0) must have ``SHORTNM`` and ``LITREF`` keywords.
Parameters
----------
filename : str
FITS table filename.
Attributes
----------
wave : array_like
Wavelength values from the ``WAVELENGTH`` column in EXT 1.
waveunits : str
Value of ``TUNIT1`` in EXT 1 header.
name : str
Value of ``SHORTNM`` in EXT 0 header.
litref : str
Value of ``LITREF`` in EXT 0 header.
obscuration
Values from the ``Av/E(B-V)`` column in EXT 1.
"""
def __init__(self,filename):
f=pyfits.open(filename)
d=f[1].data
CustomRedLaw.__init__(self,
wave=d.field('wavelength'),
waveunits=f[1].header['tunit1'],
Avscaled=d.field('Av/E(B-V)'),
litref=f[0].header['litref'],
name=f[0].header['shortnm'])
f.close()
def print_red_laws():
"""Print available extinction laws to screen.
Available extinction laws are extracted from ``pysynphot.locations.EXTDIR``.
The printed names may be used with :func:`Extinction`
to retrieve available reddening laws.
Examples
--------
>>> S.reddening.print_red_laws()
name reference
-------- --------------------------------------------------------------
None Cardelli, Clayton, & Mathis (1989, ApJ, 345, 245) R_V = 3.10.
gal3 Cardelli, Clayton, & Mathis (1989, ApJ, 345, 245) R_V = 3.10.
lmc30dor Gordon et al. (2003, ApJ, 594, 279) R_V = 2.76.
lmcavg Gordon et al. (2003, ApJ, 594, 279) R_V = 3.41.
mwavg Cardelli, Clayton, & Mathis (1989, ApJ, 345, 245) R_V = 3.10.
mwdense Cardelli, Clayton, & Mathis (1989, ApJ, 345, 245) R_V = 5.00.
mwrv21 Cardelli, Clayton, & Mathis (1989, ApJ, 345, 245) R_V = 2.1.
mwrv4 Cardelli, Clayton, & Mathis (1989, ApJ, 345, 245) R_V = 4.0.
smcbar Gordon et al. (2003, ApJ, 594, 279) R_V=2.74.
xgalsb Calzetti et al. (2000. ApJ, 533, 682)
"""
laws = {}
# start by converting the Cache.RedLaws file names to RedLaw objects
# if they aren't already
for k in Cache.RedLaws:
if isinstance(Cache.RedLaws[k],str):
Cache.RedLaws[k] = RedLaw(Cache.RedLaws[k])
laws[str(k)] = Cache.RedLaws[k].litref
# get the length of the longest name and litref
maxname = max([len(name) for name in laws.keys()])
maxref = max([len(ref) for ref in laws.values()])
s = '%-' + str(maxname) + 's %-' + str(maxref) + 's'
print(s % ('name','reference'))
print(s % ('-'*maxname,'-'*maxref))
for k in sorted(laws.keys()):
print(s % (k, laws[k]))
def Extinction(extval,name=None):
"""Generate extinction curve to be used with spectra.
By default, :meth:`~CustomRedLaw.reddening` is used to
generate the extinction curve. If a deprecated
reddening law is given, then
`~pysynphot.extinction.DeprecatedExtinction` is used
instead.
.. note::
Reddening laws are cached in ``pysynphot.Cache.RedLaws``
for better performance. Repeated calls to the same
reddening law here returns the cached result.
Parameters
----------
extval : float
Value of :math:`E(B-V)` in magnitudes.
name : str or `None`
Name of reddening law (see :func:`print_red_laws`).
If `None` (default), the average Milky Way extinction
(``'mwavg'``) will be used.
Returns
-------
ext : `~pysynphot.spectrum.ArraySpectralElement` or `~pysynphot.extinction.DeprecatedExtinction`
Extinction curve.
Raises
------
ValueError
Invalid reddening law.
Examples
--------
>>> ext = S.Extinction(0.3, 'mwavg')
"""
try:
ext=Cache.RedLaws[name].reddening(extval)
except AttributeError:
#The cache hasn't yet been filled.
Cache.RedLaws[name]=RedLaw(Cache.RedLaws[name])
ext=Cache.RedLaws[name].reddening(extval)
except KeyError:
#There's no reddening law by that name. See if we've been
#given a filename from which we can read one.
try:
Cache.RedLaws[name]=RedLaw(name)
ext=Cache.RedLaws[name].reddening(extval)
except IOError:
#If not, see if it's an old extinction law
try:
ext=extinction.DeprecatedExtinction(extval,name)
except KeyError:
raise ValueError('No extinction law has been defined for "%s", and no such file exists'%name)
return ext
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,583 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/locations.py | """This module handles locations of data files.
**Global Variables**
* ``pysynphot.locations.rootdir`` - Root directory for TRDS/CRDS
data files. By default, it is extracted from your ``PYSYN_CDBS``
environment variable.
* ``pysynphot.locations.specdir`` - Data directory for
data files distributed with this software.
* ``pysynphot.locations.CAT_TEMPLATE`` and
``pysynphot.locations.KUR_TEMPLATE`` - String templates used for
`~pysynphot.catalog.Icat` to select spectra from catalogs.
* ``pysynphot.locations.VegaFile`` - Vega spectrum to use for
``vegamag`` calculations.
* ``pysynphot.locations.EXTDIR`` - Directory containing extinction
curves.
* ``pysynphot.locations.RedLaws`` - Dictionary mapping reddening laws
to data files or cached instances (see `~pysynphot.Cache`).
* ``pysynphot.locations.wavecat`` - Data file for `~pysynphot.wavetable`.
* ``pysynphot.locations.CONVERTDICT`` - Dictionary mapping IRAF-style
directory shortcuts to actual paths.
"""
from __future__ import division, print_function
from six.moves.urllib import request
import fnmatch
import glob
import os
import re
import warnings
from astropy.io import fits as pyfits
from bs4 import BeautifulSoup
try:
rootdir = os.environ['PYSYN_CDBS']
except KeyError:
warnings.warn("PYSYN_CDBS is undefined; functionality will be SEVERELY "
"crippled.")
rootdir = ''
ftp_rootdir = 'https://ssb.stsci.edu/trds'
# Data directory is now installed locally
specdir = os.path.join(os.path.dirname(__file__), 'data')
if not os.path.isdir(specdir):
# We might be running out of the source; try looking up a level
pardir = os.path.join(os.path.dirname(__file__), os.pardir)
specdir = os.path.join(pardir, 'data')
setup_py = os.path.join(pardir, 'setup.py')
# Ensure that we're actually in the source tree
if not os.path.exists(specdir) or not os.path.exists(setup_py):
# It's possible when running ./setup.py nosetests that we're running
# out of the build/ directory so check for that case too (note we
# can't guarnatee the directory is named 'build')
pardir = os.path.join(pardir, os.pardir, os.pardir)
specdir = os.path.join(pardir, 'data')
setup_py = os.path.join(pardir, 'setup.py')
if not os.path.exists(specdir) or not os.path.exists(setup_py):
raise RuntimeError('pysynphot data directory missing!')
del pardir
del setup_py
specdir = os.path.abspath(specdir) + os.sep
# Map of filenames to their actual path
_data_map = None
# This dictionary maps IRAF-specific directory names for synphot
# directories into their Unix equivalents.
# BUG: supports only a single variable in a string
# ............basically this is a weak routine that should be made
# ............more robust
# BUG: this dictionary should be in a data file
CONVERTDICT = {'crrefer': rootdir,
'crcalobs': os.path.join(rootdir, 'calobs'),
'crcalspec': os.path.join(rootdir, 'calspec'),
'croldcalspec': os.path.join(rootdir, 'oldcalspec'),
'crcomp': os.path.join(rootdir, 'comp'),
'crfgs': os.path.join(rootdir, 'fgs'),
'crfields': os.path.join(rootdir, 'fields'),
'crmodewave': os.path.join(rootdir, 'modewave'),
'crcostarcomp': os.path.join(rootdir, 'comp', 'costar'),
'cracscomp': os.path.join(rootdir, 'comp', 'acs'),
'crfoccomp': os.path.join(rootdir, 'comp', 'foc'),
'crfoscomp': os.path.join(rootdir, 'comp', 'fos'),
'crfgscomp': os.path.join(rootdir, 'comp', 'fgs'),
'crhrscomp': os.path.join(rootdir, 'comp', 'hrs'),
'crhspcomp': os.path.join(rootdir, 'comp', 'hsp'),
'crotacomp': os.path.join(rootdir, 'comp', 'ota'),
'crnicmoscomp': os.path.join(rootdir, 'comp', 'nicmos'),
'crnonhstcomp': os.path.join(rootdir, 'comp', 'nonhst'),
'crstiscomp': os.path.join(rootdir, 'comp', 'stis'),
'crwfc3comp': os.path.join(rootdir, 'comp', 'wfc3'),
'crcoscomp': os.path.join(rootdir, 'comp', 'cos'),
'coscomp': os.path.join(rootdir, 'comp', 'cos'),
'crwave': os.path.join(rootdir, 'crwave'),
'crwfpccomp': os.path.join(rootdir, 'comp', 'wfpc'),
'crwfpc2comp': os.path.join(rootdir, 'comp', 'wfpc2'),
'crgrid': os.path.join(rootdir, 'grid'),
'crgridbz77': os.path.join(rootdir, 'grid', 'bz77'),
'crgridgs': os.path.join(rootdir, 'grid', 'gunnstryker'),
'crgridjac': os.path.join(rootdir, 'grid', 'jacobi'),
'crgridbpgs': os.path.join(rootdir, 'grid', 'bpgs'),
'crgridbk': os.path.join(rootdir, 'grid', 'bkmodels'),
'crgridk93': os.path.join(rootdir, 'grid', 'k93models'),
'crgridagn': os.path.join(rootdir, 'grid', 'agn'),
'crgridgalactic': os.path.join(rootdir, 'grid', 'galactic'),
'crgridkc96': os.path.join(rootdir, 'grid', 'kc96'),
'mtab': os.path.join(rootdir, 'mtab'),
'synphot': os.path.dirname(__file__) + os.path.sep,
# PATH for JWST instrument files
'crjwstotecomp': os.path.join(rootdir, 'comp', 'jwstote'),
# PATH for JWST MIRI instrument files
'crmiricomp': os.path.join(rootdir, 'comp', 'miri'),
# PATH for JWST NIRCam instrument files
'crnircamcomp': os.path.join(rootdir, 'comp', 'nircam'),
# PATH for JWST NIRSpec instrument files
'crnirspeccomp': os.path.join(rootdir, 'comp', 'nirspec'),
# PATH for JWST NIRISS instrument files
'crnirisscomp': os.path.join(rootdir, 'comp', 'niriss'),
}
def irafconvert(iraffilename):
"""Convert the IRAF file name to its Unix equivalent.
Input can be in ``directory$file`` or ``$directory/file`` format.
If ``'$'`` is not found in the input string, it is returned as-is.
Parameters
----------
iraffilename : str
Filename in IRAF format.
Returns
-------
unixfilename : str
Filename in Unix format.
Raises
------
AttributeError
Input is not a string.
"""
convertdict = CONVERTDICT
# remove duplicate separators and extraneous relative paths
if not iraffilename.lower().startswith(('http', 'ftp')):
iraffilename = os.path.normpath(iraffilename)
# BUG: supports environment variables only as the leading element in the
# filename
if iraffilename.startswith('$'):
# Then this is an environment variable.
# Use a regex to pull off the front piece.
pat = re.compile(r'\$(\w*)')
match = re.match(pat, iraffilename)
dirname = match.group(1)
unixdir = os.environ[dirname]
basename = iraffilename[match.end() + 1:] # 1 to omit leading slash
unixfilename = os.path.join(unixdir, basename)
return unixfilename
elif '$' in iraffilename:
# Then it's an iraf-style variable
irafdir, basename = iraffilename.split('$')
if irafdir == 'synphot':
return get_data_filename(os.path.basename(basename))
unixdir = convertdict[irafdir]
unixfilename = os.path.join(unixdir, basename)
return unixfilename
else:
# If no $ sign found, just return the filename unchanged
return iraffilename
def get_data_filename(filename):
"""Map filename to its actual path.
Parameters
----------
filename : str
Filename to search.
Returns
-------
path : str
Full path to the file in data directory.
"""
global _data_map
if _data_map is None:
_data_map = {}
for root, dirs, files in os.walk(specdir):
for fname in files:
_data_map[fname] = os.path.join(root, fname)
if filename not in _data_map:
raise KeyError(filename + ' not found in ' + specdir)
return _data_map[filename]
# Eliminate use of temporary directory; use python tmpfile utilities instead
CAT_TEMPLATE = os.path.join(rootdir, 'grid', '*', 'catalog.fits')
KUR_TEMPLATE = os.path.join(rootdir, 'grid', '*')
# Vega
VegaFile = get_data_filename('alpha_lyr_stis_010.fits')
# RedCat moved extinction files to $PYSYN_CDBS/extinction .
# The old location $PYSYN_CDBS/grid/extinction is no longer used.
EXTDIR = 'extinction'
# Define wavecat file explicitly
wavecat = get_data_filename('wavecat.dat')
# Copied over from stsynphot
def get_latest_file(template, raise_error=False, err_msg=''):
"""Find the filename that appears last in sorted order
based on given template.
Parameters
----------
template : str
Search template in the form of ``path/pattern``
where pattern is acceptable by :py:mod:`fnmatch`.
raise_error : bool, optional
Raise an error when no files found.
Otherwise, will issue warning only.
err_msg : str
Alternate message for when no files found.
If not given, generic message is used.
Returns
-------
filename : str
Latest filename.
Raises
------
IOError
No files found.
"""
path, pattern = os.path.split(irafconvert(template))
path_lowercase = path.lower()
# Remote HTTP directory
if path_lowercase.startswith('http'):
try:
response = request.urlopen(path) # PY2 has no context manager
soup = BeautifulSoup(response, 'html.parser')
allfiles = list(set([x.text for x in soup.find_all("a")])) # Rid symlink
except Exception:
allfiles = []
# Remote FTP directory
elif path_lowercase.startswith('ftp:'):
try:
response = request.urlopen(path).read().decode('utf-8').splitlines() # noqa
except Exception:
allfiles = []
else:
# Rid symlink
allfiles = list(set([x.split()[-1] for x in response]))
# Local directory
elif os.path.isdir(path):
allfiles = os.listdir(path)
# Bogus directory
else:
allfiles = []
matched_files = sorted(fnmatch.filter(allfiles, pattern))
# Last file in sorted listing
if matched_files:
filename = os.path.join(path, matched_files[-1])
# No files found
else:
if not err_msg:
err_msg = 'No files found for {0}'.format(template)
if raise_error:
raise IOError(err_msg)
else:
warnings.warn(err_msg)
filename = ''
return filename
def _refTable(template):
return get_latest_file(
os.path.join(os.environ.get('PYSYN_CDBS', ftp_rootdir), template),
raise_error=True)
RedLaws = {}
def _get_RedLaws():
global RedLaws
extdir = os.path.join(rootdir, EXTDIR)
extdir_lowercase = extdir.lower()
# get all the fits files in EXTDIR
globstr = os.path.join(extdir, '*.fits')
if extdir_lowercase.startswith('http'):
response = request.urlopen(extdir) # PY2 has no context manager
soup = BeautifulSoup(response, 'html.parser')
files = list(set([x.text for x in soup.find_all("a")
if x.text.endswith('.fits')])) # Rid symlink
files = [os.path.join(extdir, f) for f in files]
elif extdir_lowercase.startswith('ftp:'):
response = request.urlopen(extdir).read().decode('utf-8').splitlines()
files = list(set([x.split()[-1] for x in response
if x.endswith('.fits')])) # Rid symlink
files = [os.path.join(extdir, f) for f in files]
else:
files = glob.glob(globstr)
if not files:
warnings.warn('Extinction files not found in %s' % (extdir, ))
return
# replace ###.fits at the end of file names with *.fits
# and get a unique set
patterns = set(f[:-8] + '*.fits' for f in files)
# use _refTable to get the most recent version of each extinction file
# and add that to the RedLaws dict
for pattern in patterns:
lawf = sorted(fnmatch.filter(files, pattern))[-1]
key = pyfits.getval(lawf, 'shortnm')
RedLaws[key.lower()] = lawf
# load the extintion law file names
_get_RedLaws()
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,584 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_ticket113.py | from __future__ import absolute_import, division, print_function
import pytest
from ..spparser import scan
@pytest.mark.parametrize('pstr', ['/a/b/c/foo.fits', 'C:/a/b/c/foo.fits'])
def test_path(pstr):
tokens = [pstr]
x = scan(pstr)
assert x[0].attr == tokens[0]
assert len(x) == len(tokens)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,585 | spacetelescope/pysynphot | refs/heads/master | /setup.py | #!/usr/bin/env python
from glob import glob
from numpy import get_include as np_include
from setuptools import setup, Extension
setup(
name='pysynphot',
use_scm_version={'write_to': 'pysynphot/version.py'},
author=('Vicki Laidler, Pey Lian Lim, Matt Davis, Robert Jedrzejewski, '
'Ivo Busko'),
author_email='help@stsci.edu',
description='Python Synthetic Photometry Utilities',
url='https://github.com/spacetelescope/pysynphot',
license='BSD',
classifiers=[
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering :: Astronomy',
'Topic :: Software Development :: Libraries :: Python Modules',
],
setup_requires=['setuptools_scm'],
python_requires='>=3.6',
install_requires=[
'astropy',
'numpy',
'beautifulsoup4',
'six'
],
tests_require=['pytest', 'pytest-remotedata'],
packages=['pysynphot',
'pysynphot.test'],
package_dir={'pysynphot': 'pysynphot'},
package_data={'pysynphot': ['data/generic/*', 'data/wavecat/*'],
'pysynphot.test': ['data/*.*', 'data/cdbs/extinction/*',
'data/cdbs/jref/*', 'data/cdbs/mtab/*']},
ext_modules=[
Extension('pysynphot.pysynphot_utils',
glob('pysynphot/src/*.c'),
include_dirs=[np_include()],
optional=True)
],
zip_safe=False
)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,586 | spacetelescope/pysynphot | refs/heads/master | /commissioning/extrap/remove_unpinned.py | """ Use this script to remove the pinned versions from the allpinned
directory created by extrap.py."""
from __future__ import print_function
from extrap import fincre
import os, sys
def run(flist,dirname):
f=open(flist)
for fname in f:
#increment the version number
newname=fincre(fname.strip())
#delete the file
try:
os.unlink(os.path.join(dirname,newname))
except (OSError,IOError) as e:
print("Error removing %s"%newname)
print("...%s"%str(e))
f.close()
if __name__ == '__main__':
print(' '.join(sys.argv))
run(*sys.argv[1:])
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,587 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/spectrum.py | """This module contains the basis for all spectra classes,
including source spectra and bandpasses.
It also pre-loads the built-in :ref:`pysynphot-vega-spec` spectrum to
``pysynphot.spectrum.Vega``.
"""
from __future__ import absolute_import, division, print_function
import re
import os
import math
import warnings
from astropy.io import fits as pyfits
from astropy.utils.data import get_file_contents
import numpy as N
from . import refs
from . import units
from . import locations
from . import planck
import pysynphot.exceptions as exceptions # custom pysyn exceptions
try:
from pysynphot import __version__
except ImportError:
__version__ = 'unk'
try:
from pysynphot import __svn_revision__
except ImportError:
__svn_revision__ = 'unk'
# Renormalization constants from synphot:
PI = 3.14159265 # Mysterious math constant
RSUN = 6.9599E10 # Radius of sun
PC = 3.085678E18 # Parsec
RADIAN = RSUN / PC / 1000.
RENORM = PI * RADIAN * RADIAN # Normalize to 1 solar radius @ 1 kpc
# MergeWaveSets "too close together" constant
MERGETHRESH = 1.e-12
# Single-precision epsilon value, taken from the synphot FAQ.
# This is the minimum separation in wavelength value necessary for
# synphot to read the entries as distinct single-precision numbers.
syn_epsilon = 0.00032
def MergeWaveSets(waveset1, waveset2):
"""Return the union of the two wavelength sets.
The union is computed using `numpy.union1d`, unless one or
both of them is `None`.
The merged result may sometimes contain numbers which are nearly
equal but differ at levels as small as 1E-14. Having values this
close together can cause problems due to effectively duplicate
wavelength values. Therefore, wavelength values having differences
smaller than or equal to ``pysynphot.spectrum.MERGETHRESH``
(defaults to 1E-12) are considered as the same.
Parameters
----------
waveset1, waveset2 : array_like or `None`
Wavelength sets to combine.
Returns
-------
MergedWaveSet : array_like or `None`
Merged wavelength set. It is `None` if both inputs are such.
"""
if waveset1 is None and waveset2 is not None:
MergedWaveSet = waveset2
elif waveset2 is None and waveset1 is not None:
MergedWaveSet = waveset1
elif waveset1 is None and waveset2 is None:
MergedWaveSet = None
else:
MergedWaveSet = N.union1d(waveset1, waveset2)
# The merged wave sets may sometimes contain numbers which are nearly
# equal but differ at levels as small as 1e-14. Having values this
# close together can cause problems down the line so here we test
# whether any such small differences are present, with a small
# difference defined as less than MERGETHRESH.
#
# If small differences are present we make a copy of the union'ed array
# with the lower of the close together pairs removed.
delta = MergedWaveSet[1:] - MergedWaveSet[:-1]
if not (delta > MERGETHRESH).all():
newlen = len(delta[delta > MERGETHRESH]) + 1
newmerged = N.zeros(newlen, dtype=MergedWaveSet.dtype)
newmerged[:-1] = MergedWaveSet[:-1][delta > MERGETHRESH]
newmerged[-1] = MergedWaveSet[-1]
MergedWaveSet = newmerged
return MergedWaveSet
def trimSpectrum(sp, minw, maxw):
"""Create a new spectrum with trimmed upper and lower ranges.
Parameters
----------
sp : `SourceSpectrum`
Spectrum to trim.
minw, maxw : number
Lower and upper limits (inclusive) for the wavelength set
in the trimmed spectrum.
Returns
-------
result : `TabularSourceSpectrum`
Trimmed spectrum.
"""
wave = sp.GetWaveSet()
flux = sp(wave)
new_wave = N.compress(wave >= minw, wave)
new_flux = N.compress(wave >= minw, flux)
new_wave = N.compress(new_wave <= maxw, new_wave)
new_flux = N.compress(new_wave <= maxw, new_flux)
result = TabularSourceSpectrum()
result._wavetable = new_wave
result._fluxtable = new_flux
result.waveunits = units.Units(sp.waveunits.name)
result.fluxunits = units.Units(sp.fluxunits.name)
return result
class Integrator(object):
"""Integrator engine, which is the base class for
`SourceSpectrum` and `SpectralElement`.
"""
def trapezoidIntegration(self, x, y):
"""Perform trapezoid integration.
Parameters
----------
x : array_like
Wavelength set.
y : array_like
Integrand. For example, throughput or throughput
multiplied by wavelength.
Returns
-------
sum : float
Integrated sum.
"""
npoints = x.size
if npoints > 0:
indices = N.arange(npoints)[:-1]
deltas = x[indices+1] - x[indices]
integrand = 0.5*(y[indices+1] + y[indices])*deltas
sum = integrand.sum()
if x[-1] < x[0]:
sum *= -1.0
return sum
else:
return 0.0
def _columnsFromASCII(self, filename):
"""Following synphot/TABLES, ASCII files may contain blank lines,
comment lines (beginning with '#'), or terminal comments. This routine
may be called by both Spectrum and SpectralElement objects to extract
the first two columns from a file."""
wlist = []
flist = []
lcount = 0
if filename.lower().startswith(('http://', 'ftp://')):
lines = get_file_contents(filename)
else:
with open(filename) as fs:
lines = fs.readlines()
for line in lines:
lcount += 1
cline = line.strip()
if ((len(cline) > 0) and (not cline.startswith('#'))):
try:
cols = cline.split()
if len(cols) >= 2:
wlist.append(float(cols[0]))
flist.append(float(cols[1]))
except Exception as e:
raise exceptions.BadRow("Error reading %s: %s" % (
filename, str(e)), rows=lcount)
return wlist, flist
def validate_wavetable(self):
"""Enforce monotonic, ascending wavelength array with no zero or
negative values.
Raises
------
pysynphot.exceptions.DuplicateWavelength
Wavelength array contains duplicate entries.
pysynphot.exceptions.UnsortedWavelength
Wavelength array is not monotonic ascending or descending.
pysynphot.exceptions.ZeroWavelength
Wavelength array has zero or negative value(s).
"""
# First check for invalid values
wave = self._wavetable
if N.any(wave <= 0):
wrong = N.where(wave <= 0)[0]
raise exceptions.ZeroWavelength(
'Negative or Zero wavelength occurs in wavelength array',
rows=wrong)
# Now check for monotonicity & enforce ascending
sorted = N.sort(wave)
if not N.alltrue(sorted == wave):
if N.alltrue(sorted[::-1] == wave):
# monotonic descending is allowed
pass
else:
wrong = N.where(sorted != wave)[0]
raise exceptions.UnsortedWavelength(
'Wavelength array is not monotonic', rows=wrong)
# Check for duplicate values
dw = sorted[1:] - sorted[:-1]
if N.any(dw == 0):
wrong = N.where(dw == 0)[0]
raise exceptions.DuplicateWavelength(
"Wavelength array contains duplicate entries", rows=wrong)
def validate_fluxtable(self):
"""Check for non-negative fluxes.
If found, the negative flux values are set to zero, and
a warning is printed to screen. This check is not done
if flux unit is a magnitude because negative magnitude
values are legal.
"""
# neg. magnitudes are legal
if ((not self.fluxunits.isMag) and (self._fluxtable.min() < 0)):
idx = N.where(self._fluxtable < 0)
self._fluxtable[idx] = 0.0
print("Warning, %d of %d bins contained negative fluxes; they "
"have been set to zero." % (
len(idx[0]), len(self._fluxtable)))
class SourceSpectrum(Integrator):
"""This is the base class for all
:ref:`source spectra <pysynphot-spectrum>`.
"""
def __add__(self, other):
"""Source Spectra can be added. Delegate the work to the
CompositeSourceSpectrum class.
"""
if not isinstance(other, SourceSpectrum):
raise TypeError("Can only add two SourceSpectrum objects")
return CompositeSourceSpectrum(self, other, 'add')
def __sub__(self, other):
"""Source Spectra can be subtracted, which is just another way
of adding.
"""
return self.__add__(-1.0*other)
def __mul__(self, other):
"""Source Spectra can be multiplied, by constants or by
SpectralElement objects.
"""
# Multiplying by numeric constants is allowed
if isinstance(other, (int, float)):
other = UniformTransmission(other)
# so is by SpectralElements. Otherwise, raise an exception.
if not isinstance(other, SpectralElement):
raise TypeError("SourceSpectrum objects can only be multiplied "
"by SpectralElement objects or constants; %s "
"type detected" % type(other))
# Delegate the work of multiplying to CompositeSourceSpectrum
return CompositeSourceSpectrum(self, other, 'multiply')
def __rmul__(self, other):
return self.__mul__(other)
def addmag(self, magval):
"""Add a scalar magnitude to existing flux values.
.. math::
\\mathrm{flux}_{\\mathrm{new}} = 10^{-0.4 \\; \\mathrm{magval}} \\; \\mathrm{flux}
Parameters
----------
magval : number
Magnitude value.
Returns
-------
sp : `CompositeSourceSpectrum`
New source spectrum with adjusted flux values.
Raises
------
TypeError
Magnitude value is not a scalar number.
"""
if N.isscalar(magval):
factor = 10**(-0.4*magval)
return self*factor
else:
raise TypeError(".addmag() only takes a constant scalar argument")
def getArrays(self):
"""Return wavelength and flux arrays in user units.
Returns
-------
wave : array_like
Wavelength array in ``self.waveunits``.
flux : array_like
Flux array in ``self.fluxunits``.
When necessary, ``self.primary_area`` is used for unit conversion.
"""
if hasattr(self, 'primary_area'):
area = self.primary_area
else:
area = None
wave = self.GetWaveSet()
flux = self(wave)
flux = units.Photlam().Convert(
wave, flux, self.fluxunits.name, area=area)
wave = units.Angstrom().Convert(wave, self.waveunits.name)
return wave, flux
# Define properties for consistent UI
def _getWaveProp(self):
wave, flux = self.getArrays()
return wave
def _getFluxProp(self):
wave, flux = self.getArrays()
return flux
wave = property(_getWaveProp, doc="Wavelength property.")
flux = property(_getFluxProp, doc="Flux property.")
def validate_units(self):
"""Ensure that wavelenth and flux units belong to the
correct classes.
Raises
------
TypeError
Wavelength unit is not `~pysynphot.units.WaveUnits` or
flux unit is not `~pysynphot.units.FluxUnits`.
"""
if (not isinstance(self.waveunits, units.WaveUnits)):
raise TypeError("%s is not a valid WaveUnit" % self.waveunits)
if (not isinstance(self.fluxunits, units.FluxUnits)):
raise TypeError("%s is not a valid FluxUnit" % self.fluxunits)
def writefits(self, filename, clobber=True, trimzero=True,
binned=False, precision=None, hkeys=None):
"""Write the spectrum to a FITS table.
Primary header in EXT 0. ``FILENAME``, ``ORIGIN``, and any
extra keyword(s) from ``hkeys`` will also be added.
Table header and data are in EXT 1. The table has 2 columns,
i.e., ``WAVELENGTH`` and ``FLUX``. Data are stored in user units.
Its header also will have these additional keywords:
* ``EXPR`` - Description of the spectrum.
* ``TDISP1`` and ``TDISP2`` - Columns display format,
always "G15.7".
* ``GRFTABLE`` and ``CMPTABLE`` - Graph and component
table names to use with associated observation mode.
These are only added if applicable.
If data is already double-precision but user explicitly
set output precision to single, ``pysynphot.spectrum.syn_epsilon``
defines the allowed minimum wavelength separation.
This limit (:math:`3.2 \\times 10^{-4}`) was taken from
IRAF STSDAS SYNPHOT FAQ.
Values equal or smaller than this limit are considered as the
same, and duplicates are ignored, resulting in data loss.
In the way that this comparison is coded, when such precision clash
happens, even when no duplicates are detected, the last row is
always omitted (also data loss). Therefore, it is *not* recommended
for user to force single-precision when the data is in
double-precision.
Parameters
----------
filename : str
Output filename.
clobber : bool
Overwrite existing file. Default is `True`.
trimzero : bool
Trim off duplicate rows with flux values of zero from both ends
of the spectrum. This keeps one row of zero-flux at each end,
if it exists; However, it does not add a zero-flux row if it
does not. Default is `True`.
binned : bool
Write ``self.binwave`` and ``self.binflux`` (binned) dataset,
instead of ``self.wave`` and ``self.flux`` (native). Using
this option when object does not have binned data will cause
an exception to be raised. Default is `False`.
precision : {'s', 'd', `None`}
Write data out in single (``'s'``) or double (``'d'``)
precision. Default is `None`, which will enforce native
precision from ``self.flux``.
hkeys : dict
Additional keyword(s) to be added to primary FITS header,
in the format of ``{keyword:(value,comment)}``.
"""
pcodes={'d':'D', 's':'E'}
if precision is None:
precision = self.flux.dtype.char
_precision = precision.lower()[0]
pcodes = {'d':'D','s':'E','f':'E'}
if clobber:
try:
os.remove(filename)
except OSError:
pass
if binned:
wave = self.binwave
flux = self.binflux
else:
wave = self.wave
flux = self.flux
# Add a check for single/double precision clash, so
# that if written out in single precision, the wavelength table
# will still be sorted with no duplicates
# The value of epsilon is taken from the Synphot FAQ.
if wave.dtype == N.float64 and _precision == 's':
idx = N.where(abs(wave[1:]-wave[:-1]) > syn_epsilon)
else:
idx = N.where(wave) #=> idx=[:]
wave = wave[idx]
flux = flux[idx]
first, last = 0, len(flux)
if trimzero:
# Keep one zero at each end
nz = flux.nonzero()[0]
try:
first = max(nz[0] - 1, first)
last = min(nz[-1] + 2, last)
except IndexError:
pass
# Construct the columns and HDUlist
cw = pyfits.Column(name='WAVELENGTH',
array=wave[first:last],
unit=self.waveunits.name,
format=pcodes[_precision])
cf = pyfits.Column(name='FLUX',
array=flux[first:last],
unit=self.fluxunits.name,
format=pcodes[_precision])
# Make the primary header
hdu = pyfits.PrimaryHDU()
hdulist = pyfits.HDUList([hdu])
# User-provided keys are written to the primary header
# so are filename and origin
bkeys = dict(filename=(os.path.basename(filename), 'name of file'),
origin=('pysynphot', 'Version (%s, %s)' %
(__version__, __svn_revision__)))
# User-values if present may override default values
if hkeys is not None:
bkeys.update(hkeys)
# Now update the primary header
for key, val in bkeys.items():
hdu.header[key] = val
# Make the extension HDU
cols = pyfits.ColDefs([cw, cf])
hdu = pyfits.BinTableHDU.from_columns(cols)
# There are some standard keywords that should be added
# to the extension header.
bkeys = dict(expr=(str(self), 'pysyn expression'),
tdisp1=('G15.7',),
tdisp2=('G15.7',))
try:
bkeys['grftable'] = (self.bandpass.obsmode.gtname,)
bkeys['cmptable'] = (self.bandpass.obsmode.ctname,)
except AttributeError:
pass # Not all spectra have these
for key, val in bkeys.items():
hdu.header[key] = val
# Add the header to the list, and write the file
hdulist.append(hdu)
hdulist.writeto(filename)
def integrate(self, fluxunits='photlam'):
"""Integrate the flux in given unit.
Integration is done using :meth:`~Integrator.trapezoidIntegration`
with ``x=wave`` and ``y=flux``, where flux has been
convert to given unit first.
.. math::
\\mathrm{result} = \\int F_{\\lambda} d\\lambda
Parameters
----------
fluxunits : str
Flux unit to integrate in.
Returns
-------
result : float
Integrated sum. Its unit should take account of the
integration over wavelength. For example, if
``fluxunits='photlam'`` is given, then its unit
is ``photon/s/cm^2``.
"""
# Extract the flux in the desired units
u = self.fluxunits
self.convert(fluxunits)
wave, flux = self.getArrays()
self.convert(u)
# then do the integration
return self.trapezoidIntegration(wave, flux)
def sample(self, wave, interp=True):
"""Sample the spectrum at given wavelength(s).
This method has two behaviors:
* When ``interp=True``, wavelength(s) must be provided
as a Numpy array. Interpolation is done in internal units
(Angstrom and ``photlam``).
* When ``interp=False``, wavelength must be a scalar number.
The flux that corresponds to the closest matching wavelength
value is returned. This option should only be used for sampling
binned data in `~pysynphot.observation.Observation`.
Parameters
----------
wave : number or array_like
Wavelength(s) to sample, given in user unit.
interp : bool
Allow flux interpolation. Default is `True`.
Returns
-------
ans : number or array_like
Sampled flux in user unit.
Raises
------
NotImplementedError
Non-scalar wavelength set provided when interpolation
is not allowed.
"""
if interp:
# convert input wavelengths to Angstroms since the __call__ method
# will be expecting that
angwave = self.waveunits.ToAngstrom(wave)
# First use the __call__ to get it in photlam
flux = self(angwave)
if hasattr(self, 'primary_area'):
area = self.primary_area
else:
area = None
# Then convert to the desired units
ans = units.Photlam().Convert(angwave, flux,
self.fluxunits.name, area=area)
else:
# Get the arrays in the proper units
wave_array, flux_array = self.getArrays()
if N.isscalar(wave):
# Find the correct index
diff = abs(wave-wave_array)
idx = diff.argmin()
ans = flux_array[idx]
else:
raise NotImplementedError(
"Interp=False not yet supported for non-scalars")
return ans
def convert(self, targetunits):
"""Set new user unit, for either wavelength or flux.
This effectively converts the spectrum wavelength or flux
to given unit. Note that actual data are always kept in
internal units (Angstrom and ``photlam``), and only converted
to user units by :meth:`getArrays` during actual computation.
User units are stored in ``self.waveunits`` and ``self.fluxunits``.
Parameters
----------
targetunits : str
New unit name, as accepted by `~pysynphot.units.Units`.
"""
nunits = units.Units(targetunits)
if nunits.isFlux:
self.fluxunits = nunits
else:
self.waveunits = nunits
def redshift(self, z):
"""Apply :ref:`redshift <pysynphot-redshift>` to the spectrum.
Redshifted spectrum is never analytic even if the input
spectrum is. Output units are always Angstrom and PHOTLAM
regardless of user units.
Parameters
----------
z : number
Redshift value.
Returns
-------
copy : `ArraySourceSpectrum`
Redshifted spectrum.
"""
# By default, apply only the doppler shift.
waveunits = self.waveunits
fluxunits = self.fluxunits
self.convert('angstrom')
self.convert('photlam')
newwave = self.wave.astype(N.float64) * (1.0 + z)
copy = ArraySourceSpectrum(wave=newwave,
flux=self.flux,
waveunits=self.waveunits,
fluxunits=self.fluxunits,
name="%s at z=%g" % (self.name, z))
self.convert(waveunits)
self.convert(fluxunits)
return copy
def setMagnitude(self, band, value):
"""Makes the magnitude of the source in the band equal to value.
band is a SpectralElement.
This method is marked for deletion once the .renorm method is
well tested.
Object returned is a CompositeSourceSpectrum.
.. warning:: DO NOT USED
"""
objectFlux = band.calcTotalFlux(self)
vegaFlux = band.calcVegaFlux()
magDiff = -2.5*math.log10(objectFlux/vegaFlux)
factor = 10**(-0.4*(value - magDiff))
return self * factor
# Calls a function in another module to alleviate circular import
# issues.
def renorm(self, RNval, RNUnits, band, force=False):
""":ref:`Renormalize <pysynphot-renorm>` the spectrum to the
specified value, unit, and bandpass.
This wraps :func:`~pysynphot.renorm.StdRenorm` for convenience.
Basically, the spectrum is multiplied by a numeric factor so that
the total integrated flux will be the given value in the given
unit in the given bandpass.
When ``force=False``, if spectrum is not fully defined within the
given bandpass, but the overlap is at least 99%, a warning is
printed to screen and ``self.warnings['PartialRenorm']`` is set
to `True`.
Parameters
----------
RNval : number
Flux value for renormalization.
RNUnits : str
Unit name, as accepted by `~pysynphot.units.Units`, for ``RNval``.
band : `SpectralElement`
Bandpass that ``RNval`` is based on.
force : bool
Force renormalization regardless of overlap status with given
bandpass. If `True`, overlap check is skipped. Default is `False`.
Returns
-------
newsp : `~pysynphot.spectrum.CompositeSourceSpectrum`
Renormalized spectrum.
Raises
------
ValueError
Integrated flux is zero, negative, NaN, or infinite.
pysynphot.exceptions.DisjointError
Spectrum and bandpass are disjoint.
pysynphot.exceptions.OverlapError
Spectrum and bandpass do not fully overlap.
"""
from .renorm import StdRenorm
return StdRenorm(self, band, RNval, RNUnits, force=force)
def effstim(self, fluxunits='photlam'):
"""Not implemented."""
print("?? %s" % fluxunits)
raise NotImplementedError(
"Ticket #140: calcphot.effstim functionality")
class CompositeSourceSpectrum(SourceSpectrum):
"""Class to handle :ref:`composite spectrum <pysynphot-composite-spectrum>`
involving source spectra.
Parameters
----------
source1, source2 : `SourceSpectrum` or `SpectralElement`
One or both of the inputs must be source spectrum.
operation : {'add', 'multiply'}
Math operation to perform.
Attributes
----------
component1, component2
Same as input ``source1`` and ``source2``.
operation
Same as input.
name : str
Short description of the spectrum.
warnings : dict
To store warnings, which are inherited from both input sources. If inputs have the same warning keyword, the one from ``source2`` is used.
isAnalytic : bool
Flag to indicate whether this is an analytic spectrum. This is only `True` if both inputs are analytic.
primary_area : number or `None`
:ref:`pysynphot-area` of the telescope. This is inherited from either of the inputs, if available (not `None`). If inputs have different values, an exception is raised.
waveunits, fluxunits : `~pysynphot.units.Units`
User units inherited from ``source1`` (if available) or ``source2`` (if not).
wave, flux : array_like
Wavelength set and associated flux in user units.
Raises
------
pysynphot.exceptions.IncompatibleSources
Input spectra have different telescope areas defined.
"""
def __init__(self, source1, source2, operation):
self.component1 = source1
self.component2 = source2
self.operation = operation
self.name = str(self)
# Propagate warnings
self.warnings = {}
self.warnings.update(source1.warnings)
self.warnings.update(source2.warnings)
# for now we keep these attributes here, in spite of the internal
# units model. There is code that still breaks down if these attributes
# are not here.
try:
self.waveunits = source1.waveunits
self.fluxunits = source1.fluxunits
except AttributeError:
self.waveunits = source2.waveunits
self.fluxunits = source2.fluxunits
self.isAnalytic = source1.isAnalytic and source2.isAnalytic
# check areas
if hasattr(source1, 'primary_area'):
source1_area = source1.primary_area
else:
source1_area = None
if hasattr(source2, 'primary_area'):
source2_area = source2.primary_area
else:
source2_area = None
if not source1_area and not source2_area:
self.primary_area = None
elif source1_area and not source2_area:
self.primary_area = source1_area
elif not source1_area and source2_area:
self.primary_area = source2_area
else:
if source1_area == source2_area:
self.primary_area = source1_area
else:
err = ('Components have different area attributes: '
'%s: %f, %s: %f')
err = err % (str(source1), source1_area,
str(source2), source2_area)
raise exceptions.IncompatibleSources(err)
def __str__(self):
opdict = {'add': '+', 'multiply': '*'}
return "%s %s %s" % (str(self.component1), opdict[self.operation],
str(self.component2))
def __call__(self, wavelength):
"""Add or multiply components, delegating the function calculation
to the individual objects.
"""
if self.operation == 'add':
return self.component1(wavelength) + self.component2(wavelength)
if self.operation == 'multiply':
return self.component1(wavelength) * self.component2(wavelength)
def __iter__(self):
"""Allow iteration over each component."""
complist = self.complist()
return complist.__iter__()
def complist(self):
"""Return a list of all components and sub-components.
This is for use with :py:meth:`~object.__iter__`.
"""
ans = []
for comp in (self.component1, self.component2):
try:
ans.extend(comp.complist())
except AttributeError:
ans.append(comp)
return ans
def GetWaveSet(self):
"""Obtain the wavelength set for the composite spectrum.
This is done by using :func:`MergeWaveSets` to form a union of
wavelength sets from its components.
Returns
-------
waveset : array_like
Composite wavelength set.
"""
waveset1 = self.component1.GetWaveSet()
waveset2 = self.component2.GetWaveSet()
return MergeWaveSets(waveset1, waveset2)
def tabulate(self):
"""Return a simplified version of the spectrum.
Composite spectrum can be overly complicated when it
has too many components and sub-components. This method
copies the following into a simple (tabulated) source spectrum:
* Name
* Wavelength array and unit
* Flux array and unit
Returns
-------
sp : `ArraySourceSpectrum`
Tabulated source spectrum.
"""
sp = ArraySourceSpectrum(wave=self.wave,
flux=self.flux,
waveunits=self.waveunits,
fluxunits=self.fluxunits,
name='%s (tabulated)' % self.name)
return sp
class TabularSourceSpectrum(SourceSpectrum):
"""Base class for `ArraySourceSpectrum` and `FileSourceSpectrum`.
Parameters
----------
filename : str or `None`
File with spectral data (can be ASCII or FITS). If not `None`,
data will be loaded from file at initialization.
fluxname : str or `None`
Column name containing flux data. This is only used if filename
is given and is of FITS format.
keepneg : bool
Keep negative flux values instead of setting them to zero with
a warning. Default is `False`.
Attributes
----------
filename, name
Same as input.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `False`.
waveunits, fluxunits : `~pysynphot.units.Units`
User units for wavelength and flux.
wave, flux : array_like
Wavelength set and associated flux in user units.
"""
def __init__(self, filename=None, fluxname=None, keepneg=False):
self.isAnalytic = False
self.warnings = {}
if filename:
self._readSpectrumFile(filename, fluxname)
self.filename = filename
self.validate_units()
self.validate_wavetable()
if not keepneg:
self.validate_fluxtable()
self.ToInternal()
self.name = self.filename
self.isAnalytic = False
else:
self._wavetable = None
self._fluxtable = None
self.waveunits = None
self.fluxunits = None
self.filename = None
self.name = self.filename
def _reverse_wave(self):
self._wavetable = self._wavetable[::-1]
def __str__(self):
return str(self.name)
def _readSpectrumFile(self, filename, fluxname):
if filename.endswith('.fits') or filename.endswith('.fit'):
self._readFITS(filename, fluxname)
else:
self._readASCII(filename)
def _readFITS(self, filename, fluxname):
fs = pyfits.open(filename)
# pyfits cannot close the file on .close() if there are still
# references to mmapped data
self._wavetable = fs[1].data.field('wavelength').copy()
if fluxname is None:
fluxname = 'flux'
self._fluxtable = fs[1].data.field(fluxname).copy()
self.waveunits = units.Units(fs[1].header['tunit1'].lower())
self.fluxunits = units.Units(fs[1].header['tunit2'].lower())
fs.close()
def _readASCII(self, filename):
"""ASCII files have no headers. Following synphot, this
routine will assume the first column is wavelength in Angstroms,
and the second column is flux in Flam.
"""
self.waveunits = units.Units('angstrom')
self.fluxunits = units.Units('flam')
wlist, flist = self._columnsFromASCII(filename)
self._wavetable = N.array(wlist, dtype=N.float64)
self._fluxtable = N.array(flist, dtype=N.float64)
def __call__(self, wavelengths):
"""This is where the flux array is actually calculated given a
wavelength array. Returns an array of flux values calculated at
the wavelength values input.
"""
if N.isscalar(wavelengths):
delta = 0.0001
ww = N.array([wavelengths - delta, wavelengths,
wavelengths + delta])
tmp = self.resample(ww)
return tmp._fluxtable[1]
else:
return self.resample(wavelengths)._fluxtable
def taper(self):
"""Taper the spectrum by adding zero flux to each end.
This is similar to :meth:`SpectralElement.taper`.
There is no check to see if the spectrum is already tapered.
Hence, calling this on a tapered spectrum will result in
multiple zero-flux entries at both ends.
The wavelengths to use for the new first and last points are
calculated by using the same ratio as for the two interior points
used at each end.
Returns
-------
OutSpec : `TabularSourceSpectrum`
Tapered spectrum.
"""
OutSpec = TabularSourceSpectrum()
wcopy = N.zeros(self._wavetable.size+2, dtype=N.float64)
fcopy = N.zeros(self._fluxtable.size+2, dtype=N.float64)
wcopy[1:-1] = self._wavetable
fcopy[1:-1] = self._fluxtable
fcopy[0] = 0.0
fcopy[-1] = 0.0
# The wavelengths to use for the first and last points are
# calculated by using the same ratio as for the 2 interior points
wcopy[0] = wcopy[1]*wcopy[1]/wcopy[2]
wcopy[-1] = wcopy[-2]*wcopy[-2]/wcopy[-3]
OutSpec._wavetable = wcopy
OutSpec._fluxtable = fcopy
OutSpec.waveunits = units.Units(str(self.waveunits))
OutSpec.fluxunits = units.Units(str(self.fluxunits))
return OutSpec
def resample(self, resampledWaveTab):
"""Resample the spectrum for the given wavelength set.
Given wavelength array must be monotonically increasing
or decreasing. Flux interpolation is done using :func:`numpy.interp`.
Parameters
----------
resampledWaveTab : array_like
Wavelength set for resampling.
Returns
-------
resampled : `ArraySourceSpectrum`
Resampled spectrum.
"""
# Check whether the input wavetab is in descending order
if resampledWaveTab[0] < resampledWaveTab[-1]:
newwave = resampledWaveTab
newasc = True
else:
newwave = resampledWaveTab[::-1]
newasc = False
# Use numpy interpolation function
if self._wavetable[0] < self._wavetable[-1]:
oldasc = True
ans = N.interp(newwave, self._wavetable, self._fluxtable)
else:
oldasc = False
rev = N.interp(newwave, self._wavetable[::-1],
self._fluxtable[::-1])
ans = rev[::-1]
# If the new and old waveset don't have the same parity,
# the answer has to be flipped again
if (newasc != oldasc):
ans = ans[::-1]
# Finally, make the new object
# NB: these manipulations were done using the internal
# tables in Angstrom and photlam, so those are the units
# that must be fed to the constructor.
resampled = ArraySourceSpectrum(wave=resampledWaveTab.copy(),
waveunits='angstroms',
flux=ans.copy(),
fluxunits='photlam',
keepneg=True)
# Use the convert method to set the units desired by the user.
resampled.convert(self.waveunits)
resampled.convert(self.fluxunits)
return resampled
def GetWaveSet(self):
"""Return the wavelength set for the spectrum.
Returns
-------
waveset : array_like
Wavelength set (a copy of the internal wavelength table).
"""
# For a TabularSource Spectrum, the WaveSet is just the _wavetable
# member. Return a copy so that there is no reference to the original
# object.
return self._wavetable.copy()
def ToInternal(self):
"""Convert to the internal representation of (angstroms, photlam).
This is for internal use only.
"""
self.validate_units()
savewunits = self.waveunits
savefunits = self.fluxunits
if hasattr(self, 'primary_area'):
area = self.primary_area
else:
area = None
angwave = self.waveunits.Convert(self.GetWaveSet(), 'angstrom')
phoflux = self.fluxunits.Convert(angwave, self._fluxtable, 'photlam',
area=area)
self._wavetable = angwave.copy()
self._fluxtable = phoflux.copy()
self.waveunits = savewunits
self.fluxunits = savefunits
class ArraySourceSpectrum(TabularSourceSpectrum):
"""Class to handle
:ref:`source spectrum from arrays <pysynphot-empirical-source>`.
Parameters
----------
wave, flux : array_like
Wavelength and flux arrays.
waveunits, fluxunits : str
Wavelength and flux units, as accepted by `~pysynphot.units.Units`.
Defaults are Angstrom and ``photlam``.
name : str
Description of the spectrum. Default is "UnnamedArraySpectrum".
keepneg : bool
Keep negative flux values instead of setting them to zero with
a warning. Default is `False`.
Attributes
----------
name
Same as input.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `False`.
waveunits, fluxunits : `~pysynphot.units.Units`
User units for wavelength and flux.
wave, flux : array_like
Wavelength set and associated flux in user units.
Raises
------
ValueError
Mismatched wavelength and flux arrays.
"""
def __init__(self, wave=None, flux=None,
waveunits='angstrom', fluxunits='photlam',
name='UnnamedArraySpectrum',
keepneg=False):
if len(wave) != len(flux):
raise ValueError("wave and flux arrays must be of equal length")
self._wavetable = wave
self._fluxtable = flux
self.waveunits = units.Units(waveunits)
self.fluxunits = units.Units(fluxunits)
self.name = name
self.isAnalytic = False
self.warnings = {}
# must do before validate_fluxtable because it tests against unit type
self.validate_units()
# must do before ToInternal in case of descending
self.validate_wavetable()
if not keepneg:
self.validate_fluxtable()
self.ToInternal()
class FileSourceSpectrum(TabularSourceSpectrum):
"""Class to handle
:ref:`source spectrum loaded from ASCII or FITS table <pysynphot-source-from-file>`.
Also see :ref:`pysynphot-io`.
Parameters
----------
filename : str
File with spectral data (can be ASCII or FITS).
fluxname : str or `None`
Column name containing flux data. This is only used if the given
file is in FITS format.
keepneg : bool
Keep negative flux values instead of setting them to zero with
a warning. Default is `False`.
Attributes
----------
name : str
Resolved filename; i.e., IRAF-style directory name is expanded to actual path name.
fheader : dict
For FITS file, this contains headers from both extensions 0 and 1. If the extensions have the same keyword, the one from the latter is used.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `False`.
waveunits, fluxunits : `~pysynphot.units.Units`
User units for wavelength and flux.
wave, flux : array_like
Wavelength set and associated flux in user units.
"""
def __init__(self, filename, fluxname=None, keepneg=False):
self.name = locations.irafconvert(filename)
self._readSpectrumFile(self.name, fluxname)
self.validate_units()
self.validate_wavetable()
if not keepneg:
self.validate_fluxtable()
self.ToInternal()
self.isAnalytic = False
self.warnings = {}
def _readSpectrumFile(self, filename, fluxname):
if filename.endswith('.fits') or filename.endswith('.fit'):
self._readFITS(filename, fluxname)
else:
self._readASCII(filename)
def _readFITS(self, filename, fluxname):
fs = pyfits.open(filename)
# pyfits cannot close the file on .close() if there are still
# references to mmapped data
self._wavetable = fs[1].data.field('wavelength').copy()
if fluxname is None:
fluxname = 'flux'
self._fluxtable = fs[1].data.field(fluxname).copy()
self.waveunits = units.Units(fs[1].header['tunit1'].lower())
self.fluxunits = units.Units(fs[1].header['tunit2'].lower())
# Retain the header information as a convenience for the user.
# If duplicate keywords exist, the value in the extension
# header will override that in the primary.
self.fheader = dict(fs[0].header)
self.fheader.update(dict(fs[1].header))
fs.close()
def _readASCII(self, filename):
"""ASCII files have no headers. Following synphot, this
routine will assume the first column is wavelength in Angstroms,
and the second column is flux in Flam."""
self.waveunits = units.Units('angstrom')
self.fluxunits = units.Units('flam')
wlist, flist = self._columnsFromASCII(filename)
self._wavetable = N.array(wlist, dtype=N.float64)
self._fluxtable = N.array(flist, dtype=N.float64)
# We don't support headers from ascii files
self.fheader = dict()
class AnalyticSpectrum(SourceSpectrum):
"""Base class for analytic source spectrum.
This includes `BlackBody`, `FlatSpectrum`, `GaussianSource`, and
`Powerlaw`.
Parameters
----------
waveunits, fluxunits : str
Wavelength and flux units, as accepted by `~pysynphot.units.Units`.
Defaults are Angstrom and ``photlam``.
Attributes
----------
warnings : dict
To store warnings.
isAnalytic : bool
This is always `True`.
waveunits, fluxunits : `~pysynphot.units.Units`
User units for wavelength and flux.
wave, flux : array_like
Wavelength set and associated flux in user units.
"""
def __init__(self, waveunits='angstrom', fluxunits='photlam'):
# All AnalyticSpectra must set wave & flux units; do it here
self.waveunits = units.Units(waveunits)
self.fluxunits = units.Units(fluxunits)
self.validate_units()
self.isAnalytic = True
self.warnings = {}
def GetWaveSet(self):
"""Return the wavelength set for the spectrum.
Returns
-------
waveset : array_like
Wavelength set (a copy of the default wavelength table).
"""
return refs._default_waveset.copy()
class GaussianSource(AnalyticSpectrum):
"""Class to handle a :ref:`Gaussian source <pysynphot-gaussian>`.
Parameters
----------
flux : float
Total flux under the Gaussian curve, in given flux unit.
center : float
Central wavelength of the Gaussian curve, in given wavelength unit.
fwhm : float
FWHM of the Gaussian curve, in given wavelength unit.
waveunits, fluxunits : str
Wavelength and flux units, as accepted by `~pysynphot.units.Units`.
Defaults are Angstrom and ``flam``.
Attributes
----------
total_flux
Same as input ``flux``.
center, fwhm
Same as inputs.
sigma, factor : float
These are :math:`\\sigma` and :math:`A` as defined in :ref:`pysynphot-gaussian`.
name : str
Description of the spectrum.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `True`.
waveunits, fluxunits : `~pysynphot.units.Units`
User units for wavelength and flux.
wave, flux : array_like
Wavelength set and associated flux in user units.
"""
def __init__(self, flux, center, fwhm, waveunits='angstrom',
fluxunits='flam'):
AnalyticSpectrum.__init__(self, waveunits, fluxunits)
self.center = center
self.fwhm = fwhm
self.total_flux = flux
self._input_flux_units = self.fluxunits
self._input_wave_units = self.waveunits
self.sigma = fwhm / math.sqrt(8.0 * math.log(2.0))
self.factor = flux / (math.sqrt(2.0 * math.pi) * self.sigma)
self.name = ('Gaussian: mu=%g %s,fwhm=%g %s, total flux=%g %s' %
(self.center, self._input_wave_units, self.fwhm,
self._input_wave_units, self.total_flux,
self._input_flux_units))
def __str__(self):
return self.name
def __call__(self, wavelength):
# wavelength comes in as Angstom but Gaussian properties are stored
# in user defined units
wave = units.Angstrom().Convert(
wavelength, self._input_wave_units.name)
# calculate flux
flux = (self.factor *
N.exp(-0.5 * ((wave - self.center) / self.sigma) ** 2))
if hasattr(self, 'primary_area'):
area = self.primary_area
else:
area = None
# convert flux to photlam before returning
return self._input_flux_units.ToPhotlam(wave, flux, area=area)
def GetWaveSet(self):
"""Return the wavelength set that optimally samples the Gaussian curve.
It has 101 values, as defined below:
.. math::
x_{\\mathrm{first,last}} = x_{0} \\; \\pm \\; 5 \\; \\sigma
\\delta x = 0.1 \\; \\sigma
Returns
-------
waveset : array_like
Wavelength set in internal unit.
"""
increment = 0.1*self.sigma
first = self.center - 50.0*increment
last = self.center + 50.0*increment
waveset = N.arange(first, last, increment)
return self._input_wave_units.Convert(waveset, 'angstrom')
class FlatSpectrum(AnalyticSpectrum):
"""Class to handle a :ref:`flat source spectrum <pysynphot-flat-spec>`.
Parameters
----------
fluxdensity : float
The constant flux value in the given flux unit.
waveunits, fluxunits : str
Wavelength and flux units, as accepted by `~pysynphot.units.Units`.
Defaults are Angstrom and ``photlam``.
Attributes
----------
name : str
Description of the spectrum.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `True`.
waveunits, fluxunits : `~pysynphot.units.Units`
User units for wavelength and flux.
wave, flux : array_like
Wavelength set and associated flux in user units.
"""
def __init__(self, fluxdensity, waveunits='angstrom', fluxunits='photlam'):
AnalyticSpectrum.__init__(self, waveunits, fluxunits)
self.wavelength = None
self._fluxdensity = fluxdensity
self._input_flux_units = self.fluxunits
self.name = "Flat spectrum of %g %s" % (self._fluxdensity,
self._input_flux_units)
def __str__(self):
return self.name
def __call__(self, wavelength):
if hasattr(wavelength, 'shape'):
flux = self._fluxdensity * N.ones(wavelength.shape,
dtype=N.float64)
else:
flux = self._fluxdensity
# __call__ is supposed to return photflam so we need to do the
# conversion here since it doesn't make sense to store the _fluxdensity
# attribute in photlam
wave = units.Angstrom().Convert(wavelength, self.waveunits.name)
if hasattr(self, 'primary_area'):
area = self.primary_area
else:
area = None
return self._input_flux_units.ToPhotlam(wave, flux, area=area)
def redshift(self, z):
"""Apply redshift to the flat spectrum.
Unlike :meth:`SourceSpectrum.redshift`, the redshifted spectrum
remains an analytic flat source.
Parameters
----------
z : number
Redshift value.
Returns
-------
ans : `FlatSpectrum`
"""
tmp = SourceSpectrum.redshift(self, z)
ans = FlatSpectrum(tmp.flux.max(), fluxunits=tmp.fluxunits)
return ans
# This change produces 5 errors and 17 failures in cos_etc_test.py
# def GetWaveSet(self):
# return N.array([_default_waveset[0],_default_waveset[-1]])
class Powerlaw(AnalyticSpectrum):
"""Class to handle a :ref:`power-law source spectrum <pysynphot-powerlaw>`.
Parameters
----------
refwave : number
Reference wavelength in the given unit.
index : number
Power-law index.
waveunits, fluxunits : str
Wavelength and flux units, as accepted by `~pysynphot.units.Units`.
Defaults are Angstrom and ``photlam``.
Attributes
----------
name : str
Description of the spectrum.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `True`.
waveunits, fluxunits : `~pysynphot.units.Units`
User units for wavelength and flux.
wave, flux : array_like
Wavelength set and associated flux in user units.
"""
def __init__(self, refwave, index, waveunits='angstrom',
fluxunits='photlam'):
AnalyticSpectrum.__init__(self, waveunits, fluxunits)
self.wavelength = None
self._input_flux_units = self.fluxunits
self._input_wave_units = self.waveunits
self._refwave = refwave
self._index = index
self.name = ("Power law: refwave %g %s, index %g" % (
self._refwave, self._input_wave_units, self._index))
def __str__(self):
return self.name
def __call__(self, wavelength):
# input wavelength is assumed to be angstroms
# and either a scalar or a numpy array
# need to first convert input wavelength to the units the user
# specified when creating this object
wave = units.Angstrom().Convert(
wavelength, self._input_wave_units.name)
flux = (wave / self._refwave) ** self._index
if hasattr(self, 'primary_area'):
area = self.primary_area
else:
area = None
# convert flux to photlam before returning
return self._input_flux_units.ToPhotlam(wave, flux, area=area)
class BlackBody(AnalyticSpectrum):
"""Class to handle a :ref:`blackbody source <pysynphot-planck-law>`.
Flux is evaluated with :func:`~pysynphot.planck.bbfunc` and
normalized with ``pysynphot.spectrum.RENORM``, which is:
.. math::
\\mathrm{RENORM} = \\pi \\; (\\frac{R_{\\odot}}{1 \\; \\mathrm{kpc}})^{2}
Parameters
----------
temperature : number
Blackbody temperature in Kelvin.
Attributes
----------
temperature
Same as input.
name : str
Description of the spectrum.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `True`.
waveunits, fluxunits : `~pysynphot.units.Units`
User units for wavelength and flux.
wave, flux : array_like
Wavelength set and associated flux in user units.
"""
def __init__(self, temperature):
waveunits = units.Units('angstrom')
fluxunits = units.Units('photlam')
AnalyticSpectrum.__init__(self, waveunits, fluxunits)
self.wavelength = None
self.temperature = temperature
self.name = 'BB(T=%d)' % self.temperature
def __str__(self):
return self.name
def __call__(self, wavelength):
return planck.bbfunc(wavelength, self.temperature) * RENORM
class SpectralElement(Integrator):
"""This is the base class for all :ref:`bandpasses <pysynphot-bandpass>`
and spectral elements (e.g., filter and detector response curves).
Attributes
----------
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
"""
def __init__(self):
self.binset = None
def validate_units(self):
"""Ensure that wavelenth unit belongs to the correct class.
There is no check for throughput because it is unitless.
Raises
------
TypeError
Wavelength unit is not `~pysynphot.units.WaveUnits`.
"""
if (not isinstance(self.waveunits, units.WaveUnits)):
raise TypeError("%s is not a valid WaveUnit" % self.waveunits)
def __mul__(self, other):
"""Permitted to multiply a SpectralElement by another
SpectralElement, or by a SourceSpectrum. In the former
case we return a CompositeSpectralElement, while in the
latter case a CompositeSourceSpectrum.
"""
if isinstance(other, SpectralElement):
return CompositeSpectralElement(self, other)
if isinstance(other, SourceSpectrum):
return CompositeSourceSpectrum(self, other, 'multiply')
# Multiplying by a constant is the same as multiplying by a
# UniformTransmission object
if isinstance(other, (int, float)):
return CompositeSpectralElement(self, UniformTransmission(other))
else:
print("SpectralElements can only be multiplied by other " +
"SpectralElements or SourceSpectrum objects")
def __rmul__(self, other):
return self.__mul__(other)
def integrate(self, wave=None):
"""Integrate the throughput over the specified wavelength set.
If no wavelength set is specified, the built-in one is used.
Integration is done using :meth:`~Integrator.trapezoidIntegration`
with ``x=wave`` and ``y=throughput``.
Also see :ref:`pysynphot-formula-equvw`.
Parameters
----------
wave : array_like or `None`
Wavelength set for integration.
Returns
-------
ans : float
Integrated sum.
"""
if wave is None:
wave = self.wave
ans = self.trapezoidIntegration(wave, self(wave))
return ans
# ..................................................................
# Methods to implement bandpar functionality go here
# ..................................................................
def avgwave(self):
"""Calculate :ref:`pysynphot-formula-avgwv`.
Returns
-------
ans : float
Average wavelength.
"""
mywaveunits = self.waveunits.name
self.convert('angstroms')
wave = self.wave
thru = self.throughput
self.convert(mywaveunits)
num = self.trapezoidIntegration(wave, thru*wave)
den = self.trapezoidIntegration(wave, thru)
if 0.0 in (num, den):
return 0.0
else:
return num/den
# This is the calculation performed when the ETC invokes calcphot.
# Does this need to be calculated on binned waveset, or may
# it be calculated on native waveset?
def pivot(self, binned=False):
"""Calculate :ref:`pysynphot-formula-pivwv`.
Parameters
----------
binned : bool
This is reserved for use by `~pysynphot.observation.Observation`.
If `True`, binned wavelength set is used. Default is `False`.
Returns
-------
ans : float
Pivot wavelength.
Raises
------
AttributeError
Binned wavelength set requested but not found.
"""
if binned:
try:
wave = self.binwave
except AttributeError:
raise AttributeError('Class ' + str(type(self)) +
' does not support binning.')
else:
wave = self.wave
countmulwave = self(wave)*wave
countdivwave = self(wave)/wave
num = self.trapezoidIntegration(wave, countmulwave)
den = self.trapezoidIntegration(wave, countdivwave)
if num == 0.0 or den == 0.0:
return 0.0
return math.sqrt(num/den)
def rmswidth(self, floor=0):
"""Calculate :ref:`pysynphot-formula-rmswidth`.
Parameters
----------
floor : float
Throughput values equal or below this threshold are not
included in the calculation. By default (0), all points
are included.
Returns
-------
ans : float
RMS band width.
"""
mywaveunits = self.waveunits.name
self.convert('angstroms')
wave = self.wave
thru = self.throughput
self.convert(mywaveunits)
if floor != 0:
idx = N.where(thru >= floor)
wave = wave[idx]
thru = thru[idx]
integrand = (wave-self.avgwave())**2 * thru
num = self.trapezoidIntegration(wave, integrand)
den = self.trapezoidIntegration(wave, thru)
if 0.0 in (num, den):
return 0.0
else:
ans = math.sqrt(num/den)
return ans
def photbw(self, floor=0):
"""Calculate :ref:`pysynphot-formula-bandw`.
.. note:: For backward-compatibility with IRAF STSDAS SYNPHOT only.
Parameters
----------
floor : float
Same as :meth:`rmswidth`.
Returns
-------
ans : float
RMS band width (deprecated).
"""
mywaveunits = self.waveunits.name
self.convert('angstroms')
wave = self.wave
thru = self.throughput
self.convert(mywaveunits)
# calculate the average wavelength
num = self.trapezoidIntegration(wave, thru * N.log(wave) / wave)
den = self.trapezoidIntegration(wave, thru / wave)
if num == 0 or den == 0:
return 0.0
avg_wave = N.exp(num/den)
if floor != 0:
idx = N.where(thru >= floor)
wave = wave[idx]
thru = thru[idx]
# calcualte the rms width
integrand = thru * N.log(wave / avg_wave)**2 / wave
num = self.trapezoidIntegration(wave, integrand)
if num == 0 or den == 0:
return 0.0
return avg_wave * N.sqrt(num/den)
def rectwidth(self):
"""Calculate :ref:`pysynphot-formula-rectw`.
Returns
-------
ans : float
Bandpass rectangular width.
"""
mywaveunits = self.waveunits.name
self.convert('angstroms')
wave = self.wave
thru = self.throughput
self.convert(mywaveunits)
num = self.trapezoidIntegration(wave, thru)
den = thru.max()
if 0.0 in (num, den):
return 0.0
else:
return num/den
def equivwidth(self):
"""Calculate :ref:`pysynphot-formula-equvw`.
This basically just calls :meth:`integrate`.
Returns
-------
ans : float
Bandpass equivalent width.
"""
return self.integrate()
def efficiency(self):
"""Calculate :ref:`pysynphot-formula-qtlam`.
Returns
-------
ans : float
Bandpass dimensionless efficiency.
"""
mywaveunits = self.waveunits.name
self.convert('angstroms')
wave = self.wave
thru = self.throughput
self.convert(mywaveunits)
ans = self.trapezoidIntegration(wave, thru/wave)
return ans
# ..................................................................
def check_sig(self, other):
"""Check overlap insignificance with another spectrum.
Also see :ref:`pysynphot-command-checko`.
.. note::
Only use when :meth:`check_overlap` returns "partial".
Parameters
----------
other : `SourceSpectrum` or `SpectralElement`
The other spectrum.
Returns
-------
ans : bool
`True` means the *lack* of overlap is *insignificant*
(i.e., okay to proceed).
"""
swave = self.wave[N.where(self.throughput != 0)]
s1, s2 = swave.min(), swave.max()
owave = other.wave
o1, o2 = owave.min(), owave.max()
lorange = sorted([s1, o1])
hirange = sorted([s2, o2])
# Get the full throughput
total = self.integrate()
# Now get the other two pieces
# We cannot yet do
# low = self[slice(*lowrange)].integrate()
wave = self.wave
idxs = [N.searchsorted(wave, lorange, 'left'),
N.searchsorted(wave, hirange, 'left')]
excluded = 0.0
for idx in idxs:
try:
excluded += self.integrate(wave=wave[slice(*idx)])
except IndexError:
pass # If the range is zero, do nothing
if excluded/total < 0.01:
return True
else:
return False
def check_overlap(self, other):
"""Check overlap with another spectrum.
Also see :ref:`pysynphot-command-checko`.
This checks whether the wavelength set of the given spectrum
is defined everywhere within ``self``.
Wavelength values where throughput is zero are excluded from the check.
Typical use case is for checking whether a source spectrum
is fully defined over the range of a bandpass.
This check is asymmetric in the sense that if ``self`` is fully
defined within the given spectrum, but not the other way around,
it will still only return "partial".
If the given spectrum is analytic, the result is always "full".
Example of full overlap::
|---------- other ----------|
|------ self ------|
Examples of partial overlap::
|---------- self ----------|
|------ other ------|
|---- other ----|
|---- self ----|
|---- self ----|
|---- other ----|
Examples of no overlap::
|---- self ----| |---- other ----|
|---- other ----| |---- self ----|
Parameters
----------
other : `SourceSpectrum` or `SpectralElement`
The other spectrum.
Returns
-------
ans : {'full', 'partial', 'none'}
Overlap status.
"""
if other.isAnalytic and not isinstance(other, Box):
# then it's defined everywhere, except for Box
return 'full'
swave = self.wave[N.where(self.throughput != 0)]
s1, s2 = swave.min(), swave.max()
owave = other.wave
o1, o2 = owave.min(), owave.max()
if (s1 >= o1 and s2 <= o2):
ans = 'full'
elif (s2 < o1) or (o2 < s1):
ans = 'none'
else:
ans = 'partial'
return ans
def convert(self, targetunits):
"""Set new user unit, for wavelength only.
This effectively converts the spectrum wavelength
to given unit. Note that actual data are always kept in
internal unit (Angstrom), and only converted
to user unit by :meth:`GetWaveSet` during actual computation.
User unit is stored in ``self.waveunits``.
Throughput is unitless and cannot be converted.
Parameters
----------
targetunits : str
New unit name, as accepted by `~pysynphot.units.Units`.
"""
nunits = units.Units(targetunits)
self.waveunits = nunits
def ToInternal(self):
"""Convert wavelengths to the internal representation of angstroms.
Note: This is not yet used, but should be for safety when creating
TabularSpectralElements from files. It will also be necessary for the
ArraySpectralElement class that we want to create RSN.
.. note:: For internal use only.
"""
self.validate_units()
savewunits = self.waveunits
angwave = self.waveunits.Convert(self.GetWaveSet(), 'angstrom')
self._wavetable = angwave.copy()
self.waveunits = savewunits
def __call__(self, wavelengths):
"""This is where the throughput array is calculated for a given
input wavelength table.
Parameters
----------
wavelengths : ndarray
An array of wavelengths in Angstrom at which the
throughput should be sampled.
"""
if N.isscalar(wavelengths):
delta = 0.0001
ww = N.array([wavelengths - delta, wavelengths,
wavelengths + delta])
tmp = self.resample(ww)
return tmp._throughputtable[1]
else:
return self.resample(wavelengths)._throughputtable
def sample(self, wave):
"""Sample the spectrum.
This uses :meth:`resample` to do the actual computation.
Parameters
----------
wave : number or array_like
Wavelength set for sampling, given in user unit.
Returns
-------
throughput : number or array_like
Sampled throughput.
"""
angwave = self.waveunits.ToAngstrom(wave)
return self.__call__(angwave)
def taper(self):
"""Taper the spectrum by adding zero throughput to each end.
This is similar to :meth:`TabularSourceSpectrum.taper`.
There is no check to see if the spectrum is already tapered.
Hence, calling this on a tapered spectrum will result in
multiple zero-throughput entries at both ends.
The wavelengths to use for the new first and last points are
calculated by using the same ratio as for the two interior points
used at each end.
Returns
-------
OutElement : `TabularSpectralElement`
Tapered spectrum.
"""
OutElement = TabularSpectralElement()
wcopy = N.zeros(self._wavetable.size + 2, dtype=N.float64)
fcopy = N.zeros(self._throughputtable.size + 2, dtype=N.float64)
wcopy[1:-1] = self._wavetable
fcopy[1:-1] = self._throughputtable
fcopy[0] = 0.0
fcopy[-1] = 0.0
# The wavelengths to use for the first and last points are
# calculated by using the same ratio as for the 2 interior points
wcopy[0] = wcopy[1]*wcopy[1]/wcopy[2]
wcopy[-1] = wcopy[-2]*wcopy[-2]/wcopy[-3]
OutElement._wavetable = wcopy
OutElement._throughputtable = fcopy
return OutElement
def writefits(self, filename, clobber=True, trimzero=True,
precision=None, hkeys=None):
"""Write the spectrum to a FITS table.
Primary header in EXT 0. ``FILENAME``, ``ORIGIN``, and any
extra keyword(s) from ``hkeys`` will also be added.
Table header and data are in EXT 1. The table has 2 columns,
i.e., ``WAVELENGTH`` and ``THROUGHPUT``.
Wavelength data are stored in user unit.
Its header also will have these additional keywords:
* ``EXPR`` - Description of the spectrum.
* ``TDISP1`` and ``TDISP2`` - Columns display format,
always "G15.7".
* ``GRFTABLE`` and ``CMPTABLE`` - Graph and component
table names to use with associated observation mode.
These are only added if applicable.
If data is already double-precision but user explicitly
set output precision to single, ``pysynphot.spectrum.syn_epsilon``
defines the allowed minimum wavelength separation.
This limit (:math:`3.2 \\times 10^{-4}`) was taken from
IRAF STSDAS SYNPHOT FAQ.
Values equal or smaller than this limit are considered as the
same, and duplicates are ignored, resulting in data loss.
In the way that this comparison is coded, when such precision clash
happens, even when no duplicates are detected, the last row is
always omitted (also data loss). Therefore, it is *not* recommended
for user to force single-precision when the data is in
double-precision.
Parameters
----------
filename : str
Output filename.
clobber : bool
Overwrite existing file. Default is `True`.
trimzero : bool
Trim off duplicate rows with flux values of zero from both ends
of the spectrum. This keeps one row of zero-flux at each end,
if it exists; However, it does not add a zero-flux row if it
does not. Default is `True`.
precision : {'s', 'd', `None`}
Write data out in single (``'s'``) or double (``'d'``)
precision. Default is `None`, which will enforce native
precision from ``self.throughput``.
hkeys : dict
Additional keyword(s) to be added to primary FITS header,
in the format of ``{keyword:(value,comment)}``.
"""
if precision is None:
precision = self.throughput.dtype.char
_precision = precision.lower()[0]
pcodes = {'d':'D', 's':'E', 'f':'E'}
if clobber:
try:
os.remove(filename)
except OSError:
pass
wave = self.wave
thru = self(wave)
# Add a check for single/double precision clash, so
# that if written out in single precision, the wavelength table
# will still be sorted with no duplicates
# The value of epsilon is taken from the Synphot FAQ.
if wave.dtype == N.float64 and _precision == 's':
idx = N.where(abs(wave[1:] - wave[:-1]) > syn_epsilon)
else:
idx = N.where(wave) # => idx=[:]
wave = wave[idx]
thru = thru[idx]
first, last = 0, len(thru)
if trimzero:
# Keep one zero at each end
nz = thru.nonzero()[0]
try:
first = max(nz[0] - 1, first)
last = min(nz[-1] + 2, last)
except IndexError:
pass
# Construct the columns and HDUlist
cw = pyfits.Column(name='WAVELENGTH',
array=wave[first:last],
unit=self.waveunits.name,
format=pcodes[_precision])
cf = pyfits.Column(name='THROUGHPUT',
array=thru[first:last],
unit=' ',
format=pcodes[_precision])
# Make the primary header
hdu = pyfits.PrimaryHDU()
hdulist = pyfits.HDUList([hdu])
# User-provided keys are written to the primary header;
# so are filename and origin
bkeys = dict(filename=(os.path.basename(filename), 'name of file'),
origin=('pysynphot', 'Version (%s, %s)' %
(__version__, __svn_revision__)))
# User-values if present may override default values
if hkeys is not None:
bkeys.update(hkeys)
# Now update the primary header
for key, val in bkeys.items():
hdu.header[key] = val
# Make the extension HDU
cols = pyfits.ColDefs([cw, cf])
hdu = pyfits.BinTableHDU.from_columns(cols)
# There are also some keys to be written to the extension header
bkeys = dict(expr=(str(self), 'pysyn expression'),
tdisp1=('G15.7',),
tdisp2=('G15.7',))
try:
bkeys['grftable'] = (os.path.basename(self.obsmode.gtname),
'graph table used')
bkeys['cmptable'] = (os.path.basename(self.obsmode.ctname),
'component table used')
except AttributeError:
pass # Not all bandpasses have these
for key, val in bkeys.items():
hdu.header[key] = val
# Add the extension to the list, and write to file.
hdulist.append(hdu)
hdulist.writeto(filename)
def resample(self, resampledWaveTab):
"""Resample the spectrum for the given wavelength set.
Given wavelength array must be monotonically increasing or decreasing.
Throughput interpolation is done using :func:`numpy.interp`.
Parameters
----------
resampledWaveTab : array_like
Wavelength set for resampling.
Returns
-------
resampled : `ArraySpectralElement`
Resampled spectrum.
"""
# Check whether the input wavetab is in descending order
if resampledWaveTab[0] < resampledWaveTab[-1]:
newwave = resampledWaveTab
newasc = True
else:
newwave = resampledWaveTab[::-1]
newasc = False
# Use numpy interpolation function
if self._wavetable[0] < self._wavetable[-1]:
oldasc = True
ans = N.interp(newwave, self._wavetable, self._throughputtable)
else:
oldasc = False
rev = N.interp(newwave, self._wavetable[::-1],
self._throughputtable[::-1])
ans = rev[::-1]
# If the new and old waveset don't have the same parity,
# the answer has to be flipped again
if (newasc != oldasc):
ans = ans[::-1]
# Finally, make the new object.
# NB: these manipulations were done using the internal
# tables in Angstrom, so those are the units
# that must be fed to the constructor.
resampled = ArraySpectralElement(wave=resampledWaveTab.copy(),
waveunits='angstroms',
throughput=ans.copy())
# Use the convert method to set the units desired by the user.
resampled.convert(self.waveunits)
return resampled
def unit_response(self):
"""Calculate :ref:`pysynphot-formula-uresp`.
.. warning::
Result is correct only if ``self.waveunits`` is in Angstrom.
Returns
-------
ans : float
Bandpass unit response.
"""
hc = units.HC
if hasattr(self, 'primary_area'):
area = self.primary_area
else:
area = refs.PRIMARY_AREA
wave = self.GetWaveSet()
thru = self(wave)
return hc / (area * self.trapezoidIntegration(wave, thru*wave))
def GetWaveSet(self):
"""Obtain the wavelength set for the spectrum.
Returns
-------
wave : array_like
Wavelength set in internal unit.
"""
return self._wavetable
# Define properties for consistent UI
def _getWaveProp(self):
"""Return wavelength in user units."""
wave = self.GetWaveSet()
wave = units.Angstrom().Convert(wave, self.waveunits.name)
return wave
wave = property(_getWaveProp, doc="Wavelength property.")
# NB: Throughput never changes units no matter what the
# wavelength does. There is an implicit assumption here that
# the units of the input waveset to the __call__ are always
# Angstroms.
def GetThroughput(self):
"""Obtain throughput for the spectrum.
Returns
-------
throughput : array_like
Throughput values.
"""
# See https://aeon.stsci.edu/ssb/trac/astrolib/ticket/169
return self.__call__(self.GetWaveSet())
throughput = property(GetThroughput, doc='Throughput property.')
def fwhm(self):
"""Not implemented."""
raise NotImplementedError("#139: Implement calcband functionality")
class CompositeSpectralElement(SpectralElement):
"""Class to handle :ref:`composite spectrum <pysynphot-composite-spectrum>`
involving bandpasses.
Parameters
----------
component1, component2 : `SpectralElement`
Input bandpass.
Attributes
----------
component1, component2
Same as inputs.
name : str
Short description of the spectrum.
isAnalytic : bool
Flag to indicate whether this is an analytic spectrum. This is only `True` if both inputs are analytic.
warnings : dict
To store warnings, which are inherited from both input sources. If inputs have the same warning keyword, the one from ``component2`` is used.
primary_area : number or `None`
:ref:`pysynphot-area` of the telescope. This is inherited from either of the inputs, if available (not `None`). If inputs have different values, an exception is raised.
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
waveunits : `~pysynphot.units.Units`
User unit inherited from inputs, where both inputs are required to have the same unit or an exception will be raised.
throughputunits : `None`
This is only to inform user that throughput is unitless.
wave, throughput : array_like
Wavelength set in user unit and associated unitless throughput.
Raises
------
NotImplementedError
Inputs have different wavelength units.
TypeError
Both input spectra must be bandpasses.
pysynphot.exceptions.IncompatibleSources
Input spectra have different telescope areas defined.
"""
def __init__(self, component1, component2):
SpectralElement.__init__(self)
if (not isinstance(component1, SpectralElement) or
not isinstance(component2, SpectralElement)):
raise TypeError("Arguments must be SpectralElements")
self.component1 = component1
self.component2 = component2
self.isAnalytic = component1.isAnalytic and component2.isAnalytic
if component1.waveunits.name == component2.waveunits.name:
self.waveunits = component1.waveunits
else:
msg = ("Components have different waveunits (%s and %s)" %
(component1.waveunits, component2.waveunits))
raise NotImplementedError(msg)
self.throughputunits = None
self.name = "(%s * %s)" % (str(self.component1), str(self.component2))
self.warnings = {}
self.warnings.update(component1.warnings)
self.warnings.update(component2.warnings)
# check areas
if hasattr(component1, 'primary_area'):
comp1_area = component1.primary_area
else:
comp1_area = None
if hasattr(component2, 'primary_area'):
comp2_area = component2.primary_area
else:
comp2_area = None
if not comp1_area and not comp2_area:
self.primary_area = None
elif comp1_area and not comp2_area:
self.primary_area = comp1_area
elif not comp1_area and comp2_area:
self.primary_area = comp2_area
else:
if comp1_area == comp2_area:
self.primary_area = comp1_area
else:
err = ('Components have different area attributes: '
'%s: %f, %s: %f')
err = err % (str(component1), comp1_area,
str(component2), comp2_area)
raise exceptions.IncompatibleSources(err)
def __call__(self, wavelength):
"""This is where the throughput calculation is delegated."""
return self.component1(wavelength) * self.component2(wavelength)
def __str__(self):
return self.name
def complist(self):
"""Return a list of all components and sub-components."""
ans = []
for comp in (self.component1, self.component2):
try:
ans.extend(comp.complist())
except AttributeError:
ans.append(comp)
return ans
def GetWaveSet(self):
"""Obtain the wavelength set for the composite spectrum.
This is done by using :func:`MergeWaveSets` to form a union of
wavelength sets from its components.
Returns
-------
waveset : array_like
Composite wavelength set.
"""
wave1 = self.component1.GetWaveSet()
wave2 = self.component2.GetWaveSet()
return MergeWaveSets(wave1, wave2)
wave = property(GetWaveSet, doc='Wavelength property.')
class UniformTransmission(SpectralElement):
"""Class to handle a :ref:`uniform bandpass <pysynphot-bandpass-uniform>`.
Parameters
----------
value : number
Constant throughput value for the bandpass.
waveunits : str
Wavelength unit, as accepted by `~pysynphot.units.Units`.
Default is Angstrom.
Attributes
----------
value
Same as input.
name : str
Short description of the spectrum.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `True`.
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
waveunits : `~pysynphot.units.Units`
User unit for wavelength.
wave, throughput : array_like
Wavelength set in user unit and associated unitless throughput.
"""
def __init__(self, value, waveunits='angstrom'):
SpectralElement.__init__(self)
self.waveunits = units.Units(waveunits)
self.value = value
self.name = str(self)
self.isAnalytic = True
self.warnings = {}
# The ._wavetable is used only by the .writefits() method at this time
# It is not for general use.
self._wavetable = N.array([refs._default_waveset[0],
refs._default_waveset[-1]])
self._wave = self.GetWaveSet()
# TODO: Find a less hacky way to do this?
def writefits(self, *args, **kwargs):
"""Write to file using default waveset."""
old_wave = self.wave
self.wave = self._wavetable
try:
super(UniformTransmission, self).writefits(*args, **kwargs)
finally:
self.wave = old_wave
@property
def wave(self):
"""``waveset`` for uniform transmission."""
return self._wave
@wave.setter
def wave(self, val):
self._wave = val
def GetWaveSet(self):
"""Obtain wavelength set for the spectrum.
Returns
-------
waveset : `None`
Due to the nature of uniform transmission,
this is always undefined.
"""
return None
# This produced 15 test failures in cos_etc_test.
# def GetWaveSet(self):
# return N.array([_default_waveset[0],_default_waveset[-1]])
def __str__(self):
return "%g" % self.value
def check_overlap(self, spectrum):
"""Apply special overlap logic for UniformTransmission.
By definition, a UniformTransmission is defined everywhere.
Therefore, this is a special case for which the overlap check
should be ignored (because the alternative is that it will
always fail and always require users to override it, so it
becomes meaningless).
"""
pass
def __call__(self, wavelength):
"""__call__ returns the constant value as an array, given a
wavelength array as argument.
"""
if wavelength is None:
thru = N.array([self.value], dtype=float)
else:
thru = N.zeros_like(wavelength, dtype=float) + self.value
return thru
class TabularSpectralElement(SpectralElement):
"""Base class for `ArraySpectralElement` and `FileSpectralElement`.
Parameters
----------
fileName : str or `None`
File with spectral data (can be ASCII or FITS). If not `None`,
data will be loaded from file at initialization.
thrucol : str
Column name containing throughput data.
Default is "throughput" (case-insensitive).
This is only used if filename is given and is of FITS format.
Attributes
----------
name
Same as input ``fileName``.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `False`.
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
waveunits : `~pysynphot.units.Units`
User unit for wavelength.
throughputunits : {'none', `None`}
This is only to inform user that throughput is unitless.
wave, throughput : array_like
Wavelength set in user unit and associated unitless throughput.
"""
def __init__(self, fileName=None, thrucol='throughput'):
SpectralElement.__init__(self)
self.isAnalytic = False
self.warnings = {}
if fileName:
if fileName.endswith('.fits') or fileName.endswith('.fit'):
self._readFITS(fileName, thrucol)
else:
self._readASCII(fileName)
self.name = fileName
else:
self.name = None
self._wavetable = None
self._throughputtable = None
self.waveunits = None
self.throughputunits = None
def _reverse_wave(self):
self._wavetable = self._wavetable[::-1]
def __str__(self):
return str(self.name)
def ToInternal(self):
"""Convert wavelengths to the internal representation of angstroms.
For internal use only."""
self.validate_units()
savewunits = self.waveunits
angwave = self.waveunits.Convert(self._wavetable, 'angstrom')
self._wavetable = angwave.copy()
self.waveunits = savewunits
def _readASCII(self, filename):
"""ASCII files have no headers. Following synphot, this
routine will assume the first column is wavelength in Angstroms,
and the second column is throughput (dimensionless)."""
self.waveunits = units.Units('angstrom')
self.throughputunits = 'none'
wlist, tlist = self._columnsFromASCII(filename)
self._wavetable = N.array(wlist, dtype=N.float64)
self._throughputtable = N.array(tlist, dtype=N.float64)
def _readFITS(self, filename, thrucol='throughput'):
fs = pyfits.open(filename)
# pyfits cannot close the file on .close() if there are still
# references to mmapped data
self._wavetable = fs[1].data.field('wavelength').copy()
self._throughputtable = fs[1].data.field(thrucol).copy()
self.waveunits = units.Units(fs[1].header['tunit1'].lower())
self.throughputunits = 'none'
self.getHeaderKeywords(fs[1].header)
fs.close()
def getHeaderKeywords(self, header):
"""This is a placeholder for subclasses to get header keywords without
having to reopen the file again."""
pass
class ArraySpectralElement(TabularSpectralElement):
"""Class to handle :ref:`bandpass from arrays <pysynphot-bandpass-arrays>`.
Parameters
----------
wave, throughput : array_like
Wavelength and throughput arrays.
waveunits : str
Wavelength unit, as accepted by `~pysynphot.units.Units`.
Default is Angstrom.
name : str
Description of the spectrum. Default is "UnnamedArrayBandpass".
Attributes
----------
name
Same as input.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `False`.
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
waveunits : `~pysynphot.units.Units`
User unit for wavelength.
wave, throughput : array_like
Wavelength set in user unit and associated unitless throughput.
Raises
------
ValueError
Mismatched wavelength and throughput arrays.
"""
def __init__(self, wave=None, throughput=None,
waveunits='angstrom',
name='UnnamedArrayBandpass'):
if len(wave) != len(throughput):
raise ValueError("wave and throughput arrays must be of "
"equal length")
self._wavetable = wave
self._throughputtable = throughput
self.waveunits = units.Units(waveunits)
self.name = name
self.isAnalytic = False
self.warnings = {}
# must do before validate_fluxtable because it tests against unit type
self.validate_units()
# must do before ToInternal in case of descending
self.validate_wavetable()
self.ToInternal()
class FileSpectralElement(TabularSpectralElement):
"""Class to handle
:ref:`bandpass loaded from ASCII or FITS table <pysynphot-bandpass-from-file>`.
Also see :ref:`pysynphot-io`.
Parameters
-----------
filename : str
File with spectral data (can be ASCII or FITS).
thrucol : str or `None`
Column name containing throughput data. This is only used if the given
file is in FITS format.
Attributes
----------
name : str
Resolved filename; i.e., IRAF-style directory name is expanded to actual path name.
fheader : dict
For FITS file, this contains headers from both extensions 0 and 1. If the extensions have the same keyword, the one from the latter is used.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `False`.
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
waveunits : `~pysynphot.units.Units`
User unit for wavelength.
wave, throughput : array_like
Wavelength set in user unit and associated unitless throughput.
"""
def __init__(self, filename, thrucol=None):
self.name = locations.irafconvert(filename)
self._readThroughputFile(self.name, thrucol)
self.validate_units()
self.validate_wavetable()
self.ToInternal()
self.isAnalytic = False
self.warnings = {}
def _readThroughputFile(self, filename, throughputname):
if filename.endswith('.fits') or filename.endswith('.fit'):
self._readFITS(filename, throughputname)
else:
self._readASCII(filename)
def _readFITS(self, filename, throughputname):
fs = pyfits.open(filename)
# pyfits cannot close the file on .close() if there are still
# references to mmapped data
self._wavetable = fs[1].data.field('wavelength').copy()
if throughputname is None:
throughputname = 'throughput'
self._throughputtable = fs[1].data.field(throughputname).copy()
self.waveunits = units.Units(fs[1].header['tunit1'].lower())
# Retain the header information as a convenience for the user.
# If duplicate keywords exist, the value in the extension
# header will override that in the primary.
self.fheader = dict(fs[0].header)
self.fheader.update(dict(fs[1].header))
fs.close()
def _readASCII(self, filename):
""" Ascii files have no headers. Following synphot, this
routine will assume the first column is wavelength in Angstroms,
and the second column is throughput in Flam."""
self.waveunits = units.Units('angstrom')
wlist, flist = self._columnsFromASCII(filename)
self._wavetable = N.array(wlist, dtype=N.float64)
self._throughputtable = N.array(flist, dtype=N.float64)
# We don't support headers from asii files
self.fheader = dict()
class InterpolatedSpectralElement(SpectralElement):
"""Class to handle :ref:`parameterized keyword <pysynphot-parameterized>`
in an observation mode.
Parameters
----------
fileName : str
Filename followed by a column name specification between square
brackets. For example: "mythru_syn.fits[fr388n#]"
wavelength : number
Desired value to interpolate to. This is not restricted to wavelength,
but rather whatever parameter the file is parameterized for.
Attributes
----------
name : str
Expanded filename.
interpval
Same as input ``wavelength``.
warnings : dict
To store warnings. When extrapolation is not allowed but a default
throughput column is present and used, ``warnings['DefaultThroughput']``
is set to `True`.
isAnalytic : bool
This is always `False`.
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
waveunits : `~pysynphot.units.Units`
User unit for wavelength.
throughputunits : 'none'
This is only to inform user that throughput is unitless.
wave, throughput : array_like
Wavelength set in user unit and associated unitless throughput.
Raises
------
Exception
File does not have columns needed for interpolation.
pysynphot.exceptions.ExtrapolationNotAllowed
Extrapolation is not allowed and no default throughput column found.
"""
def __init__(self, fileName, wavelength):
SpectralElement.__init__(self)
xre = re.search(r'\[(?P<col>.*?)\]', fileName)
self.name = os.path.expandvars(fileName[0:(xre.start())])
colSpec = xre.group('col')
self.isAnalytic = False
self.warnings = {}
self.interpval = wavelength
fs = pyfits.open(self.name)
# if the file has the PARAMS header keyword and if it is set to
# WAVELENGTH then we want to perform a wavelength shift before
# interpolation, otherwise we don't want to shift.
if ('PARAMS' in fs[0].header and
fs[0].header['PARAMS'].lower() == 'wavelength'):
doshift = True
else:
doshift = False
# check whether we are supposed to extrapolate when we're given an
# interpolation value beyond the columns of the table.
# extrapolation is assumed to false if the EXTRAP keyword is missing.
if 'EXTRAP' in fs[0].header and fs[0].header['EXTRAP'] is True:
extrapolate = True
else:
extrapolate = False
# The wavelength table will have to be adjusted before use.
# pyfits cannot close the file on .close() if there are still
# references to mmapped data
wave0 = fs[1].data.field('wavelength').copy()
# Determine the columns that bracket the desired value
# grab all columns that beging with the parameter name (e.g. 'MJD#')
# then split off the numbers after the '#'
colNames = [n for n in fs[1].data.names
if n.startswith(colSpec.upper())]
colWaves = [float(cn.split('#')[1]) for cn in colNames]
if colNames == []:
raise Exception(
'File %s contains no interpolated columns.' % (fileName, ))
# easy case: wavelength matches a column
if self.interpval in colWaves:
self._no_interp_init(
wave0, fs[1].data[colNames[colWaves.index(wavelength)]])
# need interpolation
elif self.interpval > colWaves[0] and self.interpval < colWaves[-1]:
upper_ind = N.searchsorted(colWaves, self.interpval)
lower_ind = upper_ind - 1
self._interp_init(wave0, colWaves[lower_ind], colWaves[upper_ind],
fs[1].data[colNames[lower_ind]],
fs[1].data[colNames[upper_ind]], doshift)
# extrapolate below lowest columns
elif extrapolate and self.interpval < colWaves[0]:
self._extrap_init(wave0, colWaves[0], colWaves[1],
fs[1].data[colNames[0]],
fs[1].data[colNames[1]])
# extrapolate above highest columns
elif extrapolate and self.interpval > colWaves[-1]:
self._extrap_init(wave0, colWaves[-2], colWaves[-1],
fs[1].data[colNames[-2]],
fs[1].data[colNames[-1]])
# can't extrapolate, use default
elif not extrapolate and 'THROUGHPUT' in fs[1].data.names:
s = ('Extrapolation not allowed, using default throughput '
'for %s' % (fileName, ))
warnings.warn(s, UserWarning)
self.warnings['DefaultThroughput'] = True
self._no_interp_init(wave0, fs[1].data['THROUGHPUT'])
# can't extrapolate and no default
elif not extrapolate and 'THROUGHPUT' not in fs[1].data.names:
s = ('Cannot extrapolate and no default throughput '
'for %s' % (fileName, ))
raise exceptions.ExtrapolationNotAllowed(s)
# assign units
self.waveunits = units.Units(fs[1].header['tunit1'].lower())
self.throughputunits = 'none'
fs.close()
def __str__(self):
return "%s#%g" % (self.name, self.interpval)
def _no_interp_init(self, waves, throughput):
self._wavetable = waves
self._throughputtable = throughput
def _interp_init(self, waves, lower_val, upper_val, lower_thru,
upper_thru, doshift):
self._wavetable = waves
if doshift:
# Adjust the wavelength table to bracket the range
lwave = waves + (lower_val - self.interpval)
uwave = waves + (upper_val - self.interpval)
# Interpolate the columns at those ranges
lower_thru = N.interp(lwave, waves, lower_thru)
upper_thru = N.interp(uwave, waves, upper_thru)
# Then interpolate between the two columns
w = (self.interpval - lower_val) / (upper_val - lower_val)
self._throughputtable = (upper_thru * w) + lower_thru * (1.0 - w)
def _extrap_init(self, waves, lower_val, upper_val, lower_thru,
upper_thru):
self._wavetable = waves
throughput = []
for y1, y2 in zip(lower_thru, upper_thru):
m = (y2 - y1) / (upper_val - lower_val)
b = y1 - m * lower_val
throughput.append(m*self.interpval + b)
self._throughputtable = N.array(throughput)
class ThermalSpectralElement(TabularSpectralElement):
"""Class to handle
:ref:`spectral element with thermal properties <pysynphot_thermal_em>`
read from a FITS table.
.. note::
This class does not know how to apply itself to an existing beam.
Its emissivity is handled by
:meth:`~pysynphot.observationmode.ObservationMode.ThermalSpectrum`.
Parameters
----------
fileName : str
Filename of the thermal emissivity table.
Attributes
----------
name
Same as input ``fileName``.
temperature : number
Default temperature in Kelvin from header.
beamFillFactor : number
Beam filling factor from header.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `False`.
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
waveunits : `~pysynphot.units.Units`
User unit for wavelength.
throughputunits : 'none'
This is only to inform user that throughput is unitless.
wave, throughput : array_like
Wavelength set in user unit and associated unitless emissivity.
"""
def __init__(self, fileName):
TabularSpectralElement.__init__(self, fileName=fileName,
thrucol='emissivity')
self.warnings = {}
def getHeaderKeywords(self, header):
"""Overrides base class in order to get thermal keywords.
For internal use only."""
self.temperature = header['DEFT']
self.beamFillFactor = header['BEAMFILL']
class Box(SpectralElement):
"""Class to handle a :ref:`box-shaped bandpass <pysynphot-box-bandpass>`.
Parameters
----------
center, width : number
Center and width of the box in the given wavelength unit.
waveunits : str or `None`
Wavelength unit, as accepted by `~pysynphot.units.Units`.
If not given, assumed to be in Angstrom.
Attributes
----------
name : str
Description of the spectrum.
warnings : dict
To store warnings.
isAnalytic : bool
This is always `False`.
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
waveunits : `~pysynphot.units.Units`
User unit for wavelength.
wave, throughput : array_like
Wavelength set in user unit and associated unitless throughput.
"""
def __init__(self, center, width, waveunits=None):
SpectralElement.__init__(self)
if waveunits is None:
self.waveunits = units.Units('angstrom') # per docstring: for now
self.center = center
self.width = width
else:
self.waveunits = units.Units(waveunits)
self.center = self.waveunits.Convert(center, 'angstrom')
self.width = self.waveunits.Convert(width, 'angstrom')
self.name = 'Box at %g (%g wide)' % (self.center, self.width)
self.isAnalytic = True
self.warnings = {}
# Construct some default lookup table
self.lower = self.center - self.width / 2.0
self.upper = self.center + self.width / 2.0
step = 0.01 # fixed step for now (in A)
self._wavetable = N.arange(
self.lower - step, self.upper + step + step, step)
self._throughputtable = self(self._wavetable)
def __call__(self, wave):
"""Input wavelengths assumed to be in Angstrom."""
if N.isscalar(wave):
if (wave >= self.lower) & (wave <= self.upper):
thru = 1.0
else:
thru = 0.0
else:
wave = N.asarray(wave)
thru = N.zeros(wave.shape, dtype=N.float64)
thru[(wave >= self.lower) & (wave <= self.upper)] = 1.0
return thru
def sample(self, wavelength):
"""Input wavelengths assumed to be in user unit."""
wave = self.waveunits.Convert(wavelength, 'angstrom')
return self(wave)
def resample(self, resampledWaveTab):
"""Resample the spectrum for the given wavelength set.
Given wavelength array must be monotonically increasing or decreasing.
Parameters
----------
resampledWaveTab : array_like
Wavelength set for resampling.
Returns
-------
resampled : `ArraySpectralElement`
Resampled spectrum. This is no longer a real `Box` spectrum.
"""
return ArraySpectralElement(
wave=resampledWaveTab.copy(), waveunits='angstrom',
throughput=self(resampledWaveTab).copy())
Vega = FileSourceSpectrum(locations.VegaFile)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,588 | spacetelescope/pysynphot | refs/heads/master | /commissioning/nicmos_effstim_cases.py | from pytools import testutil
import sys
import basecase
class E1photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E1flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E1fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E1vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E1abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E1stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E1obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E1counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E2photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E2flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E2fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E2vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E2abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E2stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E2obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E2counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E3photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E3flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E3fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E3vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E3abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E3stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E3obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E3counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E4photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E4flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E4fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E4vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E4abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E4stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E4obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E4counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,3,f110w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E5photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E5flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E5fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E5vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E5abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E5stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E5obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E5counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E6photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E6flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E6fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E6vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E6abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E6stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E6obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E6counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E7photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,k"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E7flam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,k"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E7fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,k"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E7vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,k"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E7abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,k"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E7stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,k"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E7obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,k"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E7counts(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,k"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E8photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E8flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E8fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E8vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E8abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E8stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E8obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E8counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E9photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E9flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E9fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E9vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E9abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E9stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E9obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E9counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E10photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E10flam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E10fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E10vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E10abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E10stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E10obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E10counts(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E11photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E11flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E11fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E11vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E11abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E11stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E11obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E11counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E12photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E12flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E12fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E12vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E12abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E12stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E12obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E12counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E13photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E13flam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E13fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E13vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E13abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E13stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E13obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E13counts(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E14photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E14flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E14fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E14vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E14abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E14stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E14obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E14counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E15photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E15flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E15fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E15vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E15abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E15stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E15obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E15counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E16photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E16flam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E16fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E16vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E16abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E16stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E16obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E16counts(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E17photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E17flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E17fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E17vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E17abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E17stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E17obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E17counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E18photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,2,f237m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E18flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,2,f237m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E18fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,2,f237m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E18vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,2,f237m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E18abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,2,f237m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E18stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,2,f237m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E18obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,2,f237m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E18counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,2,f237m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E19photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E19flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E19fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E19vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E19abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E19stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E19obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E19counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E20photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.5) "
self.obsmode="nicmos,2,f237m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E20flam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.5) "
self.obsmode="nicmos,2,f237m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E20fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.5) "
self.obsmode="nicmos,2,f237m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E20vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.5) "
self.obsmode="nicmos,2,f237m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E20abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.5) "
self.obsmode="nicmos,2,f237m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E20stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.5) "
self.obsmode="nicmos,2,f237m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E20obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.5) "
self.obsmode="nicmos,2,f237m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E20counts(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.5) "
self.obsmode="nicmos,2,f237m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E21photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E21flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E21fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E21vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E21abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E21stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E21obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E21counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E22photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E22flam(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E22fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E22vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E22abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E22stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E22obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E22counts(basecase.effstimCase):
def setUp(self):
self.spectrum="crgridkc96$sb_template.fits "
self.obsmode="nicmos,1,f090m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E23photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E23flam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E23fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E23vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E23abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E23stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E23obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E23counts(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.0) "
self.obsmode="nicmos,2,f237m"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E24photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E24flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E24fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E24vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E24abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E24stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E24obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E24counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="bessell,h"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E25photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,3,f108n"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E25flam(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,3,f108n"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E25fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,3,f108n"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E25vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,3,f108n"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E25abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,3,f108n"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E25stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,3,f108n"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E25obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,3,f108n"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E25counts(basecase.effstimCase):
def setUp(self):
self.spectrum="bb(5000) "
self.obsmode="nicmos,3,f108n"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E26photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.5) "
self.obsmode="nicmos,3,f215n"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E26flam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.5) "
self.obsmode="nicmos,3,f215n"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E26fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.5) "
self.obsmode="nicmos,3,f215n"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E26vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.5) "
self.obsmode="nicmos,3,f215n"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E26abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.5) "
self.obsmode="nicmos,3,f215n"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E26stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.5) "
self.obsmode="nicmos,3,f215n"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E26obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.5) "
self.obsmode="nicmos,3,f215n"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E26counts(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,2.5) "
self.obsmode="nicmos,3,f215n"
self.form="counts"
self.setglobal(__file__)
self.runpy()
class E27photlam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.0) "
self.obsmode="nicmos,2,f205w"
self.form="photlam"
self.setglobal(__file__)
self.runpy()
class E27flam(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.0) "
self.obsmode="nicmos,2,f205w"
self.form="flam"
self.setglobal(__file__)
self.runpy()
class E27fnu(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.0) "
self.obsmode="nicmos,2,f205w"
self.form="fnu"
self.setglobal(__file__)
self.runpy()
class E27vegamag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.0) "
self.obsmode="nicmos,2,f205w"
self.form="vegamag"
self.setglobal(__file__)
self.runpy()
class E27abmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.0) "
self.obsmode="nicmos,2,f205w"
self.form="abmag"
self.setglobal(__file__)
self.runpy()
class E27stmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.0) "
self.obsmode="nicmos,2,f205w"
self.form="stmag"
self.setglobal(__file__)
self.runpy()
class E27obmag(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.0) "
self.obsmode="nicmos,2,f205w"
self.form="obmag"
self.setglobal(__file__)
self.runpy()
class E27counts(basecase.effstimCase):
def setUp(self):
self.spectrum="z(crgridkc96$sb_template.fits,1.0) "
self.obsmode="nicmos,2,f205w"
self.form="counts"
self.setglobal(__file__)
self.runpy()
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,589 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/graphtab.py | """ Graph table re-implementation
Data structure & traversal algorithm suggested by Alex Martelli,
http://stackoverflow.com/questions/844505/is-a-graph-library-eg-networkx-the-right-solution-for-my-python-problem
"""
from __future__ import division, print_function
from collections import defaultdict
from astropy.io import fits as pyfits
class GraphNode(object):
""" Structure to hold all the information associated with a single
innode of the graph table. The constructor produces an empty node,
which must be filled later.
This structure will be the value associated with the GraphTab dict.
"""
def __init__(self):
""" ( (default_outnode, compname, thcompname),
{'kwd':(outnode, compname, thcompname)} )"""
self.default = (None,None,None)
self.named = {}
self.entry = ( self.default, self.named )
def __repr__(self):
"""Maybe change this"""
return str((self.default, self.named))
def set_default(self, outnode, compname, thcompname):
self.default = (outnode, compname, thcompname)
self.entry = (self.default, self.named)
def set_named(self, kwd, outnode, compname, thcompname):
if kwd in self.named:
raise IndexError("%s entry already exists for this node"%kwd)
else:
self.named[kwd]=(outnode, compname, thcompname)
self.entry = (self.default, self.named)
def get_default(self):
return self.default
def get_named(self,kwd):
return self.named[kwd]
class GraphPath(object):
"""Simple class containing the result of a traversal of the GraphTable"""
def __init__(self, obsmode_string, optical, thermal, params, tname):
"""
Parameters
-----------
optical : list of strings
optical component names
thermal : list of strings
thermal component names
params : dict
dictionary of {compname:parameterized value} for
any parameterized keywords used in the obsmode string
"""
self.obsmode = obsmode_string
self.optical = optical
self.thermal = thermal
self.params = params
self.gtable = tname
def __repr__(self):
return str((self.optical, self.thermal, self.params, self.gtable))
def __len__(self):
return max(len(self.optical),
len(self.thermal))
class GraphTable(object):
def __init__(self, fname):
self.tab = defaultdict(GraphNode)
self.tname = fname
self.problemset=set()
self.inittab()
if self.problemset:
print("warning, ambiguous nodes encountered")
print("(innode, kwd, (outnode, compname, thcompname)")
for k in self.problemset:
print(k)
self.all_nodes = set()
for node in self.tab:
self.all_nodes.add(node)
self.add_descendants(node, self.all_nodes)
def inittab(self):
#Both FITS files and text files are supported
# In either case, process one row at a time
if self.tname.endswith('.fits'):
f = pyfits.open(self.tname)
if 'PRIMAREA' in f[0].header:
self.primary_area = f[0].header['PRIMAREA']
for row in f[1].data:
if not row.field('compname').endswith('graph'):
#Make it a list because FITS_records don't fully
#implement all the usual sequence behaviors
self._setrow(list(row))
else:
raise NotImplementedError('Segmented graph tables not yet supported')
f.close()
else: #Not a FITS file; assume text
f=open(self.tname)
for line in f:
try:
row = line.split()
except ValueError as e:
print("Error parsine line %s"%line)
raise e
self._setrow(row)
f.close()
def _setrow(self, row):
"""
Parameters
----------
row : a list or tuple
the list or tuple containing ordered elements::
kwd, innode, outnode, compname, thcomp
followed by comments & other ignored things
"""
try:
compname, kwd, innode, outnode, thcomp = row[0:5]
except ValueError:
raise ValueError('Error unpacking row: %s'%row)
#Innode is an integer
k=int(innode)
#"Clear" should become None
if compname == 'clear':
compname = None
if thcomp == 'clear':
thcomp = None
#Now create the GraphNode defined by this row,
#and add it to the table. Default nodes are special.
if kwd == 'default':
self.tab[k].set_default(int(outnode),compname, thcomp)
else:
try:
self.tab[k].set_named(kwd,int(outnode),compname, thcomp)
except IndexError:
old = self.tab[k].get_named(kwd)
plist = (k, kwd, old, (outnode, compname, thcomp))
self.problemset.add(plist)
def traverse(self,icss,verbose=False):
opt=[]
thm=[]
used = set()
paramcomp = dict()
nodelist = list()
#Returns a list of keywords and a dict of paramkeys
kws, paramdict = extract_keywords(icss)
if verbose:
print(kws)
print(paramdict)
#Always start with innode=1
nextnode = 1
#Keep going as long as the next node is in this table
while nextnode in self.tab:
defnode, othernodes = self.tab[nextnode].default, self.tab[nextnode].named
#Check if the keywords match a named option
found = kws & set(othernodes)
if found:
if verbose: print(found)
#...and that we don't have ambiguity
if len(found) == 1:
used.update(found)
matchkey = found.pop()
matchnode = othernodes[matchkey]
else:
raise ValueError("Invalid obsmode: cannot use %s together"%found)
else:
#fall back to default
matchnode = defnode
#Having picked out the matching node, also pick up
#the optical & thermal components from it
nodelist.append(matchnode)
nextnode, ocomp, tcomp = matchnode
if ocomp is not None:
opt.append(ocomp)
if tcomp is not None:
thm.append(tcomp)
#Special handling of paramterization
if matchkey in paramdict:
paramcomp[ocomp]=float(paramdict[matchkey])
paramcomp[tcomp]=float(paramdict[matchkey])
if verbose: print(matchnode)
if nextnode is None:
raise ValueError("Incomplete obsmode: legal possibilities %s"%str(list(othernodes.keys())))
#We're done with the table. If there are any keywords left over,
#raise an exception.
if kws != used:
raise ValueError("Unused keywords %s"%str([k for k in (kws-used)]))
#The results are returned as a simple class
path = GraphPath(icss, opt, thm, paramcomp, self.tname)
return path
# Helper/validation methods, should be marked private
def add_descendants(self, node, updateset=None):
"auxiliary function: add all descendants of node to someset"
someset = set()
startnode = self.tab[node]
defout = startnode.default[0]
if defout is not None:
someset.add(defout)
for kwd, matchnode in startnode.named.items():
if matchnode[0] is not None:
someset.add(matchnode[0])
if someset is not None:
updateset.update(someset)
else:
return someset
def validate(self):
""" Simulataneously checks for loops and unreachable nodes
"""
msg = list()
previously_seen = set()
currently_seen = set([1])
problemset = set()
while currently_seen:
node = currently_seen.pop()
if node in previously_seen:
problemset.add(node)
else:
previously_seen.add(node)
self.add_descendants(node, currently_seen)
unreachable = self.all_nodes - previously_seen
if unreachable:
msg.append("%d unreachable nodes: "%len(unreachable))
for node in unreachable:
msg.append(str(node))
if problemset:
msg.append("Loop involving %d nodes"%len(problemset))
for node in problemset:
msg.append(str(node))
if msg:
return msg
else:
return True
def extract_keywords(icss):
"""Helper function
Parameters
----------
icss : string
comma-separated string
Returns
-------
kws : list of string
set of keywords
paramdict : dict
dict of {parameterized_keyword: parameter_value}
"""
# Force to lower case & split into keywords
kws=set(icss.lower().split(','))
#parameterized keywords require special handling
paramdict={}
parlist = [k for k in kws if '#' in k]
for k in parlist:
key,val=k.split('#')
#Take the parameterized value off the keyword...
kws.remove(k)
kws.add(key+'#')
#...and save it in the dictionary
paramdict[key+'#']=val
return kws, paramdict
class CompTable(object):
"""This class will cooperate with a GraphPath to produce a
realized list of files"""
def __init__(self, fname):
self.tab = dict()
self.tname = fname
self.inittab()
def __getitem__(self, key):
return self.tab[key]
def inittab(self):
#Support fits or text files
#Should the filenames be converted at this point, or later?
if self.tname.endswith('.fits'):
f = pyfits.open(self.tname)
for row in f[1].data:
self.tab[row.field('compname')] = row.field('filename')
f.close()
else:
#Only simple text file supported
f = open(self.tname)
for line in f:
compname, filename = line.split()
self.tab[compname] = filename
f.close()
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,590 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/test/test_obsbandpass.py | from __future__ import absolute_import, division, print_function
import os
import pytest
from numpy.testing import assert_allclose, assert_array_equal
from ..exceptions import OverlapError
from ..obsbandpass import ObsBandpass, pixel_range, wave_range
from ..refs import setref
@pytest.mark.remote_data
class TestObsBandpass(object):
def setup_class(self):
self.bp = ObsBandpass('acs,hrc,f555w')
self.bins = self.bp.binset
def test_exceptions(self):
with pytest.raises(ValueError):
pixel_range(self.bins, (5000, 5001), round='up') # rounding
with pytest.raises(OverlapError):
pixel_range(self.bins, (500, 5001)) # low wave
with pytest.raises(OverlapError):
pixel_range(self.bins, (5000, 50010)) # high wave
with pytest.raises(ValueError):
wave_range(self.bins, 5000, 100, round='up') # rounding
with pytest.raises(OverlapError):
wave_range(self.bins, 1000, 100) # low wave
with pytest.raises(OverlapError):
wave_range(self.bins, 11000, 100) # high wave
@pytest.mark.parametrize(
('args', 'rnd', 'ans'),
[((5000, 5000), 'round', 0),
((4999.5, 5000.5), 'round', 1),
((5000, 5002), 'round', 2),
((4999.6, 5008.8), 'round', 9),
((5000, 5002), 'min', 1),
((5000.5, 5002.5), 'min', 2),
((5000.5, 5004.4), 'min', 3),
((5000.2, 5004.5), 'min', 4),
((5000, 5000.1), 'max', 1),
((5000.5, 5002.5), 'max', 2),
((5000.5, 5002.6), 'max', 3),
((5001.2, 5004.5), 'max', 4)])
def test_pixel_range(self, args, rnd, ans):
num = pixel_range(self.bins, args, round=rnd)
assert num == ans
@pytest.mark.parametrize(
('args', 'ans'),
[((5000, 5000.1), 0.1),
((4999.8, 5000), 0.2),
((5000.5, 5006.5), 6),
(((5000, 5008), 8))])
def test_pixel_range_none(self, args, ans):
num = pixel_range(self.bins, args, round=None)
assert_allclose(num, ans)
def test_wave_range_eq_out(self):
w1, w2 = wave_range(self.bins, 5000.4, 0, round=None)
assert w1 == w2
@pytest.mark.parametrize(
('cenwave', 'npix', 'rnd', 'ans'),
[(5000, 2, None, (4999, 5001)),
(5000.25, 3, None, (4998.75, 5001.75)),
(5000.5, 4, None, (4998.5, 5002.5)),
(5002, 1, 'round', (5001.5, 5002.5)),
(5005, 2, 'round', (5004.5, 5006.5)),
(5005, 3, 'round', (5003.5, 5006.5)),
(5004.25, 4, 'round', (5002.5, 5006.5)),
(5004.25, 5, 'round', (5001.5, 5006.5)),
(5004.5, 6, 'round', (5001.5, 5007.5)),
(5004.5, 7, 'round', (5001.5, 5008.5)),
(5004, 1, 'min', (5003.5, 5004.5)),
(5004, 2, 'min', (5003.5, 5004.5)),
(5004, 3, 'min', (5002.5, 5005.5)),
(5006.25, 4, 'min', (5004.5, 5007.5)),
(5006.25, 5, 'min', (5004.5, 5008.5)),
(5006.5, 6, 'min', (5003.5, 5009.5)),
(5006.5, 7, 'min', (5003.5, 5009.5)),
(5004, 1, 'max', (5003.5, 5004.5)),
(5004, 2, 'max', (5002.5, 5005.5)),
(5004, 3, 'max', (5002.5, 5005.5)),
(5006.25, 4, 'max', (5003.5, 5008.5)),
(5006.25, 5, 'max', (5003.5, 5009.5)),
(5006.5, 6, 'max', (5003.5, 5009.5)),
(5006.5, 7, 'max', (5002.5, 5010.5))])
def test_wave_range(self, cenwave, npix, rnd, ans):
w = wave_range(self.bins, cenwave, npix, round=rnd)
assert_array_equal(w, ans)
def test_pixel_range_method(self):
num = self.bp.pixel_range(
(499.95, 500.05), waveunits='nm', round='round')
assert num == 1
def test_wave_range_method(self):
w = self.bp.wave_range(500, 2, waveunits='nm', round=None)
assert_array_equal(w, (499.9, 500.1))
@pytest.mark.remote_data
class TestUnitResponse(object):
"""
Test the spectrum.SpectralElement.unit_response method as
it is run by obsbandpass.ObsModeBandpass objects.
Results are compared to synphot bandpar.
"""
def setup_class(self):
path = os.environ['PYSYN_CDBS']
graphtab = os.path.join(
path, 'mtab', 'OLD_FILES', 'u921351jm_tmg.fits')
comptab = os.path.join(
path, 'mtab', 'OLD_FILES', 'v8h1925fm_tmc.fits')
thermtab = os.path.join(
path, 'mtab', 'OLD_FILES', 'tae17277m_tmt.fits')
setref(graphtable=graphtab, comptable=comptab, thermtable=thermtab)
def teardown_class(self):
setref()
@pytest.mark.parametrize(
('obsmode', 'ans'),
[('acs,hrc,f555w', 3.0074E-19),
('acs,wfc1,f555w,f814w', 1.7308E-13),
('acs,sbc,f125lp', 1.7218E-17),
('wfc3,uvis1,f395n', 5.9579E-18),
('wfc3,uvis2,fq924n', 6.9039E-18),
('wfc3,ir,f140w', 1.4574E-20),
('wfpc2,f555w', 4.8968E-19),
('cos,boa,fuv,g130m,c1309', 3.5520E-15),
('stis,ccd,f25ndq1,a2d4,mjd#55555', 3.0650E-18)])
def test_uresp(self, obsmode, ans):
bp = ObsBandpass(obsmode)
val = bp.unit_response()
assert_allclose(val, ans, rtol=1E-4)
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,591 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/Cache.py | """This module is a container for IO-intensive items that should be
read in only once, and then re-used from memory.
This includes the :ref:`reddening laws <pysynphot-extinction>`
(``pysynphot.locations.RedLaws``)
and some indices for the `~pysynphot.catalog` model atlases
(``pysynphot.Cache.CATALOG_CACHE``).
"""
from __future__ import division
from .locations import RedLaws
# if PYSYN_CDBS is undefined RedLaws will be an empty dictionary
# so we should check whether these assignments are possible
if 'mwavg' in RedLaws:
RedLaws[None]=RedLaws['mwavg'] #Establishes default
RedLaws['gal3']=RedLaws['mwavg'] #Temporary: for syn_pysyn testing
CATALOG_CACHE = {}
def reset_catalog_cache():
"""
Empty the ``CATALOG_CACHE`` global variable.
"""
global CATALOG_CACHE
CATALOG_CACHE.clear()
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,592 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/extinction.py | """This module handles deprecated extinction models for backward compatibility
with IRAF STSDAS SYNPHOT.
"""
from __future__ import division
import numpy as N
from . import spectrum
from . import units
from . import refs
_seatonx = N.array([0., 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, \
1.6, 1.7, 1.8, 1.9, 2.0, 2.1, \
2.2, 2.3, 2.4, 2.5, 2.6, 2.7])
_seatone = N.array([0., 1.36, 1.64, 1.84, 2.04, 2.24, 2.44, \
2.66, 2.88, 3.14, 3.36, 3.56, 3.77, \
3.96, 4.15, 4.26, 4.40, 4.52, 4.64])
_lmcx = N.array([0.00, 0.29, 0.45, 0.80, 1.11, 1.43, 1.83])
_lmce = N.array([0.00, 0.16, 0.38, 0.87, 1.50, 2.32, 3.1])
#Coefficients taken from Prevot et al, 1984, out to 1/lambda=7.84.
#Additional coefficient & value to extrapolate to 1000 Angstroms,
#and the value of R =3.1 necessary to return A_lambda/E(B-V) as all the
#other extinction functions do, were provided by Scott Friedman
#-- see ticket # 63.
_smcx = N.array([ 0.00, 0.29, 0.45, 0.80, 1.11, 1.43, 1.82, \
2.35, 2.70, 3.22, 3.34, 3.46, 3.60, 3.75, \
3.92, 4.09, 4.28, 4.50, 4.73, 5.00, 5.24, \
5.38, 5.52, 5.70, 5.88, 6.07, 6.27, 6.48, \
6.72, 6.98, 7.23, 7.52, 7.84, 10])
_smce = N.array([-3.10, -2.94, -2.72, -2.23, -1.60, -0.78, 0.00, \
1.00, 1.67, 2.29, 2.65, 3.00, 3.15, 3.49, \
3.91, 4.24, 4.53, 5.30, 5.85, 6.38, 6.76, \
6.90, 7.17, 7.71, 8.01, 8.49, 9.06, 9.28, \
9.84, 10.80, 11.51, 12.52, 13.54, 20.64]) + 3.1
def _buildDefaultWaveset():
wave = refs._default_waveset.copy()[::10]
result = N.empty(shape=[wave.shape[0]+1,],dtype=N.float64)
result[0:-1] = wave
result[-1] = refs._default_waveset[-1]
return 10000.0 / result # convert to 1/micron
def _interp(xdata, x, y):
xx = xdata[::-1] # xdata is arranged in descending order
xind = N.searchsorted(x, xx)-1
xind = N.clip(xind, 0, x.size-2)
xfract = (xx - x[xind]) / (x[xind+1] - x[xind])
xfract = N.clip(xfract, 0.0, 1.0)
result = y[xind] + xfract * (y[xind+1] - y[xind])
return result[::-1]
def _computeSeaton(x):
result = _seatone[1] * x * x
mask = N.where(x > 1.0, 1, 0) * N.where(x <= 2.7, 1, 0)
result = N.where(mask == 1, \
_interp(x, _seatonx, _seatone), result)
mask = N.where(x > 2.7, 1, 0) * N.where(x <= 3.65, 1, 0)
result = N.where(mask == 1, \
1.56 + 1.048 * x + 1.01 / ((x-4.6)*(x-4.6) + 0.28), result)
mask = N.where(x > 3.65, 1, 0) * N.where(x <= 7.14, 1, 0)
result = N.where(mask == 1, \
2.29 + 0.848 * x + 1.01 / ((x-4.6)*(x-4.6) + 0.28), result)
result = N.where(x > 7.14, \
16.17 + x * (-3.20 + 0.2975 * x), result)
return result
def _computeLMC(x):
result = N.zeros(x.shape, dtype=N.float64)
mask = N.where(x < 1.83, 1, 0)
result = N.where(mask == 1, _interp(x, _lmcx, _lmce), result)
mask = N.where(x >= 1.83, 1, 0) * N.where(x <= 2.75, 1, 0)
result = N.where(mask == 1, \
3.1 + (2.04 + 0.094 * (x - 1.83)) * (x - 1.83), result)
mask = N.where(x > 2.75, 1, 0)
result = N.where(mask == 1, \
3.1 - 0.236 + 0.462 * x + 0.105 * x * x + \
0.454 / ((x - 4.557)**2 + 0.293), result)
return result
def _computeSMC(x):
x1 = N.where (x > 10.0, 10.0, x)
return _interp(x1, _smcx, _smce)
def _computeXgal(x):
return 2.43 * ((0.011 * x - 0.198) * x + 1.509) * x
# extinction curves are computed at load time, once and for all, on top
# of the default wave set. Note that this is not thread safe.
_waveset = _buildDefaultWaveset()
_seaton = _computeSeaton(_waveset)
_lmc = _computeLMC(_waveset)
_smc = _computeSMC(_waveset)
_xgal = _computeXgal(_waveset)
class _ExtinctionLaw(object):
def _computeTransparency(self, extval, curve):
return 10.0 ** (-0.4 * extval * curve)
class Gal1(_ExtinctionLaw):
"""Deprecated Milky Way extinction curve
(:ref:`Seaton 1979 <synphot-ref-seaton1979>`).
Parameters
----------
extval : float
Value of :math:`E(B-V)` in magnitudes.
Attributes
----------
name : str
Name of the extinction law.
citation : str
The publication where this curve was obtained from.
transparencytable : array_like
This is the same as :math:`\\mathrm{THRU}` defined in
:meth:`~pysynphot.reddening.CustomRedLaw.reddening`.
"""
citation = 'Seaton 1979 (MNRAS 187:75)'
name = 'gal1'
def __init__(self, extval):
global _seaton
self._wavetable = _waveset.copy()
self.transparencytable = self._computeTransparency(extval, _seaton)
class Gal2(_ExtinctionLaw):
"""Not used."""
citation = 'Savage & Mathis 1979 (ARA&A 17:73)'
name = 'gal2'
def __init__(self, extval):
raise NotImplementedError("Sorry, %s is not yet implemented" % self.name)
class Gal3(_ExtinctionLaw):
"""Not used."""
citation='Cardelli, Clayton & Mathis 1989 (ApJ 345:245)'
name='gal3'
def __init__(self, extval):
raise NotImplementedError("Sorry, %s is not yet implemented" % self.name)
class Smc(_ExtinctionLaw):
"""Deprecated SMC extinction curve
(:ref:`Prevot et al. 1984 <synphot-ref-prevot1984>`).
Parameters
----------
extval : float
Value of :math:`E(B-V)` in magnitudes.
Attributes
----------
name : str
Name of the extinction law.
citation : str
The publication where this curve was obtained from.
transparencytable : array_like
This is the same as :math:`\\mathrm{THRU}` defined in
:meth:`~pysynphot.reddening.CustomRedLaw.reddening`.
"""
citation='Prevot et al.1984 (A&A 132:389)'
name='SMC'
def __init__(self, extval):
global _smc
self._wavetable = _waveset.copy()
self.transparencytable = self._computeTransparency(extval, _smc)
class Lmc(_ExtinctionLaw):
"""Deprecated LMC extinction curve
(:ref:`Howarth 1983 <synphot-ref-howarth1983>`).
Parameters
----------
extval : float
Value of :math:`E(B-V)` in magnitudes.
Attributes
----------
name : str
Name of the extinction law.
citation : str
The publication where this curve was obtained from.
transparencytable : array_like
This is the same as :math:`\\mathrm{THRU}` defined in
:meth:`~pysynphot.reddening.CustomRedLaw.reddening`.
"""
citation='Howarth 1983 (MNRAS 203:301)'
name='LMC'
def __init__(self, extval):
self.name = 'LMC'
global _lmc
self._wavetable = _waveset.copy()
self.transparencytable = self._computeTransparency(extval, _lmc)
class Xgal(_ExtinctionLaw):
"""Deprecated Extra-galactic extinction curve
(:ref:`Calzetti et al. 1994 <synphot-ref-calzetti1994>`).
Parameters
----------
extval : float
Value of :math:`E(B-V)` in magnitudes.
Attributes
----------
name : str
Name of the extinction law.
citation : str
The publication where this curve was obtained from.
transparencytable : array_like
This is the same as :math:`\\mathrm{THRU}` defined in
:meth:`~pysynphot.reddening.CustomRedLaw.reddening`.
"""
citation = 'Calzetti, Kinney and Storchi-Bergmann, 1994 (ApJ 429:582)'
name='XGAL'
def __init__(self, extval):
global _xgal
self._wavetable = _waveset.copy()
self.transparencytable = self._computeTransparency(extval, _xgal)
reddeningClasses = {'gal1': Gal1,
'gal2': Gal2,
'gal3': Gal3,
'smc': Smc,
'lmc': Lmc,
'xgal': Xgal}
def factory(redlaw, *args, **kwargs):
import sys
if sys.version_info[0] < 3:
return apply(reddeningClasses[redlaw.lower()], args, kwargs)
else:
reddening = reddeningClasses[redlaw.lower()]
return reddening(*args, **kwargs)
class DeprecatedExtinction(spectrum.SpectralElement):
"""This class handles deprecated extinction models from
IRAF STSDAS SYNPHOT like a spectral element.
Parameters
----------
extval : float
Extinction in magnitude.
redlaw : {'gal1', 'smc', 'lmc', 'xgal'}
Reddening law (`Gal1`, `Smc`, `Lmc`, or `Xgal`).
Attributes
----------
name : str
Name of the extinction law.
citation : str
The publication where this curve was obtained from.
isAnalytic : bool
This is always `False`.
warnings : dict
To store warnings
binset : `None`
This is reserved to be used by `~pysynphot.obsbandpass.ObsModeBandpass`.
waveunits : `~pysynphot.units.Units`
This is set to Angstrom at initialization.
wave, throughput : array_like
Wavelength set in ``waveunits`` and associated unitless extinction.
Examples
--------
>>> extinction = S.Extinction(0.3, 'gal1')
"""
def __init__(self, extval, redlaw):
law = factory(redlaw, extval)
self._wavetable = 10000.0 / law._wavetable
self._throughputtable = law.transparencytable
self.name=law.name
self.citation=law.citation
self.waveunits=units.Units('angstrom')
self.isAnalytic=False
self.warnings={}
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,593 | spacetelescope/pysynphot | refs/heads/master | /pysynphot/binning.py | """Utilities related to wavelength bin calculations."""
from __future__ import division
import numpy as np
def calculate_bin_edges(centers):
"""
Calculate the edges of wavelength bins given the centers.
The algorithm calculates bin edges as the midpoints between bin centers
and treats the first and last bins as symmetric about their centers.
Parameters
----------
centers : array_like
Sequence of bin centers. Must be 1D and have at least two values.
Returns
-------
edges : ndarray
Array of bin edges. Will be 1D and have one more value
than ``centers``.
"""
centers = np.asanyarray(centers)
if centers.ndim != 1:
raise ValueError('centers input array must be 1D.')
if centers.size < 2:
raise ValueError('centers input must have at least two values.')
edges = np.empty(centers.size + 1)
edges[1:-1] = (centers[1:] + centers[:-1]) / 2.
#compute the first and last by making them symmetric
edges[0] = centers[0] - (edges[1] - centers[0])
edges[-1] = centers[-1] + (centers[-1] - edges[-2])
return edges
def calculate_bin_widths(edges):
"""
Calculate the widths of wavelengths bins given their edges.
Parameters
----------
edges : array_like
Sequence of bin edges. Must be 1D and have at least two values.
Returns
-------
widths : ndarray
Array of bin widths. Will be 1D and have one less value than ``edges``.
"""
edges = np.asanyarray(edges)
if edges.ndim != 1:
raise ValueError('edges input array must be 1D.')
if edges.size < 2:
raise ValueError('edges input must have at least two values.')
return edges[1:] - edges[:-1]
def calculate_bin_centers(edges):
"""
Calculate the centers of wavelengths bins given their edges.
Parameters
----------
edges : array_like
Sequence of bin edges. Must be 1D and have at least two values.
Returns
-------
centers : ndarray
Array of bin centers. Will be 1D and have one less value than ``edges``.
"""
edges = np.asanyarray(edges, dtype=float)
if edges.ndim != 1:
raise ValueError('edges input array must be 1D.')
if edges.size < 2:
raise ValueError('edges input must have at least two values.')
centers = np.empty(edges.size - 1, dtype=float)
centers[0] = edges[:2].mean()
for i in range(1, centers.size):
centers[i] = 2. * edges[i] - centers[i - 1]
return centers
| {"/pysynphot/test/test_binning.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_spectral_element.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_thermback.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_catalog.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/catalog.py"], "/pysynphot/test/test_ticket164.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/test/test_wavecat.py": ["/pysynphot/wavetable.py"], "/pysynphot/test/test_ticket163.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_component_switch.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_box.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/units.py": ["/pysynphot/__init__.py"], "/pysynphot/spparser.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_analytic_spectrum.py": ["/pysynphot/spectrum.py"], "/pysynphot/wavetable.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket52.py": ["/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ui_tickets.py": ["/pysynphot/spectrum.py"], "/pysynphot/observationmode.py": ["/pysynphot/__init__.py", "/pysynphot/locations.py", "/pysynphot/tables.py"], "/pysynphot/test/test_spec.py": ["/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_ticket143.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_v06_tickets.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/commissioning/convert/conv_base.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py"], "/pysynphot/catalog.py": ["/pysynphot/__init__.py", "/pysynphot/Cache.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_observation.py": ["/pysynphot/observation.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_tokenizer.py": ["/pysynphot/spparser.py"], "/pysynphot/test/test_flip.py": ["/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket174.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket159.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket165.py": ["/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket139.py": ["/pysynphot/obsbandpass.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket126.py": ["/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket146.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket171.py": ["/pysynphot/locations.py"], "/commissioning/gencases.py": ["/pysynphot/__init__.py"], "/pysynphot/__init__.py": ["/pysynphot/spectrum.py", "/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/refs.py", "/pysynphot/locations.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_set_default_waveset.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket86.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/commissioning/basecase.py": ["/pysynphot/__init__.py", "/pysynphot/wavetable.py", "/pysynphot/observationmode.py"], "/pysynphot/test/test_mergewavesets.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/reddening.py", "/pysynphot/refs.py", "/pysynphot/spectrum.py"], "/pysynphot/renorm.py": ["/pysynphot/__init__.py", "/pysynphot/spectrum.py", "/pysynphot/refs.py", "/pysynphot/exceptions.py"], "/pysynphot/test/test_parsing.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_primary_area.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/tables.py"], "/pysynphot/test/test_cos.py": ["/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/obsbandpass.py": ["/pysynphot/observationmode.py", "/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_center_edges.py": ["/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/conftest.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket161.py": ["/pysynphot/obsbandpass.py"], "/pysynphot/test/test_exceptions.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket183.py": ["/pysynphot/obsbandpass.py"], "/commissioning/log2cases/parselog.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_ticket82.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket150.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_table.py": ["/pysynphot/exceptions.py", "/pysynphot/spectrum.py"], "/pysynphot/observation.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ticket21.py": ["/pysynphot/__init__.py", "/pysynphot/observationmode.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_ui.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py"], "/pysynphot/test/test_locations.py": ["/pysynphot/__init__.py"], "/commissioning/invalid_rn_cases.py": ["/pysynphot/__init__.py"], "/pysynphot/refs.py": ["/pysynphot/locations.py"], "/pysynphot/test/test_v05_tickets.py": ["/pysynphot/__init__.py", "/pysynphot/obsbandpass.py", "/pysynphot/reddening.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/commissioning/printversion.py": ["/pysynphot/__init__.py"], "/pysynphot/test/test_units.py": ["/pysynphot/__init__.py", "/pysynphot/binning.py", "/pysynphot/spectrum.py", "/pysynphot/units.py"], "/pysynphot/test/test_write.py": ["/pysynphot/catalog.py", "/pysynphot/obsbandpass.py", "/pysynphot/spectrum.py", "/pysynphot/spparser.py"], "/pysynphot/test/test_ticket157.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/commissioning/doscalars.py": ["/pysynphot/compat.py"], "/pysynphot/test/test_ticket166.py": ["/pysynphot/exceptions.py", "/pysynphot/observation.py", "/pysynphot/spectrum.py"], "/pysynphot/reddening.py": ["/pysynphot/spectrum.py", "/pysynphot/__init__.py"], "/pysynphot/test/test_ticket113.py": ["/pysynphot/spparser.py"], "/pysynphot/spectrum.py": ["/pysynphot/__init__.py", "/pysynphot/exceptions.py", "/pysynphot/renorm.py"], "/pysynphot/test/test_obsbandpass.py": ["/pysynphot/exceptions.py", "/pysynphot/obsbandpass.py", "/pysynphot/refs.py"], "/pysynphot/Cache.py": ["/pysynphot/locations.py"], "/pysynphot/extinction.py": ["/pysynphot/__init__.py"]} |
67,628 | jkelley79/data_engineering_project_capstone | refs/heads/master | /sql_queries.py | import configparser
# CONFIG
config = configparser.ConfigParser()
config.read('config.cfg')
# DROP TABLES
staging_travelers_table_drop = "DROP TABLE IF EXISTS staging_travelers"
staging_airports_table_drop = "DROP TABLE IF EXISTS staging_airports"
staging_cities_table_drop = "DROP TABLE IF EXISTS staging_cities"
staging_temperatures_table_drop = "DROP TABLE IF EXISTS staging_temperatures"
visa_table_drop = "DROP TABLE IF EXISTS visa_codes"
city_table_drop = "DROP TABLE IF EXISTS city"
airports_table_drop = "DROP TABLE IF EXISTS airports"
temperatures_table_drop = "DROP TABLE IF EXISTS temperatures"
statistics_table_drop = "DROP TABLE IF EXISTS statistics"
travelers_table_drop = "DROP TABLE IF EXISTS travelers"
# CREATE TABLES
staging_travelers_table_create= ("""
CREATE TABLE IF NOT EXISTS staging_travelers (
iata_code VARCHAR,
age INTEGER,
visa INTEGER,
gender VARCHAR,
year_of_birth INTEGER,
arrival_year INTEGER,
arrival_month INTEGER,
arrival_day INTEGER
)
""")
staging_airports_table_create= ("""
CREATE TABLE IF NOT EXISTS staging_airports (
iata_code VARCHAR,
type VARCHAR,
name VARCHAR,
elevation_ft FLOAT,
city VARCHAR,
long VARCHAR,
lat VARCHAR,
state VARCHAR
)
""")
staging_cities_table_create= ("""
CREATE TABLE IF NOT EXISTS staging_cities (
city VARCHAR,
median_age FLOAT,
cnt_male INTEGER,
cnt_female INTEGER,
population INTEGER,
cnt_veterans INTEGER,
cnt_foreign_born INTEGER,
avg_household FLOAT,
state VARCHAR,
cnt_white INTEGER,
per_white FLOAT,
cnt_his_latino INTEGER,
per_his_latino FLOAT,
cnt_asian INTEGER,
per_asian FLOAT,
cnt_amer_ind_ak_native INTEGER,
per_amer_ind_ak_native FLOAT,
cnt_black INTEGER,
per_black_afr_amer FLOAT,
per_male FLOAT,
per_female FLOAT,
per_veterans FLOAT,
per_foreign_born FLOAT
)
""")
staging_temperatures_table_create= ("""
CREATE TABLE IF NOT EXISTS staging_temperatures (
date VARCHAR,
avg_temp FLOAT,
avg_temp_uncertainty FLOAT,
city VARCHAR,
lat VARCHAR,
long VARCHAR,
month INTEGER,
year INTEGER,
average_temp_month FLOAT
)
""")
# STAGING TABLES
staging_travelers_copy = ("""
copy staging_travelers
from 's3://{}/{}/{}'
iam_role '{}'
format as csv;
""").format(config['S3']['BUCKET'],config['S3']['FOLDER'],config['OUTPUT']['TRAVELERS'],config['IAM_ROLE']['ARN'])
staging_cities_copy = ("""
copy staging_cities
from 's3://{}/{}/{}'
iam_role '{}'
format as csv
IGNOREHEADER 1;
""").format(config['S3']['BUCKET'],config['S3']['FOLDER'],config['OUTPUT']['CITIES'],config['IAM_ROLE']['ARN'])
staging_airports_copy = ("""
copy staging_airports
from 's3://{}/{}/{}'
iam_role '{}'
format as csv
IGNOREHEADER 1;
""").format(config['S3']['BUCKET'],config['S3']['FOLDER'],config['OUTPUT']['AIRPORTS'],config['IAM_ROLE']['ARN'])
staging_temperatures_copy = ("""
copy staging_temperatures
from 's3://{}/{}/{}'
iam_role '{}'
format as csv
IGNOREHEADER 1;
""").format(config['S3']['BUCKET'],config['S3']['FOLDER'],config['OUTPUT']['TEMPERATURES'],config['IAM_ROLE']['ARN'])
# FINAL TABLES
visa_table_create= ("""
CREATE TABLE IF NOT EXISTS visa_codes (
v_code INTEGER PRIMARY KEY,
v_description VARCHAR
)
""")
visa_table_insert= ("""
INSERT INTO visa_codes (v_code, v_description)
VALUES (1,'Business'),(2, 'Pleasure'),(3,'Student')
""")
city_table_create= ("""
CREATE TABLE IF NOT EXISTS city (
c_id BIGINT IDENTITY(1,1),
c_name VARCHAR,
c_state_code VARCHAR,
c_lat VARCHAR,
c_long VARCHAR
)
""")
city_table_insert = ("""
INSERT INTO city (c_name, c_state_code)
SELECT city, state from staging_airports group by city,state
""")
city_table_update = ("""
update city set c_lat = lat, c_long = long
from staging_airports
where city.c_name = staging_airports.city and city.c_state_code = staging_airports.state
"""
)
airports_table_create=("""
CREATE TABLE IF NOT EXISTS airports (
a_id BIGINT IDENTITY(1,1),
a_city_id BIGINT,
a_iata_code VARCHAR,
a_type VARCHAR,
a_name VARCHAR,
a_elevation_ft FLOAT
)
""")
airports_table_insert= ("""
INSERT INTO airports (a_city_id, a_iata_code, a_type, a_name, a_elevation_ft)
SELECT c.c_id, sa.iata_code, sa.type, sa.name, sa.elevation_ft
from staging_airports as sa
join city as c on sa.city = c.c_name and sa.state = c.c_state_code
""")
temperatures_table_create = ("""
CREATE TABLE IF NOT EXISTS temperatures (
t_city_id BIGINT,
t_date VARCHAR,
t_month INTEGER,
t_year INTEGER,
t_avg_temp FLOAT,
t_avg_temp_uncertainty FLOAT,
t_average_temp_month FLOAT
)
""")
temperatures_table_insert= ("""
INSERT INTO temperatures (t_city_id, t_date, t_month, t_year, t_avg_temp, t_avg_temp_uncertainty, t_average_temp_month)
SELECT c.c_id, st.date, st.month, st.year, st.avg_temp, st.avg_temp_uncertainty, st.average_temp_month
from staging_temperatures as st
join city as c on st.city = c.c_name
""")
statistics_table_create = ("""
CREATE TABLE IF NOT EXISTS statistics (
s_city_id BIGINT,
s_population INTEGER,
s_median_age FLOAT,
s_avg_household FLOAT,
s_cnt_male INTEGER,
s_per_male FLOAT,
s_cnt_female INTEGER,
s_per_female FLOAT,
s_cnt_veterans INTEGER,
s_per_veterans FLOAT,
s_cnt_foreign_born INTEGER,
s_per_foreign_born FLOAT,
s_cnt_white INTEGER,
s_per_white FLOAT,
s_cnt_his_latino INTEGER,
s_per_his_latino FLOAT,
s_cnt_asian INTEGER,
s_per_asian FLOAT,
s_cnt_amer_ind_ak_native INTEGER,
s_per_amer_ind_ak_native FLOAT,
s_cnt_black INTEGER,
s_per_black_afr_amer FLOAT
)
""")
statistics_table_insert = ("""
INSERT INTO statistics (s_city_id, s_population, s_median_age, s_avg_household, s_cnt_male, s_per_male,
s_cnt_female, s_per_female, s_cnt_veterans, s_per_veterans, s_cnt_foreign_born, s_per_foreign_born,
s_cnt_white, s_per_white, s_cnt_his_latino, s_per_his_latino, s_cnt_asian, s_per_asian,
s_cnt_amer_ind_ak_native, s_per_amer_ind_ak_native, s_cnt_black, s_per_black_afr_amer
)
SELECT c.c_id, population, median_age, avg_household, cnt_male, per_male,
cnt_female, per_female, cnt_veterans, per_veterans, cnt_foreign_born, per_foreign_born,
cnt_white, per_white, cnt_his_latino, per_his_latino, cnt_asian, per_asian,
cnt_amer_ind_ak_native, per_amer_ind_ak_native, cnt_black, per_black_afr_amer
from staging_cities as sc
join city as c on sc.city = c.c_name and sc.state = c.c_state_code
""")
travelers_table_create = ("""
CREATE TABLE IF NOT EXISTS travelers (
p_id BIGINT IDENTITY(1,1),
p_airport_id INTEGER,
p_age INTEGER,
p_visa_code INTEGER,
p_gender VARCHAR,
p_year_of_birth INTEGER,
p_arrival_year INTEGER,
p_arrival_month INTEGER,
p_arrival_day INTEGER
)
""")
travelers_table_insert = ("""
INSERT INTO travelers (p_airport_id, p_age, p_visa_code, p_gender, p_year_of_birth, p_arrival_year, p_arrival_month, p_arrival_day)
SELECT a_id, age, visa, gender, year_of_birth, arrival_year, arrival_month, arrival_day
from staging_travelers st
join airports on a_iata_code = st.iata_code
""")
# STAGING VALIDATION QUERIES
staging_airports_validate = "select count(*) from staging_airports"
staging_cities_validate = "select count(*) from staging_cities"
staging_temperatures_validate = "select count(*) from staging_temperatures"
staging_travelers_validate = "select count(*) from staging_travelers"
# VALIDATION QUERIES
airports_validate = "select count(*) from airports"
city_validate = "select count(*) from city"
temperatures_validate = "select count(*) from temperatures"
visa_validate = "select count(*) from visa_codes"
statistics_validate = "select count(*) from statistics"
travelers_validate = "select count(*) from travelers"
# QUERY LISTS
create_table_queries = [staging_travelers_table_create, staging_airports_table_create, staging_cities_table_create,
staging_temperatures_table_create, visa_table_create, city_table_create, airports_table_create, temperatures_table_create, statistics_table_create, travelers_table_create]
drop_table_queries = [staging_travelers_table_drop, staging_airports_table_drop, staging_cities_table_drop,
staging_temperatures_table_drop, visa_table_drop, airports_table_drop, city_table_drop, temperatures_table_drop, statistics_table_drop, travelers_table_drop]
copy_table_queries = [staging_travelers_copy, staging_cities_copy, staging_airports_copy, staging_temperatures_copy]
insert_table_queries = [visa_table_insert, city_table_insert, city_table_update, airports_table_insert, temperatures_table_insert, statistics_table_insert, travelers_table_insert]
validation_queries = [visa_validate, city_validate, airports_validate, temperatures_validate, statistics_validate, travelers_validate]
staging_validation_queries = [staging_airports_validate, staging_cities_validate, staging_temperatures_validate, staging_travelers_validate] | {"/etl.py": ["/sql_queries.py"]} |
67,629 | jkelley79/data_engineering_project_capstone | refs/heads/master | /dataprep.py | import pandas as pd
import datetime
import pyspark.sql.types as T
import pyspark.sql.functions as F
import configparser
from pyspark.sql import SparkSession
import os
import glob
import boto3
def prep_cities_data(config):
"""
Read cities data in from CSV and format into appropriate dataframe before exporting to CSV again
"""
# Enumerate the race codes to populate new columns
races = ['White', 'Hispanic or Latino', 'Asian', 'American Indian and Alaska Native', 'Black or African-American']
# Read in the CSV and then sort by state, city
citiesdf = pd.read_csv(config['INPUT']['CITIES'], sep=';')
citiesdf = citiesdf.sort_values(by=['State','City'])
# Split out race and counts into separate dataframe
citiesracesdf = citiesdf[['City', 'State','Race','Count']]
mergedcities = citiesdf
for race in races:
# Merge a count and percent column for each race into the main dataframe
racedf = citiesracesdf[citiesracesdf['Race'] == f"{race}"]
racedf = racedf.rename(columns = {'Count': f"{race} Count"}, inplace=False)
racedf = racedf.drop(['Race'], axis=1)
mergedcities = mergedcities.merge(racedf, on=['City', 'State'])
mergedcities[f"Percent {race}"] = mergedcities[f"{race} Count"] / mergedcities['Total Population']
# Merge percentages of population for various existing count columns
otherstats = ['Male Population', 'Female Population', 'Number of Veterans', 'Foreign-born']
for stat in otherstats:
mergedcities[f"Percent {stat}"] = mergedcities[f"{stat}"] / mergedcities['Total Population']
# Drop any duplicate records of City State since there will be for each race
final_cities = mergedcities.drop_duplicates(subset=["City", "State"]).sort_values(by=['City'])
# Drop additional unused columns
final_cities = final_cities.drop(columns=['State', 'Race','Count'])
# Convert column types
convert_dict = {'City': str,
'Male Population': int,
'Female Population': int,
'Total Population': int,
'Number of Veterans': int,
'Foreign-born': int,
'State Code': str
}
final_cities = final_cities.astype(convert_dict)
# Round percentages to two decimals
final_cities = final_cities.round({'Percent White': 2,
'Percent Asian': 2,
'Percent American Indian and Alaska Native': 2,
'Percent Black or African-American': 2,
'Percent Hispanic or Latino':2,
'Percent Male Population':2,
'Percent Female Population':2,
'Percent Number of Veterans':2,
'Percent Foreign-born':2
})
# Rename the columns
final_cities = final_cities.rename(columns={"City": "city",
"State Code": "state",
"Median Age": "median_age",
"Average Household Size": "avg_household",
"Male Population": "cnt_male",
'Percent Male Population': 'per_male',
"Female Population": "cnt_female",
'Percent Female Population':'per_female',
"Total Population": "population",
"Number of Veterans": "cnt_veterans",
'Percent Number of Veterans':"per_veterans",
"Foreign-born":"cnt_foreign_born",
'Percent Foreign-born':"per_foreign_born",
"White Count": "cnt_white",
"Percent White": "per_white",
"Asian Count": "cnt_asian",
'Percent Asian': "per_asian",
"American Indian and Alaska Native Count": "cnt_amer_ind_ak_native",
'Percent American Indian and Alaska Native': "per_amer_ind_ak_native",
"Black or African-American Count": "cnt_black",
'Percent Black or African-American': "per_black_afr_amer",
"Hispanic or Latino Count":"cnt_his_latino",
'Percent Hispanic or Latino':"per_his_latino",
})
# Output to CSV
final_cities.to_csv(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['CITIES'],index=False)
def prep_airport_data(config):
"""
Read airport data in from CSV and format into appropriate dataframe before exporting to CSV again
"""
# Read in data from csv
airportcodes = pd.read_csv(config['INPUT']['AIRPORTS'])
# Drop null IATA code columns and filter additional bad values
majorairports = airportcodes[airportcodes.iata_code.notnull()]
majorairports = majorairports[majorairports.iata_code != '0']
majorairports = majorairports[majorairports.iata_code != '-']
majorairports.sort_values(by='iata_code')
# Reduce the number of columns
clean_airports = majorairports.filter(['iata_code', 'type', 'name', 'elevation_ft', 'continent', 'iso_country', 'iso_region', 'municipality','coordinates'], axis=1)
# Convert coordinates to latitude and longitude separate columns
clean_airports[['long', 'lat']] = clean_airports["coordinates"].str.split(pat=",", expand=True)
clean_airports = clean_airports.drop('coordinates', axis=1)
# Drop any non-US based data from airports
clean_airports['iso_country'] = clean_airports['iso_country'].astype(str)
clean_airports = clean_airports[(clean_airports['iso_country']=="US")]
# Split up the data for iso_region to get state values
clean_airports[['country', 'state']] = clean_airports["iso_region"].str.split(pat="-", expand=True)
# Drop unused columns and rename others
clean_airports = clean_airports.drop(columns=['continent','iso_country','iso_region','country'])
clean_airports = clean_airports.rename(columns={"municipality": "city"})
clean_airports = clean_airports.sort_values(by=['city'], ascending=False)
# Convert the data in the columns to specific types
convert_dict = {'iata_code': str,
'type': str,
'name': str,
'city': str,
'lat': float,
'long': float,
'state': str
}
final_airports = clean_airports.astype(convert_dict)
# Round data appropriately
final_airports = final_airports.round({'lat': 2,'long':2})
# Format latitude/longitude into relevant N/S or E/W rather than negative numbers
final_airports["long"] = final_airports.apply(lambda x: f"{abs(x['long'])}W" if x['long'] < 0 else f"{x['long']}E", axis=1)
final_airports["lat"] = final_airports.apply(lambda x: f"{abs(x['lat'])}S" if x['lat'] < 0 else f"{x['lat']}N", axis=1)
# Output final data frame to CSV
final_airports.to_csv(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['AIRPORTS'],index=False)
def prep_temperature_data(config):
"""
Read temperature data in from CSV and format into appropriate dataframe before exporting to CSV again
"""
# Read in CSV file
temperaturedf = pd.read_csv(config['INPUT']['TEMPERATURES'])
temperaturedf = temperaturedf.sort_values(by=['dt'], ascending=False)
# Split out data columns for month and year
temperaturedf['month'] = pd.DatetimeIndex(temperaturedf['dt']).month
temperaturedf['year'] = pd.DatetimeIndex(temperaturedf['dt']).year
temperaturedf = temperaturedf.sort_values(by=['dt','City'], ascending=False)
# Drop any rows with empty columns
temperature_clean = temperaturedf.dropna()
# Drop data to only include US
temperature_clean = temperature_clean[(temperature_clean['Country']=="United States")]
# Drop extra columns and rename columns
final_temps = temperature_clean.drop(columns=['Country'])
final_temps = final_temps.rename(columns={
"dt": "date",
"AverageTemperature": "avg_temp",
"AverageTemperatureUncertainty": "avg_temp_uncertainty",
"City": "city",
"Latitude": "lat",
"Longitude": "long"
})
# Calculate the average month temperature across years by city
temp_averages = final_temps.groupby(['city', 'month'], as_index=False).agg(average_temp_month=pd.NamedAgg(column="avg_temp",aggfunc="mean"))
# Combine the results with the main dataframe and round values
combined_temps = pd.merge(final_temps, temp_averages, how='left', left_on=['city','month'], right_on = ['city','month'])
combined_temps = combined_temps.round({'avg_temp': 2,
'avg_temp_uncertainty': 2,
'average_temp_month': 2
})
# Output the data back to CSV
combined_temps.to_csv(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['TEMPERATURES'],index=False)
def prep_travelers_data(config):
"""
Read travelers data in from SAS files into Spark and export to CSV
"""
# Initiate spark connection
spark = SparkSession.builder.config("spark.jars.packages","saurfang:spark-sas7bdat:2.0.0-s_2.11")\
.enableHiveSupport().getOrCreate()
# Read data file into spark dataframe
i94_df = spark.read.format('com.github.saurfang.sas.spark').load(config['INPUT']['TRAVELERS'])
# Rename columns
travel_data = i94_df.selectExpr("i94port as iata_code", "arrdate as arrival_date","i94bir as age","i94visa as visa","biryear as year_of_birth","gender")
# Filter out any non-existant airport codes
travel_data = travel_data.filter(travel_data.iata_code != 'XXX')
# Convert the SAS date to a regular date type
start_date = datetime.datetime(1960, 1, 1)
convert_sas_date = F.udf(lambda x: start_date + datetime.timedelta(days = int(x)) if x is not None else None, T.DateType())
travel_data_clean = travel_data.withColumn('arrival_date', convert_sas_date('arrival_date'))
# Extract the arrival year, month, and day into separate columns
travel_data_clean = travel_data_clean.withColumn("arrival_year", F.date_format(F.col("arrival_date"), "y"))
travel_data_clean = travel_data_clean.withColumn("arrival_month", F.date_format(F.col("arrival_date"), "M"))
travel_data_clean = travel_data_clean.withColumn("arrival_day", F.date_format(F.col("arrival_date"), "d"))
# Drop additional column and filter out nulls from gender
travel_data_clean = travel_data_clean.drop(F.col('arrival_date'))
travel_data_clean = travel_data_clean.filter(travel_data_clean.gender.isNotNull())
# Cast datatypes to the appropriate column types
travel_data_final = travel_data_clean.selectExpr("iata_code", "cast(age as int) as age", "cast(visa as int) as visa","gender","cast(year_of_birth as int) as year_of_birth", "cast(arrival_year as int) as arrival_year", "cast(arrival_month as int) as arrival_month", "cast(arrival_day as int) as arrival_day")
# Export the dataframe to csv format
travel_data_final.write.mode("overwrite").csv(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['TRAVELERS'])
# Remove files that are not necessary for import to redshift
for f in os.listdir(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['TRAVELERS']):
if f.endswith('crc') or f.startswith('_'):
os.remove(f"{config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['TRAVELERS']}/{f}")
def upload_to_s3(config):
"""
Upload the data files to S3 to be loaded into Redshift
"""
s3 = boto3.resource('s3',
region_name=config['AWS']['REGION'],
aws_access_key_id=config['AWS']['KEY'],
aws_secret_access_key=config['AWS']['SECRET']
)
s3.Bucket(config['S3']['BUCKET']).upload_file(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['CITIES'],config['S3']['FOLDER'] + '/' + config['OUTPUT']['CITIES'])
s3.Bucket(config['S3']['BUCKET']).upload_file(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['AIRPORTS'],config['S3']['FOLDER'] + '/' + config['OUTPUT']['AIRPORTS'])
s3.Bucket(config['S3']['BUCKET']).upload_file(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['TEMPERATURES'],config['S3']['FOLDER'] + '/' + config['OUTPUT']['TEMPERATURES'])
for f in os.listdir(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['TRAVELERS']):
if f.endswith('csv'):
# Since travelers is a folder we don't need the trailing slash between the folder and the file name
s3.Bucket(config['S3']['BUCKET']).upload_file(config['OUTPUT']['FOLDER'] + '/' + config['OUTPUT']['TRAVELERS'] + f, config['S3']['FOLDER'] + '/' + config['OUTPUT']['TRAVELERS'] + f)
def main():
"""
Main program entry point to load file data into dataframes, manipulate and write back out into files for staging import
"""
try:
config = configparser.ConfigParser()
config.read('config.cfg')
print ('######## PREP CITY DATA ###########')
prep_cities_data(config)
print ('######## PREP AIRPORT DATA ###########')
prep_airport_data(config)
print ('######## PREP TEMPERATURE DATA ###########')
prep_temperature_data(config)
print ('######## PREP TRAVELERS DATA ###########')
prep_travelers_data(config)
print ('######## UPLOAD TO S3 ###########')
upload_to_s3(config)
except Exception as exc:
print('Unexpected error running program: {}'.format(exc))
if __name__ == "__main__":
main() | {"/etl.py": ["/sql_queries.py"]} |
67,630 | jkelley79/data_engineering_project_capstone | refs/heads/master | /etl.py | import configparser
import psycopg2
from sql_queries import copy_table_queries, insert_table_queries, validation_queries, staging_validation_queries
import json
def load_staging_tables(cur, conn):
"""
Loads staging data from S3 into staging tables via `copy_table_queries` list.
"""
for query in copy_table_queries:
try:
cur.execute(query)
conn.commit()
except Exception as exc:
print('Unexpected error running copy query: {} {}'.format(query, exc))
cur.execute('rollback')
def insert_tables(cur, conn):
"""
Selects data from staging tables and imports into new data model schema via `insert_table_queries` list.
"""
for query in insert_table_queries:
try:
cur.execute(query)
conn.commit()
except Exception as exc:
print('Unexpected error running insert query: {} {}'.format(query, exc))
cur.execute('rollback')
def validate_tables(cur, conn, queries):
"""
Prints results from a collection of queries
"""
for query in queries:
try:
cur.execute(query)
result = cur.fetchone()
print('{} - {}'.format(query, result[0]))
conn.commit()
except Exception as exc:
print('Unexpected error running validation query: {} {}'.format(query, exc))
cur.execute('rollback')
def main():
"""
Main program entry point to connect to Redshift cluster and load, insert and validate data in tables
"""
try:
config = configparser.ConfigParser()
config.read('config.cfg')
conn = psycopg2.connect("host={} dbname={} user={} password={} port={}".format(*config['CLUSTER'].values()))
cur = conn.cursor()
print ('######## LOADING STAGING DATA ###########')
load_staging_tables(cur, conn)
print ('######## STAGING DATA VALIDATAION ###########')
validate_tables(cur, conn, staging_validation_queries)
print ('######## LOADING DATA INTO STAR SCHEMA ###########')
insert_tables(cur, conn)
print ('######## TRANSFORMED DATA VALIDATAION ###########')
validate_tables(cur, conn, validation_queries)
conn.close()
except Exception as exc:
print('Unexpected error running program: {}'.format(exc))
if __name__ == "__main__":
main() | {"/etl.py": ["/sql_queries.py"]} |
67,637 | MikeMula/FaceRecogntionAuthorizationSystem | refs/heads/main | /enroll.py | import cv2
import os
import uuid
import numpy as np
from PIL import Image
NUM_OF_SAMPLES = 25
#
# Register a user into our database
def enroll(name, face_detector):
# Create unique ID for a user
ID = uuid.uuid4().int & (1<<32)-1
# Get a reference to a webcam
video_capture = cv2.VideoCapture(0)
# Set size of video window
video_capture.set(3, 500)
video_capture.set(4, 500)
N = 0
while True:
ret, frame = video_capture.read()
gray_scale = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # convert to grayscale image
face_locations = face_detector.detectMultiScale(gray_scale, 1.3, 5)
for (x, y, w, h) in face_locations:
cv2.rectangle(frame, (x, y), (x+w, y+h), (255,0,0), 2)
N += 1
# Save the image to our dataset
cv2.imwrite('./dataset/user.' + str(ID) + '.' + str(N) + '.jpg', gray_scale[y:y+h,x:x+w])
cv2.imshow('image', frame)
# Press 'q' on the keyboard to quit!
if cv2.waitKey(1) & 0xFF == ord('q'):
break
if N >= NUM_OF_SAMPLES:
break
# Insert user into user database
fp = open('users.txt', 'a')
fp.write(name + ' ' + str(ID) + '\n')
fp.close()
# clean up on exit
video_capture.release()
cv2.destroyAllWindows()
#
# Train the recognizer
def train(path, face_detector, recognizer):
# get the images from the dataset and the associated IDs
img_paths = [ os.path.join(path,f) for f in os.listdir(path) ]
face_samples = []
IDs = []
for img_path in img_paths:
PIL_img = Image.open(img_path).convert('L') # get a grayscale image
array_img = np.array(PIL_img, 'uint8')
ID = int(os.path.split(img_path)[-1].split('.')[1])
face_locations = face_detector.detectMultiScale(array_img)
for (x,y,w,h) in face_locations:
face_samples.append(array_img[y:y+h,x:x+w])
IDs.append(ID)
# train the recognizer
# IDs = [0]*len(face_locations)
recognizer.train(face_samples, np.array(IDs))
# save the model
recognizer.write('trainer.yml')
def main():
print('\n\n##################################################################')
print('#\n# Welcome to Rhezzon Security')
print('# Look into your camera, make sure your entire face is visible...')
print('#\n##################################################################')
# Get the user's name
name = input('\nEnter your name: ')
# Get the adaboost frontal face detector
face_detector = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# Path to dataset
path = 'dataset'
# Get the recognizer
recognizer = cv2.face.LBPHFaceRecognizer_create()
# Enroll a user
enroll(name, face_detector)
# Train the recognizer
train(path, face_detector, recognizer)
print("You have been succesffuly enrolled")
if __name__ == '__main__':
main() | {"/face_recognition.py": ["/arduino.py"]} |
67,638 | MikeMula/FaceRecogntionAuthorizationSystem | refs/heads/main | /face_recognition.py | import cv2
import numpy as np
import os
import time
import pyttsx3
import arduino
engine = pyttsx3.init()
engine.setProperty('volume',1.0)
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[33].id)
engine.setProperty('rate', 180)
#
# First time user should enroll first using enroll.py
#
# Match user to users in our database; return True if found, false otherwise
def matching(DATABASE):
recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read('trainer.yml')
face_detector = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
font = cv2.FONT_HERSHEY_SIMPLEX
id = 0
N = 0 # number of times user is recognized
capture_duration = 2.2 # duration in seconds of video capture
# Start video capture
video_capture = cv2.VideoCapture(0)
video_capture.set(3, 500)
video_capture.set(4, 500)
# minimum window size to be recognized as a face
minW = 0.1*video_capture.get(3)
minH = 0.1*video_capture.get(4)
start_time = time.time()
while( int(time.time() - start_time) < capture_duration ):
ret, frame = video_capture.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
face_locations = face_detector.detectMultiScale(
gray,
scaleFactor = 1.3,
minNeighbors = 5,
minSize = (int(minW), int(minH))
)
for (x,y,w,h) in face_locations:
cv2.rectangle(frame, (x,y), (x+w,y+h), (0,255,0), 2)
id, confidence = recognizer.predict(gray[y:y+h,x:x+w])
confidence = round(100-confidence)
# perfect match if confidence == 100
if(confidence >= 60):
N += 1
id = DATABASE[id]
confidence = f" {confidence}%"
else:
id = 'unknown'
confidence = f" {confidence}%"
# display results
cv2.putText(
frame,
str(id),
(x+5,y-5),
font,
1,
(255,255,255),
2
)
cv2.putText(
frame,
str(confidence),
(x+5,y+h-5),
font,
1,
(255,255,0),
1
)
cv2.imshow('camera', frame)
# Press 'q' on the keyboard to quit!
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Clean up on exit
video_capture.release()
cv2.destroyAllWindows()
if N >= 5:
return id
elif N == 0:
return id
else:
return None
# Grant a user access
def grantAccess(name):
arduino.openDoor('open')
engine.say('Access granted!')
engine.say(f'Welcome home {name}')
engine.runAndWait()
# Deny a user access
def denyAccess():
engine.say('Access Denied!')
engine.runAndWait()
def faceNotRecognized():
engine.say('No face was found. Please try again!')
engine.runAndWait()
def main():
print("PROGRAM STARTING")
# get the user DATABASE
DATABASE = dict()
fd = open('users.txt', 'r')
DATABASE[0] = 'unknown'
for line in fd:
line = line.split()
DATABASE[int(line[1])] = line[0]
fd.close()
# print(DATABASE)
name = matching(DATABASE)
if name == None:
faceNotRecognized()
elif( name != 'unknown' and name != 0):
grantAccess(name)
else:
denyAccess()
print("Match: ", name)
if __name__ == '__main__':
main() | {"/face_recognition.py": ["/arduino.py"]} |
67,639 | MikeMula/FaceRecogntionAuthorizationSystem | refs/heads/main | /arduino.py | import serial # import serial library
arduino = serial.Serial('/dev/cu.usbmodem14201', 9600) # create serial object named arduino
# Send 'open' command to arduino board
def openDoor(command):
print("Door opening...")
arduino.write(str.encode(command))
| {"/face_recognition.py": ["/arduino.py"]} |
67,640 | lognat0704/Progressive-Growing-Of-GANs-Pytorch- | refs/heads/master | /utils.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as nu
import torch.utils.data as d
def deconv(c_in, c_out, k_size, stride=1, pad=0, bn=True):
"""Custom deconvolutional layer for simplicity."""
layers = []
layers.append(nn.ConvTranspose2d(c_in, c_out, k_size, stride, pad))
if bn:
layers.append(nn.BatchNorm2d(c_out))
layers.append(nn.ReLU())
return nn.Sequential(*layers)
def conv(c_in, c_out, k_size, stride=1, pad=0, bn=True):
"""Custom convolutional layer for simplicity."""
layers = []
layers.append(nn.Conv2d(c_in, c_out, k_size, stride, pad))
if bn:
layers.append(nn.BatchNorm2d(c_out))
layers.append(nn.ReLU())
return nn.Sequential(*layers)
def calculate_deconv_output_dimension(input_dim,k_size,stride=1,pad=0):
return int((input_dim-1)*stride+k_size-2*pad)
def calculate_conv_output_dimension(input_dim,k_size,stride=1,pad=0):
return int((input_dim - k_size +2*pad)//stride+1)
def calculate_conv_kernel_size(input_dim,dimension_step_ratio,stride=1,pad=0):
return int(input_dim+2*pad-(input_dim*dimension_step_ratio-1)*stride)
def calculate_deconv_kernel_size(input_dim,dimension_step_ratio,stride=1,pad=0):
return int(2*pad+(input_dim*dimension_step_ratio)-stride*(input_dim-1))
def calculate_avgpool_kernel_size(input_dim,dimension_step_ratio,stride=0,pad=0):
return int(input_dim+2*pad-(input_dim*dimension_step_ratio-1)*stride)
def sum(input, axes, keepdim=False):
# probably some check for uniqueness of axes
if keepdim:
for ax in axes:
input = input.sum(ax, keepdim=True)
else:
for ax in sorted(axes, reverse=True):
input = input.sum(ax)
return input
class Noise(d.Dataset):
"""docstring for Noise"""
def __init__(self, length,dimension):
super(Noise, self).__init__()
self.length = length
self.data=torch.FloatTensor(*[self.length,1,dimension,dimension]).normal_(0,1)
def __getitem__(self,idx):
return self.data[idx]
def __len__(self):
return self.length
| {"/test_pytorch.py": ["/utils.py", "/Network.py"], "/Network.py": ["/utils.py"]} |
67,641 | lognat0704/Progressive-Growing-Of-GANs-Pytorch- | refs/heads/master | /test_pytorch.py | import torch
import torch.nn as nn
import numpy as np
from torch.autograd import Variable
import torch.nn.functional as F
from utils import *
# x=np.random.rand(100,1,2,2)
# x=torch.Tensor(x)
# y=sum(x,[2,3],keepdim=True)
# print (y.size())
# y=x.repeat(*[1,3,1,1])
# print (y.size())
# x.unsqueeze_(0)
# print (x.size())
# y=Variable(x)
# x=np.random.rand(1,2,2)
# x=torch.Tensor(x)
# x.unsqueeze_(0)
# y=Variable(x)
# from Network import Generator,Discriminator
# g=Generator(2,16,2)
# for i in range(2):
# g.add_smoothing_branch()
# g.add_layer(with_smoothing=True)
# print (g)
# d=Discriminator(2,16,0.5)
# for i in range(2):
# d.add_smoothing_branch()
# d.add_layer(with_smoothing=True)
# outputs=g(y)
# z=torch.mean((outputs-1)**2)
# z.backward()
# d.add_smoothing_branch()
# print (d(g(y,with_smoothing=True),with_smoothing=True))
from Network import Generator,Discriminator,PGGAN
# g=Generator(2,16,2)
# for i in range(1):
# g.add_smoothing_branch()
# g.add_layer(with_smoothing=True)
# g.add_smoothing_branch()
# d=Discriminator(2,16,0.5)
# for i in range(1):
# d.add_smoothing_branch()
# d.add_layer(with_smoothing=True)
# d.add_smoothing_branch()
# for i,j in zip(g.data_loader,d.data_loader):
# print (g(Variable(i),with_smoothing=True).size())
# print("##########################################")
# print (d(g(Variable(i),with_smoothing=True),with_smoothing=True).size())
# print("##########################################")
# # print (d(g(y)))
import torch
import torch.nn as nn
import torchvision.datasets as dsets
import torchvision.transforms as transforms
from torch.autograd import Variable
from utils import *
# Hyper Parameters
# num_epochs = 5
# batch_size = 100
# learning_rate = 0.001
pggan=PGGAN()
pggan.train() | {"/test_pytorch.py": ["/utils.py", "/Network.py"], "/Network.py": ["/utils.py"]} |
67,642 | lognat0704/Progressive-Growing-Of-GANs-Pytorch- | refs/heads/master | /Network.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from utils import *
import numpy as np
from torch.autograd import Variable
import torch
import torch.nn as nn
import torchvision.datasets as dsets
import torchvision.transforms as transforms
from torch.autograd import Variable
from PIL import Image
class Generator(nn.Module):
"""Generator:
Input : Noise of dimension least_size*least_size
Ouput : Single channel B/W Image of current output dimension
Parameters:
least_size : minimum size you want to start with
max_size : maximum size of output after training
size_step_ratio : ratio with which you want to increase output after each layer"""
def __init__(self,least_size,max_size,size_step_ratio,learning_rate=0.1,batch_size=100):
super(Generator, self).__init__()
self.least_size = least_size
self.max_size=max_size
self.size_step_ratio = size_step_ratio
self.input_dim=least_size
self.curr_max_size=self.input_dim*self.size_step_ratio
self.output_dim=None
self.c_in=1
self.c_out=self.c_in*2
self.layer_list=self.init_layers(self.least_size,self.curr_max_size,self.size_step_ratio)
self.model=self.make_model(self.layer_list)
self.optimizer=torch.optim.Adam(self.model.parameters(), lr=learning_rate)
self.smoothing_factor=0.2
self.batch_size=batch_size
self.will_be_next_layers=None
self.init_data()
self.learning_rate=learning_rate
def init_data(self):
"""Initialises data_loader"""
train_dataset=Noise(60000,self.least_size)
self.data_loader=torch.utils.data.DataLoader(dataset=train_dataset,
batch_size=self.batch_size,
shuffle=True)
def make_model(self,layers_list):
model=nn.Sequential(*layers_list)
return model
def init_layers(self,least_size,curr_max_size,size_step_ratio):
l_of_layer=[]
self.output_dim=self.input_dim*size_step_ratio
while True:
if self.output_dim<= curr_max_size:
k_size=calculate_deconv_kernel_size(self.input_dim,size_step_ratio)
l_of_layer.append(deconv(self.c_in,self.c_out,k_size))
self.input_dim=self.output_dim
self.output_dim=self.input_dim*size_step_ratio
self.c_in=self.c_out
self.c_out=self.c_in*2
else:
break
return l_of_layer
def add_layer(self,with_smoothing=False):
"""Adds layer to Generator"""
if not with_smoothing:
if self.output_dim<=self.max_size:
k_size=calculate_deconv_kernel_size(self.input_dim,self.size_step_ratio)
self.layer_list.append(deconv(self.c_in,self.c_out,k_size))
self.input_dim=self.input_dim*self.size_step_ratio
self.output_dim=self.input_dim*self.size_step_ratio
self.c_in=self.c_out
self.c_out=self.c_in*2
else:
print ("MAX SIZE REACHED")
self.model=self.make_model(self.layer_list)
else:
if self.will_be_next_layers==None:
print ("Smoothing branch not present, kindly call add_smoothing_branch")
return
self.input_dim=self.input_dim*self.size_step_ratio
self.output_dim=self.input_dim*self.size_step_ratio
self.c_in=self.c_out
self.c_out=self.c_in*2
self.model=self.make_model(self.will_be_next_layers)
self.layer_list=self.will_be_next_layers
self.will_be_next_layers=None
self.optimizer=torch.optim.Adam(self.model.parameters(), lr=self.learning_rate)
def add_smoothing_branch(self):
"""Adds smooothing branch with over time turns to new model"""
if self.output_dim<=self.max_size:
k_size=calculate_deconv_kernel_size(self.input_dim,self.size_step_ratio)
self.will_be_next_layers=self.layer_list+[deconv(self.c_in,self.c_out,k_size)]
self.optimizer=torch.optim.Adam(self.make_model(self.will_be_next_layers).parameters(), lr=self.learning_rate)
else:
print ("MAX SIZE REACHED")
def forward(self,input,with_smoothing=False):
if with_smoothing:
if self.will_be_next_layers==None:
print ("call add_smoothing_branch and run for few epochs and then call add_layer with Smoothing")
return
A=F.upsample((1-self.smoothing_factor)*self.model(input),scale_factor=self.size_step_ratio)
B=self.smoothing_factor*self.make_model(self.will_be_next_layers)(input)
# A=sum(A,[0,1],keepdim=True)
A=sum(A,[1],keepdim=True)
# B=sum(B,[0,1],keepdim=True)
B=sum(B,[1],keepdim=True)
C=(1-self.smoothing_factor)*A + self.smoothing_factor*B
return C.clamp(0,1)
else:
A=sum(self.model(input),[1],keepdim=True)
return A.clamp(0,1)
class Discriminator(nn.Module):
"""docstring for Discriminator"""
def __init__(self,least_size,max_size,size_step_ratio,learning_rate=0.1,batch_size=100):
super(Discriminator, self).__init__()
self.least_size = least_size
self.size_step_ratio = size_step_ratio
self.max_size = max_size
self.input_dim=int(self.least_size*(1/size_step_ratio))
self.curr_least_size=int(self.input_dim*self.size_step_ratio)
self.output_dim=int(self.input_dim*self.size_step_ratio)
self.least_size=self.least_size
self.batch_size=batch_size
self.init_data()
self.c_in=2
self.c_out=1
self.layer_list=self.init_layers()
self.model=self.make_model(self.layer_list)
self.optimizer=torch.optim.Adam(self.model.parameters(), lr=learning_rate)
self.will_be_next_layers=None
self.smoothing_factor=0.2
self.learning_rate=learning_rate
def init_data(self):
"""Initialises data_loader"""
t=transforms.Compose([transforms.Scale(self.input_dim),transforms.ToTensor()])
train_dataset = dsets.MNIST(root='./data/',
train=True,
transform=t,
download=True)
self.data_loader=torch.utils.data.DataLoader(dataset=train_dataset,
batch_size=self.batch_size,
shuffle=True)
def resize_data(self):
"""Changes data_loader"""
t=transforms.Compose([transforms.Scale(self.output_dim),transforms.ToTensor()])
train_dataset = dsets.MNIST(root='./data/',
train=True,
transform=t,
download=True)
self.data_loader=torch.utils.data.DataLoader(dataset=train_dataset,
batch_size=self.batch_size,
shuffle=True)
def make_model(self,layers_list):
model=nn.Sequential(*layers_list)
return model
def init_layers(self):
l_of_layer=[]
k_size=calculate_conv_kernel_size(self.input_dim,self.size_step_ratio)
l_of_layer.insert(0,conv(self.c_in,self.c_out,k_size))
self.output_dim=self.input_dim
self.input_dim=int(self.output_dim*(1/self.size_step_ratio))
self.c_out=self.c_in
self.c_in=self.c_out*2
return l_of_layer
def add_layer(self,with_smoothing=False):
if not with_smoothing:
if self.output_dim>=self.least_size:
k_size=calculate_conv_kernel_size(self.input_dim,self.size_step_ratio)
self.layer_list.insert(0,conv(self.c_in,self.c_out,k_size))
self.input_dim=self.input_dim*(1/self.size_step_ratio)
self.output_dim=self.input_dim*(1/self.size_step_ratio)
self.c_in=self.c_out
self.c_out=self.c_in//2
else:
print ("Least SIZE REACHED")
self.model=self.make_model(self.layer_list)
else:
if self.will_be_next_layers==None:
print ("Smoothing branch not present, kindly call add_smoothing_branch")
return
self.model=self.make_model(self.will_be_next_layers)
self.layer_list=self.will_be_next_layers
self.will_be_next_layers=None
self.optimizer=torch.optim.Adam(self.model.parameters(), lr=self.learning_rate)
def add_smoothing_branch(self):
if self.input_dim<=self.max_size:
k_size=calculate_conv_kernel_size(self.input_dim,self.size_step_ratio)
self.will_be_next_layers=[conv(self.c_in,self.c_out,k_size)]+self.layer_list
self.c_out=self.c_in
self.c_in=self.c_out*2
self.output_dim=self.input_dim
self.input_dim=int(self.output_dim*(1/self.size_step_ratio))
self.resize_data()
self.optimizer=torch.optim.Adam(self.make_model(self.will_be_next_layers).parameters(), lr=self.learning_rate)
else:
print ("MAX SIZE REACHED")
def forward(self,input,with_smoothing=False):
if with_smoothing:
if self.will_be_next_layers==None:
print ("call add_smoothing_branch and run for few epochs and then call add_layer with Smoothing")
return
input1=input.clone()
input_to_supply=input1.repeat(*[1,self.c_out,1,1])
# input_to_supply=np.tile(input1,(1,self.c_out,1,1))
# k_size=calculate_avgpool_kernel_size(self.input_dim,self.size_step_ratio)
k_size=2
avg_pool=nn.AvgPool2d(2,stride=0)
A=avg_pool(input)
# A1=A.data.numpy()
# A_to_supply=np.tile(A1,(1,int(self.c_out/2),1,1))
A_to_supply=A.repeat(*[1,int(self.c_out/2),1,1])
A=(1-self.smoothing_factor)*self.model(A_to_supply)
B=self.smoothing_factor*self.make_model(self.will_be_next_layers)(input_to_supply)
# A=sum(A,[1],keepdim=True)
# B=sum(B,[1],keepdim=True)
return A + B
else:
input1=input.clone()
input_to_supply=input1.repeat(*[1,self.c_out,1,1])
A=self.model(input_to_supply)
return A
class PGGAN(object):
"""docstring for PGGAN"""
def __init__(self, least_size=2,max_size=16,size_step_ratio=2,learning_rate=0.01,batch_size=100):
super(PGGAN, self).__init__()
self.least_size = least_size
self.size_step_ratio = size_step_ratio
self.max_size = max_size
self.G=Generator(least_size,max_size,size_step_ratio,learning_rate=learning_rate,batch_size=batch_size)
self.D=Discriminator(least_size,max_size,1/size_step_ratio,learning_rate=learning_rate,batch_size=batch_size)
def reset_grad(self):
"""Zero the gradient buffers."""
self.D.zero_grad()
self.G.zero_grad()
def train(self,num_of_epochs=100):
smoothing_on=False
for epoch in range(num_of_epochs):
avg_d_loss=0
avg_g_loss=0
for batch_no,(G_data,D_data) in enumerate(zip(self.G.data_loader,self.D.data_loader)):
self.reset_grad()
G_data=Variable(G_data)
D_data=Variable(D_data[0])
#resizing d_data to fit currently
# calculate _loss
if smoothing_on:
outputs=self.D(D_data,with_smoothing=True)
real_loss=torch.mean((outputs-1)**2)
outputs=self.G(G_data,with_smoothing=True)
fake_loss=torch.mean(self.D(outputs,with_smoothing=True)**2)
else:
outputs=self.D(D_data)
real_loss=torch.mean((outputs-1)**2)
outputs=self.G(G_data)
fake_loss=torch.mean(self.D(outputs)**2)
# Backprop + optimize
d_loss = real_loss + fake_loss
avg_d_loss+=d_loss.data
d_loss.backward(retain_graph=True)
#update weights
self.D.optimizer.step()
if smoothing_on:
outputs=self.G(G_data,with_smoothing=True)
fake_loss=torch.mean((self.D(outputs,with_smoothing=True)-1)**2)
else:
outputs=self.G(G_data)
fake_loss=torch.mean((self.D(outputs)-1)**2)
# Train G so that D recognizes G(z) as real.
g_loss = fake_loss
avg_g_loss+=g_loss.data
g_loss.backward(retain_graph=True)
#update weights
self.G.optimizer.step()
if batch_no%100==0:
print ("Batch ",batch_no,"||d_loss",d_loss.data,"||g_loss",g_loss.data)
print ("epoch",epoch)
#dump image
self.store_output(epoch)
print ("Avg G Loss",avg_g_loss,"Avg D Loss", avg_d_loss)
if smoothing_on:
self.G.smoothing_factor+=0.1
self.D.smoothing_factor+=0.1
if epoch%20==0 and epoch!=0:
self.G.add_layer(with_smoothing=True)
self.D.add_layer(with_smoothing=True)
self.G.smoothing_factor=0.2
self.D.smoothing_factor=0.2
smoothing_on=False
elif epoch%10==0 and epoch!=0:
self.G.add_smoothing_branch()
self.D.add_smoothing_branch()
smoothing_on=True
def store_output(self,epoch):
x=np.random.rand(1,1,2,2)
x=Variable(torch.Tensor(x))
image=self.G(x)
image_array=image.data.numpy()
image_array=image_array.reshape((image_array.shape[2],image_array.shape[3]))
im = Image.fromarray(image_array*255)
if im.mode != 'RGB':
im = im.convert('RGB')
im.save('Generator_Outputs/'+str(epoch)+"_gout.png")
| {"/test_pytorch.py": ["/utils.py", "/Network.py"], "/Network.py": ["/utils.py"]} |
67,654 | TrellixVulnTeam/Jumo-Test_CU93 | refs/heads/master | /loan_parameter.py |
class LoanParameter(object):
registry = {}
def __init__(self, name):
self.name = name
self.totals_loan = 0
self.count = 1
@classmethod
def create_item(cls, x):
try:
return cls.registry[x]
except KeyError:
new_item = cls(x)
cls.registry[x] = new_item
return new_item
def loan_amount(self, amt):
self.totals_loan = self.totals_loan + amt
def set_loan_type(self,type):
self.type = type
def set_number_of_loans(self):
self.count = self.count + 1
def get_number_of_loans(self):
return self.count
def getLoanAmount(self):
return self.totals_loan
def to_tuple(self):
return (self.name, self.totals_loan,self.count)
def __str__(self):
return self.name | {"/jumo_test.py": ["/loan_parameter.py"]} |
67,655 | TrellixVulnTeam/Jumo-Test_CU93 | refs/heads/master | /jumo_test.py | import pandas as pd
import dateutil.parser
from loan_parameter import LoanParameter
def read_from_csv():
file = r'Loans.csv'
df = pd.read_csv(file)
loanDataLists = []
for column in df.loc[0:, 'Network':'Amount']:
loanDataLists.append(df[column])
return loanDataLists
def get_totals_and_count(column_data, data_type):
count = 0
loadDataInterimList = []
for dataItem in column_data:
if data_type == 'Month':
dataItem = dateutil.parser.parse(dataItem).strftime('%B')
if LoanParameter.create_item(dataItem) not in loadDataInterimList:
nt = LoanParameter.create_item(dataItem)
nt.loan_amount(loanDataLists[3][count])
nt.set_loan_type(data_type)
loadDataInterimList.append(nt)
else:
bt = LoanParameter.create_item(dataItem)
bt.loan_amount(loanDataLists[3][count])
bt.set_number_of_loans()
count = count + 1
return pd.DataFrame.from_records([s.to_tuple() for s in loadDataInterimList],columns = ['Parameter','Total Amount of loans','Count of loans'])
def build_dataframes_and_write_csv():
loanParameters = ['Network', 'Month', 'Product']
dataframes = []
for param in loanParameters:
if param == 'Month':
df = get_totals_and_count(loanDataLists[1], param)
else:
df = get_totals_and_count(loanDataLists[loanParameters.index(param)], param)
dataframes.append(df)
pdoutput = pd.concat(dataframes, join='outer')
pdoutput.to_csv('Output.csv')
if __name__ == '__main__':
loanDataLists = read_from_csv()
build_dataframes_and_write_csv()
| {"/jumo_test.py": ["/loan_parameter.py"]} |
67,682 | dheerajreddy2020/CRUD_in_Flask | refs/heads/master | /details.py | from settings import *
import json
# Initializing our database
db = SQLAlchemy(app)
class Details(db.Model):
__tablename__ = 'details'
id = db.Column(db.Integer, primary_key=True)
studentid = db.Column(db.Integer, nullable=False)
firstname = db.Column(db.String(64), nullable=False)
lastname = db.Column(db.String(64), nullable=False)
dob = db.Column(db.String(64), nullable=False)
amountdue = db.Column(db.Integer, nullable=False)
def json(self):
return {'id': self.id, 'studentid': self.studentid, 'firstname': self.firstname, 'lastname': self.lastname, 'dob': self.dob, 'amountdue': self.amountdue}
def add_student(_studentid, _firstname, _lastname, _dob, _amountdue):
new_student = Details(studentid = _studentid, firstname = _firstname, lastname = _lastname, dob = _dob, amountdue = _amountdue)
db.session.add(new_student)
db.session.commit()
def get_all_students():
return [Details.json(student) for student in Details.query.all()]
def get_student(_id):
return [Details.json(Details.query.filter_by(id=_id).first())]
def update_student(_id, _studentid, _firstname, _lastname, _dob, _amountdue):
student_to_update = Details.query.filter_by(id=_id).first()
student_to_update.studentid = _studentid
student_to_update.firstname = _firstname
student_to_update.lastname = _lastname
student_to_update.dob = _dob
student_to_update.amountdue = _amountdue
db.session.commit()
def delete_student(_id):
Details.query.filter_by(id=_id).delete()
db.session.commit()
| {"/app.py": ["/details.py"]} |
67,683 | dheerajreddy2020/CRUD_in_Flask | refs/heads/master | /app.py | from details import db
db.create_all()
from details import *
# route to get all students
@app.route('/', methods=['GET'])
def get_home():
return jsonify({'Students':'This is Home Page'})
# route to get all students
@app.route('/students', methods=['GET'])
def get_students():
return jsonify({'Students': Details.get_all_students()})
@app.route('/students/<int:id>', methods=['GET'])
def get_student_by_id(id):
print(id);
return_value = Details.get_student(id)
return jsonify(return_value)
@app.route('/students', methods=['POST'])
def add_student():
'''Function to add new student to our database'''
request_data = request.get_json()
print(request_data);
Details.add_student(request_data["studentid"], request_data["firstname"],
request_data["lastname"], request_data["dob"],
request_data["amountdue"])
response = Response("Student added", 201, mimetype='application/json')
return response
# route to update student with PUT method
@app.route('/students/<int:id>', methods=['PUT'])
def update_student(id):
'''Function to edit student in our database using student id'''
request_data = request.get_json()
Details.update_student(id, request_data["studentid"], request_data["firstname"],
request_data["lastname"], request_data["dob"],
request_data["amountdue"])
response = Response("Srudent details Updated", status=200, mimetype='application/json')
return response
@app.route('/students/<int:id>', methods=['DELETE'])
def remove_student(id):
'''Function to delete student from our database'''
Details.delete_student(id)
response = Response("Student Deleted", status=200, mimetype='application/json')
return response
if __name__ == "__main__":
app.run(debug=True) | {"/app.py": ["/details.py"]} |
67,684 | mateuszdargacz/westing_sales | refs/heads/master | /westwing_sales/core/urls.py | # -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.conf.urls import url
from westwing_sales.core import views
__author__ = 'mateuszdargacz@gmail.com'
__date__ = '3/8/16 / 2:10 PM'
__git__ = 'https://github.com/mateuszdargacz'
urlpatterns = [
# URL pattern for the UserListView
url(
regex=r'^$',
view=views.HomeView.as_view(),
name='home'
),
]
| {"/westwing_sales/core/urls.py": ["/westwing_sales/core/__init__.py"], "/westwing_sales/core/views.py": ["/westwing_sales/core/get_products.py"]} |
67,685 | mateuszdargacz/westing_sales | refs/heads/master | /westwing_sales/core/__init__.py | # -*- coding: utf-8 -*-
__author__ = 'mateuszdargacz@gmail.com'
__date__ = '3/12/16 / 2:59 PM'
__git__ = 'https://github.com/mateuszdargacz'
| {"/westwing_sales/core/urls.py": ["/westwing_sales/core/__init__.py"], "/westwing_sales/core/views.py": ["/westwing_sales/core/get_products.py"]} |
67,686 | mateuszdargacz/westing_sales | refs/heads/master | /westwing_sales/core/get_products.py | # -*- coding: utf-8 -*-
import datetime
import json
import os
import re
import requests
from bs4 import BeautifulSoup
from django.conf import settings
__author__ = 'mateuszdargacz@gmail.com'
__date__ = '3/12/16 / 11:56 AM'
__git__ = 'https://github.com/mateuszdargacz'
CAMPAING_DETAILS_URL_CLASS = 'campaign-item__wrapping-link'
HEADERS = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/601.4.4',
'Referer': 'http://www.westwing.pl/campaign/',
'Cache-Control': 'max-age=0',
'Cookie': 'ww_uid=pimpmks%40o2.pl; optimizelyEndUserId=oeu1451915493817r0.49070222512818873; ww_jid=56e3fcc9aa3496.80226209; PHPSESSID=08o0a1e2esjqeo9neckb2m95b4; deviceName=desktop; deviceNameTS=1457781961; ww_login=1; 08b2c388d80a05b574a596507bac73d1=4dffd1159ec1113216fdc9c3adda7bac89a4035ea%3A4%3A%7Bi%3A0%3Bs%3A7%3A%221400525%22%3Bi%3A1%3Bs%3A13%3A%22pimpmks%40o2.pl%22%3Bi%3A2%3Bi%3A31536000%3Bi%3A3%3Ba%3A2%3A%7Bs%3A14%3A%22isPartialLogin%22%3Bb%3A1%3Bs%3A19%3A%22lastLoginFromDevice%22%3Bi%3A1457781961%3B%7D%7D; YII_CSRF_TOKEN=c2a4445f1e86fda5320819d1c6c5ba625649d8cd;'
}
URI = 'http://www.westwing.pl'
class MagicEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, (Product, ProductSet)):
a = obj.to_JSON()
return a
else:
return super(MagicEncoder, self).default(obj)
class Product(object):
name = ''
url = ''
image = ''
price = 0
sale = 0
@property
def sale_percentage(self):
return round(((self.price - self.sale) / self.price) * 100, 2)
def __str__(self):
return '%s: sale: %s%% price:%s ->%s' % (self.name, self.sale_percentage, self.price, self.url)
def __repr__(self):
return '%s: sale: %s%% price:%s ->%s' % (self.name, self.sale_percentage, self.price, self.url)
def to_JSON(self):
sale_percentage = self.sale_percentage
return dict(
name=self.name,
url=self.url,
image=self.image,
price=self.price,
sale=self.sale,
sale_percentage=sale_percentage
)
class ProductSet(object):
def add(self, *args):
self.products.add(*args)
def __init__(self):
self.products = set()
@property
def ordered(self):
return sorted(self.products, key=lambda x: x.sale_percentage, reverse=True)[:settings.MAX_FROM_CAMPAIGN]
@property
def average_percent(self):
ordered = self.ordered
if len(ordered):
return round(sum([prod.sale_percentage for prod in ordered]) / float(len(ordered)), 2)
def to_JSON(self):
average_percent = self.average_percent
return dict(
ordered=self.ordered,
average_percent=average_percent
)
def __repr__(self):
return str(len(self.products))
def get_json_from_script_variable(soup, variable_string):
"""
Helper for extracting json variable from script tag in html
:param response: requests.Response
:param variable_string: variable to extract
:return: variable json
"""
script = soup.find('script', text=re.compile('^\s*{}\s*=\s*\[.*?\]\s*;'.format(variable_string)))
if not script:
return None
json_text = re.search('^\s*{}\s*=\s*\[.*?\]\s*;'.format(variable_string),
script.string, flags=re.DOTALL | re.MULTILINE)
if json_text:
return json.loads(json_text.group(0).split('= ')[1][: -1])
def is_string_or_none(elem):
return elem and isinstance(elem, dict)
def get_campaign_products(campaign_url):
url = URI + campaign_url
product_set = ProductSet()
res = requests.get(url, headers=HEADERS)
selector = BeautifulSoup(res.content, 'html.parser')
product_lines = get_json_from_script_variable(selector, 'var productList')
if not product_lines:
print('DIDNT FOUND')
return product_set
products = list()
for product_line in product_lines:
products.extend([product.get('content') for product in product_line])
products = list(filter(is_string_or_none, products))
for prod in products:
try:
product = Product()
product.name = prod['name']
product.url = URI + prod['linkUrl']
product.image = prod['image']
product.price = round(float(prod['originalPrice'].strip()), 2)
product.sale = round(float(prod['price'].strip()), 2)
product_set.add(product)
except Exception as e:
print(prod, e)
break
print('^' * 30)
product_set.products = set(product_set.ordered)
return product_set
def get_all_products():
cache_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'products.json')
campaign_products = dict()
days_ago = 0
try:
stats = os.stat(cache_path)
mtime = datetime.datetime.fromtimestamp(stats.st_mtime)
now = datetime.datetime.now()
days_ago = (now - mtime).days
except Exception as e:
print('DATE ERROR', e)
if os.path.exists(cache_path) and days_ago < 1:
campaign_products = json.load(open(cache_path, 'r'))
else:
res = requests.get(URI + '/campaign/', headers=HEADERS)
selector = BeautifulSoup(res.content, 'html.parser')
campaigns = selector.find_all('a', class_=CAMPAING_DETAILS_URL_CLASS)
for campaign in campaigns:
campaign_name = campaign.find('div', class_='campaign-item__title-text').text
print('campain url', URI + campaign.get('href'))
product_set = get_campaign_products(campaign.get('href'))
if list(product_set.products):
campaign_products.update({
campaign_name: product_set
})
with open(cache_path, 'w+') as prod_file:
json.dump(campaign_products, prod_file, cls=MagicEncoder)
return campaign_products
| {"/westwing_sales/core/urls.py": ["/westwing_sales/core/__init__.py"], "/westwing_sales/core/views.py": ["/westwing_sales/core/get_products.py"]} |
67,687 | mateuszdargacz/westing_sales | refs/heads/master | /westwing_sales/core/views.py | # -*- coding: utf-8 -*-
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView
from westwing_sales.core.get_products import get_all_products
__author__ = 'mateuszdargacz@gmail.com'
__date__ = '3/12/16 / 2:59 PM'
__git__ = 'https://github.com/mateuszdargacz'
class HomeView(LoginRequiredMixin, TemplateView):
template_name = 'core/home.html'
def get(self, request, *args, **kwargs):
context = dict()
context.update(campaigns=get_all_products())
return self.render_to_response(context)
| {"/westwing_sales/core/urls.py": ["/westwing_sales/core/__init__.py"], "/westwing_sales/core/views.py": ["/westwing_sales/core/get_products.py"]} |
67,699 | VIVelev/nujo | refs/heads/master | /nujo/flow.py | ''' a chainable computation Flow
'''
from abc import abstractmethod
from copy import deepcopy
from itertools import chain
from typing import List, Union
from nujo.autodiff.tensor import Tensor
class _FlowMeta(type):
''' Flow's metaclass used to setup the computation flow
'''
def __call__(cls, *args, **kwargs):
''' Flow's __init__ '''
obj = type.__call__(cls, *args, **kwargs) # Call __init__
if len(obj) == 0: # If no chain has been setup
obj._register_parameters()
# Set the chain, starting with the current flow
obj = Flow(_chain=[obj])
return obj
class Flow(metaclass=_FlowMeta):
''' A chainable computation Flow
A Flow is just a sequance of functions (addition, multiplication, etc.)
that are grouped in a single object (Flow) and can be applied on a tensor.
Each nujo Flow has a list of flow objects (a chain) that a tensor will pass
through when the Flow is called on that tensor.
This allows the chaining of flows (connecting two or more chains together).
Parameters:
-----------
- name : string, idetifier of the current flow
'''
def __init__(self, name='Flow', _chain: List['Flow'] = []):
self.name = name
self._chain = _chain
if len(self._chain): # If there is a chain
self.name = self._generate_chain_name()
# setup methods
def _register_parameters(self) -> None:
''' Tensor parameters registration - called after Flow.__init__
Makes all tensors bounded to `self` diff enabled (sets their `diff`
to `True`).
Called only once, when the chain for the current flow is being created.
'''
for prop_name in dir(self):
prop = getattr(self, prop_name)
if isinstance(prop, Tensor):
prop.diff = True
def _generate_chain_name(self) -> str:
return ' >> '.join(map(lambda x: x.name, self._chain))
# parameters generators
def parameters(self) -> Tensor:
''' Generator for all the parameters of the current flow
'''
for param in self._total_parameters():
yield param
def _total_parameters(self) -> Tensor:
''' Returns an iterable of all the parameters of the current flow
Including those of other flows that are used in the current one
(namely other flows bounded to `self`).
'''
total_params = [self._current_parameters()]
for prop_name in dir(self):
prop = getattr(self, prop_name)
if isinstance(prop, Flow):
total_params.append(prop.parameters())
return chain(*total_params)
def _current_parameters(self) -> Tensor:
''' Generator for the current tensor parameters bounded to `self`
'''
for flow in self._chain:
for prop_name in dir(flow):
prop = getattr(flow, prop_name)
if isinstance(prop, Tensor):
yield prop
# API methods
def append(self, *flows: 'Flow') -> 'Flow':
''' Flow Append
Connect the current chain with those of `flows` by adding them
at the end.
Parameters:
-----------
- flows : varargs, the flows to append, sequantially
Returns:
--------
- flow : Flow, the total computation flow
'''
for flow in flows:
for chain_section in flow: # Iterate over the chain
# Connect with the current chain
self._chain.append(chain_section)
self.name = self._generate_chain_name() # Update the chain name
return self
def pop(self, idx=-1) -> 'Flow':
''' Flow Pop
Removes a flow (and it's chain) at a given index, defaults to
the last one (-1).
Parameters:
-----------
- idx : integer, index of the flow to remove
Returns:
--------
- flow : Flow, the total computation flow
'''
retflow = self._chain.pop(idx)
self.name = self._generate_chain_name()
return retflow
def copy(self) -> 'Flow':
''' Make a copy of the flow
'''
return deepcopy(self)
@abstractmethod
def forward(self, *args, **kwargs) -> Tensor:
''' Flow Forward
The flow computation is defined here.
'''
pass
# methods implementing the flow functionality
def __call__(self, *args, **kwargs) -> Tensor:
output = self[0].forward(*args, **kwargs)
for flow in self[1:]:
output = flow.forward(output, **kwargs)
return output
def __rshift__(self, other: 'Flow') -> 'Flow':
''' Chaining operator
Example:
>>> a = nj.Flow()
>>> b = nj.Flow()
>>> chained_flow = a >> b
>>> result = chained_flow(...)
>>> ...
'''
return Flow(_chain=[*list(self), *list(other)])
def __getitem__(self, key: Union[int, str]) -> 'Flow':
'''Access flows in the chain by index/name
Example:
>>> a = nj.Flow('A')
>>> b = nj.Flow('B')
>>> chained_flow = a >> b
>>> chained_flow[0] # a flow (chain section) can be get by index
'A' (this is the repr for `a`)
>>> chained_flow['A'] # can also be get by name
'A'
'''
if type(key) is str:
flow = next((x for x in self._chain if x.name == key), None)
if flow is not None:
return flow
else:
raise ValueError(f'Could not find a flow named: {key}')
else:
return self._chain[key]
def __iter__(self):
return iter(self._chain)
def __len__(self):
return len(self._chain)
def __repr__(self):
return '<|' + self.name + '>'
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,700 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/modes.py | __all__ = [
'DIFF_ENABLED',
'no_diff',
]
DIFF_ENABLED = True
''' This variable controls whether nujo to compute gradients
for the tensors in the computation graph:
- True = differentiation enabled, compute gradients
for the diff enabled (diff=True) tensors.
- False = differentiation disabled, do NOT compute gradients.
Another way to see it is:
- if DIFF_ENABLED is True, the computation graph is updated,
otherwise it is not.
'''
class no_diff():
''' No Differentiation block
Creates a block of code where no differentiation is done.
a.k.a. No gradients are computed for whatever tensor.
'''
def __enter__(self):
global DIFF_ENABLED
DIFF_ENABLED = False
def __exit__(self, type, value, traceback):
global DIFF_ENABLED
DIFF_ENABLED = True
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,701 | VIVelev/nujo | refs/heads/master | /examples/graph_visualization.py | import nujo as nj
from nujo.utils import ComputationGraphPlotter
x = nj.Tensor(10, name='X')
y = 7 * (x**2) + 5 * x + 3
cg_plot = ComputationGraphPlotter(filename='graph').create(y)
cg_plot.view()
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,702 | VIVelev/nujo | refs/heads/master | /tests/test_flow.py | import pytest
from nujo.autodiff.tensor import Tensor
from nujo.flow import Flow
# ====================================================================================================
# Test custom Flow creation
def test_custom_flow_creation():
class CustomFlow(Flow):
def __init__(self, name):
super(CustomFlow, self).__init__(name=name)
self.two = Tensor(2)
self.fourty_two = Tensor(42)
def forward(self, x):
return x**self.two + self.fourty_two
flow = CustomFlow('SomeFlowName')
assert flow.name == 'SomeFlowName'
assert repr(flow) == '<|SomeFlowName>'
assert flow[0].name == flow.name
assert flow(9) == 9**2 + 42
# ====================================================================================================
# Test Flow append and pop
def test_append(flows):
mul2, add1, supflow = flows
# -------------------------
mul2_add1 = mul2.copy().append(add1)
assert len(mul2_add1) == 2
assert mul2_add1[1] is add1[0]
assert mul2_add1[0].name == 'mul2'
assert mul2_add1[1].name == 'add1'
assert mul2_add1.name == 'mul2 >> add1'
assert mul2_add1(42) == 42 * 2 + 1
# -------------------------
supflow = supflow.append(mul2)
assert len(supflow) == 3
assert supflow[2] is mul2[0]
assert supflow[0].name == 'mul2'
assert supflow[1].name == 'add1'
assert supflow[2].name == 'mul2'
assert supflow.name == 'mul2 >> add1 >> mul2'
assert supflow(42) == (42 * 2 + 1) * 2
# -------------------------
supflow = supflow.append(supflow.copy())
assert len(supflow) == 6
assert supflow[5] is not mul2[0]
assert supflow[5].name == 'mul2'
assert supflow[0].name == 'mul2'
assert supflow[1].name == 'add1'
assert supflow[2].name == 'mul2'
assert supflow[3].name == 'mul2'
assert supflow[4].name == 'add1'
assert supflow[5].name == 'mul2'
assert supflow.name == 'mul2 >> add1 >> mul2 >> mul2 >> add1 >> mul2'
assert supflow(42) == ((42 * 2 + 1) * 2 * 2 + 1) * 2
def test_pop(flows):
mul2, add1, supflow = flows
poped = supflow.pop()
assert len(supflow) == 1
assert poped is add1[0]
assert supflow[0].name == 'mul2'
assert supflow.name == 'mul2'
assert supflow(42) == mul2(42) == 42 * 2
# ====================================================================================================
# Test Flow forward, chaining, selection
def test_forward(flows):
mul2, add1, supflow = flows
assert mul2(42) == 42 * 2
assert add1(42) == 42 + 1
assert supflow(42) == 42 * 2 + 1
def test_chaining(flows):
_, _, supflow = flows
assert supflow.name == 'mul2 >> add1'
assert repr(supflow) == '<|mul2 >> add1>'
assert len(supflow) == 2
def test_getitem(flows):
mul2, add1, supflow = flows
assert supflow[0] is mul2[0]
assert supflow[1] is add1[0]
assert supflow['mul2'] is mul2[0]
assert supflow['add1'] is add1[0]
with pytest.raises(ValueError):
supflow['random_name']
# ====================================================================================================
# Test parameters
def test_parameters(flows):
mul2, add1, supflow = flows
mul2_param = next(mul2.parameters())
assert mul2_param == 2
assert mul2_param.diff
add1_param = next(add1.parameters())
assert add1_param == 1
assert add1_param.diff
# -------------------------
supflow_params = supflow.parameters()
param = next(supflow_params)
assert param is mul2_param
param = next(supflow_params)
assert param is add1_param
# ====================================================================================================
# Unit Test fixtures
@pytest.fixture
def flows():
class Mul2(Flow):
def __init__(self, name):
super(Mul2, self).__init__(name=name)
self.two = Tensor(2)
def forward(self, x):
return x * self.two
class Add1(Flow):
def __init__(self, name):
super(Add1, self).__init__(name=name)
self.one = Tensor(1)
def forward(self, x):
return x + self.one
mul2 = Mul2('mul2')
add1 = Add1('add1')
supflow = mul2 >> add1
return mul2, add1, supflow
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,703 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/__init__.py | ''' nujo's core Reverse-mode Automatic Differentiation module
'''
from nujo.autodiff.function import Function
from nujo.autodiff.modes import no_diff
from nujo.autodiff.tensor import Tensor
__all__ = [
'Function',
'no_diff',
'Tensor',
]
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,704 | VIVelev/nujo | refs/heads/master | /nujo/nn/layers.py | from functools import lru_cache
from typing import Tuple, Union
from nujo.autodiff._functions._transform import _ConstPad, _Im2col
from nujo.autodiff.tensor import Tensor
from nujo.flow import Flow
from nujo.init.random import randn
__all__ = [
'Linear',
'Conv2d',
'ConstPad2d',
]
# ====================================================================================================
class Linear(Flow):
''' Linear Layer
f(x) = Wx + b
Parameters:
-----------
- in_features : int, dim of input variables
- out_features : int, wanted dim of output variables
- bias : bool, whether to train a bias term or no
- name : string, identifier for the current layer
'''
def __init__(self,
in_features: int,
out_features: int,
bias=True,
name='Linear'):
super(Linear,
self).__init__(name=f'{name}({in_features}, {out_features})')
self.in_features = in_features
self.out_features = out_features
self.bias = bias
self.W = randn(self.out_features,
self.in_features,
name=self.name + '.W')
if self.bias:
self.b = randn(self.out_features, 1, name=self.name + '.bias')
def forward(self, x: Tensor) -> Tensor:
out = self.W @ x
return out + self.b if self.bias else out
# ====================================================================================================
class Conv2d(Flow):
''' A 2-dimensional convolutional layer
Applies a 2D convolution over an input signal composed of
several input planes.
More info: https://cs231n.github.io/convolutional-networks/
Parameters:
-----------
- in_channels : int, number of channels in the input image
- out_channels : int, number of channels produced by the convolution
(in other word, the number of kernels)
- kernel_size : int or tuple, size of the convolving kernel
- stride : int or tuple, optional, stride of the convolution. Default: 1
- padding : int or tuple, optional, zero-padding added to both sides of
the input. Default: 0
- dilation : int or tuple, optional - spacing between kernel elements.
Default: 0
- bias : bool, optional, if True, adds a learnable bias to the output.
Default: True
- name : string, identifier for the current layer
'''
def __init__(self,
in_channels: int,
out_channels: int,
kernel_size: Union[int, Tuple[int, int]],
stride: Union[int, Tuple[int, int]] = 1,
padding: Union[int, Tuple[int, int]] = 0,
dilation: Union[int, Tuple[int, int]] = 0,
bias=True,
name='Conv2d'):
super(Conv2d,
self).__init__(name=f'{name}({in_channels}, {out_channels})')
self.in_channels = in_channels
self.out_channels = out_channels
self.kernel_size = kernel_size if isinstance(
kernel_size, tuple) else (kernel_size, kernel_size)
self.stride = stride if isinstance(stride, tuple) else (stride, stride)
self.padding = padding if isinstance(padding, tuple) else (padding,
padding)
self.dilation = dilation if isinstance(dilation, tuple) else (dilation,
dilation)
self.bias = bias
# Define trainable parameters
self.kernels = randn(self.out_channels,
self.in_channels,
*self.kernel_size,
name=self.name + '.kernels')
if self.bias:
self.b = randn(self.out_channels, 1, name=self.name + '.bias')
self._padding_layer = ConstPad2d(self.padding,
value=0,
name=self.name + '.padding')
def forward(self, x: Tensor) -> Tensor:
batch_size, channels, height, width = x.shape
assert channels == self.in_channels
# Apply padding
x_padded = self._padding_layer(x)
# Image to column transformation
x_col = _Im2col(x_padded, self.kernel_size, self.stride,
self.dilation)()
kernels_col = self.kernels.reshape(self.out_channels, -1)
# Apply the kernels
out_col = kernels_col @ x_col
if self.bias:
out_col += self.b
# Reshape
output_shape = self.get_output_shape(height, width)
return out_col.reshape(*output_shape, batch_size)\
.transpose(3, 0, 1, 2)
@lru_cache(maxsize=64)
def get_output_shape(self, height: int,
width: int) -> Tuple[int, int, int]:
''' Cached output shape calculation
'''
# Obtain needed information
pad_height, pad_width = self.padding
kernel_height, kernel_width = self.kernel_size
stride_height, stride_width = self.stride
dilation_height, dilation_width = self.dilation
return (
self.out_channels,
((height + pad_height * 2 - dilation_height *
(kernel_height - 1) - kernel_height) // stride_height) + 1,
((width + pad_width * 2 - dilation_width *
(kernel_width - 1) - kernel_width) // stride_width) + 1,
)
# ====================================================================================================
class ConstPad2d(Flow):
''' Pads the input tensor boundaries with a constant value.
Parameters:
-----------
- padding : int or tuple of two ints, specifying the padding
before and after.
- value : float, the value by which to pad
- name : string, identifier for the current layer
'''
def __init__(self,
padding: Union[int, Tuple[int, int]],
value: float = 0,
name='ConstPad2d'):
super(ConstPad2d, self).__init__(name=f'{name}({padding})')
self.padding = padding if isinstance(padding, tuple) else (padding,
padding)
self.value = value
def forward(self, x: Tensor) -> Tensor:
return _ConstPad(x, (
(0, 0),
(0, 0),
(self.padding[0], self.padding[0]),
(self.padding[1], self.padding[1]),
),
value=self.value)()
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,705 | VIVelev/nujo | refs/heads/master | /nujo/optim/__init__.py | ''' nujo's optimization module
Various optimizers used in machine learning problems are defined here.
Check out the following link for more info about the optimizers:
http://ruder.io/optimizing-gradient-descent/index.html
'''
from nujo.optim.optimizer import Optimizer
from nujo.optim.optimizers import *
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,706 | VIVelev/nujo | refs/heads/master | /nujo/math/aggregate.py | from typing import Optional
from numpy import prod as np_prod
from numpy import sum as np_sum
from nujo.autodiff._functions._aggregate import _InnerProd, _InnerSum
from nujo.autodiff.tensor import Tensor
__all__ = [
'sum',
'prod',
'mean',
]
# ====================================================================================================
def sum(*inputs: Tensor, dim: Optional[int] = None, keepdim=False) -> Tensor:
''' Summation of tensor(s)
Parameters:
-----------
- inputs : varargs, tensors to be summed;
if a single tensor is passed, its elements will be summed
- dim : int (optional), dimension to reduce over
- keepdim : bool, whether to keep `dim`
Returns:
--------
- result : Tensor
'''
if len(inputs) == 1:
return _InnerSum(inputs[0], dim=dim, keepdim=keepdim)()
else:
return np_sum(inputs, axis=dim, keepdims=keepdim)
# ====================================================================================================
def prod(*inputs: Tensor, dim: Optional[int] = None, keepdim=False) -> Tensor:
''' Product of tensor(s)
Parameters:
-----------
- inputs : varargs, tensors to be multiplied;
if a single tensor is passed, its elements will be multiplied
- dim : int (optional), dimension to reduce over
- keepdim : bool, whether to keep `dim`
Returns:
--------
- result : Tensor
'''
if len(inputs) == 1:
return _InnerProd(inputs[0], dim=dim, keepdim=keepdim)()
else:
return np_prod(inputs, axis=dim, keepdims=keepdim)
# ====================================================================================================
def mean(*inputs: Tensor, dim: Optional[int] = None, keepdim=False) -> Tensor:
''' Mean of tensor(s)
Parameters:
-----------
- inputs : varargs, tensors to compute the mean of;
if a single tensor is passed, the mean of its elements will be computed
- dim : int (optional), dimension to reduce over
- keepdim : bool, whether to keep `dim`
Returns:
--------
- result : Tensor
'''
if len(inputs) == 1:
n = np_prod(inputs[0].shape) if dim is None else inputs[0].shape[dim]
return _InnerSum(inputs[0], dim=dim, keepdim=keepdim)() / n
else:
return np_sum(inputs, axis=dim, keepdims=keepdim) / len(inputs)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,707 | VIVelev/nujo | refs/heads/master | /nujo/objective/loss.py | from typing import Optional
from nujo.flow import Flow
from nujo.math.aggregate import mean, sum
__all__ = [
'QualitativeLoss',
'QuantitativeLoss',
]
# ====================================================================================================
class _Loss(Flow):
''' Base Loss Function Class
Do NOT inherit this class directly. Instead, inherit either
`QualitativeLoss` or `QuantitativeLoss`, depending on the task
for which you implement the loss function (classification/regression).
Parameters:
-----------
- dim : int (optional), the dimension along which to reduce
- keepdim : bool, whether to keep the dimension
- reduction, string (optional), reduction function ('sum', 'mean', etc.)
'''
def __init__(self,
dim: Optional[int] = None,
keepdim=True,
reduction: Optional[str] = None):
super(_Loss, self).__init__(name=self.__class__.__name__)
self.dim = dim
self.keepdim = keepdim
if reduction == 'sum':
self.reduction_fn = sum
elif reduction == 'mean':
self.reduction_fn = mean
else: # if None
self.reduction_fn = lambda x: x
# ====================================================================================================
class QualitativeLoss(_Loss):
''' Base Qualitative (Classification) Loss Function Class
If you want to implement a custom loss function for classification,
inherit this class.
Parameters:
-----------
- dim : int (optional), the dimension along which to reduce
- keepdim : bool, whether to keep the dimension
- reduction, string (optional), reduction function (default: 'sum')
'''
def __init__(self,
dim: Optional[int] = None,
keepdim=True,
reduction='sum'):
super(QualitativeLoss, self).__init__(dim, keepdim, reduction)
# ====================================================================================================
class QuantitativeLoss(_Loss):
''' Base Quantitative (Regression) Loss Function Class
If you want to implement a custom loss function for regression,
inherit this class.
Parameters:
-----------
- dim : int (optional), the dimension along which to reduce
- keepdim : bool, whether to keep the dimension
- reduction, string (optional), reduction function (default: 'mean')
'''
def __init__(self,
dim: Optional[int] = None,
keepdim=True,
reduction='mean'):
super(QuantitativeLoss, self).__init__(dim, keepdim, reduction)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,708 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/_node.py | from itertools import count
from typing import Any
class _Node:
''' A Node in the computation graph
Can be either a Function or a Tensor.
Parameters:
-----------
- children : varargs, the children of the node
- name : string, representation of the node
'''
_id_generator = count()
def __init__(self, *children: Any, name='Node'):
self.children = list(children)
self.name = name
self.id: int = next(_Node._id_generator)
def __eq__(self, other):
return self.id == other.id
def __repr__(self):
return f'<{self.name}>'
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,709 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/tensor.py | from numbers import Number
from typing import List, Tuple, Union
from numpy import array, empty, ndarray
import nujo.autodiff.modes as modes
from nujo.autodiff._node import _Node
from nujo.autodiff._utils import _if_not_none
class Tensor(_Node):
''' Tensor - a multi-dimensional array
Tensors are the main units of data in nujo.
They "flow" in the computation graph. :)
Tensors can be either constants or trainable weights,
depending on whether gradients are computed for the given tensor.
Parameters:
-----------
- value : value, numerical value of the tensor
- diff : boolean, whether to compute gradients for the tensor
- creator : nujo function, that created this tensor;
the only child of a tensor
- name : string, representation of the tensor
'''
def __init__(self,
value: Union['Tensor', ndarray, List[Number], Number],
diff=False,
creator=None,
name='Tensor'):
super(Tensor, self).__init__(*_if_not_none(creator), name=name)
self._value: ndarray = None
self.value = value # set value
self.diff = diff
self.creator = creator
# Outputs of the functions the current tensor is input to.
# Used for backpropagation of the gradients.
self.parents_outputs: List['Tensor'] = []
# Gradient of the current tensor
self._grad: 'Tensor' = None
# Transposed tensor cache
self._T: 'Tensor' = None
self._prev_value: ndarray = None
@property
def value(self):
return self._value
@value.setter
def value(self, value: Union['Tensor', ndarray, List[Number], Number]):
if isinstance(value, Tensor):
self._value = value.value
elif isinstance(value, ndarray):
self._value = value
else:
self._value = array(value)
@value.deleter
def value(self):
del self._value
@property
def grad(self) -> 'Tensor':
if self._grad is None:
self._grad = Tensor(empty(self._value.shape),
name=f'grad[{self.name}]')
return self._grad
# Shape and shape manipulations
@property
def shape(self) -> Tuple[int, ...]:
return self._value.shape
@property
def T(self) -> 'Tensor':
# Only transpose if something has changed
if (self._value != self._prev_value).any():
self._T = self.transpose()
self._prev_value = self._value
return self._T
def transpose(self, *dims: int) -> 'Tensor':
from nujo.autodiff._functions._transform import _Transpose
return _Transpose(self, dims)()
def reshape(self, *shape: int) -> 'Tensor':
from nujo.autodiff._functions._transform import _Reshape
return _Reshape(self, shape)()
def squeeze(self, dim=-1) -> 'Tensor':
if dim < 0:
num_dims = len(self._value.shape)
if dim < -num_dims:
dim = num_dims
else:
dim += num_dims
return self.reshape(*self._value.shape[:dim],
*self._value.shape[dim + 1:])
def unsqueeze(self, dim=-1) -> 'Tensor':
if dim < 0:
num_dims = len(self._value.shape)
if dim < -num_dims:
dim = 0
else:
if dim == -1:
dim += 1
dim += num_dims
return self.reshape(*self._value.shape[:dim], 1,
*self._value.shape[dim:])
# Gradient computation
def _compute_grad_from(self,
poutput: 'Tensor') -> Union['Tensor', ndarray]:
''' Computes the gradient of `self` w.r.t. the output of the computation
graph from `poutput` (using the path of computations from `poutput`)
In other words, this functions returns:
(dOutput / dPoutput) * (dPoutput / dSelf)
'''
# Find the index of the children which gradient should be computed
# (a.k.a. find the index of `self` in `poutput.creator.children`)
idx = next(i for i, v in enumerate(poutput.creator.children)
if v is self)
if poutput._grad.diff:
# Pass a diff enabled tensor to the backward call,
# thus recording grad computations in the computation
# graph, which enables higher-order differentiation.
grad = poutput.creator.backward(idx, poutput._grad)
# Check if `self` is scalar and needs to be averaged
if self._value.shape != () and\
self._value.shape[-1] == 1:
# Record the mean in the computation graph
from nujo.math.aggregate import mean
grad = mean(grad, dim=-1, keepdim=True)
else:
# Do not leave a trace in the computation graph!
# Use numpy arrays! :)
grad = poutput.creator.backward(idx, poutput._grad._value)
# Check if `self` is scalar and needs to be averaged
if self._value.shape != () and\
self._value.shape[-1] == 1:
grad = grad.mean(axis=-1, keepdims=True)
return grad
def compute_grad(self) -> None:
if modes.DIFF_ENABLED and self.diff:
# Make sure grad is Tensor (`grad property call`) and init value
if self._grad is None:
self.zero_grad(propagate=False)
# Top-parent grad
if len(self.parents_outputs) == 0:
self._grad._value += 1
return
for poutput in self.parents_outputs:
curr_grad = self._compute_grad_from(poutput)
if self._grad.diff:
# Record grad computations in the computation graph
self._grad += curr_grad
else:
self._grad._value += curr_grad
def zero_grad(self, propagate=True) -> None:
self.grad._value.fill(0)
if propagate:
for poutput in self.parents_outputs:
poutput.zero_grad()
def backward(self, _debug=False) -> None:
''' It uses Breadth First Search to traverse the computation graph
and compute the gradient for each differentiable Tensor in the graph.
'''
nodes_to_visit: List['Tensor'] = [self]
if _debug:
i = 1
while nodes_to_visit:
node = nodes_to_visit.pop()
node.compute_grad()
if _debug:
nstr = f' [{i}]'
node.name += nstr if nstr not in node.name else ''
i += 1
if node.creator:
for child in node.creator.children:
# Avoid visiting the same node twice
if all(child is not node for node in nodes_to_visit):
nodes_to_visit.insert(0, child)
# Useful methods
def all(self) -> ndarray:
return self._value.all()
def any(self) -> ndarray:
return self._value.any()
def __getitem__(self, position: Union[int, Tuple[int, ...]]):
return Tensor(self._value[position],
diff=self.diff,
creator=self.creator,
name=f'{self.name}[{position}]')
def __setitem__(self, position: Union[int, Tuple[int, ...]],
value: Union['Tensor', ndarray, List[Number], Number]):
# TODO: This is a naive implementation. Fix it.
self._value[position] = value
def __hash__(self):
return self.id
# Static evaluation operator
def __ilshift__(
self, other: Union['Tensor', ndarray, List[Number],
Number]) -> 'Tensor':
''' In-place assignment operator: `<<=`
Transfering key properties from `other` to `self`.
Essentially a shortcut for:
>>> self.children = other.children
>>> self.creator = other.creator
>>> self.value = other.value
>>> self.grad = other.grad
'''
self.children = getattr(other, 'children', None)
if self.children:
try:
self.children.remove(self)
except ValueError: # self is not in children
pass
self.creator = getattr(other, 'creator', None)
if self.creator:
try:
self.creator.children.remove(self)
except ValueError: # self is not in children
pass
self._value = getattr(other, 'value', other)
# Transfer the gradient
self._grad = getattr(other, 'grad', None)
return self
# Comparison operations
def __lt__(self, other):
return self._value < getattr(other, 'value', other)
def __le__(self, other):
return self._value <= getattr(other, 'value', other)
def __eq__(self, other):
return self._value == getattr(other, 'value', other)
def __ne__(self, other):
return self._value != getattr(other, 'value', other)
def __gt__(self, other):
return self._value > getattr(other, 'value', other)
def __ge__(self, other):
return self._value >= getattr(other, 'value', other)
# Arithmetic operations
def __add__(self, other):
from nujo.autodiff._functions._elementary import _Addition
return _Addition(self, other)()
def __radd__(self, other):
return self.__add__(other)
def __neg__(self):
from nujo.autodiff._functions._elementary import _Negation
return _Negation(self)()
def __sub__(self, other):
return self.__add__(other.__neg__())
def __rsub__(self, other):
return self.__neg__().__add__(other)
def __mul__(self, other):
from nujo.autodiff._functions._elementary import _Multiplication
return _Multiplication(self, other)()
def __rmul__(self, other):
return self.__mul__(other)
def __truediv__(self, other):
from nujo.autodiff._functions._elementary import _Reciprocal
return self.__mul__(_Reciprocal(other)())
def __rtruediv__(self, other):
from nujo.autodiff._functions._elementary import _Reciprocal
return _Reciprocal(self)().__mul__(other)
def __pow__(self, other):
from nujo.autodiff._functions._elementary import _Power
return _Power(self, other)()
def __rpow__(self, other):
from nujo.autodiff._functions._elementary import _Power
return _Power(other, self)()
# More complex arithmetic operations
def __matmul__(self, other):
from nujo.autodiff._functions._elementary import _MatrixMul
return _MatrixMul(self, other)()
def __rmatmul__(self, other):
from nujo.autodiff._functions._elementary import _MatrixMul
return _MatrixMul(other, self)()
# Representations
def __str__(self):
# TODO: Come up with a better representation
return self.__repr__() + '\n' + '-' * 32 + '\n' + str(self._value)
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,710 | VIVelev/nujo | refs/heads/master | /nujo/nn/__init__.py | ''' nujo's Neural Network module
Neural Network utilities are defined here.
'''
from nujo.nn.activations import *
from nujo.nn.layers import *
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,711 | VIVelev/nujo | refs/heads/master | /nujo/objective/quantitative.py | from nujo.autodiff.tensor import Tensor
from nujo.math.scalar import abs
from nujo.objective.loss import QuantitativeLoss
__all__ = [
'L1Loss',
'L2Loss',
]
# ====================================================================================================
class L1Loss(QuantitativeLoss):
''' L1 loss (or Absolute Error)
| ÿ - y |
'''
def forward(self, input: Tensor, target: Tensor) -> Tensor:
return self.reduction_fn(abs(input - target),
dim=self.dim,
keepdim=self.keepdim)
# ====================================================================================================
class L2Loss(QuantitativeLoss):
''' L2 loss (or Squared Error)
(ÿ - y)^2
'''
def forward(self, input: Tensor, target: Tensor) -> Tensor:
return self.reduction_fn((input - target)**2,
dim=self.dim,
keepdim=self.keepdim)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,712 | VIVelev/nujo | refs/heads/master | /tools/decorators.py | ''' this decorators are ment to be used with
line/memory profiler's @profile decorator
'''
__all__ = [
'decorate_if',
'decorate_if_defined',
]
def decorate_if(condition, decorator):
return decorator if condition else lambda x: x
def decorate_if_defined(decorator):
return globals().get(decorator, lambda x: x)
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,713 | VIVelev/nujo | refs/heads/master | /nujo/objective/qualitative.py | from numpy import clip
from nujo.autodiff.tensor import Tensor
from nujo.math import log, sum
from nujo.objective.loss import QualitativeLoss
__all__ = [
'BinaryCrossEntropy',
'CrossEntropy',
]
# ====================================================================================================
class BinaryCrossEntropy(QualitativeLoss):
''' Binary Cross-Entropy loss
−(y * log(p) + (1 − y) * log(1 − p))
'''
def forward(self, input: Tensor, target: Tensor) -> Tensor:
# Avoid division by zero
input.value = clip(input.value, 1e-16, 1 - 1e-16)
return -self.reduction_fn(target * log(input) +
(1 - target) * log(1 - input),
dim=self.dim,
keepdim=self.keepdim)
# ====================================================================================================
class CrossEntropy(QualitativeLoss):
''' Multi-class Cross-Entropy loss
-∑ y * log(p)
'''
def forward(self, input: Tensor, target: Tensor) -> Tensor:
# Avoid division by zero
input.value = clip(input.value, 1e-16, 1 - 1e-16)
return -self.reduction_fn(sum(target * log(input), dim=1,
keepdim=True),
dim=self.dim,
keepdim=self.keepdim)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,714 | VIVelev/nujo | refs/heads/master | /tests/test_objective/test_qualitative.py | import pytest
from nujo.autodiff.tensor import Tensor
from nujo.init.random import rand
from nujo.objective.qualitative import BinaryCrossEntropy, CrossEntropy
# ====================================================================================================
# Test Binary Cross Entropy
def test_binary_cross_entropy(inputs, targets):
loss_fn = BinaryCrossEntropy()
loss = loss_fn(inputs, targets)
assert isinstance(loss, Tensor)
assert loss.shape == (1, 1)
# ====================================================================================================
# Test Cross Entropy
def test_cross_entropy(inputs, targets):
loss_fn = CrossEntropy()
loss = loss_fn(inputs, targets)
assert isinstance(loss, Tensor)
assert loss.shape == (1, 1)
# ====================================================================================================
# Unit Test fixtures
@pytest.fixture
def inputs():
return rand(42, 100)
@pytest.fixture
def targets():
return rand(42, 100)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,715 | VIVelev/nujo | refs/heads/master | /tests/test_math/test_scalar.py | import pytest
from numpy import (abs, allclose, ceil, exp, floor, log, log2, log10, round,
sqrt)
import nujo.math.scalar as scalar
from nujo.init.random import rand
# ====================================================================================================
# Test Logarithms with different bases
def test_log(inputs):
assert (scalar.log(inputs) == log(inputs.value)).all()
def test_log2(inputs):
assert allclose(scalar.log2(inputs).value, log2(inputs.value))
def test_log10(inputs):
assert allclose(scalar.log10(inputs).value, log10(inputs.value))
# ====================================================================================================
# Test Exponentiation, Square Root and Absolute functions
def test_exp(inputs):
assert allclose(scalar.exp(inputs).value, exp(inputs.value))
def test_sqrt(inputs):
assert (scalar.sqrt(inputs) == sqrt(inputs.value)).all()
def test_abs(inputs):
assert (scalar.abs(inputs) == abs(inputs.value)).all()
# ====================================================================================================
# Test Round, Ceil, Floor
def test_round(inputs):
assert (scalar.round(inputs) == round(inputs.value)).all()
def test_ceil(inputs):
assert (scalar.ceil(inputs) == ceil(inputs.value)).all()
def test_floor(inputs):
assert (scalar.floor(inputs) == floor(inputs.value)).all()
# ====================================================================================================
# Unit Test fixtures
@pytest.fixture
def inputs():
return rand(3, 3)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,716 | VIVelev/nujo | refs/heads/master | /nujo/init/random.py | from numpy.random import rand as np_rand
from numpy.random import randint as np_randint
from numpy.random import randn as np_randn
from nujo.autodiff.tensor import Tensor
__all__ = [
'rand',
'randn',
'randint',
]
def rand(*shape: int, diff=False, name='Tensor[rand]') -> Tensor:
''' Random values in a given shape.
'''
return Tensor(np_rand(*shape), diff=diff, name=name)
def randn(*shape: int, diff=False, name='Tensor[randn]') -> Tensor:
''' Return a sample (or samples) from the "standard normal" distribution.
'''
return Tensor(np_randn(*shape), diff=diff, name=name)
def randint(*shape: int,
low=0,
high=100,
diff=False,
name='Tensor[randint]') -> Tensor:
''' Return random integers from low (inclusive) to high (exclusive).
'''
return Tensor(np_randint(low, high=high, size=shape), diff=diff, name=name)
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,717 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/_utils.py | __all__ = [
'_if_not_none',
]
def _if_not_none(*args) -> list:
return [arg for arg in args if arg is not None]
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,718 | VIVelev/nujo | refs/heads/master | /nujo/utils/__init__.py | ''' nujo utils '''
from nujo.utils.computation_graph_plotter import ComputationGraphPlotter
__all__ = [
'ComputationGraphPlotter',
]
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,719 | VIVelev/nujo | refs/heads/master | /nujo/utils/computation_graph_plotter.py | from graphviz import Digraph
from nujo.autodiff._node import _Node
from nujo.autodiff.tensor import Tensor
class ComputationGraphPlotter:
''' Computation Graph Plotter
Uses graphviz.
'''
def __init__(self, **kwargs):
self.computation_graph = Digraph(**kwargs)
@staticmethod
def get_color(node: _Node) -> str:
if isinstance(node, Tensor):
if len(node.children) > 0:
return 'lightblue'
return 'indianred1'
else:
return 'gold2'
@staticmethod
def get_shape(node: _Node) -> str:
if isinstance(node, Tensor):
return 'box'
else:
return 'oval'
def create(self,
root: _Node,
display_values=False) -> 'ComputationGraphPlotter':
if len(root.children) == 0:
return
root_name = str(root) if display_values else repr(root)
for child in root.children:
child_name = str(child) if display_values else repr(child)
self.computation_graph.node(child_name,
color=self.get_color(child),
shape=self.get_shape(child),
style='filled')
self.computation_graph.node(root_name,
color=self.get_color(root),
shape=self.get_shape(root),
style='filled')
self.computation_graph.edge(child_name, root_name)
self.create(child)
return self
def view(self) -> None:
self.computation_graph.view()
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,720 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/_functions/_elementary.py | from numbers import Number
from typing import List, Union
from numpy import log, ndarray, ones
from nujo.autodiff.function import Function
from nujo.autodiff.tensor import Tensor
__all__ = [
'_Addition',
'_Negation',
'_Multiplication',
'_Reciprocal',
'_Power',
'_Logarithm',
'_MatrixMul',
]
# ====================================================================================================
class _Addition(Function):
def __init__(self, input_a: Union[Tensor, ndarray, List[Number], Number],
input_b: Union[Tensor, ndarray, List[Number], Number]):
super(_Addition, self).__init__(input_a, input_b)
# The following assert will not allow numpy's
# vector broadcasts such as:
#
# [[1, 2, 3]] + [[1], = [[2, 3, 4],
# [2], [3, 4, 5],
# [3]] [4, 5, 6]]
#
# In future versions of nujo this may be supported.
assert (self.children[0].value.shape == self.children[1].value.shape or
self.children[0].value.shape != self.children[1].value.T.shape)
def forward(self) -> ndarray:
return self.children[0].value + self.children[1].value
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * ones(self.children[idx].shape)
# ====================================================================================================
class _Negation(Function):
def __init__(self, input: Union[Tensor, ndarray, List[Number], Number]):
super(_Negation, self).__init__(input)
def forward(self) -> ndarray:
return -self.children[0].value
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * -ones(self.children[0].shape)
# ====================================================================================================
class _Multiplication(Function):
def __init__(self, input_a: Union[Tensor, ndarray, List[Number], Number],
input_b: Union[Tensor, ndarray, List[Number], Number]):
super(_Multiplication, self).__init__(input_a, input_b)
# The following assert will not allow numpy's
# vector broadcasts such as:
#
# [[1, 2, 3]] * [[1], = [[1, 2, 3],
# [2], [2, 4, 6],
# [3]] [3, 6, 6]]
#
# In future versions of nujo this may be supported.
assert (self.children[0].value.shape == self.children[1].value.shape or
self.children[0].value.shape != self.children[1].value.T.shape)
def forward(self) -> ndarray:
return self.children[0].value * self.children[1].value
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
if idx == 0:
return accum_grad * self.children[1].value
else:
return accum_grad * self.children[0].value
# ====================================================================================================
class _Reciprocal(Function):
def __init__(self,
input: Union[Tensor, ndarray, List[Number], Number],
eps=1e-18):
super(_Reciprocal, self).__init__(input)
self.eps = eps
def forward(self) -> ndarray:
return 1 / (self.children[0].value + self.eps)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * -1 / ((self.children[0].value + self.eps)**2)
# ====================================================================================================
class _Power(Function):
def __init__(self, input_a: Union[Tensor, ndarray, List[Number], Number],
input_b: Union[Tensor, ndarray, List[Number], Number]):
super(_Power, self).__init__(input_a, input_b)
def forward(self) -> ndarray:
return self.children[0].value**self.children[1].value
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
# TODO: FIX wrong partial - the second
if idx == 0:
return accum_grad * self.children[1].value *\
self.children[0].value**(self.children[1].value - 1)
else:
return type(accum_grad)(1)
# ====================================================================================================
class _Logarithm(Function):
def __init__(self, input_a: Union[Tensor, ndarray, List[Number], Number],
input_b: Union[Tensor, ndarray, List[Number], Number]):
super(_Logarithm, self).__init__(input_a, input_b)
assert (self.children[0].value > 0).all() # argument value limit
assert (self.children[1].value > 0).all() # base value limit
assert (self.children[1].value != 0).all() # base value limit
def forward(self) -> ndarray:
return log(self.children[0].value) / log(self.children[1].value)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
# TODO: FIX wrong partial - the second
if idx == 0:
return accum_grad /\
(self.children[0].value * log(self.children[1].value))
else:
return type(accum_grad)(1)
# ====================================================================================================
class _MatrixMul(Function):
def __init__(self, input_a: Union[Tensor, ndarray, List[Number], Number],
input_b: Union[Tensor, ndarray, List[Number], Number]):
super(_MatrixMul, self).__init__(input_a, input_b)
# Assert valid dimensions for matrix multiplication
assert self.children[0].value.shape[-1] ==\
self.children[1].value.shape[0]
def forward(self) -> ndarray:
return self.children[0].value @ self.children[1].value
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
if idx == 0:
return accum_grad @ self.children[1].value.T
else:
return (accum_grad.T @ self.children[0].value).T
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,721 | VIVelev/nujo | refs/heads/master | /examples/mnist_feed_forward_nn.py | import numpy as np
from mnist import MNIST
import nujo as nj
import nujo.nn as nn
import nujo.objective as obj
import nujo.optim as optim
from nujo.utils import ComputationGraphPlotter
net = nn.Linear(28 * 28, 256) >> nn.Sigmoid() \
>> nn.Linear(256, 128) >> nn.Sigmoid() \
>> nn.Linear(128, 10) >> nn.Softmax()
print(f'Defined net: {net}')
loss_fn = obj.CrossEntropy()
print(f'Loss: {loss_fn}')
optimizer = optim.Adam(net.parameters, lr=0.01)
print(f'Optimizer: {optimizer}')
def train(net, x, y, num_epochs):
for epoch in range(1, num_epochs + 1):
# Forward
output = net(x)
# Compute Loss
loss = loss_fn(output, y)
# Print the loss for monitoring
if epoch % 100 == 0:
print(f'EPOCH:\t{epoch}| LOSS:\t{loss.value}')
# Backprop
loss.backward()
# Update
optimizer.step()
# Zero grad
optimizer.zero_grad()
return loss
if __name__ == '__main__':
mndata = MNIST('datasets/MNIST', gz=False)
images, labels = mndata.load_training()
arr = []
for i in range(32):
elem = np.array(images[i]).reshape(1, -1)
arr.append(elem[0])
images = np.array(arr).T / 255
labels = np.array(labels).reshape(1, -1)[0]
labels = np.eye(max(labels) + 1)[labels][:32]
images = nj.Tensor(images, name='X_train')
labels = nj.Tensor(labels.T, name='y_train')
loss = train(net, images, labels, 1000)
# Visualize the Neural Network as a computation graph
cg_plot = ComputationGraphPlotter(filename='graph').create(loss)
cg_plot.view()
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,722 | VIVelev/nujo | refs/heads/master | /tests/test_math/test_aggregate.py | import pytest
from numpy import allclose, mean, prod, sum
import nujo.math.aggregate as aggregate
from nujo.init.random import rand
# ====================================================================================================
# Test Summation
def test_sum(inputs):
# Test Forward pass (Inner sum)
output = aggregate.sum(inputs[0])
assert (output == sum(inputs[0].value)).all()
# Test Backward pass (Inner sum)
output.backward()
assert (inputs[0].grad.shape == inputs[0].shape)
assert (inputs[0].grad == 1).all()
# Test several tensors sum
assert (aggregate.sum(*inputs) == sum(inputs)).all()
# ====================================================================================================
# Test Product
def test_prod(inputs):
# Test Forward pass (Inner product)
output = aggregate.prod(inputs[0])
assert (output == prod(inputs[0].value)).all()
# Test Backward pass (Inner product)
output.backward()
assert (inputs[0].grad.shape == inputs[0].shape)
assert allclose(inputs[0].grad.value, (output / inputs[0]).value)
# Test several tensors prod
assert (aggregate.prod(*inputs) == prod(inputs)).all()
# ====================================================================================================
# Test Mean estimation
def test_mean(inputs):
# Test Forward pass (Inner mean)
output = aggregate.mean(inputs[0])
assert allclose(output.value, mean(inputs[0].value))
# Test Backward pass (Inner mean)
output.backward()
assert (inputs[0].grad.shape == inputs[0].shape)
assert (inputs[0].grad == 1 / prod(inputs[0].shape)).all()
# Test several tensors mean
assert (aggregate.mean(*inputs) == mean(inputs)).all()
# ====================================================================================================
# Unit Test fixtures
@pytest.fixture
def inputs():
return [
rand(3, 3, diff=True),
rand(3, 3, diff=True),
rand(3, 3, diff=True),
]
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,723 | VIVelev/nujo | refs/heads/master | /nujo/init/__init__.py | ''' Tensor initializers
The functions presented here are just tiny wrappers around
`numpy` functions, in order to make them compatible with nujo.
'''
from nujo.init.basic import *
from nujo.init.random import *
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,724 | VIVelev/nujo | refs/heads/master | /tests/test_autodiff/test_tensor.py | import pytest
from numpy import expand_dims, ndarray
from nujo import Tensor
from nujo.autodiff._functions._elementary import _Addition
# ====================================================================================================
# Test Tensor value and creator properties
def test_tensor_value(tensors):
A, B, C = tensors
assert isinstance(A.value, ndarray)
assert isinstance(B.value, ndarray)
assert isinstance(C.value, ndarray)
def test_tensor_creator(tensors):
A, B, C = tensors
assert A.creator is None
assert B.creator is None
assert isinstance(C.creator, _Addition)
# ====================================================================================================
# Test Tensor backward method
def test_tensor_backward(tensors):
A, B, C = tensors
C.backward()
assert len(C.parents_outputs) == 0
assert (C.grad == 1).all()
assert len(A.parents_outputs) == 1
assert (A.parents_outputs[0] == C).all()
assert (A.grad == 1).all()
assert len(B.parents_outputs) == 1
assert (B.parents_outputs[0] == C).all()
assert (B.grad == 1).all()
# ====================================================================================================
# Test Tensor transpose and shape manipulation
# methods: reshape, repeat, squeeze, unsqueeze
def test_tensor_transpose(tensors):
A, _, _ = tensors
assert (A.T.value == A.value.T).all()
def test_tensor_shape_manipulation(tensors):
A, _, _ = tensors
assert A.shape == A.value.shape
A, A_np = A.reshape(-1, 1), A.value.reshape(-1, 1)
assert (A == A_np).all()
assert (A.squeeze(1) == A_np.squeeze(1)).all()
assert (A.unsqueeze(1) == expand_dims(A_np, 1)).all()
# ====================================================================================================
# Test gradient cleaning method
def test_tensor_zero_grad(tensors):
A, _, _ = tensors
A.zero_grad()
assert (A.grad == 0).all()
# ====================================================================================================
# Test inplace assignment operator
def test_tensor_inplace_assignment(tensors):
A, _, C = tensors
A <<= C
assert A.id != C.id
assert A.children == C.children or A.children is None
assert A.creator == C.creator or A.creator is None
assert (A.value == C.value).all()
assert (A.grad == C.grad).all()
# ====================================================================================================
# Unit Test fixtures
@pytest.fixture
def tensors():
A = Tensor([[1, 2], [3, 4]], diff=True)
B = Tensor([[5, 6], [7, 8]], diff=True)
C = A + B
return A, B, C
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,725 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/_functions/_activations.py | from math import e
from numbers import Number
from typing import List, Union
from numpy import exp, max, maximum, ndarray, ones, sum, zeros
from nujo.autodiff.function import Function
from nujo.autodiff.tensor import Tensor
__all__ = [
'_BinaryStep',
'_Sigmoid',
'_TanH',
'_ReLU',
'_LeakyReLU',
'_Swish',
'_Softmax',
]
# ====================================================================================================
# Built-in Neural Network Activation Functions
# - efficient implementation of various neural activation functions
# ====================================================================================================
class _BinaryStep(Function):
def __init__(self,
input: Union[Tensor, ndarray, List[Number], Number],
threshold=0.5):
super(_BinaryStep, self).__init__(input)
self.threshold = threshold
def forward(self) -> ndarray:
output = zeros(self.children[0].shape)
output[self.children[0].value > self.threshold] = 1
return output
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * zeros(self.children[0].shape)
# ====================================================================================================
class _Sigmoid(Function):
def __init__(self, input: Union[Tensor, ndarray, List[Number], Number]):
super(_Sigmoid, self).__init__(input)
self._output: ndarray = None # Used to compute the derivative
def forward(self) -> ndarray:
self._output = 1 / (1 + exp(-self.children[0].value))
return self._output
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * self._output * (1 - self._output)
# ====================================================================================================
class _TanH(Function):
def __init__(self, input: Union[Tensor, ndarray, List[Number], Number]):
super(_TanH, self).__init__(input)
self._output: ndarray = None # Used to compute the derivative
def forward(self) -> ndarray:
''' (2 / (1 + e ^ -2x)) - 1 is equivalent to
(e ^ x - e ^ -x) / (e ^ x + e ^ -x) it is just a
more optimal way to compute the TanH function.
'''
self._output = (2 / (1 + exp(-2 * self.children[0].value))) - 1
return self._output
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * (1 - self._output**2)
# ====================================================================================================
class _ReLU(Function):
def __init__(self, input: Union[Tensor, ndarray, List[Number], Number]):
super(_ReLU, self).__init__(input)
def forward(self) -> ndarray:
return self.children[0].value * (self.children[0].value > 0)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * ones(
self.children[0].shape) * (self.children[0].value > 0)
# ====================================================================================================
class _LeakyReLU(Function):
def __init__(self,
input: Union[Tensor, ndarray, List[Number], Number],
eps=0.1):
super(_LeakyReLU, self).__init__(input)
self.eps = eps
def forward(self) -> ndarray:
return maximum(self.eps * self.children[0].value,
self.children[0].value)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
dinput = ones(self.children[0].shape)
dinput[self.children[0].value < 0] = self.eps
return accum_grad * dinput
# ====================================================================================================
class _Swish(Function):
''' More info here: https://arxiv.org/abs/1710.05941
'''
def __init__(self,
input: Union[Tensor, ndarray, List[Number], Number],
beta=1):
super(_Swish, self).__init__(input)
self.beta = beta
# Reuse the sigmoid activation function
self._sigmoid = _Sigmoid(beta * input.value)
self._output: ndarray = None # Used to compute the derivative
def forward(self) -> ndarray:
self._output = self.children[0].value * self._sigmoid.forward()
return self._output
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * (self._output + self._sigmoid._output *
(1 - self._output))
# ====================================================================================================
class _Softmax(Function):
''' More info here:
https://aimatters.wordpress.com/2019/06/17/the-softmax-function-derivative/
'''
def __init__(self,
input: Union[Tensor, ndarray, List[Number], Number],
dim=0,
base: float = e):
super(_Softmax, self).__init__(input)
self.dim = dim
self.base = base
self._output: ndarray = None # Used to compute the derivative
def forward(self) -> ndarray:
# The max element of the input vector will be
# substracted from the inputs for numerical stability.
# This will not change the relative output of the softmax.
exps = self.base**(
self.children[0].value -
max(self.children[0].value, axis=self.dim, keepdims=True))
sums = sum(exps, axis=self.dim, keepdims=True)
self._output = exps / sums
return self._output
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * self._output * (1 - self._output)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,726 | VIVelev/nujo | refs/heads/master | /nujo/math/scalar.py | from copy import deepcopy
from math import e
from numpy import around as np_round
from numpy import ceil as np_ceil
from numpy import floor as np_floor
from nujo.autodiff._functions._elementary import _Logarithm, _Power
from nujo.autodiff.tensor import Tensor
__all__ = [
'log',
'log2',
'log10',
'exp',
'sqrt',
'abs',
'round',
'ceil',
'floor',
]
# ====================================================================================================
def log(x: Tensor, base: float = e) -> Tensor:
return _Logarithm(x, base)()
def log2(x: Tensor) -> Tensor:
return _Logarithm(x, 2)()
def log10(x: Tensor) -> Tensor:
return _Logarithm(x, 10)()
# ====================================================================================================
def exp(x: Tensor) -> Tensor:
return _Power(e, x)()
def sqrt(x: Tensor) -> Tensor:
return _Power(x, 1 / 2)()
def abs(x: Tensor) -> Tensor:
return sqrt(x**2)
# ====================================================================================================
def round(x: Tensor, inplace=False) -> Tensor:
rounded = x if inplace else deepcopy(x)
rounded.name += ' (rounded)'
rounded.value = np_round(x.value)
return rounded
def ceil(x: Tensor, inplace=False) -> Tensor:
ceiled = x if inplace else deepcopy(x)
ceiled.name += ' (ceiled)'
ceiled.value = np_ceil(x.value)
return ceiled
def floor(x: Tensor, inplace=False) -> Tensor:
floored = x if inplace else deepcopy(x)
floored.name += ' (floored)'
floored.value = np_floor(x.value)
return floored
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,727 | VIVelev/nujo | refs/heads/master | /nujo/init/basic.py | from numpy import empty as np_empty
from numpy import full as np_full
from nujo.autodiff.tensor import Tensor
__all__ = [
'empty',
'full',
'ones',
'ones_like',
'zeros',
'zeros_like',
]
# ====================================================================================================
def empty(*shape: int, diff=False, name='Tensor[empty]') -> Tensor:
''' Return a new Tensor of given shape, without initializing entries.
'''
return Tensor(np_empty(shape), diff=diff, name=name)
def full(*shape: int,
fill_value=0,
diff=False,
name='Tensor[full]]') -> Tensor:
''' Return a new Tensor of given shape, filled with `fill_value`.
'''
return Tensor(np_full(shape, fill_value), diff=diff, name=name)
# ====================================================================================================
def ones(*shape: int, diff=False, name='Tensor[ones]') -> Tensor:
''' Return a new Tensor of given shape, filled with ones.
'''
return full(*shape, fill_value=1, diff=diff, name=name)
def ones_like(x: Tensor, diff=False, name='Tensor[ones]') -> Tensor:
return ones(*x.shape, diff=diff, name=name)
# ====================================================================================================
def zeros(*shape: int, diff=False, name='Tensor[zeros]') -> Tensor:
''' Return a new Tensor of given shape, filled with zeros.
'''
return full(*shape, fill_value=0, diff=diff, name=name)
def zeros_like(x: Tensor, diff=False, name='Tensor[zeros]') -> Tensor:
return zeros(*x.shape, diff=diff, name=name)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,728 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/function.py | from abc import abstractmethod
from numbers import Number
from typing import Any, Dict, Iterable, List, TypeVar, Union
from numpy import ndarray
import nujo.autodiff.modes as modes
from nujo.autodiff._node import _Node
from nujo.autodiff.tensor import Tensor
# ====================================================================================================
class _FunctionMeta(type):
def __call__(cls, *children: Union[Tensor, ndarray, List[Number], Number],
**kwargs):
''' Used to lookup the cache for an already defined function of
the current type using the current `children` as inputs, and reuse
it. If a function satisfying this requirements could not be found,
a new function is created and added to the cache, in order to be,
potentially, later reused.
'''
obj = cls.__new__(cls, *children, **kwargs)
# Only cache functions that are in the computation graph
if modes.DIFF_ENABLED:
key = _get_function_identifier(cls, children)
cache = cls._func_children_lookup_cache
if key in cache:
return cache[key]
else:
cls.__init__(obj, *children, **kwargs)
cache[key] = obj
return obj
# Otherwise - standard call
cls.__init__(obj, *children, **kwargs)
return obj
# ====================================================================================================
class Function(_Node, metaclass=_FunctionMeta):
''' Base Class for functions
Functions are applied to tensors. They take multiple
tensors as input and produces only one tensor as output.
They do NOT change tensors in-place.
Functions were also written so they reuse the input/output tensors
when possible, which results in the computation graph being:
- "Dynamically defined, statically evaluated."
taking the best from both worlds.
Parameters:
-----------
- children : varargs, the inpute tensors
'''
_func_children_lookup_cache: Dict[str, 'Function'] = {}
''' Cache used to lookup for functions that may have already been defined
in the computation graph.
- key : hash(FuncType) + (children's identifiers);
use `_get_function_identifier` to obtain a key
- value : the already defined function which can be reused
'''
T = TypeVar('T', Tensor, ndarray)
def __init__(self, *children: Union[Tensor, ndarray, List[Number],
Number]):
super(Function, self).__init__(*_parse_inputs(children),
name=self.__class__.__name__)
# This output placeholder is reused when possible
self._output_placeholder = Tensor(
None,
diff=any(x.diff for x in self.children) and modes.DIFF_ENABLED,
creator=self if modes.DIFF_ENABLED else None,
name=self._generate_tensor_name())
if modes.DIFF_ENABLED: # If graph building is enabled.
# Allocate space for parent's output (output placeholder)
for child in self.children:
child.parents_outputs.append(self._output_placeholder)
def __repr__(self):
return super(Function, self).__repr__() + f'#{self.id}'
def _generate_tensor_name(self) -> str:
return 'Z' + self.__repr__()
@abstractmethod
def forward(self) -> ndarray:
''' Implement forward pass of the function here.
Use the `self.children` list to access the inputs.
'''
pass
@abstractmethod
def backward(self, idx: int, accum_grad: T) -> T:
''' Implement backward pass of the function here
Compute the gradient of children[idx] w.r.t. output of the
computation graph from the accumulated gradient (the gradient
of the output of the function w.r.t. the output of the graph).
Parameters:
-----------
- idx : int, the index of the children for which to compute the
gradient w.r.t. output of the computation graph
- accum_grad : T (Tensor or ndarray), the accumulated grad in the graph
so far, you can otherwise think of it as the gradient of the output of
the function w.r.t. the output of the graph.
- `accum_grad` is Tensor if differentiantion is enabled
(`DIFF_ENABLED`) and the children has opted for differentiation
(`diff` is True), thus the computations will be recorded in the
computation graph and higher-order derivatives could be computed.
- otherwise, `accum_grad` is ndarray and the computations are not
recorded; ndarrays are used since the computations with them are
more efficient.
Returns:
--------
- grad : T (Tensor or ndarray), the computed gradient of
`self.children[idx]`
'''
pass
def __call__(self) -> Tensor:
''' Executes cached forward pass
'''
# Forward pass
self._output_placeholder.value = self.forward()
return self._output_placeholder
# ====================================================================================================
def _parse_inputs(inputs: Iterable[Any]) -> List[Tensor]:
''' Parse all inputs that are not Nodes to Tensors
'''
return [
x if isinstance(x, _Node) else Tensor(x, name=str(x)) for x in inputs
]
# ====================================================================================================
def _get_function_identifier(func_type: type, inputs: Iterable[Any]) -> str:
''' Returns a string identifier for the current function type and its inputs,
used for a key in the cache.
'''
key = str(hash(func_type)) # Inlcude the function type hash in the key
# Include the inputs' (children's) identifiers in the key
key += ''.join(('T' + str(x.id) if isinstance(x, Tensor) else 'P' + str(x)
for x in inputs))
# 'T' and 'P' signatures were added in order to avoid
# collisions between Tensor and Python values
return key
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,729 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/_functions/_aggregate.py | from numbers import Number
from typing import List, Optional, Union
from numpy import ndarray, ones, prod, sum
from nujo.autodiff.function import Function
from nujo.autodiff.tensor import Tensor
__all__ = [
'_InnerSum',
'_InnerProd',
]
# ====================================================================================================
class _InnerSum(Function):
def __init__(self,
input: Union[Tensor, ndarray, List[Number], Number],
dim: Optional[int] = None,
keepdim=False):
super(_InnerSum, self).__init__(input)
self.dim = dim
self.keepdim = keepdim
def forward(self) -> ndarray:
return sum(self.children[0].value,
axis=self.dim,
keepdims=self.keepdim)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * ones(self.children[0].shape)
# ====================================================================================================
class _InnerProd(Function):
def __init__(self,
input: Union[Tensor, ndarray, List[Number], Number],
dim: Optional[int] = None,
keepdim=False):
super(_InnerProd, self).__init__(input)
self.dim = dim
self.keepdim = keepdim
self._output: ndarray = None # Used to compute the derivative
def forward(self) -> ndarray:
self._output = prod(self.children[0].value,
axis=self.dim,
keepdims=self.keepdim)
return self._output
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * self._output / self.children[0].value
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,730 | VIVelev/nujo | refs/heads/master | /tools/profiler.py | import os
import sys
if __name__ == '__main__':
path_to_script_with_args = ' '.join(sys.argv[1:])
os.system(
f'python -m cProfile -o output.pstats {path_to_script_with_args}')
os.system('gprof2dot --colour-nodes-by-selftime -f pstats output.pstats |\
dot -Tpng -o output.png')
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,731 | VIVelev/nujo | refs/heads/master | /nujo/nn/activations.py | ''' Neural Network activation functions
More info here:
https://missinglink.ai/guides/neural-network-concepts/7-types-neural-network-activation-functions-right/
'''
from math import e
from nujo.autodiff._functions._activations import (_BinaryStep, _LeakyReLU,
_ReLU, _Sigmoid, _Softmax,
_Swish, _TanH)
from nujo.autodiff.tensor import Tensor
from nujo.flow import Flow
__all__ = [
'BinaryStep',
'Sigmoid',
'TanH',
'ReLU',
'LeakyReLU',
'Swish',
'Softmax',
]
# ====================================================================================================
# Scalar (Single-class) activation functions
# ====================================================================================================
class BinaryStep(Flow):
''' Binary step function
if val > threshold:
return 1
else:
return 0
'''
def __init__(self, threshold=0.5, name='BinaryStep'):
super(BinaryStep, self).__init__(name=name)
self.threshold = threshold
def forward(self, x: Tensor) -> Tensor:
return _BinaryStep(x, threshold=self.threshold)()
# ====================================================================================================
class Sigmoid(Flow):
''' Sigmoid activation function
sigmoid(x) = 1 / (1 + e ^ -x)
'''
def __init__(self, name='Sigmoid'):
super(Sigmoid, self).__init__(name=name)
def forward(self, x: Tensor) -> Tensor:
return _Sigmoid(x)()
# ====================================================================================================
class TanH(Flow):
''' TanH activation function
tanh(x) = (e ^ x - e ^ -x) / (e ^ x + e ^ -x)
'''
def __init__(self, name='TanH'):
super(TanH, self).__init__(name=name)
def forward(self, x: Tensor) -> Tensor:
return _TanH(x)()
# ====================================================================================================
class ReLU(Flow):
''' ReLU (Rectified Linear Unit) activation function
relu(x) = max(0, x)
'''
def __init__(self, name='ReLU'):
super(ReLU, self).__init__(name=name)
def forward(self, x: Tensor) -> Tensor:
return _ReLU(x)()
# ====================================================================================================
class LeakyReLU(Flow):
''' Leaky ReLU activation function
leaky_relu = max(eps * x, x)
'''
def __init__(self, eps=0.1, name='LeakyReLU'):
super(LeakyReLU, self).__init__(name=name)
self.eps = eps
def forward(self, x: Tensor) -> Tensor:
return _LeakyReLU(x, eps=self.eps)()
# ====================================================================================================
class Swish(Flow):
''' Swish activation function
swish(x) = x * sigmoid(beta * x) = x / (1 + e ^ (-beta * x))
"Searching for Activation Functions"
Prajit Ramachandran, Barret Zoph, Quoc V. Le
(https://arxiv.org/abs/1710.05941)
'''
def __init__(self, beta=1, name='Swish'):
super(Swish, self).__init__(name=name)
self.beta = beta
def forward(self, x: Tensor) -> Tensor:
return _Swish(x, beta=self.beta)()
# ====================================================================================================
# Vector (Multi-class) activation functions
# ====================================================================================================
class Softmax(Flow):
''' Softmax activation function
softmax(z) = e ^ z_i / sum(e ^ z_i)
Nice read here:
https://aimatters.wordpress.com/2019/06/17/the-softmax-function-derivative/
Parameters:
-----------
- dim : int, the dimension along which to exponentiate and then sum;
(default: 0)
- base : float, the base of the exponentiation; (default: e)
(you can use this parameter to adjust the sharpness of attenuation
of the softmax; lower numbers will result in lower attenuation, and
higher numbers will result in higher attenuation, but most people
just stick with e)
'''
def __init__(self, dim=0, base: float = e, name='Softmax'):
super(Softmax, self).__init__(name=name)
self.dim = dim
self.base = base
def forward(self, x: Tensor) -> Tensor:
return _Softmax(x, dim=self.dim, base=self.base)()
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,732 | VIVelev/nujo | refs/heads/master | /tests/test_objective/test_quantitative.py | import pytest
from nujo.autodiff.tensor import Tensor
from nujo.init.random import rand
from nujo.objective.quantitative import L1Loss, L2Loss
# ====================================================================================================
# Test L1 Loss
def test_l1_loss(inputs, targets):
loss_fn = L1Loss()
loss = loss_fn(inputs, targets)
assert isinstance(loss, Tensor)
assert loss.shape == (1, 1)
# ====================================================================================================
# Test L2 Loss
def test_l2_loss(inputs, targets):
loss_fn = L2Loss()
loss = loss_fn(inputs, targets)
assert isinstance(loss, Tensor)
assert loss.shape == (1, 1)
# ====================================================================================================
# Unit Test fixtures
@pytest.fixture
def inputs():
return rand(100, 1)
@pytest.fixture
def targets():
return rand(100, 1)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,733 | VIVelev/nujo | refs/heads/master | /tests/test_autodiff/test_functions/test_elementary.py | import pytest
from numpy import allclose, log, log2
import nujo.autodiff._functions._elementary as funcs
from nujo import Tensor, ones
# ====================================================================================================
# Unit Testing Addition
def test_addition(inputs):
A, B = inputs
add = funcs._Addition(A, B)
# Test Forwardprop
C = add()
assert isinstance(C, Tensor)
assert (A.value + B.value == C.value).all()
# Test Backprop
grad_A, grad_B = add.backward(0, Tensor(1)), add.backward(1, Tensor(1))
assert isinstance(grad_A, Tensor)
assert isinstance(grad_B, Tensor)
# Test Derivative computation
assert grad_A.shape == A.shape
assert (grad_A == 1).all()
assert grad_B.shape == B.shape
assert (grad_B == 1).all()
# ====================================================================================================
# Unit Testing Negation
def test_negation(inputs):
A, _ = inputs
neg = funcs._Negation(A)
# Test Forwardprop
C = neg()
assert isinstance(C, Tensor)
assert (-A.value == C.value).all()
# Test Backprop
grad_A = neg.backward(0, Tensor(1))
assert isinstance(grad_A, Tensor)
# Test Derivative computation
assert grad_A.shape == A.shape
assert (grad_A == -1).all()
# ====================================================================================================
# Unit Testing Multiplication
def test_multiplication(inputs):
A, B = inputs
mul = funcs._Multiplication(A, B)
# Test Forwardprop
C = mul()
assert isinstance(C, Tensor)
assert (A.value * B.value == C.value).all()
# Test Backprop
grad_A, grad_B = mul.backward(0, Tensor(1)), mul.backward(1, Tensor(1))
assert isinstance(grad_A, Tensor)
assert isinstance(grad_B, Tensor)
# Test Derivative computation
assert grad_A.shape == A.shape
assert (grad_A == B).all()
assert grad_B.shape == B.shape
assert (grad_B == A).all()
# ====================================================================================================
# Unit Testing Reciprocal
def test_reciprocal(inputs):
A, _ = inputs
recipr = funcs._Reciprocal(A)
# Test Forwardprop
C = recipr()
assert isinstance(C, Tensor)
assert (1 / A.value == C.value).all()
# Test Backprop
grad_A = recipr.backward(0, Tensor(1))
assert isinstance(grad_A, Tensor)
# Test Derivative computation
assert grad_A.shape == A.shape
assert (grad_A == -1 / A**2).all()
# ====================================================================================================
# Unit Testing Power
def test_power(inputs):
A, _ = inputs
pow = funcs._Power(A, 2)
# Test Forwardprop
C = pow()
assert isinstance(C, Tensor)
assert (A.value**2 == C.value).all()
# Test Backprop
grad_A, grad_B = pow.backward(0, Tensor(1)), pow.backward(1, Tensor(1))
assert isinstance(grad_A, Tensor)
assert isinstance(grad_B, Tensor)
# Test Derivative computation
assert grad_A.shape == A.shape
assert (grad_A == 2 * A).all()
assert grad_B == 1
# ====================================================================================================
# Unit Testing Logarithm
def test_logarithm(inputs):
A, _ = inputs
log_2 = funcs._Logarithm(A, 2) # log_2(A)
# Test Forwardprop
C = log_2()
assert isinstance(C, Tensor)
assert allclose(log2(A.value), C.value)
# Test Backprop
grad_A, grad_B = log_2.backward(0, Tensor(1)), log_2.backward(1, Tensor(1))
assert isinstance(grad_A, Tensor)
assert isinstance(grad_B, Tensor)
# Test Derivative computation
assert grad_A.shape == A.shape
assert allclose(grad_A.value, 1 / (A.value * log(2)))
assert grad_B == 1
# ====================================================================================================
# Unit Testing Matrix Multiplication
def test_matrixmul(inputs):
A, B = inputs
matmul = funcs._MatrixMul(A, B)
# Test Forwardprop
C = matmul()
assert isinstance(C, Tensor)
assert (A.value @ B.value == C.value).all()
# Test Backprop
output_shape = (A.shape[0], B.shape[1])
doutput = ones(*output_shape)
grad_A, grad_B = matmul.backward(0, doutput), matmul.backward(1, doutput)
assert isinstance(grad_A, Tensor)
assert isinstance(grad_B, Tensor)
# Test Derivative computation
assert grad_A.shape[0] == A.shape[1]
assert (grad_A == doutput @ B.T).all()
assert grad_B.shape[1] == B.shape[0]
assert (grad_B == (doutput.T @ A).T).all()
# ====================================================================================================
# Unit Test fixtures
@pytest.fixture
def inputs():
A = Tensor([[1, 2], [3, 4]])
B = Tensor([[5, 6], [7, 8]])
return A, B
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,734 | VIVelev/nujo | refs/heads/master | /nujo/optim/optimizers.py | ''' Stochastic Gradient Descent (SGD) Optimizers
Check out the following link for more info about the optimizers:
http://ruder.io/optimizing-gradient-descent/index.html
'''
from typing import Dict, List
from nujo.autodiff.tensor import Tensor
from nujo.init.basic import zeros_like
from nujo.math.scalar import sqrt
from nujo.optim.optimizer import Optimizer
__all__ = [
'SGD',
'Momentum',
'RMSprop',
'Adam',
]
# ====================================================================================================
class SGD(Optimizer):
''' SGD: Stochastic Gradient Descent
An iterative method for optimizing an objective function.
Parameters:
-----------
- params : list of Tensors, the parameters which to update
- lr : float, the learning rate
'''
def __init__(self, params: List[Tensor], lr=0.005):
super(SGD, self).__init__(params, lr)
def update_rule(self, param: Tensor, grad: Tensor) -> Tensor:
return param - self.lr * grad
# ====================================================================================================
class Momentum(Optimizer):
''' Momentum
A method that helps accelerate SGD in the relevant direction and
dampens oscillations. It does this by adding a fraction of the
update vector of the past time step to the current update vector.
Parameters:
-----------
- params : list of Tensors, the parameters which to update
- lr : float, the learning rate
- beta : float, the fraction of the update vector of the past
time step to be added to the current update vector
'''
def __init__(self, params: List[Tensor], lr=0.001, beta=0.9):
super(Momentum, self).__init__(params, lr)
self.beta = beta
self._velocity: Dict[str, Tensor] = {}
def update_rule(self, param: Tensor, grad: Tensor) -> Tensor:
# Get the corresponding velocity
key = param.name
if key not in self._velocity:
self._velocity[key] = zeros_like(param)
# Exponentially Weighted Moving Average
self._velocity[key] = self.beta * self._velocity[key] +\
(1 - self.beta) * grad
# Update rule
return param - self.lr * self._velocity[key]
# ====================================================================================================
class RMSprop(Optimizer):
''' RMSprop
A gradient-based optimization technique proposed by Geoffrey Hinton
at his Neural Networks Coursera course. It uses a moving average
of squared gradients to normalize the gradient itself.
Parameters:
-----------
- params : list of Tensors, the parameters which to update
- lr : float, the learning rate
- beta : float, the squared gradient coefficients
- eps : float, added for numerical stability
'''
def __init__(self, params: List[Tensor], lr=0.001, beta=0.999, eps=1e-09):
super(RMSprop, self).__init__(params, lr)
self.beta = beta
self.eps = eps
self._squared: Dict[str, Tensor] = {}
def update_rule(self, param: Tensor, grad: Tensor) -> Tensor:
# Get the corresponding squared gradient
key = param.name
if key not in self._squared:
self._squared[key] = zeros_like(param)
# Exponentially Weighted Moving Average
self._squared[key] = self.beta * self._squared[key] +\
(1 - self.beta) * grad**2
# Update rule
return param - self.lr * grad / (sqrt(self._squared[key]) + self.eps)
# ====================================================================================================
class Adam(Optimizer):
''' Adam: Adaptive Moment Estimation
Another method that computes adaptive learning rates
for each parameter. It basically combines Momentum
and RMSprop into one update rule.
Parameters:
-----------
- params : list of Tensors, the parameters which to update
- lr : float, the learning rate
- betas : tuple of 2 floats, the velocity (Momentum) and
squared gradient (RMSprop) coefficients
- eps : float, added for numerical stability
'''
def __init__(self,
params: List[Tensor],
lr=0.001,
betas=(0.9, 0.999),
eps=1e-09):
super(Adam, self).__init__(params, lr)
self.betas = betas
self.eps = eps
self._velocity: Dict[str, Tensor] = {}
self._squared: Dict[str, Tensor] = {}
self._t = 1
def update_rule(self, param: Tensor, grad: Tensor) -> Tensor:
# Get the corresponding velocity and squared gradient
key = param.name
if key not in self._velocity:
self._velocity[key] = zeros_like(param)
self._squared[key] = zeros_like(param)
# Exponentially Weighted Moving Average
self._velocity[key] = self.betas[0]*self._velocity[key] +\
(1 - self.betas[0]) * grad
self._squared[key] = self.betas[1] * self._squared[key] +\
(1 - self.betas[1]) * grad**2
# Bias correction
v_corrected = self._velocity[key] / (1 - self.betas[0]**self._t)
s_corrected = self._squared[key] / (1 - self.betas[1]**self._t)
self._t += 1
# Update rule
return param - self.lr * v_corrected / (sqrt(s_corrected) + self.eps)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,735 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/_functions/_trigonometric.py | from numpy import cos, ndarray, sin, tan
from nujo.autodiff.function import Function
__all__ = [
'_Sin',
'_Cos',
'_Tan',
]
# ====================================================================================================
class _Sin(Function):
def forward(self) -> ndarray:
return sin(self.children[0].value)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * cos(self.children[0].value)
# ====================================================================================================
class _Cos(Function):
def forward(self) -> ndarray:
return cos(self.children[0].value)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * -sin(self.children[0].value)
# ====================================================================================================
class _Tan(Function):
def forward(self) -> ndarray:
return tan(self.children[0].value)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad * (1 / cos(self.children[0].value))**2
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,736 | VIVelev/nujo | refs/heads/master | /nujo/math/__init__.py | ''' nujo's core mathematical functionality
'''
from nujo.math.aggregate import *
from nujo.math.scalar import *
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,737 | VIVelev/nujo | refs/heads/master | /nujo/__init__.py | from nujo.autodiff import Function, Tensor, no_diff
from nujo.flow import Flow
from nujo.init import *
from nujo.math import *
__all__ = [
'Function',
'Tensor',
'no_diff',
'Flow',
]
__version__ = '0.3.0'
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,738 | VIVelev/nujo | refs/heads/master | /docs/gendocs.py | ''' Documentation generation and update procedure
'''
import os
import shutil
def gen_docs():
print('Generating HTML documentation for nujo out of docstrings...')
nujo = os.path.join(os.path.dirname(__file__), '../nujo')
docs = os.path.dirname(__file__)
print('nujo dir:', nujo)
print('docs dir:', docs)
os.system(f'pdoc3 --html {nujo} --output-dir {docs} --force')
print('Done.\n')
def extract_docs():
print('Extracting documentation...')
source = os.path.join(os.path.dirname(__file__), 'nujo')
dest = os.path.dirname(__file__)
print('source dir:', source)
print('dest dir:', dest)
for f in os.listdir(source):
current_dest = dest + '/' + f
if os.path.isdir(current_dest):
shutil.rmtree(current_dest)
shutil.move(source + '/' + f, current_dest)
shutil.rmtree(source)
print('Done.\n')
if __name__ == '__main__':
gen_docs()
extract_docs()
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,739 | VIVelev/nujo | refs/heads/master | /tests/test_autodiff/test_node.py | from nujo.autodiff._node import _Node
def test_node_equality():
A, B = _Node(), _Node()
assert A == A
assert A != B
def test_node_children():
A = _Node(_Node(1), _Node(2), 3)
assert len(A.children) == 3
assert isinstance(A.children[0], _Node)
assert A.children[1].children[0] == 2
assert A.children[2] == 3
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,740 | VIVelev/nujo | refs/heads/master | /tests/test_autodiff/test_autodiff.py | import pytest
import torch
from numpy import allclose, random
import nujo as nj
# ====================================================================================================
def test_scalar_diff(scalar_tensors):
(X_nj, y_nj, W1_nj, W2_nj, X_torch, y_torch, W1_torch,
W2_torch) = scalar_tensors
# Test Forward
loss_nj = nj.mean((X_nj * W1_nj * W2_nj - y_nj)**2)
loss_torch = torch.mean((X_torch * W1_torch * W2_torch - y_torch)**2)
assert allclose(loss_nj.value, loss_torch.detach().numpy())
# Test Backward
loss_nj.backward()
loss_torch.backward()
assert allclose(W1_nj.grad.value, W1_torch.grad.detach().numpy())
assert allclose(W2_nj.grad.value, W2_torch.grad.detach().numpy())
# ====================================================================================================
def test_matrix_diff(matrix_tensors):
(X_nj, y_nj, W1_nj, W2_nj, X_torch, y_torch, W1_torch,
W2_torch) = matrix_tensors
# Test Forward
loss_nj = nj.mean((X_nj @ W1_nj @ W2_nj - y_nj)**2)
loss_torch = torch.mean((X_torch @ W1_torch @ W2_torch - y_torch)**2)
assert allclose(loss_nj.value, loss_torch.detach().numpy())
# Test Backward
loss_nj.backward()
loss_torch.backward()
assert allclose(W1_nj.grad.value, W1_torch.grad.detach().numpy())
assert allclose(W2_nj.grad.value, W2_torch.grad.detach().numpy())
# ====================================================================================================
def test_prod_log(matrix_tensors):
(X_nj, y_nj, W1_nj, W2_nj, X_torch, y_torch, W1_torch,
W2_torch) = matrix_tensors
# Test Forward
loss_nj = nj.prod(nj.log(X_nj @ W1_nj @ W2_nj) + y_nj)
loss_torch = torch.prod(torch.log(X_torch @ W1_torch @ W2_torch) + y_torch)
assert allclose(loss_nj.value, loss_torch.detach().numpy())
# Test Backward
loss_nj.backward()
loss_torch.backward()
assert allclose(W1_nj.grad.value, W1_torch.grad.detach().numpy())
assert allclose(W2_nj.grad.value, W2_torch.grad.detach().numpy())
# ====================================================================================================
def test_aggregate_by_dim(matrix_tensors):
(X_nj, y_nj, W1_nj, _, X_torch, y_torch, W1_torch, _) = matrix_tensors
# Test Forward
loss_nj = nj.prod(nj.mean(X_nj @ W1_nj, dim=1, keepdim=True) + y_nj)
loss_torch = torch.prod(
torch.mean(X_torch @ W1_torch, axis=1, keepdim=True) + y_torch)
assert allclose(loss_nj.value, loss_torch.detach().numpy())
# Test Backward
loss_nj.backward()
loss_torch.backward()
assert allclose(W1_nj.grad.value, W1_torch.grad.detach().numpy())
# ====================================================================================================
# Unit Test fixtures - generate the same nujo and PyTorch tensors
@pytest.fixture
def scalar_tensors():
X = random.rand()
y = random.rand()
W1 = random.rand()
W2 = random.rand()
X_nj = nj.Tensor(X)
y_nj = nj.Tensor(y)
W1_nj = nj.Tensor(W1, diff=True)
W2_nj = nj.Tensor(W2, diff=True)
X_torch = torch.tensor(X)
y_torch = torch.tensor(y)
W1_torch = torch.tensor(W1, requires_grad=True)
W2_torch = torch.tensor(W2, requires_grad=True)
return X_nj, y_nj, W1_nj, W2_nj, X_torch, y_torch, W1_torch, W2_torch
@pytest.fixture
def matrix_tensors():
X = random.rand(3, 3)
y = random.rand(3, 1)
W1 = random.rand(3, 2)
W2 = random.rand(2, 1)
X_nj = nj.Tensor(X)
y_nj = nj.Tensor(y)
W1_nj = nj.Tensor(W1, diff=True)
W2_nj = nj.Tensor(W2, diff=True)
X_torch = torch.tensor(X)
y_torch = torch.tensor(y)
W1_torch = torch.tensor(W1, requires_grad=True)
W2_torch = torch.tensor(W2, requires_grad=True)
return X_nj, y_nj, W1_nj, W2_nj, X_torch, y_torch, W1_torch, W2_torch
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,741 | VIVelev/nujo | refs/heads/master | /examples/nn_linear.py | import nujo as nj
import nujo.nn as nn
import nujo.objective as obj
import nujo.optim as optim
from nujo.utils import ComputationGraphPlotter
# Define the net and optimizer
net = nn.Linear(3, 6) >> nn.Linear(6, 2) >> nn.Linear(2, 1)
print('Defined net:', net)
loss_fn = obj.L2Loss()
print('Loss:', loss_fn)
optimizer = optim.Adam(net.parameters, lr=0.1)
print('Optimizer:', optimizer)
# Training loop
def train(net, x, y, num_epochs):
for epoch in range(1, num_epochs + 1):
# Forward
output = net(x)
# Compute Loss
loss = loss_fn(output, y)
# Print the loss every 10th epoch for monitoring
if epoch % 10 == 0:
print('EPOCH:', epoch, '| LOSS: ', loss.value)
# Backprop
loss.backward()
# Update
optimizer.step()
# Zero grad
optimizer.zero_grad()
return loss
if __name__ == '__main__':
# Create example data
x = nj.rand(3, 30, name='X_train')
y = nj.Tensor([2, 3, 4] @ x - 10, name='y_train')
# Train
loss = train(net, x, y, 100)
# Visualize the Neural Network as a computation graph
cg_plot = ComputationGraphPlotter(filename='graph').create(loss)
cg_plot.view()
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,742 | VIVelev/nujo | refs/heads/master | /nujo/optim/optimizer.py | from abc import abstractmethod
from typing import Generator
from nujo.autodiff import Tensor, no_diff
class Optimizer:
''' Stochastic Gradient Descent Optimizer
A base class. If you want to implement a custom
optimizer you should inherit this class.
The optimizers are made to work with nujo flows.
Parameters:
-----------
- params : generator of Tensors, the parameters which to update
- lr : float, the learning rate
'''
def __init__(self, params: Generator[Tensor, None, None], lr: float):
self.params = params
self.lr = lr
@abstractmethod
def update_rule(self, param: Tensor, grad: Tensor) -> Tensor:
''' Implement the update rule here. '''
pass
def step(self) -> None:
''' Updates all the parameters.
'''
with no_diff():
for param in self.params():
param <<= self.update_rule(param, param.grad)
def zero_grad(self) -> None:
''' Zeros the gradients of the parameters.
'''
for param in self.params():
param.zero_grad()
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,743 | VIVelev/nujo | refs/heads/master | /tests/test_optim/test_optimizers.py | import pytest
import nujo.optim as optim
from nujo import mean, rand, randn
# ====================================================================================================
# Test Stochastic Gradient Descent (SGD)
@pytest.mark.slow
def test_sgd_basic(scalar_params, get_generator_for, num_iters,
quadratic_loss):
optimizer = optim.SGD(get_generator_for(scalar_params))
prev_loss = 1e3
for _ in range(num_iters):
loss = quadratic_loss(scalar_params)
loss.backward()
optimizer.step()
optimizer.zero_grad()
assert loss < prev_loss
prev_loss = loss.value
@pytest.mark.slow
def test_sgd_matrix(vec_params, get_generator_for, num_iters, matrix_mse_loss):
optimizer = optim.SGD(get_generator_for(vec_params))
prev_loss = 1e3
for i in range(num_iters):
loss = matrix_mse_loss(vec_params)
loss.backward()
optimizer.step()
optimizer.zero_grad()
assert loss < prev_loss
prev_loss = loss.value
# ====================================================================================================
# Test Momentum optimizer
@pytest.mark.slow
def test_momentum_basic(scalar_params, get_generator_for, num_iters,
quadratic_loss):
optimizer = optim.Momentum(get_generator_for(scalar_params))
prev_loss = 1e3
for _ in range(num_iters):
loss = quadratic_loss(scalar_params)
loss.backward()
optimizer.step()
optimizer.zero_grad()
assert loss < prev_loss
prev_loss = loss.value
@pytest.mark.slow
def test_momentum_matrix(vec_params, get_generator_for, num_iters,
matrix_mse_loss):
optimizer = optim.Momentum(get_generator_for(vec_params))
prev_loss = 1e3
for i in range(num_iters):
loss = matrix_mse_loss(vec_params)
loss.backward()
optimizer.step()
optimizer.zero_grad()
assert loss < prev_loss
prev_loss = loss.value
# ====================================================================================================
# Test RMSprop optimizer
@pytest.mark.slow
def test_rmsprop_basic(scalar_params, get_generator_for, num_iters,
quadratic_loss):
optimizer = optim.RMSprop(get_generator_for(scalar_params))
prev_loss = 1e3
for _ in range(num_iters):
loss = quadratic_loss(scalar_params)
loss.backward()
optimizer.step()
optimizer.zero_grad()
assert loss < prev_loss
prev_loss = loss.value
@pytest.mark.slow
def test_rmsprop_matrix(vec_params, get_generator_for, num_iters,
matrix_mse_loss):
optimizer = optim.RMSprop(get_generator_for(vec_params))
prev_loss = 1e3
for i in range(num_iters):
loss = matrix_mse_loss(vec_params)
loss.backward()
optimizer.step()
optimizer.zero_grad()
assert loss < prev_loss
prev_loss = loss.value
# ====================================================================================================
# Test Adam optimizer
@pytest.mark.slow
def test_adam_basic(scalar_params, get_generator_for, num_iters,
quadratic_loss):
optimizer = optim.Adam(get_generator_for(scalar_params))
prev_loss = 1e3
for _ in range(num_iters):
loss = quadratic_loss(scalar_params)
loss.backward()
optimizer.step()
optimizer.zero_grad()
assert loss < prev_loss
prev_loss = loss.value
@pytest.mark.slow
def test_adam_matrix(vec_params, get_generator_for, num_iters,
matrix_mse_loss):
optimizer = optim.Adam(get_generator_for(vec_params))
prev_loss = 1e3
for i in range(num_iters):
loss = matrix_mse_loss(vec_params)
loss.backward()
optimizer.step()
optimizer.zero_grad()
assert loss < prev_loss
prev_loss = loss.value
# ====================================================================================================
# PyTest Fixtures
@pytest.fixture
def scalar_params():
return [rand(diff=True)]
@pytest.fixture
def vec_params():
return [rand(3, 1, diff=True)]
@pytest.fixture
def get_generator_for():
def gen(params):
def g():
yield params[0]
return g
return gen
@pytest.fixture
def num_iters():
return 512
@pytest.fixture
def quadratic_loss():
def compute(params):
return 3 * (params[0]**2) + 5 * params[0] + 7
return compute
@pytest.fixture
def matrix_mse_loss():
X = rand(3, 3)
y = X @ randn(3, 1) + rand()
def compute(params):
return mean((y - X @ params[0])**2)
return compute
# ===================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,744 | VIVelev/nujo | refs/heads/master | /nujo/objective/__init__.py | ''' nujo's objective functions module
All sorts of objective functions used in machine learning are defined here.
More details here:
https://ml-cheatsheet.readthedocs.io/en/latest/loss_functions.html
'''
from nujo.objective.loss import *
from nujo.objective.qualitative import *
from nujo.objective.quantitative import *
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,745 | VIVelev/nujo | refs/heads/master | /tests/test_nn/test_layers.py | import pytest
import torch
import torch.nn as torch_nn
import nujo as nj
import nujo.nn as nj_nn
# ====================================================================================================
def test_single_conv2d(image_input):
nj_tensor, torch_tensor = image_input
nj_conv = nj_nn.Conv2d(3, 6, 4, stride=2, padding=4, dilation=1)
torch_conv = torch_nn.Conv2d(3, 6, 4, stride=2, padding=4, dilation=2)
# Test Forward
nj_output = nj_conv(nj_tensor)
torch_output = torch_conv(torch_tensor)
assert nj_output.shape == torch_output.shape
# Test Backward
nj_output.backward()
nj_params = list(nj_conv.parameters())
assert nj_params[0].shape == nj_conv[0].b.shape
assert nj_params[1].shape == nj_conv[0].kernels.shape
# ====================================================================================================
def test_chained_conv2d(image_input):
nj_tensor, torch_tensor = image_input
nj_conv = nj_nn.Conv2d(3, 6, 4, stride=2, padding=4, dilation=1) >> \
nj_nn.Conv2d(6, 9, 5, stride=2, padding=4, dilation=1) >> \
nj_nn.Conv2d(9, 12, 6, stride=2, padding=4, dilation=1)
torch_conv = torch_nn.Sequential(
torch_nn.Conv2d(3, 6, 4, stride=2, padding=4, dilation=2),
torch_nn.Conv2d(6, 9, 5, stride=2, padding=4, dilation=2),
torch_nn.Conv2d(9, 12, 6, stride=2, padding=4, dilation=2))
# Test Forward
nj_output = nj_conv(nj_tensor)
torch_output = torch_conv(torch_tensor)
assert nj_output.shape == torch_output.shape
# Test Backward
nj_output.backward()
nj_params = list(nj_conv.parameters())
assert nj_params[0].shape == nj_conv[0].b.shape
assert nj_params[1].shape == nj_conv[0].kernels.shape
# ====================================================================================================
# Unit Test fixtures
@pytest.fixture
def image_input():
shape = (32, 3, 28, 28)
return nj.randn(*shape), torch.randn(*shape).float()
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,746 | VIVelev/nujo | refs/heads/master | /nujo/autodiff/_functions/_transform.py | from numbers import Number
from typing import List, Optional, Tuple, Union
from numpy import add, arange, ndarray, pad, repeat, tile, zeros
from nujo._cache import cached_property
from nujo.autodiff.function import Function
from nujo.autodiff.tensor import Tensor
__all__ = [
'_Reshape',
'_Transpose',
'_ConstPad',
'_Im2col',
]
# ====================================================================================================
class _Reshape(Function):
def __init__(self, input: Union[Tensor, ndarray, List[Number], Number],
shape: Tuple[int, ...]):
super(_Reshape, self).__init__(input)
self.shape = shape
self._input_shape = self.children[0].shape
def forward(self) -> ndarray:
return self.children[0].value.reshape(*self.shape)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad.reshape(*self._input_shape)
# ====================================================================================================
class _Transpose(Function):
def __init__(self,
input: Union[Tensor, ndarray, List[Number], Number],
dims: Optional[Tuple[int, ...]] = None):
super(_Transpose, self).__init__(input)
self.dims = dims if dims is not None else reversed(
range(len(self.children[0].shape)))
self._detranspose_dims = sorted(range(len(self.dims)),
key=lambda idx: self.dims[idx])
def forward(self) -> ndarray:
return self.children[0].value.transpose(*self.dims)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
return accum_grad.transpose(*self._detranspose_dims)
# ====================================================================================================
class _ConstPad(Function):
''' Constant padding by a value
Pads an array before and after for each dimension with a given constant
value. (default: 0)
Parameters:
-----------
- input : array to pad
- padding : tuple of tuples of two ints specifying the padding before
and after for each dimension
- value : float, the constant value to pad with (default: 0)
'''
def __init__(self,
input: Union[Tensor, ndarray, List[Number], Number],
padding: Tuple[Tuple[int, int], ...],
value: float = 0):
super(_ConstPad, self).__init__(input)
# Assert a padding `(before, after)` was specified for each dimension
# only. No more, no less.
assert len(self.children[0].shape) == len(padding)
self.padding = padding
self.value = value
def forward(self) -> ndarray:
return pad(self.children[0].value,
self.padding,
constant_values=self.value)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
idxs = tuple(
slice(dim_pad[0], accum_grad.shape[i] - dim_pad[1])
for i, dim_pad in enumerate(self.padding))
return accum_grad[idxs]
# ====================================================================================================
class _Im2col(Function):
''' Image to column shape transformation
The local regions in the input image are stretched out into columns.
For example, if the input is [3x227x227] and it is to be convolved
with 3x11x11 filters at stride (4, 4), then we would take [3x11x11]
blocks of pixels in the input and stretch each block into a column
vector of size 3*11*11 = 363. Iterating this process in the input
at stride of (4, 4) gives (227-11)/4+1 = 55 locations along both
height and width, leading to an output matrix X_col of Im2col of size
[363 x 3025], where every column is a stretched out receptive field
and there are 55*55 = 3025 of them in total.
Reference: CS231n Stanford
(https://cs231n.github.io/convolutional-networks/)
Parameters:
-----------
- input : image shaped array, shape: (batch_size, channels, height, width)
- kernel_size : tuple of 2 integers, image filter height and width
- stride : tuple of 2 integers, stride of the convolution
- dilation : tuple of 2 integers, spacing between kernel elements
'''
def __init__(
self,
input: Union[Tensor, ndarray, List[Number], Number],
kernel_size: Tuple[int, int],
stride: Tuple[int, int],
dilation: Tuple[int, int],
):
super(_Im2col, self).__init__(input)
# Shape of `input` should be: (batch_size, channels, height, width)
assert len(self.children[0].shape) == 4
self.kernel_size = kernel_size
self.stride = stride
self.dilation = dilation
def forward(self) -> ndarray:
''' Method which turns the image shaped input to column shape
'''
images = self.children[0].value
# Reshape content into column shape
k, i, j = self._im2col_indices
return images[:, k, i, j]\
.transpose(1, 2, 0).reshape(self._n_features, -1)
def backward(self, idx: int, accum_grad: Function.T) -> Function.T:
''' Method which turns the column shaped input to image shape
'''
# Create images placeholder
images = zeros(self.children[0].shape)
# Separate the image sections and the batch_size (shape[0])
separated_grad = accum_grad\
.reshape(self._n_features, -1, images.shape[0])\
.transpose(2, 0, 1) # Move the batch_size at the beginning
# Fill in the placeholder
k, i, j = self._im2col_indices
add.at(images, (slice(None), k, i, j), separated_grad)
return images
@cached_property
def _im2col_indices(self) -> Tuple[ndarray, ndarray, ndarray]:
''' Calculate the indices where the dot products are
to be applied between the weights and the image.
'''
# Obtain needed information
channels = self.children[0].shape[1]
kernel_height, kernel_width = self.kernel_size
stride_height, stride_width = self.stride
dilation_height, dilation_width = self.dilation
out_height, out_width = self._output_shape
# Calculate sections' rows
step = dilation_height + 1
section_rows = repeat(arange(0, kernel_height * step, step),
kernel_width)
section_rows = tile(section_rows, channels)
# Slide rows by stride
slide_rows = stride_width * repeat(arange(out_height), out_width)
section_rows = section_rows.reshape(-1, 1) + slide_rows.reshape(1, -1)
# Calculate sections' columns
step = dilation_width + 1
section_cols = tile(arange(0, kernel_width * step, step),
kernel_height * channels)
# Slide cols by stride
slide_cols = stride_height * tile(arange(out_width), out_height)
section_cols = section_cols.reshape(-1, 1) + slide_cols.reshape(1, -1)
# Calculate sections' channels
section_channels = repeat(arange(channels),
kernel_height * kernel_width).reshape(-1, 1)
# Return indices
return section_channels, section_rows, section_cols
@cached_property
def _output_shape(self):
# Obtain needed information
_, _, height, width = self.children[0].shape
kernel_height, kernel_width = self.kernel_size
stride_height, stride_width = self.stride
dilation_height, dilation_width = self.dilation
# Calculate output shape
out_height = (height - dilation_height *
(kernel_height - 1) - kernel_height) // stride_height + 1
out_width = (width - dilation_width *
(kernel_width - 1) - kernel_width) // stride_width + 1
return out_height, out_width
@cached_property
def _n_features(self):
''' number of features in the column form
'''
return self.kernel_size[0] * self.kernel_size[1] *\
self.children[0].shape[1] # number of channels
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,747 | VIVelev/nujo | refs/heads/master | /tests/test_nn/test_activations.py | import pytest
from numpy import allclose, exp, maximum, sum
import nujo.nn.activations as activ
from nujo.autodiff.tensor import Tensor
# ====================================================================================================
# Test BinaryStep activation function
def test_binary_step(inputs):
# Test Forward pass
output = activ.BinaryStep()(inputs)
assert (output == [[0, 0, 0], [1, 0, 1]]).all()
# Test Backward pass
output.backward()
assert (inputs.grad == 0).all()
# ====================================================================================================
# Test Sigmoid activation function
def test_sigmoid(inputs):
# Test Forward pass
output = activ.Sigmoid()(inputs)
x = inputs.value
assert (output == 1 / (1 + exp(-x))).all()
# Test Backward pass
output.backward()
assert (inputs.grad == output.value * (1 - output.value)).all()
# ====================================================================================================
# Test TanH activation function
def test_tanh(inputs):
# Test Forward pass
output = activ.TanH()(inputs)
x = inputs.value
assert allclose(output.value, (exp(x) - exp(-x)) / (exp(x) + exp(-x)))
# Test Backward pass
output.backward()
assert (inputs.grad == 1 - output.value**2).all()
# ====================================================================================================
# Test ReLU activation function
def test_relu(inputs):
# Test Forward pass
output = activ.ReLU()(inputs)
x = inputs.value
assert (output == maximum(0, x)).all()
# Test Backward pass
output.backward()
assert (inputs.grad[inputs.grad > 0] == 1).all()
assert (inputs.grad[inputs.grad <= 0] == 0).all()
# ====================================================================================================
# Test LeakyReLU activation function
def test_leaky_relu(inputs):
# Test Forward pass
eps = 0.1
output = activ.LeakyReLU(eps=eps)(inputs)
x = inputs.value
assert (output == maximum(eps * x, x)).all()
# Test Backward pass
output.backward()
assert (inputs.grad[inputs.grad > 0] == 1).all()
assert (inputs.grad[inputs.grad <= 0] == eps).all()
# ====================================================================================================
# Test Swish activation function
def test_swish(inputs):
# Test Forward pass
beta = 1
output = activ.Swish(beta=beta)(inputs)
x = inputs.value
sigma = activ.Sigmoid()(beta * x).value
assert (output == x * sigma).all()
# Test Backward pass
output.backward()
assert (inputs.grad == output.value + sigma * (1 - output.value)).all()
# ====================================================================================================
# Test Softmax activation function
def test_softmax(inputs):
# Test Forward pass
output = activ.Softmax()(inputs)
exps = exp(inputs.value)
sums = sum(exps, axis=0, keepdims=True)
assert allclose(output.value, exps / sums)
# Test Backward pass
# TODO: Test Backward pass appropriately.
output.backward()
assert True
# ====================================================================================================
# Unit Test fixtures
@pytest.fixture
def inputs():
return Tensor([[0.42, 0.32, 0.34], [0.6, 0.1, 1.1]], diff=True)
# ====================================================================================================
| {"/nujo/flow.py": ["/nujo/autodiff/tensor.py"], "/examples/graph_visualization.py": ["/nujo/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_flow.py": ["/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/nujo/autodiff/__init__.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/modes.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/layers.py": ["/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py", "/nujo/init/random.py"], "/nujo/optim/__init__.py": ["/nujo/optim/optimizer.py", "/nujo/optim/optimizers.py"], "/nujo/math/aggregate.py": ["/nujo/autodiff/_functions/_aggregate.py", "/nujo/autodiff/tensor.py"], "/nujo/objective/loss.py": ["/nujo/flow.py", "/nujo/math/aggregate.py"], "/nujo/autodiff/tensor.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/_utils.py", "/nujo/autodiff/_functions/_transform.py", "/nujo/autodiff/_functions/_elementary.py", "/nujo/math/aggregate.py"], "/nujo/nn/__init__.py": ["/nujo/nn/activations.py", "/nujo/nn/layers.py"], "/nujo/objective/quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/scalar.py", "/nujo/objective/loss.py"], "/nujo/objective/qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/math/__init__.py", "/nujo/objective/loss.py"], "/tests/test_objective/test_qualitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/qualitative.py"], "/tests/test_math/test_scalar.py": ["/nujo/math/scalar.py", "/nujo/init/random.py"], "/nujo/init/random.py": ["/nujo/autodiff/tensor.py"], "/nujo/utils/__init__.py": ["/nujo/utils/computation_graph_plotter.py"], "/nujo/utils/computation_graph_plotter.py": ["/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_elementary.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/examples/mnist_feed_forward_nn.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/tests/test_math/test_aggregate.py": ["/nujo/math/aggregate.py", "/nujo/init/random.py"], "/nujo/init/__init__.py": ["/nujo/init/basic.py", "/nujo/init/random.py"], "/tests/test_autodiff/test_tensor.py": ["/nujo/__init__.py", "/nujo/autodiff/_functions/_elementary.py"], "/nujo/autodiff/_functions/_activations.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/math/scalar.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/autodiff/tensor.py"], "/nujo/init/basic.py": ["/nujo/autodiff/tensor.py"], "/nujo/autodiff/function.py": ["/nujo/autodiff/modes.py", "/nujo/autodiff/_node.py", "/nujo/autodiff/tensor.py"], "/nujo/autodiff/_functions/_aggregate.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/nujo/nn/activations.py": ["/nujo/autodiff/_functions/_activations.py", "/nujo/autodiff/tensor.py", "/nujo/flow.py"], "/tests/test_objective/test_quantitative.py": ["/nujo/autodiff/tensor.py", "/nujo/init/random.py", "/nujo/objective/quantitative.py"], "/tests/test_autodiff/test_functions/test_elementary.py": ["/nujo/autodiff/_functions/_elementary.py", "/nujo/__init__.py"], "/nujo/optim/optimizers.py": ["/nujo/autodiff/tensor.py", "/nujo/init/basic.py", "/nujo/math/scalar.py", "/nujo/optim/optimizer.py"], "/nujo/autodiff/_functions/_trigonometric.py": ["/nujo/autodiff/function.py"], "/nujo/math/__init__.py": ["/nujo/math/aggregate.py", "/nujo/math/scalar.py"], "/nujo/__init__.py": ["/nujo/autodiff/__init__.py", "/nujo/flow.py", "/nujo/init/__init__.py", "/nujo/math/__init__.py"], "/tests/test_autodiff/test_node.py": ["/nujo/autodiff/_node.py"], "/tests/test_autodiff/test_autodiff.py": ["/nujo/__init__.py"], "/examples/nn_linear.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py", "/nujo/objective/__init__.py", "/nujo/optim/__init__.py", "/nujo/utils/__init__.py"], "/nujo/optim/optimizer.py": ["/nujo/autodiff/__init__.py"], "/tests/test_optim/test_optimizers.py": ["/nujo/optim/__init__.py", "/nujo/__init__.py"], "/nujo/objective/__init__.py": ["/nujo/objective/loss.py", "/nujo/objective/qualitative.py", "/nujo/objective/quantitative.py"], "/tests/test_nn/test_layers.py": ["/nujo/__init__.py", "/nujo/nn/__init__.py"], "/nujo/autodiff/_functions/_transform.py": ["/nujo/autodiff/function.py", "/nujo/autodiff/tensor.py"], "/tests/test_nn/test_activations.py": ["/nujo/nn/activations.py", "/nujo/autodiff/tensor.py"]} |
67,749 | luozhouyang/stupidtree | refs/heads/master | /stupidtree/examples/address/node_test.py | # Copyright (c) 2018 luozhouyang
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import unittest
from stupidtree.examples.address.level import Level
from .node import AddressNode
class TestNode(unittest.TestCase):
def test_equality(self):
n0 = AddressNode(data='中国', level=Level.COUNTRY, parent=None)
n1 = AddressNode(data='浙江', level=Level.PROVINCE, parent=n0)
n2 = AddressNode(data='浙江', level=Level.CITY, parent=n0)
n3 = AddressNode(data='浙江', level=Level.PROVINCE, parent=None)
n4 = AddressNode(data='杭州', level=Level.PROVINCE, parent=n0)
n5 = AddressNode(data='杭州', level=Level.CITY, parent=n0)
n6 = AddressNode(data='杭州', level=Level.CITY, parent=n1)
self.assertNotEqual(n0, n1)
self.assertNotEqual(n1, n2)
self.assertNotEqual(n2, n3)
self.assertNotEqual(n3, n4)
self.assertNotEqual(n4, n5)
self.assertNotEqual(n5, n6)
n7 = AddressNode(data='浙江', level=Level.PROVINCE, parent=None)
self.assertEqual(n3, n7)
self.assertEqual(n3.path_value(), n7.path_value())
self.assertEqual(n3.csv_path_value(), n7.csv_path_value())
n8 = AddressNode(data=None, level=None, parent=None)
n9 = AddressNode(data=None, level=None, parent=None)
self.assertEqual(n8, n9)
self.assertEqual(n8.path_value(), n9.path_value())
self.assertEqual(n8.csv_path_value(), n9.csv_path_value())
if __name__ == "__main__":
unittest.main()
| {"/stupidtree/examples/address/pcd_tree_test.py": ["/stupidtree/examples/address/pcd_tree.py"]} |
67,750 | luozhouyang/stupidtree | refs/heads/master | /stupidtree/core/base_tree.py | # Copyright (c) 2018 luozhouyang
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import abc
from stupidtree.core.node import Node
class BaseTreeInterface(abc.ABC):
"""A interface defines basic abilities a tree has."""
@abc.abstractmethod
def put(self, words):
"""Put a list of string or a single SPACE separated string to tree.
:param words: If it is a list of string, each word in that will be inserted
into tree. If it is a SPACE separated string, it will be split
to a list of string and then insert these words to the tree.
:return:
"""
raise NotImplementedError()
@abc.abstractmethod
def get(self, key):
"""Get all the nodes in the tree whose `data` field equals the `key`.
:param key: The key to match.
:return: A list of `AddressNode` objects if found, or empty list.
"""
raise NotImplementedError()
@abc.abstractmethod
def remove(self, key, rm_filter=None):
"""Remove nodes whose `data` field euqls the `key` from the tree.
If not found any node by the `key` in the tree, then do noting.
If found node(s), the caller can decide whether remove the node or not
using the `rm_filter` argument, whose signature is:
```python
def callback(node)
if ...:
return True
return False
```
If `callback` returns `True`, the node will be removed,
or returns `False', the node will be reserved.
If `callback` is None, each node matched will be removed.
:param key: The key to match.
:param rm_filter: A callback function to decide whether remove the node
or not.This is helpful when there has multi nodes that
match the `key`.
:return:
"""
raise NotImplementedError()
@abc.abstractmethod
def size(self):
"""The total number of nodes in the tree."""
raise NotImplementedError()
class BaseTree(BaseTreeInterface):
def __init__(self):
self.root = None
self.nodes_count = 0
def put(self, words):
if isinstance(words, list):
self._put(self.root, words, 0)
elif isinstance(words, str):
self._put(self.root, words.split(" "), 0)
else:
raise TypeError("Argument `words` must be SPACE "
"separated str or list Type.")
def _put(self, node, words, depth):
if not node:
node = self._create_root_node(words, depth)
self.root = node
assert node
self.on_insert(node)
if depth == len(words):
return
# child = AddressNode(words[depth], Level(depth + 2), node)
child = self._create_node(node, words, depth)
assert isinstance(child, Node)
for c in node.children:
if c == child:
self._put(c, words, depth + 1)
return
child.parent = node
node.children.append(child)
self.on_insert(child)
self._put(child, words, depth + 1)
@abc.abstractmethod
def _create_root_node(self, words, depth):
"""Create the root node.
:param words: words that to be inserted
:param depth: index of current word in words
:return: A root node. Can not be NoneType
"""
raise NotImplementedError()
@abc.abstractmethod
def _create_node(self, node, words, depth):
"""Create node
:param node: parent node
:param words: words to be inserted
:param depth: index of current word in words
:return: A node. Can not be NoneType
"""
raise NotImplementedError()
@abc.abstractmethod
def on_insert(self, node):
"""Notify node insertion
:param node: the node to be inserted.
:return:
"""
raise NotImplementedError()
@abc.abstractmethod
def get(self, key):
raise NotImplementedError()
def remove(self, key, rm_filter=None):
nodes = self.get(key)
if not nodes or len(nodes) == 0:
return
for n in nodes.copy():
if not rm_filter or rm_filter(n):
self._remove(n)
def _remove(self, n):
for c in n.children.copy():
self._remove(c)
self.on_remove(n)
if n.parent:
n.parent.children.remove(n)
n.parent = None
@abc.abstractmethod
def on_remove(self, node):
"""Notify node remove
:param node: the node to be removed
:return:
"""
raise NotImplementedError()
def size(self):
return self.nodes_count
def print(self):
self._print(self.root, 0)
def _print(self, node, depth):
if depth == 0:
print("+--" + node.data)
for c in node.children:
print("| " * (depth + 1) + "+--" + c.data)
self._print(c, depth + 1)
| {"/stupidtree/examples/address/pcd_tree_test.py": ["/stupidtree/examples/address/pcd_tree.py"]} |
67,751 | luozhouyang/stupidtree | refs/heads/master | /stupidtree/examples/address/pcd_tree_test.py | # Copyright (c) 2018 luozhouyang
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import unittest
from stupidtree.examples.address.level import Level
from stupidtree.examples.address.pcd_tree import PCDTree
class TestPCDTree(unittest.TestCase):
def test_put(self):
tree = PCDTree()
a0 = '浙江省 杭州市 西湖区'
tree.put(a0)
self.assertEqual(4, tree.size())
tree.print()
a1 = '浙江省 杭州市 江干区'
tree.put(a1)
self.assertEqual(5, tree.size())
nodes = tree.get('浙江省')
self.assertEqual(1, len(nodes))
for n in nodes:
self.assertEqual(Level.PROVINCE, n.tag)
def test_remove(self):
tree = PCDTree()
a0 = '浙江省 杭州市 西湖区'
tree.put(a0)
a1 = '浙江省 杭州市 江干区'
tree.put(a1)
tree.print()
tree.remove('江干区')
self.assertEqual(4, tree.size())
tree.print()
tree.remove('浙江省')
self.assertEqual(1, tree.size())
tree.print()
tree.remove('')
print()
tree.print()
self.assertEqual(0, tree.size())
if __name__ == "__main__":
unittest.main()
| {"/stupidtree/examples/address/pcd_tree_test.py": ["/stupidtree/examples/address/pcd_tree.py"]} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.