Example #1
0
def test_gki_2_prows_no_append():
    """ Test 2 prow calls with no append (2 dev$pix rows) to 2 .ps's """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot
    iraf.prow("dev$pix", row=250, dev=PSDEV)  # plot again (flushes 1st)
    # get output postscript temp file name
    prf = None
    if os.uname()[0] == 'SunOS':
        prf = '.eps'  # Solaris can leave extras here
    psOut = getNewTmpPskFile(flistBef, "2_prows_no_append - A", preferred=prf)
    # diff
    # NOTE - this seems to get 0-len files when (not stdin.isatty()) for psdump
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_256.ps"))
    # NOW flush second
    flistBef = findAllTmpPskFiles()
    iraf.gflush()
    # get output postscript temp file name
    prf = None
    if os.uname()[0] == 'SunOS':
        prf = '.eps'  # Solaris can leave extras here
    psOut = getNewTmpPskFile(flistBef, "2_prows_no_append - B", preferred=prf)
    # diff
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_250.ps"))
Example #2
0
def test_gki_prow_to_different_devices():  # rename to disable for now
    """Test 2 prow calls, each to different devices - one .ps written.

    10 May 2012 - rename to disable for now - is sending nightly prints
    to hpc84.
    It seems that the cups system takes the print to hp_dev_null and
    changes that to an existing printer, knowing it is wrong ...
    When there is time, look into a way to start this test up again without any
    danger of prints going to an actual printer.
    """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # use a fake printer name so we don't waste a sheet of paper with each test
    os.environ['LPDEST'] = "hp_dev_null"
    os.environ['PRINTER'] = "hp_dev_null"
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot (no .ps file yet)
    # plot to fake printer, should flush
    iraf.prow("dev$pix", row=333, dev="lw")
    # last plot, and should warn @ fake
    # get output postscript temp file name
    psOut = getNewTmpPskFile(flistBef, "prow_to_different_devices")
    # diff
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_256.ps"))
    # NOW flush - should do nothing
    flistBef = findAllTmpPskFiles()
    iraf.gflush()
    flistAft = findAllTmpPskFiles()
    assert flistBef == flistAft, "Extra tmp .ps file written? "+str(flistAft)
Example #3
0
def gki_2_prows_no_append_test():
   """ Test 2 prow calls with no append (2 dev$pix rows) to 2 .ps's """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot
   iraf.prow("dev$pix", row=250, dev=PSDEV) # plot again (flushes 1st)
   # get output postscript temp file name
   prf = None
   if os.uname()[0] == 'SunOS': prf = '.eps' # Solaris can leave extras here
   psOut = getNewTmpPskFile(flistBef, "2_prows_no_append - A", preferred=prf)
   # diff
   # NOTE - this seems to get 0-len files when (not stdin.isatty()) for psdump
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256.ps")
   # NOW flush second
   flistBef = findAllTmpPskFiles()
   iraf.gflush()
   # get output postscript temp file name
   prf = None
   if os.uname()[0] == 'SunOS': prf = '.eps' # Solaris can leave extras here
   psOut = getNewTmpPskFile(flistBef, "2_prows_no_append - B", preferred=prf)
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_250.ps")
Example #4
0
def test_whereis(tmpdir):
    iraf.plot(_doprint=0)
    iraf.images(_doprint=0)
    outfile = str(tmpdir.join('output.txt'))

    cases = ("pw", "lang", "st", "std", "stdg", "stdpl", "star", "star man",
             "vi", "noao", "impl", "ls", "surf", "surf man", "smart man",
             "img", "prot", "pro", "prow", "prows", "prowss", "dis", "no")

    # Test the whereis function
    for arg in cases:
        args = arg.split(" ")  # convert to a list
        iraf.printf("--> whereis " + arg + '\n', StdoutAppend=outfile)
        kw = {'StderrAppend': outfile}
        iraf.whereis(*args, **kw)  # catches stdout+err

    with open(outfile) as f:
        for line in f:
            if 'task not found' in line:
                continue

            row = line.split()
            if line.startswith('-->'):
                cmd = row[2]
                if len(row) > 3:
                    cmd2 = row[3]
            elif row[0] == 'user.man' and cmd2 == 'man':
                pass
            else:
                assert all([s.split('.')[1].startswith(cmd) for s in row]), \
                    '{}'.format(row)
