Skip to content

Commit

Permalink
Merge pull request #70 from desihub/statusfile
Browse files Browse the repository at this point in the history
Update surveysim to match recent desisurvey updates, particularly regarding fiber assignment.
  • Loading branch information
schlafly committed Jun 26, 2020
2 parents 12067c9 + 9aee8f8 commit 488eb18
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,24 @@ env:
# to repeat them for all configurations.
# - NUMPY_VERSION=1.10
# - SCIPY_VERSION=0.16
- ASTROPY_VERSION=2.0.4
- SPHINX_VERSION=1.5
- DESIUTIL_VERSION=1.9.9
- ASTROPY_VERSION=2.0.14
- SPHINX_VERSION=1.8.5
# - DESIUTIL_VERSION=2.0.1
- DESIUTIL_VERSION=master
# - SPECLITE_VERSION=0.5
- SPECSIM_VERSION=v0.9
- SPECSIM_VERSION=v0.13
# - SPECTER_VERSION=0.6.0
- DESIMODEL_VERSION=0.9.8
- DESIMODEL_DATA=branches/test-0.9.8
- DESISURVEY_VERSION=0.12.0
- DESIMODEL_VERSION=0.12.0
- DESIMODEL_DATA=branches/test-0.12
- DESISURVEY_VERSION=master
# - HARP_VERSION=1.0.1
# - SPECEX_VERSION=0.3.9
- MAIN_CMD='python setup.py'
# These packages will always be installed.
- CONDA_DEPENDENCIES=""
# These packages will only be installed if we really need them.
# - CONDA_ALL_DEPENDENCIES="scipy matplotlib healpy pyephem"
- CONDA_ALL_DEPENDENCIES="scipy pyyaml pytz healpy pyephem"
- CONDA_ALL_DEPENDENCIES="scipy matplotlib pyephem pytz"
# These packages will always be installed.
- PIP_DEPENDENCIES=""
# These packages will only be installed if we really need them.
Expand All @@ -80,7 +81,6 @@ env:
# Debug the Travis install process.
- DEBUG=False
matrix:
# - PYTHON_VERSION=2.7 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.5 SETUP_CMD='egg_info'

matrix:
Expand All @@ -96,7 +96,7 @@ matrix:
# Check for sphinx doc build warnings - we do this first because it
# runs for a long time
- os: linux
env: PYTHON_VERSION=3.5 SETUP_CMD='build_sphinx --warning-is-error'
env: PYTHON_VERSION=3.6 SETUP_CMD='build_sphinx --warning-is-error'
# CONDA_DEPENDENCIES=$CONDA_ALL_DEPENDENCIES
# PIP_DEPENDENCIES=$PIP_ALL_DEPENDENCIES

Expand Down
7 changes: 5 additions & 2 deletions doc/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ top-level simulation driver directly into your own script or jupyter notebook::
explist = surveysim.exposures.ExposureList()
# Initialize afternoon planning.
planner = desisurvey.plan.Planner(rules)
planner = desisurvey.plan.Planner(rules, simulate=True)

# Initialize next tile selection.
scheduler = desisurvey.scheduler.Scheduler()
Expand All @@ -309,12 +309,15 @@ top-level simulation driver directly into your own script or jupyter notebook::
night = start + datetime.timedelta(num_simulated)

# Perform afternoon planning.
explist.update_tiles(night, *scheduler.update_tiles(*planner.afternoon_plan(night, scheduler.completed)))
explist.update_tiles(night, *scheduler.update_tiles(*planner.afternoon_plan(night)))

if not desisurvey.utils.is_monsoon(night) and not scheduler.ephem.is_full_moon(night):
# Simulate one night of observing.
surveysim.nightops.simulate_night(
night, scheduler, stats, explist, weather=weather, use_twilight=use_twilight)
planner.set_donefrac(scheduler.tiles.tileID, scheduler.snr2frac,
scheduler.lastexpid)

if scheduler.survey_completed():
break

