def __init__(self, basis_functions, basis_weights, extra_features=None, smoothing_kernel=None, ignore_obs=None, survey_name='', nside=None, seed=42, dither=True, detailers=None, camera='LSST', area_required=None): super(BaseMarkovDF_survey, self).__init__(basis_functions=basis_functions, extra_features=extra_features, ignore_obs=ignore_obs, survey_name=survey_name, nside=nside, detailers=detailers) self.basis_weights = basis_weights # Check that weights and basis functions are same length if len(basis_functions) != np.size(basis_weights): raise ValueError( 'basis_functions and basis_weights must be same length.') self.camera = camera # Load the OpSim field tesselation and map healpix to fields if self.camera == 'LSST': self.fields_init = read_fields() elif self.camera == 'comcam': self.fields_init = comcamTessellate() else: ValueError('camera %s unknown, should be "LSST" or "comcam"' % camera) self.fields = self.fields_init.copy() self.hp2fields = np.array([]) self._hp2fieldsetup(self.fields['RA'], self.fields['dec']) if smoothing_kernel is not None: self.smoothing_kernel = np.radians(smoothing_kernel) else: self.smoothing_kernel = None if area_required is None: self.area_required = area_required else: self.area_required = area_required * (np.pi / 180.)**2 # To steradians # Start tracking the night self.night = -1 # Set the seed np.random.seed(seed) self.dither = dither
def _make_fields(self): """ Make tesselation of the sky """ # RA and dec in radians fields = read_fields() # crop off so we only worry about things that are up good = np.where(fields['dec'] > (self.alt_limit_rad - self.fov_rad))[0] self.fields = fields[good] self.fields_empty = np.zeros(self.fields.size) # we'll use a single tessellation of alt az leafsize = 100 self.tree = _buildTree(self.fields['RA'], self.fields['dec'], leafsize, scale=None)
import numpy as np from lsst.sims.featureScheduler.utils import read_fields np.random.seed(42) fields_init = read_fields() def thetaphi2xyz(theta, phi): x = np.sin(phi)*np.cos(theta) y = np.sin(phi)*np.sin(theta) z = np.cos(phi) return x, y, z def xyz2thetaphi(x, y, z): phi = np.arccos(z) theta = np.arctan2(y, x) return theta, phi def rotx(theta, x, y, z): """rotate the x,y,z points theta radians about x axis""" sin_t = np.sin(theta) cos_t = np.cos(theta) xp = x yp = y*cos_t+z*sin_t zp = -y*sin_t+z*cos_t return xp, yp, zp