Example #5
0
def test_whereis(tmpdir):
    iraf.plot(_doprint=0)
    iraf.images(_doprint=0)
    outfile = str(tmpdir.join('output.txt'))

    cases = ("pw", "lang", "st", "std", "stdg", "stdpl", "star", "star man",
             "vi", "noao", "impl", "ls", "surf", "surf man", "smart man",
             "img", "prot", "pro", "prow", "prows", "prowss", "dis", "no")

    # Test the whereis function
    for arg in cases:
        args = arg.split(" ")  # convert to a list
        iraf.printf("--> whereis " + arg + '\n', StdoutAppend=outfile)
        kw = {'StderrAppend': outfile}
        iraf.whereis(*args, **kw)  # catches stdout+err

    with open(outfile) as f:
        for line in f:
            if 'task not found' in line:
                continue

            row = line.split()
            if line.startswith('-->'):
                cmd = row[2]
                if len(row) > 3:
                    cmd2 = row[3]
            elif row[0] == 'user.man' and cmd2 == 'man':
                pass
            else:
                assert all([s.split('.')[1].startswith(cmd) for s in row]), \
                    '{}'.format(row)
Example #6
0
def test_gkidecode(tmpdir):
    iraf.plot(_doprint=0)
    prow_stdout = str(tmpdir.join('test_prow_256.gki'))
    gki_stdout = str(tmpdir.join('gkidecode_stdout.txt'))
    gki_stderr = str(tmpdir.join('gkidecode_stderr.txt'))

    iraf.prow("dev$pix", row=256, StdoutG=prow_stdout)
    iraf.gkidecode(prow_stdout, Stdout=gki_stdout, Stderr=gki_stderr)
    assert 'close_workstation' in open(gki_stdout).readlines()[-1]
    assert not open(gki_stderr).readlines()
Example #7
0
def radprofile(xint,yint,radius,intv,az1=0,az2=360):
	p=[]
	pe=[]
	px=[]
	iraf.plot(_doprint=0)
	iraf.pradprof("pi.fits", xinit=xint, yinit=yint, radius=radius, az1=az1, az2=az2, center="no", list="yes",Stdout="profile1")
	x,y=loadtxt("profile1", usecols=(0,1), unpack=True)
	t=radius/intv
	for i in range(t):
		px.append(intv*(i+0.5))
Example #8
0
def test_gki_single_prow():
    """ Test a prow-plot of a single row from dev$pix to .ps """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot
    iraf.gflush()
    # get output postscript temp file name
    psOut = getNewTmpPskFile(flistBef, "single_prow")
    # diff
    diffit(EXP2IGNORE, psOut, os.path.join(DATA_DIR, PSDEV + "_prow_256.ps"))
Example #9
0
def setup():
    orig_graphics = capable.OF_GRAPHICS
    capable.OF_GRAPHICS = True
    iraf.plot()  # load plot pkg
    #    gki._resetGraphicsKernel()
    # clean slate
    graphenv = os.environ.get('PYRAFGRAPHICS')
    if graphenv is not None:
        del os.environ['PYRAFGRAPHICS']
    yield
    gki.kernel.clear()
    capable.OF_GRAPHICS = orig_graphics
    if graphenv is not None:
        os.environ['PYRAFGRAPHICS'] = graphenv
Example #10
0
def test_gki_prow_1_append():
    """ Test a prow-plot with 1 append (2 rows total, dev$pix) to .ps """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot
    iraf.prow("dev$pix", row=250, dev=PSDEV, append=True)  # append #1
    iraf.gflush()
    # get output postscript temp file name
    psOut = getNewTmpPskFile(flistBef, "prow_1_append")
    # diff
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_256_250.ps"))
Example #11
0
def gki_prow_1_append_test():
   """ Test a prow-plot with 1 append (2 rows total, dev$pix) to .ps """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot
   iraf.prow("dev$pix", row=250, dev=PSDEV, append=True) # append #1
   iraf.gflush()
   # get output postscript temp file name
   psOut = getNewTmpPskFile(flistBef, "prow_1_append")
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256_250.ps")
Example #12
0
def gki_prow_2_appends_test():
   """ Test a prow-plot with 2 appends (3 rows total, dev$pix) to .ps """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot
   iraf.prow("dev$pix", row=250, dev=PSDEV, append=True) # append #1
   iraf.prow("dev$pix", row=200, dev=PSDEV, append=True) # append #2
   iraf.gflush()
   # get output postscript temp file name
   psOut = getNewTmpPskFile(flistBef, "prow_2_appends")
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256_250_200.ps")
Example #13
0
def test_gki_prow_2_appends():
    """ Test a prow-plot with 2 appends (3 rows total, dev$pix) to .ps """
    iraf.plot(_doprint=0)  # load plot for prow
    # get look at tmp dir before plot/flush
    flistBef = findAllTmpPskFiles()
    # plot
    iraf.prow("dev$pix", row=256, dev=PSDEV)  # plot
    iraf.prow("dev$pix", row=250, dev=PSDEV, append=True)  # append #1
    iraf.prow("dev$pix", row=200, dev=PSDEV, append=True)  # append #2
    iraf.gflush()
    # get output postscript temp file name
    psOut = getNewTmpPskFile(flistBef, "prow_2_appends")
    # diff
    diffit(EXP2IGNORE, psOut,
           os.path.join(DATA_DIR, PSDEV + "_prow_256_250_200.ps"))
