示例#1
0
文件: plant.py 项目: sevenlin123/MOP
def plant(expnums, ccd, rmin, rmax, ang, width, version='s'):
    '''run the plant script on this combination of exposures'''

    ptf = open('proc-these-files','w')
    ptf.write("# Files to be planted and search\n")
    ptf.write("# image fwhm plant\n")

    for expnum in expnums:
        fwhm = storage.get_fwhm(expnum,ccd)
        filename = storage.get_image(expnum, ccd=ccd, version=version)
        ptf.write("%s %3.1f YES\n" % ( filename[0:-5],
                                    fwhm ))
        for ext in ['apcor',
                    'obj.jmp',
                    'trans.jmp',
                    'psf.fits',
                    'mopheader',
                    'phot',
                    'zeropoint.used']:
            apcor = storage.get_image(expnum, ccd=ccd, version='s',
                                      ext=ext)

    ptf.close()

    cmd_args = ['plant.csh',os.curdir,
             str(rmin), str(rmax), str(ang), str(width)]

    util.exec_prog(cmd_args)
    
    if args.dryrun:
        # Don't push back to VOSpace
        return 

    uri = storage.get_uri('Object',ext='planted',version='',
                          subdir=str(
        expnums[0])+"/ccd%s" % (str(ccd).zfill(2)))
    storage.copy('Object.planted',uri)
    uri = os.path.join(os.path.dirname(uri), 'shifts')
    storage.copy('shifts', uri)
    for expnum in expnums:
        uri = storage.get_uri(expnum,
                              ccd=ccd,
                              version=version,
                              ext='fits', prefix='fk')
        filename =  os.path.basename(uri)
        storage.copy(filename, uri)

        for ext in ['mopheader',
                    'psf.fits',
                    'fwhm',
                    'apcor', 'zeropoint.used', 'trans.jmp']:
            storage.delete(expnum, ccd, 's', ext, prefix='fk')
            storage.vlink(expnum, ccd, 'p', ext,
                          expnum, ccd, 's', ext, l_prefix='fk')
                          

    
    return
示例#2
0
def scramble(expnums, ccd, version='p'):
    '''run the plant script on this combination of exposures'''

    mjds = []
    fobjs = []
    for expnum in expnums:
        filename = storage.get_image(expnum, ccd=ccd, version=version)
        fobjs.append(fits.open(filename))
        # Pull out values to replace in headers.. must pull them
        # as otherwise we get pointers...
        mjds.append(fobjs[-1][0].header['MJD-OBS'])

    order = [1, 0, 2]
    for idx in range(len(fobjs)):
        logging.info("Flipping %d to %d" %
                     (fobjs[idx][0].header['EXPNUM'], expnums[order[idx]]))
        fobjs[idx][0].header['EXPNUM'] = expnums[order[idx]]
        fobjs[idx][0].header['MJD-OBS'] = mjds[order[idx]]
        uri = storage.get_uri(expnums[order[idx]],
                              ccd=ccd,
                              version='s',
                              ext='fits')
        fname = os.path.basename(uri)
        if os.access(fname, os.F_OK):
            os.unlink(fname)
        fobjs[idx].writeto(fname)
        storage.copy(fname, uri)

        # now make a link between files that the plant system will need
        for ext in [
                'apcor', 'obj.jmp', 'mopheader', 'phot', 'psf.fits',
                'trans.jmp', 'zeropoint.used', 'fwhm'
        ]:
            storage.delete(expnums[order[idx]], ccd, 's', ext)
            storage.vlink(expnums[idx], ccd, 'p', ext, expnums[order[idx]],
                          ccd, 's', ext)

    return
示例#3
0
文件: plant.py 项目: R136a1-/MOP
def plant(expnums, ccd, rmin, rmax, ang, width, version="s"):
    """run the plant script on this combination of exposures"""

    ptf = open("proc-these-files", "w")
    ptf.write("# Files to be planted and search\n")
    ptf.write("# image fwhm plant\n")

    for expnum in expnums:
        fwhm = storage.get_fwhm(expnum, ccd, version=version)
        filename = storage.get_image(expnum, ccd=ccd, version=version)
        ptf.write("%s %3.1f YES\n" % (filename[0:-5], fwhm))
        for ext in ["apcor", "obj.jmp", "trans.jmp", "psf.fits", "mopheader", "phot", "zeropoint.used"]:
            apcor = storage.get_image(expnum, ccd=ccd, version=version, ext=ext)

    ptf.close()

    cmd_args = ["plant.csh", os.curdir, str(rmin), str(rmax), str(ang), str(width)]

    util.exec_prog(cmd_args)

    if args.dryrun:
        # Don't push back to VOSpace
        return

    uri = storage.get_uri("Object", ext="planted", version="", subdir=str(expnums[0]) + "/ccd%s" % (str(ccd).zfill(2)))
    storage.copy("Object.planted", uri)
    uri = os.path.join(os.path.dirname(uri), "plant.shifts")
    storage.copy("shifts", uri)
    for expnum in expnums:
        uri = storage.get_uri(expnum, ccd=ccd, version=version, ext="fits", prefix="fk")
        filename = os.path.basename(uri)
        storage.copy(filename, uri)

        for ext in ["mopheader", "psf.fits", "fwhm", "apcor", "zeropoint.used", "trans.jmp"]:
            storage.delete(expnum, ccd, "s", ext, prefix="fk")
            storage.vlink(expnum, ccd, "s", ext, expnum, ccd, "s", ext, l_prefix="fk")

    return
