Skip to content

Commit c46f2ec

Browse files
committed
post refactor test
1 parent c25245c commit c46f2ec

File tree

2 files changed

+128
-1
lines changed

2 files changed

+128
-1
lines changed

runs/baseline_tests/v2/base_try.py

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import numpy as np
2+
import lsst.sims.featureScheduler as fs
3+
from lsst.sims.featureScheduler.utils import (sim_runner, set_default_nside, standard_goals,
4+
calc_norm_factor, generate_goal_map)
5+
import lsst.sims.featureScheduler.surveys as survey
6+
import lsst.sims.featureScheduler.basis_functions as basis_functions
7+
from lsst.sims.speedObservatory import Speed_observatory
8+
import matplotlib.pylab as plt
9+
import healpy as hp
10+
import time
11+
12+
# Let's add a zenith mask to see if that brings the slewtime down
13+
14+
t0 = time.time()
15+
16+
survey_length = 365.25*10 # days
17+
nside = set_default_nside(nside=32)
18+
# Define what we want the final visit ratio map to look like
19+
years = np.round(survey_length/365.25)
20+
# get rid of silly northern strip.
21+
target_map = standard_goals(nside=nside)
22+
norm_factor = calc_norm_factor(target_map)
23+
24+
# set up a cloud map
25+
cloud_map = target_map['r']*0 + 0.7
26+
27+
# List to hold all the surveys (for easy plotting later)
28+
surveys = []
29+
30+
# Set up observations to be taken in blocks
31+
filter1s = ['u', 'g', 'r', 'i', 'z', 'y']
32+
filter2s = [None, 'g', 'r', 'i', None, None]
33+
pair_surveys = []
34+
for filtername, filtername2 in zip(filter1s, filter2s):
35+
bfs = []
36+
bfs.append(basis_functions.M5_diff_basis_function(filtername=filtername, nside=nside))
37+
if filtername2 is not None:
38+
bfs.append(basis_functions.M5_diff_basis_function(filtername=filtername2, nside=nside))
39+
bfs.append(basis_functions.Target_map_basis_function(filtername=filtername,
40+
target_map=target_map[filtername],
41+
out_of_bounds_val=hp.UNSEEN, nside=nside,
42+
norm_factor=norm_factor))
43+
if filtername2 is not None:
44+
bfs.append(basis_functions.Target_map_basis_function(filtername=filtername2,
45+
target_map=target_map[filtername2],
46+
out_of_bounds_val=hp.UNSEEN, nside=nside,
47+
norm_factor=norm_factor))
48+
bfs.append(basis_functions.Slewtime_basis_function(filtername=filtername, nside=nside))
49+
bfs.append(basis_functions.Strict_filter_basis_function(filtername=filtername))
50+
# Masks, give these 0 weight
51+
bfs.append(basis_functions.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.))
52+
bfs.append(basis_functions.Moon_avoidance_basis_function(nside=nside, moon_distance=40.))
53+
bfs.append(basis_functions.Bulk_cloud_basis_function(max_cloud_map=cloud_map, nside=nside))
54+
weights = np.array([3.0, 3.0, .3, .3, 3., 3., 0., 0., 0.])
55+
if filtername2 is None:
56+
# Need to scale weights up so filter balancing still works properly.
57+
weights = np.array([6.0, 0.6, 3., 3., 0., 0., 0.])
58+
# XXX-
59+
# This is where we could add a look-ahead basis function to include m5_diff in the future.
60+
# Actually, having a near-future m5 would also help prevent switching to u or g right at twilight?
61+
# Maybe just need a "filter future" basis function?
62+
if filtername2 is None:
63+
survey_name = 'blob, %s' % filtername
64+
else:
65+
survey_name = 'blob, %s%s' % (filtername, filtername2)
66+
surveys.append(survey.Blob_survey(bfs, weights, filtername1=filtername, filtername2=filtername2,
67+
survey_note=survey_name, ignore_obs='DD'))
68+
pair_surveys.append(surveys[-1])
69+
70+
71+
# Let's set up some standard surveys as well to fill in the gaps. This is my old silly masked version.
72+
# It would be good to put in Tiago's verion and lift nearly all the masking. That way this can also
73+
# chase sucker holes.
74+
#filters = ['u', 'g', 'r', 'i', 'z', 'y']
75+
filters = ['i', 'z', 'y']
76+
77+
greedy_target_map = standard_goals(nside=nside)
78+
# Let's take out the NES area on the target maps. This way we won't
79+
# take images in the NES that aren't paired.
80+
temp_map = generate_goal_map(nside=nside, NES_fraction=1.,
81+
WFD_fraction=0, SCP_fraction=0,
82+
GP_fraction=0, WFD_upper_edge_fraction=0.)
83+
nes_pix = np.where(temp_map == 1)
84+
for filtername in greedy_target_map:
85+
greedy_target_map[filtername][nes_pix] = 0
86+
87+
greedy_surveys = []
88+
for filtername in filters:
89+
bfs = []
90+
bfs.append(basis_functions.M5_diff_basis_function(filtername=filtername, nside=nside))
91+
bfs.append(basis_functions.Target_map_basis_function(filtername=filtername,
92+
target_map=greedy_target_map[filtername],
93+
out_of_bounds_val=hp.UNSEEN, nside=nside,
94+
norm_factor=norm_factor))
95+
96+
#bfs.append(fs.North_south_patch_basis_function(zenith_min_alt=50., nside=nside))
97+
bfs.append(basis_functions.Slewtime_basis_function(filtername=filtername, nside=nside))
98+
bfs.append(basis_functions.Strict_filter_basis_function(filtername=filtername))
99+
bfs.append(basis_functions.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.))
100+
bfs.append(basis_functions.Moon_avoidance_basis_function(nside=nside, moon_distance=40.))
101+
bfs.append(basis_functions.Bulk_cloud_basis_function(max_cloud_map=cloud_map, nside=nside))
102+
weights = np.array([3.0, 0.3, 3., 3., 0., 0., 0.])
103+
# Might want to try ignoring DD observations here, so the DD area gets covered normally--DONE
104+
surveys.append(survey.Greedy_survey(bfs, weights, block_size=1, filtername=filtername,
105+
dither=True, nside=nside, ignore_obs='DD'))
106+
greedy_surveys.append(surveys[-1])
107+
108+
# Set up the DD surveys
109+
dd_surveys = survey.generate_dd_surveys()
110+
surveys.extend(dd_surveys)
111+
112+
survey_list_o_lists = [dd_surveys, pair_surveys, greedy_surveys]
113+
114+
# Debug to stop at a spot if needed
115+
n_visit_limit = None
116+
117+
# put in as list-of-lists so pairs get evaluated first.
118+
scheduler = fs.Core_scheduler(survey_list_o_lists, nside=nside)
119+
observatory = Speed_observatory(nside=nside, quickTest=True)
120+
observatory, scheduler, observations = sim_runner(observatory, scheduler,
121+
survey_length=survey_length,
122+
filename='baseline_test%iyrs.db' % years,
123+
delete_past=True, n_visit_limit=n_visit_limit)
124+
t1 = time.time()
125+
delta_t = t1-t0
126+
print('ran in %.1f min = %.1f hours' % (delta_t/60., delta_t/3600.))
127+

upload.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
rsync -av --progress . lsst-dev.ncsa.illinois.edu:"/datasets/public_html/sim-data/beta_slair_surveys/"
2+
rsync -av --progress --delete . lsst-dev.ncsa.illinois.edu:"/datasets/public_html/sim-data/beta_slair_surveys/"
33
#

0 commit comments

Comments
 (0)