|
| 1 | +import numpy as np |
| 2 | +import lsst.sims.featureScheduler as fs |
| 3 | +from lsst.sims.speedObservatory import Speed_observatory |
| 4 | +import matplotlib.pylab as plt |
| 5 | +import healpy as hp |
| 6 | +from lsst.sims.skybrightness_pre import M5percentiles |
| 7 | + |
| 8 | + |
| 9 | +class Time_limit_basis_function(fs.Base_basis_function): |
| 10 | + """Limit how long a survey can run with a basis function |
| 11 | + """ |
| 12 | + def __init__(self, mjd_start=None, day_max=365.25, day_min=0, |
| 13 | + survey_features=None, condition_features=None, **kwargs): |
| 14 | + """ |
| 15 | + Parameters |
| 16 | + ---------- |
| 17 | + day_max : float (365.25) |
| 18 | +
|
| 19 | + """ |
| 20 | + |
| 21 | + self.mjd_start = mjd_start |
| 22 | + self.day_max = day_max |
| 23 | + self.day_min = day_min |
| 24 | + |
| 25 | + if condition_features is None: |
| 26 | + self.condition_features = {} |
| 27 | + self.condition_features['Current_mjd'] = fs.features.Current_mjd() |
| 28 | + |
| 29 | + def update_conditions(self, conditions): |
| 30 | + for feature in self.condition_features: |
| 31 | + self.condition_features[feature].update_conditions(conditions) |
| 32 | + # if we haven't set a start date, use the current conditions. |
| 33 | + # XXX-This might not be cold start compatible |
| 34 | + if self.mjd_start is None: |
| 35 | + self.mjd_start = self.condition_features['Current_mjd'].feature |
| 36 | + |
| 37 | + def check_feasibility(self): |
| 38 | + |
| 39 | + day = self.condition_features['Current_mjd'].feature - self.mjd_start |
| 40 | + if (day > self.day_max) | (day < self.day_min): |
| 41 | + result = False |
| 42 | + else: |
| 43 | + result = True |
| 44 | + return result |
| 45 | + |
| 46 | + def __call__(self): |
| 47 | + return 0 |
| 48 | + |
| 49 | + |
| 50 | +class Seeing_limit_basis_function(fs.Base_basis_function): |
| 51 | + def __init__(self, max_seeing=1.2, filtername='r', nside=None, |
| 52 | + survey_features=None, condition_features=None, **kwargs): |
| 53 | + """ |
| 54 | + Parameters |
| 55 | + ---------- |
| 56 | + max_seeing : float (365.25) |
| 57 | +
|
| 58 | + """ |
| 59 | + if nside is None: |
| 60 | + nside = fs.utils.set_default_nside() |
| 61 | + self.max_seeing = max_seeing |
| 62 | + self.filtername = filtername |
| 63 | + |
| 64 | + if condition_features is None: |
| 65 | + self.condition_features = {} |
| 66 | + self.condition_features['Current_seeing'] = fs.features.Current_seeing(filtername=filtername, |
| 67 | + nside=nside) |
| 68 | + self.result_map = np.zeros(hp.nside2npix(self.nside)) |
| 69 | + |
| 70 | + def check_feasibility(self): |
| 71 | + if np.max(self()) == hp.UNSEEN: |
| 72 | + return False |
| 73 | + else: |
| 74 | + return True |
| 75 | + |
| 76 | + def __call__(self): |
| 77 | + result = self.result_map.copy() |
| 78 | + poor_seeing = np.where(self.condition_features['Current_seeing'] > self.max_seeing) |
| 79 | + result[poor_seeing] = hp.UNSEEN |
| 80 | + return result |
| 81 | + |
| 82 | + |
| 83 | +class Nvis_limit_basis_function(fs.Seeing_limit_basis_function): |
| 84 | + """Shut off observations after a given number of visits |
| 85 | + """ |
| 86 | + def __init__(self, ): |
| 87 | + pass |
| 88 | + |
| 89 | + |
| 90 | +class Limit_m5_percentile_basis_function(fs.Seeing_limit_basis_function): |
| 91 | + """ |
| 92 | + """ |
| 93 | + def __init__(self, percentile_limit=60., nside=None, |
| 94 | + survey_features=None, condition_features=None, **kwargs): |
| 95 | + |
| 96 | + self.m5p = M5percentiles() |
| 97 | + |
| 98 | + def __call__(self): |
| 99 | + pass |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | +def year_1_surveys(nside=32, mjd0=None): |
| 105 | + """ |
| 106 | + Generate a list of surveys for executing in year 1 |
| 107 | + """ |
| 108 | + |
| 109 | + filters = ['u', 'g', 'r', 'i', 'z', 'y'] |
| 110 | + |
| 111 | + |
| 112 | + # Don't let observations be taken in the same night--maybe just set to 13 hours or something. |
| 113 | + fs.Avoid_Fast_Revists |
| 114 | + |
| 115 | + # Maybe this would be a good time to invoke the percentile limit again! That way we won't take |
| 116 | + # images in really poor depth conditions. |
0 commit comments