本文整理汇总了Python中pyraf.iraf.imred函数的典型用法代码示例。如果您正苦于以下问题:Python imred函数的具体用法?Python imred怎么用?Python imred使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imred函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: wl_cal
def wl_cal(filename, outname, cals):
print 'run wavelength calibration...'
if os.path.isfile(outname):
print 'file %s is already exist' % outname
else:
iraf.imred()
iraf.specred()
print 'The calibration file is listed below:'
for i in xrange(len(cals)):
print i, cals[i], get_fits_objname(cals[i])
valget = 0
if len(cals) > 1:
valget = raw_input('Which one are you want to use?:')
while type(eval(valget)) != int:
valget = raw_input('input is not a int type, please reinput:')
valget = int(valget)
iraf.refspectra(input = filename
, references = cals[valget], apertures = '', refaps = ''
, ignoreaps = True, select = 'interp', sort = ''
, group = '', time = False, timewrap = 17.0
, override = False, confirm = True, assign = True
, logfiles = 'STDOUT,logfile', verbose = False, answer = 'yes')
print 'make file ' + outname + '...'
iraf.dispcor(input = filename
, output = outname, linearize = True, database = 'database'
, table = '', w1 = 'INDEF', w2 = 'INDEF', dw = 'INDEF'
, nw = 'INDEF', log = False, flux = True, blank = 0.0
, samedisp = False, ignoreaps = True
, confirm = False, listonly = False, verbose = True
, logfile = '')
print 'splot %s' % outname
iraf.splot(images = outname)
开发者ID:zzxihep,项目名称:spec2015,代码行数:32,代码来源:ext_spec_line.py
示例2: divflat
def divflat(imagesre, flat='Flat'):
'''Run ccdproc task to images'''
imageslist = glob.glob(imagesre)
imagesin = ', '.join(imageslist)
# Load packages
iraf.imred()
iraf.ccdred()
# Unlearn settings
iraf.ccdred.ccdproc.unlearn()
iraf.ccdred.combine.unlearn()
# Setup and run task
iraf.ccdred.ccdproc.ccdtype = ''
iraf.ccdred.ccdproc.noproc = False
iraf.ccdred.ccdproc.fixpix = False
iraf.ccdred.ccdproc.overscan = False
iraf.ccdred.ccdproc.darkcor = False
iraf.ccdred.ccdproc.illumcor = False
iraf.ccdred.ccdproc.fringecor = False
iraf.ccdred.ccdproc.readcor = False
iraf.ccdred.ccdproc.scancor = False
iraf.ccdred.ccdproc.trim = False
iraf.ccdred.ccdproc.trimsec = ''
iraf.ccdred.ccdproc.readaxis = 'line'
iraf.ccdred.ccdproc.zerocor = False
iraf.ccdred.ccdproc.zero = ''
iraf.ccdred.ccdproc.flatcor = True
iraf.ccdred.ccdproc.flat = flat
iraf.ccdred.ccdproc(images=imagesin)
开发者ID:evandromr,项目名称:scripts_pyraf,代码行数:30,代码来源:lnacoudetasks.py
示例3: coroverbiastrim
def coroverbiastrim(lstfile):
iraf.noao()
iraf.imred()
iraf.ccdred()
x1,x2,y1,y2 = get_trim_sec()
iraf.ccdproc(images = '@' + lstfile + '//[1]'
, output = '%bo%bo%@' + lstfile
, ccdtype = '', max_cache = 0, noproc = False
, fixpix = False, overscan = True, trim = False
, zerocor = True, darkcor = False, flatcor = False
, illumcor = False, fringecor = False, readcor = False
, scancor = False, readaxis = 'line', fixfile = ''
, biassec = '[5:45,%s:%s]'%(y1,y2), trimsec = '[%s:%s,%s:%s]'%(x1,x2,y1,y2)
, zero = 'Zero', dark = '', flat = '', illum = '', fringe = ''
, minreplace = 1.0, scantype = 'shortscan', nscan = 1
, interactive = False, function = 'chebyshev', order = 1
, sample = '*', naverage = 1, niterate = 1
, low_reject = 3.0, high_reject = 3.0, grow = 1.0)
iraf.ccdproc(images = '%bo%bo%@' + lstfile
, output = '%tbo%tbo%@' + lstfile
, ccdtype = '', max_cache = 0, noproc = False
, fixpix = False, overscan = False, trim = True
, zerocor = False, darkcor = False, flatcor = False
, illumcor = False, fringecor = False, readcor = False
, scancor = False, readaxis = 'line', fixfile = ''
, biassec = '[5:45,%s:%s]'%(y1,y2), trimsec = '[%s:%s,%s:%s]'%(x1,x2,y1,y2)
, zero = 'Zero', dark = '', flat = '', illum = '', fringe = ''
, minreplace = 1.0, scantype = 'shortscan', nscan = 1
, interactive = False, function = 'chebyshev', order = 1
, sample = '*', naverage = 1, niterate = 1
, low_reject = 3.0, high_reject = 3.0, grow = 1.0)
iraf.flpr()
开发者ID:zzxihep,项目名称:spec2015_1,代码行数:32,代码来源:cor_ftbo.py
示例4: correctimages
def correctimages(imagesre, zero='Zero', flat='nFlat'):
'''Run ccdproc task to correct images'''
imageslist = glob.glob(imagesre)
imagesin = ', '.join(imageslist)
trimsection = str(raw_input('Enter trim section (or Hit <Enter>): '))
trimquery = True
if trimsection == '':
trimquery = False
# Load Packages
iraf.imred()
iraf.ccdred()
# Unlearn Settings
iraf.ccdred.ccdproc.unlearn()
iraf.ccdred.combine.unlearn()
# Setup and run task
iraf.ccdred.ccdproc.ccdtype = ''
iraf.ccdred.ccdproc.noproc = False
iraf.ccdred.ccdproc.fixpix = False
iraf.ccdred.ccdproc.overscan = False
iraf.ccdred.ccdproc.darkcor = False
iraf.ccdred.ccdproc.illumcor = False
iraf.ccdred.ccdproc.fringecor = False
iraf.ccdred.ccdproc.readcor = False
iraf.ccdred.ccdproc.scancor = False
iraf.ccdred.ccdproc.trim = trimquery
iraf.ccdred.ccdproc.trimsec = trimsection
iraf.ccdred.ccdproc.readaxis = 'line'
iraf.ccdred.ccdproc.zerocor = True
iraf.ccdred.ccdproc.zero = zero
iraf.ccdred.ccdproc.flatcor = True
iraf.ccdred.ccdproc.flat = flat
iraf.ccdred.ccdproc(images=imagesin)
开发者ID:evandromr,项目名称:scripts_pyraf,代码行数:35,代码来源:lnacoudetasks.py
示例5: subzero
def subzero(imagesre, zero='Zero'):
'''Run ccdproc remove Zero level noise'''
imageslist = glob.glob(imagesre)
imagesin = ', '.join(imageslist)
# Load packages
iraf.imred()
iraf.ccdred()
# Unlearn previouse settings
iraf.ccdred.ccdproc.unlearn()
iraf.ccdred.combine.unlearn()
# setup and run task
iraf.ccdred.ccdproc.ccdtype = ''
iraf.ccdred.ccdproc.noproc = False
iraf.ccdred.ccdproc.fixpix = False
iraf.ccdred.ccdproc.overscan = False
iraf.ccdred.ccdproc.darkcor = False
iraf.ccdred.ccdproc.illumcor = False
iraf.ccdred.ccdproc.fringecor = False
iraf.ccdred.ccdproc.readcor = False
iraf.ccdred.ccdproc.scancor = False
iraf.ccdred.ccdproc.trim = False
iraf.ccdred.ccdproc.trimsec = ''
iraf.ccdred.ccdproc.readaxis = 'line'
iraf.ccdred.ccdproc.zerocor = True
iraf.ccdred.ccdproc.zero = zero
iraf.ccdred.ccdproc.flatcor = False
iraf.ccdred.ccdproc.flat = ''
iraf.ccdred.ccdproc(images=imagesin)
开发者ID:evandromr,项目名称:scripts_pyraf,代码行数:30,代码来源:lnacoudetasks.py
示例6: masterbias
def masterbias(biasre, output='Zero', combine='median', reject='minmax',
ccdtype='', rdnoise='rdnoise', gain='gain'):
'''run the task ccdred.zerocombine with chosen parameters
Input:
-------
str biasre: regular expression to identify zero level images
Output:
-------
file Zero.fits: combined zerolevel images
'''
biaslist = glob.glob(biasre)
biasstring = ', '.join(biaslist)
# load packages
iraf.imred()
iraf.ccdred()
# unlearn settings
iraf.imred.unlearn()
iraf.ccdred.unlearn()
iraf.ccdred.ccdproc.unlearn()
iraf.ccdred.combine.unlearn()
iraf.ccdred.zerocombine.unlearn()
iraf.ccdred.setinstrument.unlearn()
# setup task
iraf.ccdred.zerocombine.output = output
iraf.ccdred.zerocombine.combine = combine
iraf.ccdred.zerocombine.reject = reject
iraf.ccdred.zerocombine.ccdtype = ccdtype
iraf.ccdred.zerocombine.rdnoise = rdnoise
iraf.ccdred.zerocombine.gain = gain
# run task
iraf.ccdred.zerocombine(input=biasstring)
开发者ID:evandromr,项目名称:scripts_pyraf,代码行数:35,代码来源:lnacoudetasks.py
示例7: scalewavelenght
def scalewavelenght(calspec):
''' Creates a wavelenght solution for 'calspec' '''
iraf.imred()
iraf.specred()
linelist = str(raw_input('Enter file with list of lines (linelists$thar.dat) : '))
if linelist == '':
linelist = 'linelists$thar.dat'
iraf.specred.identify.coordlist = linelist
iraf.specred.identify(images=calspec)
开发者ID:evandromr,项目名称:scripts_pyraf,代码行数:10,代码来源:lnacoudetasks.py
示例8: combinebias
def combinebias(filename):
iraf.noao()
iraf.imred()
iraf.ccdred()
iraf.zerocombine(input = 'o//@' + filename
, output = 'Zero', combine = 'average', reject = 'minmax'
, ccdtype = '', process = False, delete = False
, clobber = False, scale = 'none', statsec = ''
, nlow = 0, nhigh = 1, nkeep = 1, mclip = True
, lsigma = 3.0, hsigma = 3.0, rdnoise = 'rdnoise'
, gain = 'gain', snoise = 0.0, pclip = -0.5, blank = 0.0)
开发者ID:zzxihep,项目名称:spec2015_1,代码行数:11,代码来源:gen_zero.py
示例9: main
def main():
iraf.noao()
iraf.imred()
iraf.ccdred()
print '=' * 20, 'Overscan', '=' * 20
correct_overscan('spec.lst')
print '=' * 20, 'combine bias', '=' * 20
combine_bias('bias.lst')
print '=' * 20, 'correct bias', '=' * 20
correct_bias('spec_no_bias.lst', 'bias_spec.fits')
name = os.popen('ls object*.lst').readlines()
name = [i.split()[0] for i in name]
for i in name:
ntrim_flat(i)
开发者ID:zzxihep,项目名称:spec2015,代码行数:14,代码来源:correct_fits_ftbo.py
示例10: flatresponse
def flatresponse(input='Flat', output='nFlat'):
''' normalize Flat to correct illumination patterns'''
iraf.imred()
iraf.ccdred()
iraf.specred()
iraf.ccdred.combine.unlearn()
iraf.ccdred.ccdproc.unlearn()
iraf.specred.response.unlearn()
iraf.specred.response.interactive = True
iraf.specred.response.function = 'chebyshev'
iraf.specred.response.order = 1
iraf.specred.response(calibration=input, normalization=input,
response=output)
开发者ID:evandromr,项目名称:scripts_pyraf,代码行数:15,代码来源:lnacoudetasks.py
示例11: ImportPackages
def ImportPackages():
iraf.noao(_doprint=0)
iraf.rv(_doprint=0)
iraf.imred(_doprint=0)
iraf.kpnoslit(_doprint=0)
iraf.ccdred(_doprint=0)
iraf.astutil(_doprint=0)
iraf.keywpars.setParam('ra','CAT-RA')
iraf.keywpars.setParam('dec','CAT-DEC')
iraf.keywpars.setParam('ut','UT')
iraf.keywpars.setParam('utmiddl','UT-M_E')
iraf.keywpars.setParam('exptime','EXPTIME')
iraf.keywpars.setParam('epoch','CAT-EPOC')
iraf.keywpars.setParam('date_ob','DATE-OBS')
iraf.keywpars.setParam('hjd','HJD')
iraf.keywpars.setParam('mjd_obs','MJD-OBS')
iraf.keywpars.setParam('vobs','VOBS')
iraf.keywpars.setParam('vrel','VREL')
iraf.keywpars.setParam('vhelio','VHELIO')
iraf.keywpars.setParam('vlsr','VLSR')
iraf.keywpars.setParam('vsun','VSUN')
iraf.keywpars.setParam('mode','ql')
iraf.fxcor.setParam('continu','both')
iraf.fxcor.setParam('filter','none')
iraf.fxcor.setParam('rebin','smallest')
iraf.fxcor.setParam('pixcorr','no')
iraf.fxcor.setParam('apodize','0.2')
iraf.fxcor.setParam('function','gaussian')
iraf.fxcor.setParam('width','INDEF')
iraf.fxcor.setParam('height','0.')
iraf.fxcor.setParam('peak','no')
iraf.fxcor.setParam('minwidt','3.')
iraf.fxcor.setParam('maxwidt','21.')
iraf.fxcor.setParam('weights','1.')
iraf.fxcor.setParam('backgro','0.')
iraf.fxcor.setParam('window','INDEF')
iraf.fxcor.setParam('wincent','INDEF')
iraf.fxcor.setParam('verbose','long')
iraf.fxcor.setParam('imupdat','no')
iraf.fxcor.setParam('graphic','stdgraph')
iraf.fxcor.setParam('interac','yes')
iraf.fxcor.setParam('autowri','yes')
iraf.fxcor.setParam('autodra','yes')
iraf.fxcor.setParam('ccftype','image')
iraf.fxcor.setParam('observa','lapalma')
iraf.fxcor.setParam('mode','ql')
return 0
开发者ID:jmccormac01,项目名称:Spectroscopy,代码行数:48,代码来源:FXCOR.py
示例12: corhalogen
def corhalogen(lstfile):
iraf.noao()
iraf.imred()
iraf.ccdred()
iraf.ccdproc(images = '[email protected]' + lstfile
, output = '%ftbo%ftbo%@' + lstfile
, ccdtype = '', max_cache = 0, noproc = False
, fixpix = False, overscan = False, trim = False
, zerocor = False, darkcor = False, flatcor = True
, illumcor = False, fringecor = False, readcor = False
, scancor = False, readaxis = 'line', fixfile = ''
, biassec = '', trimsec = ''
, zero = 'Zero', dark = '', flat = 'Resp', illum = '', fringe = ''
, minreplace = 1.0, scantype = 'shortscan', nscan = 1
, interactive = False, function = 'chebyshev', order = 1
, sample = '*', naverage = 1, niterate = 1
, low_reject = 3.0, high_reject = 3.0, grow = 1.0)
iraf.flpr()
开发者ID:zzxihep,项目名称:spec2015_1,代码行数:18,代码来源:cor_ftbo.py
示例13: coroverscan
def coroverscan(filename):
iraf.noao()
iraf.imred()
iraf.ccdred()
iraf.ccdproc(images = '@' + filename + '//[1]'
, output = '%o%o%@' + filename
, ccdtype = '', max_cache = 0, noproc = False
, fixpix = False, overscan = True, trim = False
, zerocor = False, darkcor = False, flatcor = False
, illumcor = False, fringecor = False, readcor = False
, scancor = False, readaxis = 'line', fixfile = ''
, biassec = '[5:45,1:4612]', trimsec = '', zero = ''
, dark = '', flat = '', illum = '', fringe = ''
, minreplace = 1.0, scantype = 'shortscan', nscan = 1
, interactive = False, function = 'chebyshev', order = 1
, sample = '*', naverage = 1, niterate = 1
, low_reject = 3.0, high_reject = 3.0, grow = 1.0)
iraf.flpr()
开发者ID:zzxihep,项目名称:spec2015_1,代码行数:18,代码来源:gen_zero.py
示例14: runapall
def runapall(imagesre, gain='gain', rdnoise='rdnoise'):
'''Extract aperture spectra for science images ...'''
imageslist = glob.glob(imagesre)
imagesin = ', '.join(imageslist)
# load packages
iraf.imred()
iraf.ccdred()
iraf.specred()
# unlearn previous settings
iraf.ccdred.combine.unlearn()
iraf.ccdred.ccdproc.unlearn()
iraf.specred.apall.unlearn()
# setup and run task
iraf.specred.apall.format = 'onedspec'
iraf.specred.apall.readnoise = rdnoise
iraf.specred.apall.gain = gain
iraf.specred.apall(input=imagesin)
开发者ID:evandromr,项目名称:scripts_pyraf,代码行数:19,代码来源:lnacoudetasks.py
示例15: findaperture
def findaperture(img, _interactive=False):
# print "LOGX:: Entering `findaperture` method/function in %(__file__)s" %
# globals()
import re
import string
import os
from pyraf import iraf
import ntt
iraf.noao(_doprint=0)
iraf.imred(_doprint=0)
iraf.specred(_doprint=0)
toforget = ['specred.apfind']
for t in toforget:
iraf.unlearn(t)
iraf.specred.databas = 'database'
iraf.specred.dispaxi = 2
iraf.specred.apedit.thresho = 0
dv = ntt.dvex()
grism = ntt.util.readkey3(ntt.util.readhdr(img), 'grism')
if _interactive:
_interac = 'yes'
_edit = 'yes'
else:
_interac = 'no'
_edit = 'no'
if os.path.isfile('database/ap' + re.sub('.fits', '', img)):
ntt.util.delete('database/ap' + re.sub('.fits', '', img))
xx = iraf.specred.apfind(img, interac=_interac, find='yes', recenter='yes', edit=_edit, resize='no',
aperture=1, Stdout=1, nfind=1, line=dv['line'][grism], nsum=50, mode='h')
try:
for line in open('database/ap' + re.sub('.fits', '', img)):
if "center" in line:
center = float(string.split(line)[1])
except:
center = 9999
return center
开发者ID:svalenti,项目名称:pessto,代码行数:38,代码来源:sofispec1Ddef.py
示例16: combine_flat
def combine_flat(lstfile):
iraf.noao()
iraf.imred()
iraf.ccdred()
iraf.flatcombine(input = 'tbo//@' + lstfile
, output = 'Halogen', combine = 'average', reject = 'crreject'
, ccdtype = '', process = False, subsets = False
, delete = False, clobber = False, scale = 'mode'
, statsec = '', nlow = 1, nhigh = 1, nkeep = 1
, mclip = True, lsigma = 3.0, hsigma = 3.0
, rdnoise = 'rdnoise', gain = 'gain', snoise = 0.0
, pclip = -0.5, blank = 1.0)
script_path = os.path.split(os.path.realpath(__file__))[0]
iraf.twodspec()
iraf.longslit(dispaxis = 2, nsum = 1, observatory = 'observatory'
, extinction = script_path + os.sep + 'LJextinct.dat'
, caldir = script_path + os.sep + 'standarddir' + os.sep, interp = 'poly5')
iraf.response(calibration = 'Halogen'
, normalization = 'Halogen', response = 'Resp'
, interactive = True, threshold = 'INDEF', sample = '*'
, naverage = 1, function = 'spline3', order = 25
, low_reject = 10.0, high_reject = 10.0, niterate = 1
, grow = 0.0, graphics = 'stdgraph', cursor = '')
开发者ID:zzxihep,项目名称:spec2015_1,代码行数:23,代码来源:cor_ftbo.py
示例17: masterflat
def masterflat(flatre, output='Flat', combine='median', reject='sigclip',
scale='mode', rdnoise='rdnoise', gain='gain'):
'''combine flat images with the task ccdred.flatcombine
Input:
-------
str: flatre - regular expression to bias files in the current directory
Output:
-------
file: Flat.fits - combined flat field images
'''
flatlist = glob.glob(flatre)
flatstring = ', '.join(flatlist)
# load packages
iraf.imred()
iraf.ccdred()
# unlearn settings
iraf.imred.unlearn()
iraf.ccdred.unlearn()
iraf.ccdred.ccdproc.unlearn()
iraf.ccdred.combine.unlearn()
iraf.ccdred.flatcombine.unlearn()
iraf.ccdred.setinstrument.unlearn()
# setup task
iraf.ccdred.flatcombine.output = output
iraf.ccdred.flatcombine.combine = combine
iraf.ccdred.flatcombine.reject = reject
iraf.ccdred.flatcombine.ccdtype = ''
iraf.ccdred.flatcombine.process = 'no'
iraf.ccdred.flatcombine.subsets = 'yes'
iraf.ccdred.flatcombine.scale = scale
iraf.ccdred.flatcombine.rdnoise = rdnoise
iraf.ccdred.flatcombine.gain = gain
iraf.ccdred.flatcombine(input=flatstring)
开发者ID:evandromr,项目名称:scripts_pyraf,代码行数:37,代码来源:lnacoudetasks.py
示例18: extractSpectra
def extractSpectra():
"""
Extract 1D spectra using IRAF interactively
Interpolate across the two arcs either side to
get the most accurate wavelength solution
TODO: Finish docstring
Add method of using super arc for inital
identify
"""
# load IRAF from the location of the login.cl file
here = os.getcwd()
os.chdir(loginCl_location)
from pyraf import iraf
os.chdir(here)
time.sleep(2)
# make a list of the science images to be analysed
templist = g.glob('i_s*')
# import IRAF packages for spectroscopy
iraf.imred(_doprint=0)
iraf.kpnoslit(_doprint=0)
# apall parameters
iraf.apall.setParam('format', 'multispec')
iraf.apall.setParam('interac', 'yes')
iraf.apall.setParam('find', 'yes')
iraf.apall.setParam('recen', 'yes')
iraf.apall.setParam('resize', 'yes')
iraf.apall.setParam('trace', 'yes')
iraf.apall.setParam('fittrac', 'yes')
iraf.apall.setParam('extract', 'yes')
iraf.apall.setParam('extras', 'yes')
iraf.apall.setParam('review', 'yes')
iraf.apall.setParam('line', 'INDEF')
iraf.apall.setParam('nsum', '12')
iraf.apall.setParam('lower', '-6')
iraf.apall.setParam('upper', '6')
iraf.apall.setParam('b_funct', 'chebyshev')
iraf.apall.setParam('b_order', '1')
iraf.apall.setParam('b_sampl', '-25:-15,15:25')
iraf.apall.setParam('b_naver', '-100')
iraf.apall.setParam('b_niter', '0')
iraf.apall.setParam('b_low_r', '3')
iraf.apall.setParam('b_high', '3')
iraf.apall.setParam('b_grow', '0')
iraf.apall.setParam('width', '10')
iraf.apall.setParam('radius', '10')
iraf.apall.setParam('threshold', '0')
iraf.apall.setParam('nfind', '1')
iraf.apall.setParam('t_nsum', '10')
iraf.apall.setParam('t_step', '10')
iraf.apall.setParam('t_nlost', '3')
iraf.apall.setParam('t_niter', '7')
iraf.apall.setParam('t_funct', 'spline3')
iraf.apall.setParam('t_order', '3')
iraf.apall.setParam('backgro', 'fit')
iraf.apall.setParam('skybox', '1')
iraf.apall.setParam('weights', 'variance')
iraf.apall.setParam('pfit', 'fit1d')
iraf.apall.setParam('clean', 'yes')
iraf.apall.setParam('saturat', SATURATION)
iraf.apall.setParam('readnoi', RDNOISE)
iraf.apall.setParam('gain', GAIN)
iraf.apall.setParam('lsigma', '4.0')
iraf.apall.setParam('usigma', '4.0')
iraf.apall.setParam('nsubaps', '1')
iraf.apall.saveParList(filename="apall.pars")
# make reference arc for reidentify
if '.' in args.refarc:
args.refarc = args.refarc.split('.')[0]
refarc = "a_s_{}_t.fits".format(args.refarc)
refarc_out = "a_s_{}_t.ms.fits".format(args.refarc)
# loop over all the the spectra
for i in range(0, len(templist)):
hdulist = fits.open(templist[i])
prihdr = hdulist[0].header
target_id = prihdr['CAT-NAME']
spectrum_id = int(templist[i].split('_')[2].split('r')[1])
if args.ds9:
os.system('xpaset fuckingds9 fits < {}'.format(templist[i]))
# extract the object spectrum
print("[{}/{}] Extracting spectrum of {} from image {}".format(i+1, len(templist), target_id, templist[i]))
print("[{}/{}] Check aperture and background. Change if required".format(i+1, len(templist)))
print("[{}/{}] AP: m = mark aperture, d = delete aperture".format(i+1, len(templist)))
print("[{}/{}] SKY: s = mark sky, t = delete sky, f = refit".format(i+1, len(templist)))
print("[{}/{}] q = continue".format(i+1, len(templist)))
iraf.apall(input=templist[i])
print("Spectrum extracted!")
# find the arcs either side of the object
arclist = []
arc1 = "a_s_r{0:d}_t.fits".format(spectrum_id-1)
arc2 = "a_s_r{0:d}_t.fits".format(spectrum_id+1)
arc1_out = "a_s_r{0:d}_t.ms.fits".format(spectrum_id-1)
arc2_out = "a_s_r{0:d}_t.ms.fits".format(spectrum_id+1)
# predict the arc names
print("\nPredicting arcs names...")
print("Arc1: {}".format(arc1))
#.........这里部分代码省略.........
开发者ID:jmccormac01,项目名称:Spectroscopy,代码行数:101,代码来源:Spector.py
示例19: efoscspec1Dredu
def efoscspec1Dredu(files, _interactive, _ext_trace, _dispersionline, liststandard, listatmo0, _automaticex,
_verbose=False):
# print "LOGX:: Entering `efoscspec1Dredu` method/function in
# %(__file__)s" % globals()
import ntt
try: import pyfits
except: from astropy.io import fits as pyfits
import re
import string
import sys
import os
import numpy as np
os.environ["PYRAF_BETA_STATUS"] = "1"
_extinctdir = 'direc$standard/extinction/'
_extinction = 'lasilla2.txt'
_observatory = 'lasilla'
import datetime
now = datetime.datetime.now()
datenow = now.strftime('20%y%m%d%H%M')
MJDtoday = 55927 + (datetime.date.today() - datetime.date(2012, 01, 01)).days
dv = ntt.dvex()
scal = np.pi / 180.
_gain = ntt.util.readkey3(ntt.util.readhdr(
re.sub('\n', '', files[0])), 'gain')
_rdnoise = ntt.util.readkey3(
ntt.util.readhdr(re.sub('\n', '', files[0])), 'ron')
std, rastd, decstd, magstd = ntt.util.readstandard(
'standard_efosc_mab.txt')
objectlist = {}
for img in files:
hdr = ntt.util.readhdr(img)
img = re.sub('\n', '', img)
ntt.util.correctcard(img)
_ra = ntt.util.readkey3(hdr, 'RA')
_dec = ntt.util.readkey3(hdr, 'DEC')
_object = ntt.util.readkey3(hdr, 'object')
_grism = ntt.util.readkey3(hdr, 'grism')
_filter = ntt.util.readkey3(hdr, 'filter')
_slit = ntt.util.readkey3(hdr, 'slit')
dd = np.arccos(np.sin(_dec * scal) * np.sin(decstd * scal) + np.cos(_dec * scal) *
np.cos(decstd * scal) * np.cos((_ra - rastd) * scal)) * ((180 / np.pi) * 3600)
if min(dd) < 100:
_type = 'stdsens'
else:
_type = 'obj'
if min(dd) < 100:
ntt.util.updateheader(
img, 0, {'stdname': [std[np.argmin(dd)], '']})
ntt.util.updateheader(
img, 0, {'magstd': [float(magstd[np.argmin(dd)]), '']})
if _type not in objectlist:
objectlist[_type] = {}
if (_grism, _filter, _slit) not in objectlist[_type]:
objectlist[_type][_grism, _filter, _slit] = [img]
else:
objectlist[_type][_grism, _filter, _slit].append(img)
from pyraf import iraf
iraf.noao(_doprint=0)
iraf.imred(_doprint=0)
iraf.specred(_doprint=0)
iraf.imutil(_doprint=0)
toforget = ['imutil.imcopy', 'specred.sarith', 'specred.standard']
for t in toforget:
iraf.unlearn(t)
iraf.specred.verbose = 'no'
iraf.specred.dispaxi = 2
iraf.set(direc=ntt.__path__[0] + '/')
sens = {}
print objectlist
outputfile = []
if 'obj' in objectlist.keys():
tpe = 'obj'
elif 'stdsens' in objectlist.keys():
tpe = 'stdsens'
else:
sys.exit('error: no objects and no standards in the list')
for setup in objectlist[tpe]:
extracted = []
listatmo = []
if setup not in sens:
sens[setup] = []
if tpe == 'obj':
print '\n### setup= ', setup, '\n### objects= ', objectlist['obj'][setup], '\n'
for img in objectlist['obj'][setup]:
# hdr=readhdr(img)
print '\n\n### next object= ', img, ' ', ntt.util.readkey3(ntt.util.readhdr(img), 'object'), '\n'
if os.path.isfile(re.sub('.fits', '_ex.fits', img)):
if ntt.util.readkey3(ntt.util.readhdr(re.sub('.fits', '_ex.fits', img)), 'quality') == 'Rapid':
ntt.util.delete(re.sub('.fits', '_ex.fits', img))
imgex = ntt.util.extractspectrum(img, dv, _ext_trace, _dispersionline, _interactive, 'obj',
automaticex=_automaticex)
if not os.path.isfile(imgex):
sys.exit('### error, extraction not computed')
#.........这里部分代码省略.........
开发者ID:svalenti,项目名称:pessto,代码行数:101,代码来源:efoscspec1Ddef.py
示例20: sensfunction
def sensfunction(standardfile, _function, _order, _interactive):
# print "LOGX:: Entering `sensfunction` method/function in %(__file__)s" %
# globals()
import re
import os
import sys
import ntt
import datetime
try: import pyfits # added later
except: from astropy.io import fits as pyfits
from pyraf import iraf
import numpy as np
MJDtoday = 55927 + (datetime.date.today() - datetime.date(2012, 01, 01)).days
iraf.noao(_doprint=0)
iraf.imred(_doprint=0)
iraf.specred(_doprint=0)
toforget = ['specred.scopy', 'specred.sensfunc', 'specred.standard']
for t in toforget:
iraf.unlearn(t)
iraf.specred.scopy.format = 'multispec'
iraf.specred.verbose = 'no'
hdrs = ntt.util.readhdr(standardfile)
try:
_outputsens = 'sens_' + str(ntt.util.readkey3(hdrs, 'date-night')) + '_' + \
str(ntt.util.readkey3(hdrs, 'grism')) + '_' + str(ntt.util.readkey3(hdrs, 'filter')) + '_' + \
re.sub('.dat', '', ntt.util.readkey3(
hdrs, 'stdname')) + '_' + str(MJDtoday)
except:
sys.exit('Error: missing header -stdname- in standard ' +
str(standardfile) + ' ')
_outputsens = ntt.util.name_duplicate(standardfile, _outputsens, '')
if os.path.isfile(_outputsens):
if _interactive.lower() != 'yes':
ntt.util.delete(_outputsens)
else:
answ = raw_input(
'sensitivity function already computed, do you want to do it again [[y]/n] ? ')
if not answ:
answ = 'y'
if answ.lower() in ['y', 'yes']:
ntt.util.delete(_outputsens)
if not os.path.isfile(_outputsens):
iraf.set(direc=ntt.__path__[0] + '/')
_caldir = 'direc$standard/MAB/'
_extinctdir = 'direc$standard/extinction/'
_observatory = 'lasilla'
_extinction = 'lasilla2.txt'
refstar = 'm' + \
re.sub('.dat', '', pyfits.open(standardfile)
[0].header.get('stdname'))
_airmass = ntt.util.readkey3(hdrs, 'airmass')
_exptime = ntt.util.readkey3(hdrs, 'exptime')
_outputstd = 'std_' + str(ntt.util.readkey3(hdrs, 'grism')) + '_' + \
str(ntt.util.readkey3(hdrs, 'filter')) + '.fits'
ntt.util.delete(_outputstd)
ntt.util.delete(_outputsens)
iraf.specred.standard(input=standardfile, output=_outputstd, extinct=_extinctdir + _extinction,
caldir=_caldir, observa=_observatory, star_nam=refstar, airmass=_airmass,
exptime=_exptime, interac=_interactive)
iraf.specred.sensfunc(standard=_outputstd, sensitiv=_outputsens, extinct=_extinctdir + _extinction,
ignorea='yes', observa=_observatory, functio=_function, order=_order,
interac=_interactive)
data, hdr = pyfits.getdata(standardfile, 0, header=True) # added later
data1, hdr1 = pyfits.getdata(
_outputsens, 0, header=True) # added later
ntt.util.delete(_outputsens) # added later
pyfits.writeto(_outputsens, np.float32(data1), hdr) # added later
return _outputsens
开发者ID:svalenti,项目名称:pessto,代码行数:74,代码来源:efoscspec1Ddef.py
注:本文中的pyraf.iraf.imred函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论