예제 #1
0
 def test_update_obslog(self):
     #- These shouldn't fail, but we don't really have verification
     #- code that they did anything correct.
     expid, dateobs = obs.update_obslog(expid=1)
     self.assertEqual(expid, 1)
     expid, dateobs = obs.update_obslog(obstype='arc', program='calib', expid=2)
     self.assertEqual(expid, 2)
     expid, dateobs = obs.update_obslog(obstype='science', expid=3, tileid=1)
     expid, dateobs = obs.update_obslog(obstype='science', expid=3,
         tileid=1, ra=0.1, dec=2.3)
예제 #2
0
파일: test_obs.py 프로젝트: akremin/desisim
 def test_get_next_tileid(self):
     #- Two tileid request without an observation should be the same
     a = obs.get_next_tileid()
     b = obs.get_next_tileid()
     self.assertEqual(a, b)
     
     #- But then register the obs, and we should get a different tile
     obs.update_obslog(expid=0, tileid=a)
     c = obs.get_next_tileid()
     self.assertNotEqual(a, c)
예제 #3
0
    def test_get_next_tileid(self):
        #- Two tileid request without an observation should be the same
        a = obs.get_next_tileid()
        b = obs.get_next_tileid()
        self.assertEqual(a, b)

        #- But then register the obs, and we should get a different tile
        print('### Updating obslog ###')
        obs.update_obslog(expid=0, tileid=a)
        print('### Getting more tiles ###')
        c = obs.get_next_tileid()
        self.assertNotEqual(a, c)

        #- different programs should be different tiles
        a = obs.get_next_tileid(program='dark')
        b = obs.get_next_tileid(program='gray')
        c = obs.get_next_tileid(program='bright')
        self.assertNotEqual(a, b)
        self.assertNotEqual(a, c)

        #- program is case insensitive
        a = obs.get_next_tileid(program='GRAY')
        b = obs.get_next_tileid(program='gray')
        self.assertEqual(a, b)
예제 #4
0
파일: test_obs.py 프로젝트: desihub/desisim
    def test_get_next_tileid(self):
        #- Two tileid request without an observation should be the same
        a = obs.get_next_tileid()
        b = obs.get_next_tileid()
        self.assertEqual(a, b)

        #- But then register the obs, and we should get a different tile
        print('### Updating obslog ###')
        obs.update_obslog(expid=0, tileid=a)
        print('### Getting more tiles ###')
        c = obs.get_next_tileid()        
        self.assertNotEqual(a, c)
        
        #- different programs should be different tiles
        a = obs.get_next_tileid(program='dark')
        b = obs.get_next_tileid(program='gray')
        c = obs.get_next_tileid(program='bright')
        self.assertNotEqual(a, b)
        self.assertNotEqual(a, c)
        
        #- program is case insensitive
        a = obs.get_next_tileid(program='GRAY')
        b = obs.get_next_tileid(program='gray')
        self.assertEqual(a, b)
