def _calc_value(self, conditions, indx=None):
        """
        Parameters
        ----------
        indx : list (None)
            Index values to compute, if None, full map is computed
        Returns
        -------
        Healpix reward map
        """

        result = self.result.copy()
        if indx is None:
            indx = self.all_indx

        # Compute what season it is at each pixel
        seasons = utils.season_calc(conditions.night, offset=self.day_offset,
                                    modulo=self.season_modulo, max_season=self.max_season,
                                    season_length=self.season_length)

        composite_target = self.result.copy()[indx]
        composite_nobs = self.result.copy()[indx]

        composite_goal_N = self.result.copy()[indx]

        for season in np.unique(seasons):
            season_indx = np.where(seasons == season)[0]
            composite_target[season_indx] = self.target_maps[season][season_indx]
            composite_nobs[season_indx] = self.survey_features['N_obs_%i' % season].feature[season_indx]
            composite_goal_N[season_indx] = composite_target[season_indx] * self.survey_features['N_obs_count_all_%i' % season].feature * self.norm_factor

        result[indx] = composite_goal_N - composite_nobs[indx]
        result[self.out_of_bounds_area] = self.out_of_bounds_val

        return result
Example #2
0
    def testSeason(self):
        """
        Test that the season utils work as intended
        """
        night = 365.25 * 3.5
        plain = season_calc(night)
        assert (plain == 3)

        mod2 = season_calc(night, modulo=2)
        assert (mod2 == 1)

        mod3 = season_calc(night, modulo=3)
        assert (mod3 == 0)

        mod3 = season_calc(night, modulo=3, max_season=2)
        assert (mod3 == -1)

        mod3 = season_calc(night, modulo=3, max_season=2, offset=-365.25 * 2)
        assert (mod3 == 1)

        mod3 = season_calc(night, modulo=3, max_season=2, offset=-365.25 * 10)
        assert (mod3 == -1)

        mod3 = season_calc(night, modulo=3, offset=-365.25 * 10)
        assert (mod3 == -1)
Example #3
0
    def add_observation(self, observation, indx=None):
        current_season = utils.season_calc(observation['night'],
                                           offset=self.offset,
                                           season_length=self.season_length)
        # If the season has changed anywhere, set that count to zero
        new_season = np.where((self.season_map - current_season) != 0)
        self.feature[new_season] = 0
        self.season_map = current_season

        if self.filtername is None or observation['filter'][
                0] in self.filtername:
            self.feature[indx] += 1
Example #4
0
 def __init__(self,
              filtername=None,
              nside=None,
              offset=0,
              season_length=365.25):
     self.filtername = filtername
     if nside is None:
         nside = utils.set_default_nside()
     if offset is None:
         offset = np.zeros(hp.nside2npix(nside), dtype=int)
     self.offset = offset
     self.season_length = season_length
     self.season_map = utils.season_calc(0.,
                                         offset=self.offset,
                                         season_length=season_length)
     self.feature = np.zeros(hp.nside2npix(nside), dtype=float)
Example #5
0
    def season(self, modulo=None, max_season=None, season_length=365.25, floor=True):
        if self.season_offset is not None:
            kwargs_match = (modulo == self.season_modulo) & (max_season == self.season_max_season) & (season_length == self.season_length) & (floor == self.season_floor)
            if ~kwargs_match:
                self.season_modulo = modulo
                self.season_max_season = max_season
                self.season_length = season_length
                self.season_floor = floor
            if (self._season is None) | (~kwargs_match):
                self._season = season_calc(self.night, offset=self.season_offset,
                                           modulo=modulo, max_season=max_season,
                                           season_length=season_length, floor=floor)
        else:
            self._season = None

        return self._season
Example #6
0
    def add_observation(self, observation, indx=None):
        """
        Parameters
        ----------
        indx : ints
            The indices of the healpixel map that have been observed by observation
        """

        observation_season = utils.season_calc(
            observation['night'],
            offset=self.offset[indx],
            modulo=self.modulo,
            max_season=self.max_season,
            season_length=self.season_length)
        if self.season in observation_season:
            if self.filtername is None or observation['filter'][
                    0] in self.filtername:
                self.feature[indx] += 1
    def _calc_value(self, conditions, indx=None):
        result = self.result.copy()

        # Compute what season it is at each pixel
        seasons = utils.season_calc(conditions.night, offset=self.day_offset,
                                    modulo=self.season_modulo, max_season=self.max_season,
                                    season_length=self.season_length)

        # Compute the constant parts of the footprint like before
        desired = self.footprints[-1] / self.all_footprints_sum * np.sum(self.survey_features['N_obs_all_-1'].feature)
        result[self.constant_footprint_indx] = desired[self.constant_footprint_indx] - self.survey_features['N_obs_-1'].feature[self.constant_footprint_indx]

        # Now for the rolling sections
        for season in np.unique(seasons[self.rolling_footprint_indx]):
            season_indx = np.where(seasons[self.rolling_footprint_indx] == season)[0]
            desired = self.footprints[season][self.rolling_footprint_indx][season_indx] / self.all_rolling_sum * np.sum(self.survey_features['N_obs_all_%i' % season].feature[self.rolling_footprint_indx])
            result[self.rolling_footprint_indx[season_indx]] = desired - self.survey_features['N_obs_%i' % season].feature[self.rolling_footprint_indx][season_indx]

        result[self.out_of_bounds_area] = self.out_of_bounds_val
        return result
Example #8
0
    def add_observation(self, observation, indx=None):

        season = utils.season_calc(observation['night'],
                                   modulo=self.season_modulo,
                                   offset=self.offset[indx],
                                   max_season=self.max_season,
                                   season_length=self.season_length)
        if self.season in season:
            if (self.filtername is None) and (self.tag is None):
                # Track all observations
                self.feature += 1
            elif (self.filtername is not None) and (self.tag is None) and (
                    observation['filter'][0] in self.filtername):
                # Track all observations on a specified filter
                self.feature += 1
            elif (self.filtername is None) and (self.tag is not None) and (
                    observation['tag'][0] in self.tag):
                # Track all observations on a specified tag
                self.feature += 1
            elif ((self.filtername is None) and (self.tag is not None) and
                  # Track all observations on a specified filter on a specified tag
                  (observation['filter'][0] in self.filtername)
                  and (observation['tag'][0] in self.tag)):
                self.feature += 1