_x, _y, _fw = xycoo[i].split() gg.write(_x+' '+_y+' '+str(_racat[idcat[i]-1])+' '+\ str(_decat[idcat[i]-1])+' \n') fw.append(float(_fw)) gg.close() src.updateheader(img, 0, 'Seeing', mean(fw)) gg = open('tmp.coo', 'w') for i in range(len(_racat)): gg.write(str(_racat[i]) + ' ' + str(_decat[i]) + ' \n') gg.close() iraf.ccmap('tmp.ccmap','tmp.ccdb',images=img,fitgeome='rscale',\ xcolum=1,ycolum=2,lngcolum=3,latcolumn=4,lngunit='degrees',\ update='yes',interact=False,verbose='yes') tmp = iraf.ccfind('tmp.coo','tmp.star',img,lngcolu=1,latcolu=2,\ lngunit='degrees',usewcs='yes',verbose='yes',Stderr=1) print '>>>', tmp[-2] if int(tmp[-2].split()[1]) <= 3: print "!!! Error: stars are not matched !!!" sys.exit() iraf.ccmap('tmp.star','tmp.ccdb',solution='tmp.sol',images=img,\ fitgeome='rscale',xcolum=3,ycolum=4,lngcolum=1,\ latcolumn=2,lngunit='degrees',\ update='yes',interact=False) iraf.ccmap('tmp.ccmap', 'tmp.ccdb', images=img, fitgeome='rscale',
nxoffse=5, nyoffse=5, color=205, txsize=4) src.delete("tmp.ccmap") src.delete("tmp.coo") src.delete("tmp.ccdb") answ = raw_input( 'is the astrometry of the field good [y/n] ? [y]') if not answ: answ = 'y' src.delete("tmp.star") 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) src.delete('tmp.' + _filter + '.coo')
fw.append(float(_fw)) gg.close() iraf.hedit(img, 'Seeing', mean(fw), add='yes', update='yes', verify='yes') iraf.ccmap('tmp.ccmap', 'tmp.ccdb', images=img, fitgeome='rscale', lngunit='degrees', update='yes', interact=False) iraf.ccfind('tmp.cat', 'tmp.star', img, lngcolu=2, latcolu=3, lngunit='degrees', usewcs='yes') iraf.ccmap('tmp.star', 'tmp.ccdb', images=img, fitgeome='general', xcolum=10, ycolum=11, lngcolum=2, latcolumn=3, lngunit='degrees', update='yes', interact=interactive)
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'