예제 #5
0
파일: pixsim.py 프로젝트: tskisner/desisim
def batch_newexp(batchfile,
                 flavors,
                 nspec=5000,
                 night=None,
                 expids=None,
                 nodes=None,
                 pixprod=None,
                 desi_spectro_sim=None,
                 tileids=None,
                 seed=None):
    '''
    Write a slurm batch script for run newexp-desi for the list of flavors
    '''
    nexp = len(flavors)
    timestr = '00:30:00'
    logfile = '{}.%j.log'.format(batchfile)

    np.random.seed(seed)
    seeds = np.random.randint(2**32, size=nexp)

    if night is None:
        night = obs.get_night()

    if expids is None:
        expids = obs.get_next_expid(nexp)

    if nodes is None:
        nodes = calc_nodes(nexp, tasktime=1.5, maxtime=20)

    if tileids is None:
        tileids = list()
        for flavor in flavors:
            flavor = flavor.lower()
            t = obs.get_next_tileid(program=flavor)
            tileids.append(t)
            if flavor in ('arc', 'flat'):
                obs.update_obslog(obstype=flavor, program='calib', tileid=t)
            elif flavor in ('bright', 'bgs', 'mws'):
                obs.update_obslog(obstype='science',
                                  program='bright',
                                  tileid=t)
            elif flavor in ('gray', 'grey'):
                obs.update_obslog(obstype='science', program='gray', tileid=t)
            else:
                obs.update_obslog(obstype='science', program='dark', tileid=t)

    if pixprod is None:
        if 'PIXPROD' in os.environ:
            pixprod = os.environ['PIXPROD']
        else:
            raise ValueError('must provide pixprod or set $PIXPROD')

    if desi_spectro_sim is None:
        if 'DESI_SPECTRO_SIM' in os.environ:
            desi_spectro_sim = os.environ['DESI_SPECTRO_SIM']
        else:
            raise ValueError(
                'must provide desi_spectro_sim or set $DESI_SPECTRO_SIM')

    log.info('output dir {}/{}/{}'.format(desi_spectro_sim, pixprod, night))

    assert len(expids) == len(flavors)

    cmd = "srun -n 1 -N 1 -c $nproc /usr/bin/time newexp-desi --night {night} --nspec {nspec} --flavor {flavor} --expid {expid} --tileid {tileid} --seed {seed}"
    with open(batchfile, 'w') as fx:
        fx.write("#!/bin/bash -l\n\n")
        fx.write("#SBATCH --partition=debug\n")
        fx.write("#SBATCH --account=desi\n")
        fx.write("#SBATCH --nodes={}\n".format(nodes))
        fx.write("#SBATCH --time={}\n".format(timestr))
        fx.write("#SBATCH --job-name=newexp\n")
        fx.write("#SBATCH --output={}\n".format(logfile))

        fx.write("if [ ${NERSC_HOST} = edison ]; then\n")
        fx.write("  nproc=24\n")
        fx.write("else\n")
        fx.write("  nproc=32\n")
        fx.write("fi\n\n")

        fx.write('export DESI_SPECTRO_SIM={}\n'.format(desi_spectro_sim))
        fx.write('export PIXPROD={}\n'.format(pixprod))
        fx.write('\n')
        fx.write('echo Starting at `date`\n\n')

        fx.write('mkdir -p $DESI_SPECTRO_SIM/$PIXPROD/etc\n')
        fx.write('mkdir -p $DESI_SPECTRO_SIM/$PIXPROD/{}\n'.format(night))
        fx.write('\n')

        for expid, flavor, tileid, seed in zip(expids, flavors, tileids,
                                               seeds):
            fx.write(
                cmd.format(nspec=nspec,
                           night=night,
                           expid=expid,
                           flavor=flavor,
                           tileid=tileid,
                           seed=seed) + ' &\n')

        fx.write('\nwait\n')
        fx.write('\necho Done at `date`\n')

    return expids
예제 #6
0
seeds = np.random.randint(2**32, size=ntask)

expids = None
if comm.rank == 0:
    expids = obs.get_next_expid(ntask)
expids = comm.bcast(expids, root=0)

tileids = list()
if comm.rank == 0:
    for nt in nights:
        for fl in flavors:
            flavor = fl.lower()
            t = obs.get_next_tileid(program=flavor)
            tileids.append(t)
            if flavor in ('arc', 'flat'):
                obs.update_obslog(obstype=flavor, program='calib', tileid=t)
            elif flavor in ('bright', 'bgs', 'mws'):
                obs.update_obslog(obstype='science', program='bright', tileid=t)
            elif flavor in ('gray', 'grey'):
                obs.update_obslog(obstype='science', program='gray', tileid=t)
            else:
                obs.update_obslog(obstype='science', program='dark', tileid=t)

tileids = comm.bcast(tileids, root=0)

if comm.rank == 0:
    simdir = os.path.join(os.environ['DESI_SPECTRO_SIM'], 
        os.environ['PIXPROD'])
    etcdir = os.path.join(simdir, 'etc')
    if not os.path.isdir(etcdir):
        os.makedirs(etcdir)