Expand Down
4 changes: 3 additions & 1 deletion py/surveysim/exposures.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ExposureList(object):
def __init__(self, restore=None, max_nexp=60000):
self.tiles = desisurvey.tiles.get_tiles()
self._exposures = np.empty(max_nexp, dtype=[
('EXPID', np.float64),
('MJD', np.float64),
('EXPTIME', np.float32),
('TILEID', np.int32),
Expand Down Expand Up @@ -117,7 +118,8 @@ def add(self, mjd, exptime, tileID, snr2frac, airmass, seeing, transp, sky):
raise RuntimeError(
'Need to increase max_nexp={}'.format(len(self._exposures)))
self._exposures[self.nexp] = (
mjd, exptime, tileID, snr2frac, airmass, seeing, transp, sky)
self.nexp, mjd, exptime, tileID, snr2frac, airmass, seeing,
transp, sky)
self.nexp += 1
tileinfo = self._tiledata[self.tiles.index(tileID)]
tileinfo['EXPTIME'] += exptime
Expand Down
3 changes: 2 additions & 1 deletion py/surveysim/nightops.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def get_weather(mjd):
explist.add(
mjd_now - ETC.exptime, 86400 * ETC.exptime, tileid, ETC.snr2frac,
airmass, seeing_now, transp_now, sky_now)
scheduler.update_snr(tileid, ETC.snr2frac)
scheduler.update_snr(tileid, ETC.snr2frac,
explist.nexp)

if continue_this_tile:
# Prepare for the next exposure of the same tile.
Expand Down
16 changes: 9 additions & 7 deletions py/surveysim/scripts/surveysim.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def main(args):
rules = desisurvey.rules.Rules(args.rules)

# Initialize afternoon planning.
planner = desisurvey.plan.Planner(rules)
planner = desisurvey.plan.Planner(rules, simulate=True)

# Initialize next tile selection.
scheduler = desisurvey.scheduler.Scheduler()
Expand All @@ -149,25 +149,27 @@ def main(args):

if args.save_restore and num_simulated > 0:
# Restore the planner and scheduler saved after the previous night.
planner = desisurvey.plan.Planner(rules, restore='planner_{}.fits'.format(last_night))
scheduler = desisurvey.scheduler.Scheduler(restore='scheduler_{}.fits'.format(last_night))
planner = desisurvey.plan.Planner(rules, restore='desi-status-{}.fits'.format(last_night),
simulate=True)
scheduler = desisurvey.scheduler.Scheduler(restore='desi-status-{}.fits'.format(last_night))
scheduler.update_tiles(planner.tile_available, planner.tile_priority)

# Perform afternoon planning.
explist.update_tiles(night, *scheduler.update_tiles(*planner.afternoon_plan(night, scheduler.completed)))
explist.update_tiles(night, *scheduler.update_tiles(*planner.afternoon_plan(night)))

if not desisurvey.utils.is_monsoon(night) and not scheduler.ephem.is_full_moon(night):
# Simulate one night of observing.
surveysim.nightops.simulate_night(
night, scheduler, stats, explist, weather=weather, use_twilight=args.twilight)
planner.set_donefrac(scheduler.tiles.tileID, scheduler.snr2frac,
scheduler.lastexpid)
if scheduler.survey_completed():
log.info('Survey complete on {}.'.format(night))
break

if args.save_restore:
last_night = night.isoformat()
planner.save('planner_{}.fits'.format(last_night))
scheduler.save('scheduler_{}.fits'.format(last_night))
last_night = desisurvey.utils.night_to_str(night)
planner.save('desi-status-{}.fits'.format(last_night))

if num_simulated % args.log_interval == args.log_interval - 1:
log.info('Completed {} / {} tiles after {} / {} nights.'.format(
Expand Down
1 change: 1 addition & 0 deletions py/surveysim/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def add_calibration_exposures(exposures, flats_per_night=3, arcs_per_night=3,
nout = nexp + ncalib
output['EXPID'] = np.arange(nout, dtype=np.int32)
template = astropy.table.Table(dtype=exposures.dtype)
template.remove_column('EXPID')
for colname in template.colnames:
col = template[colname]
output[colname] = astropy.table.Column(dtype=col.dtype, length=nout)
Expand Down

0 comments on commit 488eb18

Please sign in to comment.