示例#4
0
文件: scramble.py 项目: R136a1-/MOP
def scramble(expnums, ccd, version='p'):
    '''run the plant script on this combination of exposures'''

    mjds = []
    fobjs = []
    for expnum in expnums:
        filename = storage.get_image(expnum, ccd=ccd, version=version)
        fobjs.append(fits.open(filename))
        # Pull out values to replace in headers.. must pull them
        # as otherwise we get pointers...
        mjds.append(fobjs[-1][0].header['MJD-OBS'])

    order = [1,0,2]
    for idx in range(len(fobjs)):
        logging.info("Flipping %d to %d" % ( fobjs[idx][0].header['EXPNUM'],
                                             expnums[order[idx]]))
        fobjs[idx][0].header['EXPNUM'] = expnums[order[idx]]
        fobjs[idx][0].header['MJD-OBS'] = mjds[order[idx]]
        uri = storage.get_uri(expnums[order[idx]],
                                ccd=ccd,
                                version='s',
                                ext='fits')
        fname = os.path.basename(uri)
        if os.access(fname, os.F_OK):
            os.unlink(fname)
        fobjs[idx].writeto(fname)
        storage.copy(fname, uri)

        # now make a link between files that the plant system will need
        for ext in ['apcor', 'obj.jmp', 'mopheader', 'phot',
                    'psf.fits','trans.jmp', 'zeropoint.used', 'fwhm']:
            if storage.exists(storage.get_uri(expnums[order[idx]], ccd, 's', ext)):
                storage.delete(expnums[order[idx]], ccd, 's', ext)
                storage.vlink(expnums[idx], ccd, 'p', ext,
                         expnums[order[idx]], ccd, 's', ext)

    return
示例#5
0

from ossos import storage


triples=storage.open_vos_or_local('vos:OSSOS/triplets/E_13A_discovery_expnums.txt').read()
for line in triples.split('\n'):
    line = line.strip(' ')
    if not len(line) > 0:
        continue
    for expnum in line.split(' ')[0:3]:
        for ccd in range(36):
            for ext in ['.apcor',
                        '.zeropoint.used',
                        '.psf.fits',
                        '.mopheader',
                        '.fwhm',
                        '.trans.jmp']:
                storage.delete(expnum=expnum, ccd=ccd, version='s', ext=ext, prefix='fk')
                storage.vlink(s_expnum=expnum,
                            s_ccd=ccd,
                            s_version='s',
                            s_prefix='',
                            s_ext=ext,
                            l_expnum=expnum,
                            l_ccd=ccd,
                            l_version='s',
                            l_prefix='fk',
                            l_ext =ext)
        print expnum,ccd,"DONE"
sys.exit()
示例#6
0
def plant(expnums, ccd, rmin, rmax, ang, width, version='s'):
    '''run the plant script on this combination of exposures'''

    ptf = open('proc-these-files', 'w')
    ptf.write("# Files to be planted and search\n")
    ptf.write("# image fwhm plant\n")

    for expnum in expnums:
        fwhm = storage.get_fwhm(expnum, ccd)
        filename = storage.get_image(expnum, ccd=ccd, version=version)
        ptf.write("%s %3.1f YES\n" % (filename[0:-5], fwhm))
        for ext in [
                'apcor', 'obj.jmp', 'trans.jmp', 'psf.fits', 'mopheader',
                'phot', 'zeropoint.used'
        ]:
            apcor = storage.get_image(expnum, ccd=ccd, version='s', ext=ext)

    ptf.close()

    cmd_args = [
        'plant.csh', os.curdir,
        str(rmin),
        str(rmax),
        str(ang),
        str(width)
    ]

    util.exec_prog(cmd_args)

    if args.dryrun:
        # Don't push back to VOSpace
        return

    uri = storage.get_uri('Object',
                          ext='planted',
                          version='',
                          subdir=str(expnums[0]) + "/ccd%s" %
                          (str(ccd).zfill(2)))
    storage.copy('Object.planted', uri)
    uri = os.path.join(os.path.dirname(uri), 'shifts')
    storage.copy('shifts', uri)
    for expnum in expnums:
        uri = storage.get_uri(expnum,
                              ccd=ccd,
                              version=version,
                              ext='fits',
                              prefix='fk')
        filename = os.path.basename(uri)
        storage.copy(filename, uri)

        for ext in [
                'mopheader', 'psf.fits', 'fwhm', 'apcor', 'zeropoint.used',
                'trans.jmp'
        ]:
            storage.delete(expnum, ccd, 's', ext, prefix='fk')
            storage.vlink(expnum,
                          ccd,
                          'p',
                          ext,
                          expnum,
                          ccd,
                          's',
                          ext,
                          l_prefix='fk')

    return