Example #14
0
def test_which(tmpdir):
    iraf.plot(_doprint=0)
    iraf.images(_doprint=0)
    outfile = str(tmpdir.join('output.txt'))

    # To Test: normal case, disambiguation, ambiguous, not found, multiple
    #          inputs for a single command
    cases = ("pw", "lang", "stdg", "stdp", "star", "star man", "vi", "noao",
             "impl", "ls", "surf", "surface", "img", "pro", "prot", "prow",
             "prows", "prowss", "dis")

    # Test the which function
    for arg in cases:
        args = arg.split(" ")  # convert to a list
        iraf.printf("--> which " + arg + '\n', StdoutAppend=outfile)
        kw = {"StderrAppend": outfile}
        iraf.which(*args, **kw)  # catches stdout+err

    diff_outputs(outfile, 'data/cli_which_output.ref')
Example #15
0
def test_which(tmpdir):
    iraf.plot(_doprint=0)
    iraf.images(_doprint=0)
    outfile = str(tmpdir.join('output.txt'))

    # To Test: normal case, disambiguation, ambiguous, not found, multiple
    #          inputs for a single command
    cases = ("pw", "lang", "stdg", "stdp", "star", "star man", "vi", "noao",
             "impl", "ls", "surf", "surface", "img", "pro", "prot", "prow",
             "prows", "prowss", "dis")

    # Test the which function
    for arg in cases:
        args = arg.split(" ")  # convert to a list
        iraf.printf("--> which " + arg + '\n', StdoutAppend=outfile)
        kw = {"StderrAppend": outfile}
        iraf.which(*args, **kw)  # catches stdout+err

    diff_outputs(outfile, 'data/cli_which_output.ref')
Example #16
0
def gki_prow_to_different_devices_tst(): # rename to disable for now
   """ Test 2 prow calls, each to different devices - one .ps written """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # use a fake printer name so we don't waste a sheet of paper with each test
   os.environ['LPDEST'] = "hp_dev_null"
   os.environ['PRINTER'] = "hp_dev_null"
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot (no .ps file yet)
   iraf.prow("dev$pix", row=333, dev="lw") # plot to fake printer, should flush
                                           # last plot, and should warn @ fake
   # get output postscript temp file name
   psOut = getNewTmpPskFile(flistBef, "prow_to_different_devices")
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256.ps")
   # NOW flush - should do nothing
   flistBef = findAllTmpPskFiles()
   iraf.gflush()
   flistAft = findAllTmpPskFiles()
   assert flistBef==flistAft, "Extra tmp .ps file written? "+str(flistAft)
Example #17
0
def gki_prow_to_different_devices_tst(): # rename to disable for now
   """ Test 2 prow calls, each to different devices - one .ps written """
   iraf.plot(_doprint=0) # load plot for prow
   # get look at tmp dir before plot/flush
   flistBef = findAllTmpPskFiles()
   # use a fake printer name so we don't waste a sheet of paper with each test
   os.environ['LPDEST'] = "hp_dev_null"
   os.environ['PRINTER'] = "hp_dev_null"
   # plot
   iraf.prow("dev$pix", row=256, dev=PSDEV) # plot (no .ps file yet)
   iraf.prow("dev$pix", row=333, dev="lw") # plot to fake printer, should flush
                                           # last plot, and should warn @ fake
   # get output postscript temp file name
   psOut = getNewTmpPskFile(flistBef, "prow_to_different_devices")
   # diff
   diffit(EXP2IGNORE, psOut,
          os.environ['PYRAF_TEST_DATA']+os.sep+PSDEV+"_prow_256.ps")
   # NOW flush - should do nothing
   flistBef = findAllTmpPskFiles()
   iraf.gflush()
   flistAft = findAllTmpPskFiles()
   assert flistBef==flistAft, "Extra tmp .ps file written? "+str(flistAft)
