decsn = _dec distvec, pos0, pos1 = crossmatch(_rasex, _decsex, [_ra], [_dec], 5) else: targ = agnkey.agnsqldef.targimg(img) aa = agnkey.agnsqldef.query(['select ra_sn,dec_sn from lsc_sn_pos where id="' + str(targ) + '"']) if len(aa) > 0: rasn = aa[0]['ra_sn'] decsn = aa[0]['dec_sn'] else: rasn = '' decsn = '' if rasn and decsn: from pyraf import iraf iraf.astcat(_doprint=0) iraf.imcoords(_doprint=0) iraf.digiphot(_doprint=0) iraf.daophot(_doprint=0) lll = [str(rasn) + ' ' + str(decsn)] sss = iraf.wcsctran('STDIN', 'STDOUT', re.sub('sn2.','',img)+'[0]', Stdin=lll, inwcs='world', units='degrees degrees', outwcs='logical', columns='1 2', formats='%10.1f %10.1f', Stdout=1) if _verbose: iraf.display(re.sub('sn2.','',img)+'[0]',fill='yes',frame=1) iraf.tvmark(1, 'STDIN', Stdin = list(sss) ,mark = "circle" , number = 'yes' ,label = 'no' , radii = 10, nxoffse = 5, nyoffse = 5, color = 204, txsize = 2) if 'diff' in img: diffimg = re.sub('diff.sn2.','',img) iraf.display(diffimg+'[0]',fill='yes',frame=2)
if option.show == False: _show = False else: _show = True if option.redo == False: redo = False else: redo = True arterr = '' if _interactive: _show = True print _show, _interactive # ####################### SET IRAF PARAMETERS ####################### from pyraf import iraf iraf.astcat(_doprint=0) iraf.imcoords(_doprint=0) iraf.digiphot(_doprint=0) iraf.daophot(_doprint=0) zmag = 0 iraf.digiphot.daophot.photpars.zmag = zmag ################################# CHECK HEADER ###################################### warn = '##################################\n' for imglong in imglist: if imglong: if imglong[-5:] == '.fits': img = imglong[:-5] else: img = imglong ###### try:
def register_module(img, _system, coordinatelist, interactive, logincl, _filter): from snoopy2 import src import snoopy2 import string, os # logincl=src.open_program() from pyraf import iraf iraf.astcat(_doprint=0) iraf.imcoords(_doprint=0) iraf.set(stdimage='imt1024') iraf.tv.rimexam.backgrou = 'yes' subdirectory = ['optical/', 'infrared/', 'sloan/'] iraf.delete(coordinatelist + ".tv", verify='no') iraf.delete(coordinatelist + "_templ.coo", verify='no') iraf.delete("_templ.*", verify='no') try: dir_system = subdirectory[_system] iraf.fields('home$coordinate_std/' + dir_system + coordinatelist + '.list', '2,3,1', Stdout=coordinatelist + '.tv') iraf.fields('home$coordinate_std/' + dir_system + coordinatelist + '.list', '1', Stdout='_templ.coo') iraf.wcsctran(coordinatelist + '.tv', '_templ.coo2', 'home$coordinate_std/' + dir_system + coordinatelist + '_templ.fits', inwcs='world', units='degrees degrees', outwcs='logical', columns='1 2', formats='%10.1f %10.1f') a = iraf.fields('_templ.coo', '1', Stdout=1) b = iraf.fields('_templ.coo2', '1,2', Stdout=1)[2:] ff = open(coordinatelist + '_templ.coo', 'w') for i in range(len(a)): ff.write(b[i] + '\t' + a[i] + ' \n') ff.close() if _system == 0 or _system == 2: standard = iraf.fields('home$coordinate_std/' + dir_system + coordinatelist + '.list', '1,4,5,6,7,8', Stdout=1) else: standard = iraf.fields('home$coordinate_std/' + dir_system + coordinatelist + '.list', '1,4,5,6', Stdout=1) except Exception as e: print e print "WARNING: no coordinate " + coordinatelist + " file found in " + snoopy2.__path__[ 0] + '/coordinate_std/' + dir_system + ' !!! ' src.close_program(logincl) stars = [] for i in standard: nome = string.split(i) stars.append(nome[0]) # _filter='XXX' src.delete("tmp." + img + ".coo") iraf.wcsctran(coordinatelist + '.tv', 'tmp.' + img + '.coo', img, inwcs='world', units='degrees degrees', outwcs='logical', columns='1 2', formats='%10.1f %10.1f') if interactive: print '######### Select FRAME TILE on your DS9 !!!!!' _z1, _z2, goon = src.display_image( snoopy2.__path__[0] + '/coordinate_std/' + dir_system + coordinatelist + '_templ.fits', 2, '', '', False) if not goon: src.close_program(logincl) iraf.tvmark(2, coordinatelist + '_templ.coo', mark="circle", number='no', label='yes', radii=20, nxoffse=15, nyoffse=15, color=214, txsize=4) _z1, _z2, goon = src.display_image(img, 1, '', '', False) if not goon: src.close_program(logincl) iraf.tvmark(1, 'tmp.' + img + '.coo', mark="circle", number='no', label='yes', radii=20, nxoffse=15, nyoffse=15, color=205, txsize=2) answ = raw_input( 'is the astrometry of the field good ? \n [y/n] ? [y] ') if not answ: answ = 'y' if answ == 'n': try: src.delete('tmp.' + img + '.coo') src.delete('tmp.ccdb') iraf.ccmap('_first.ccmap', 'tmp.ccdb', images=img, fitgeome='rscale', lngunit='degrees', update='yes', interact=False) iraf.wcsctran('_first_image.tv', 'tmp.' + img + '.coo', img, inwcs='world', units='degrees degrees', outwcs='logical', columns='1 2', formats='%10.1f %10.1f') iraf.tvmark(1, 'tmp.' + img + '.coo', mark="circle", number='no', label='yes', radii=20, nxoffse=15, nyoffse=15, color=206, txsize=4) answ = raw_input( 'AND NOW, is the astrometry of the field good [y/n] ? [y] ' ) if not answ: answ = 'y' except: pass while answ == 'n': _z1, _z2, goon = src.display_image(img, 1, '', '', False) if not goon: src.close_program(logincl) print '>> Identify (minimum 2, preferably 3) reference stars (mark with "a")' iraf.delete('tmp.coo', verify='no') iraf.imexamine(img, 1, logfile='tmp.coo', keeplog='yes') iraf.tvmark(1, 'tmp.coo', mark="circle", number='yes', label='no', radii=15, nxoffse=15, nyoffse=15, color=214, txsize=4) xycoo = iraf.fields('tmp.coo', '1,2,13', Stdout=1) print '>> Identify reference stars' idcat = [] for i in range(len(xycoo)): idcat.append(raw_input('Star ' + str(i + 1) + '= ? ')) ff = open(coordinatelist + '.tv', 'r') rr = ff.readlines() ff.close() gg = open('tmp.ccmap', 'w') fw = [] for i in range(len(idcat)): idpos = stars.index(idcat[i]) _rr = string.split(rr[idpos]) _x, _y, _fw = string.split(xycoo[i]) gg.write(_x + ' ' + _y + ' ' + _rr[0] + ' ' + _rr[1] + ' \n') fw.append(float(_fw)) gg.close() iraf.delete('_first_image.tv', verify='no') iraf.delete('_first.ccmap', verify='no') os.system('cp ' + coordinatelist + '.tv _first_image.tv') os.system('cp tmp.ccmap _first.ccmap') iraf.ccmap('tmp.ccmap', 'tmp.ccdb', images=img, fitgeome='rscale', lngunit='degrees', update='yes', interact=False) _z1, _z2, goon = src.display_image(img, 1, '', '', False) if not goon: src.close_program(logincl) iraf.delete('tmp.' + img + '.coo', verify='no') iraf.wcsctran(coordinatelist + '.tv', 'tmp.' + img + '.coo', img, inwcs='world', units='degrees degrees', outwcs='logical', columns='1 2', formats='%10.1f %10.1f') iraf.tvmark(1, 'tmp.' + img + '.coo', mark="circle", number='yes', label='no', radii=20, nxoffse=15, nyoffse=15, color=205, txsize=4) iraf.delete("tmp.ccmap", verify='no') iraf.delete("tmp.coo", verify='no') iraf.delete("tmp.ccdb", verify='no') answ = raw_input( 'is the astrometry of the field good [y/n] ? [y]') if not answ: answ = 'y' iraf.delete("tmp.star", verify='no') iraf.ccfind('home$coordinate_std/' + dir_system + coordinatelist + '.list', 'tmp.star', img, lngcolu=2, latcolu=3, lngunit='degrees', usewcs='yes') iraf.ccmap('tmp.star', 'tmp.ccdb', images=img, fitgeome='rscale', xcolum=9, ycolum=10, lngcolum=2, latcolumn=3, lngunit='degrees', update='yes', interact=False) iraf.delete('tmp.' + img + '.coo', verify='no') iraf.wcsctran(coordinatelist + '.tv', 'tmp.' + img + '.coo', img, inwcs='world', units='degrees degrees', outwcs='logical', columns='1 2', formats='%10.1f %10.1f') iraf.delete("tmp.ccdb", verify='no') iraf.delete("tmp.star", verify='no') iraf.delete("tmp.coo", verify='no') return stars, 'tmp.' + img + '.coo'