Example #18
0
import matplotlib.pyplot as plt
import sys
from pyraf import iraf
import math
#import pdb
import matplotlib

#matplotlib.rc('text', usetex=True)
#matplotlib.rcParams['text.latex.preamble']=[r"\usepackage{amsmath}"]

#pyraf command
p=[]
pe=[]
for i in range(360/5):
  q=[]
  iraf.plot(_doprint=0)
  iraf.pradprof("pi.fits", xinit=257.071, yinit=256.058, radius=50, az1=5*i, az2=5*i+5, center="no", list="yes",Stdout="profile1")
  x,y=loadtxt("profile1", usecols=(0,1), unpack=True)
  t=len(x)
  
  
#determine range of the profile
  for j in range(t):
    if x[j] < 15: continue
    q.append(y[j])
  p.append(mean(q))
  pe.append(std(q))
px=range(0,360,5)


#convert ADU to Jy
Example #19
0
from scipy.integrate import quad
from scipy.stats import *
from datetime import datetime, date, time
import matplotlib.pyplot as plt
from datetime import timedelta
from numpy.random import randint
import pyfits
iraf.tables()
iraf.noao()
iraf.imred()
iraf.twodspec()
iraf.onedspec()
iraf.ccdred()
iraf.apextract()
iraf.longslit()
iraf.plot()
iraf.stsdas()
iraf.nebular()
from time import strftime


#############################################################
########Setup a list of lines and fitting regions
#############################################################

#the list of lines
linenames=[3727,4102,4340,4363,4686,4861,4959,5007,5755,5876,6548,6562,6584,6717,6731]
elines=array([.5*(3727.092+3729.875),4102.89,4341.68,4364.436,4686,4862.68,4960.295,5008.240,5754.59,5876,6549.86,6564.61,6585.27,6718.29,6732.67])
#define a preferred background region width
bgsize=20
#define a perferred background region offset (should be larger than the expected line half-width)
Example #20
0
                  resDict['case names'].append(case)
            else:
               resDict['case names'] = [case]
            # add times to results dict
            if case in resDict:
               resDict[case].append(secs)
            else:
               resDict[case] = [secs]
            # only do one plot for surface or contour (not varied cases)
            if mo in ('surface','contour'):
               break
         did = 1


if __name__ == '__main__':
   iraf.plot() # load plot pkg

   # clean slate
   if 'PYRAFGRAPHICS' in os.environ:
      del os.environ['PYRAFGRAPHICS']
   os.environ['PYRAF_GRAPHICS_ALWAYS_ON_TOP']='1' # rm display bounce dur test
   total = time.time()

   res = {} # mostly a dict of test case times, but 1 item is list of case names

   # Tk
   os.environ['PYRAFGRAPHICS'] = 'tkplot'
   runAllCases('TK', res)

   # MPL kernel
   os.environ['PYRAFGRAPHICS'] = 'matplotlib'
Example #21
0
                        resDict['case names'].append(case)
                else:
                    resDict['case names'] = [case]
                # add times to results dict
                if case in resDict:
                    resDict[case].append(secs)
                else:
                    resDict[case] = [secs]
                # only do one plot for surface or contour (not varied cases)
                if mo in ('surface', 'contour'):
                    break
            did = 1


if __name__ == '__main__':
    iraf.plot()  # load plot pkg

    # clean slate
    if 'PYRAFGRAPHICS' in os.environ:
        del os.environ['PYRAFGRAPHICS']
    os.environ[
        'PYRAF_GRAPHICS_ALWAYS_ON_TOP'] = '1'  # rm display bounce dur test
    total = time.time()

    res = {
    }  # mostly a dict of test case times, but 1 item is list of case names

    # Tk
    os.environ['PYRAFGRAPHICS'] = 'tkplot'
    runAllCases('TK', res)