Coverage for python/lsst/sims/featureScheduler/features/conditions.py : 19%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Class to hold telemetry information
If the incoming value is a healpix map, we use a setter to ensure the resolution matches.
Unless otherwise noted, all values are assumed to be valid at the time given by self.mjd """ """ Parameters ---------- nside : int The healpixel nside to set the resolution of attributes. site : str ('LSST') A site name used to create a sims.utils.Site object. For looking up observatory paramteres like latitude and longitude. expTime : float (30) The exposure time to assume when computing the 5-sigma limiting depth
Atributes (Set on init) ----------- nside : int Healpix resolution. All maps are set to this reslution. site : lsst.sims.Site object ('LSST') Contains static site-specific data (lat, lon, altitude, etc). Defaults to 'LSST'. ra : np.array A healpix array with the RA of each healpixel center (radians). Automatically generated. dec : np.array A healpix array with the Dec of each healpixel center (radians). Automatically generated.
Atributes (to be set by user/telemetry stream) ------------------------------------------- mjd : float Modified Julian Date (days). clouds : float The fraction of sky covered by clouds. (In the future might update to transparency map) slewtime : np.array Healpix showing the slewtime to each healpixel center (seconds) current_filter : str The name of the current filter. (expect one of u, g, r, i, z, y). mounted_filters : list of str The filters that are currently mounted and thu available (expect 5 of u, g, r, i, z, y) night : int The current night number (days). Probably starts at 1. skybrightness : dict of np.array Dictionary keyed by filtername. Values are healpix arrays with the sky brightness at each healpix center (mag/acsec^2) FWHMeff : dict of np.array Dictionary keyed by filtername. Values are the effective seeing FWHM at each healpix center (arcseconds) moonAlt : float The altitude of the Moon (radians) moonAz : float The Azimuth of the moon (radians) moonRA : float RA of the moon (radians) moonDec : float Declination of the moon (radians) moonPhase : float The Phase of the moon. (fraction, 0=new moon, 1=full moon) sunAlt : float The altitude of the sun (radians). sunAz : float The Azimuth of the sun (radians). sunRA : float The RA of the sun (radians). sunDec : float The Dec of the sun (radians). telRA : float The current telescope RA pointing (radians). telDec : float The current telescope Declination cloud_map : np.array A healpix map with the cloud coverage. XXX-expand, is this bool map? Transparency map? airmass : np.array A healpix map with the airmass value of each healpixel. (unitless) sunset : float The MJD of sunset that starts the current night. Note MJDs of sunset, moonset, twilight times, etc are from interpolations. This means the sun may actually be slightly above/below the horizon at the given sunset time. sun_n12_setting : float The MJD of when the sun is at -12 degees altitude and setting during the current night. From interpolation. sun_n18_setting : float The MJD when the sun is at -18 degrees altitude and setting during the current night. From interpolation. sun_n18_rising : float The MJD when the sun is at -18 degrees altitude and rising during the current night. From interpolation. sun_n12_rising : float The MJD when the sun is at -12 degrees altitude and rising during the current night. From interpolation. sunrise : float The MJD of sunrise during the current night. From interpolation moonrise : float The MJD of moonrise during the current night. From interpolation. moonset : float The MJD of moonset during the current night. From interpolation.
Attributes (calculated on demand and cached) ------------------------------------------ alt : np.array Altitude of each healpixel (radians). Recaclulated if mjd is updated. Uses fast approximate equation for converting RA,Dec to alt,az. az : np.array Azimuth of each healpixel (radians). Recaclulated if mjd is updated. Uses fast approximate equation for converting RA,Dec to alt,az. pa : np.array The parallactic angle of each healpixel (radians). Recaclulated if mjd is updated. Based on the fast approximate alt,az values. lmst : float The local mean sidearal time (hours). Updates is mjd is changed. M5Depth : dict of np.array the 5-sigma limiting depth healpix maps, keyed by filtername (mags). Will be recalculated if the skybrightness, seeing, or airmass are updated. HA : np.array Healpix map of the hour angle of each healpixel (radians).
Attributes (set by the scheduler) ------------------------------- queue : list of observation objects The current queue of observations core_scheduler is waiting to execute.
""" if nside is None: nside = set_default_nside() self.nside = nside self.site = Site(site) self.exptime = exptime hpids = np.arange(hp.nside2npix(nside)) # Generate an empty map so we can copy when we need a new map self.zeros_map = np.zeros(hp.nside2npix(nside), dtype=float) self.nan_map = np.zeros(hp.nside2npix(nside), dtype=float) self.nan_map.fill(np.nan) # The RA, Dec grid we are using self.ra, self.dec = _hpid2RaDec(nside, hpids)
# Modified Julian Date (day) self._mjd = None # Altitude and azimuth. Dict with degrees and radians self._alt = None self._az = None self._pa = None # The cloud level. Fraction, but could upgrade to transparency map self.clouds = None self._slewtime = None self.current_filter = None self.mounted_filters = None self.night = None self._lmst = None # Should be a dict with filtername keys self._skybrightness = {} self._FWHMeff = {} self._M5Depth = None self._airmass = None
# Attribute to hold the current observing queue self.queue = None
# Moon self.moonAlt = None self.moonAz = None self.moonRA = None self.moonDec = None self.moonPhase = None
# Sun self.sunAlt = None self.sunAz = None self.sunRA = None self.sunDec = None
# Almanac information self.sunset = None self.sun_n12_setting = None self.sun_n18_setting = None self.sun_n18_rising = None self.sun_n12_rising = None self.sunrise = None self.moonrise = None self.moonset = None
# Current telescope pointing self.telRA = None self.telDec = None
# Full sky cloud map self._cloud_map = None self._HA = None
# XXX--document self.bulk_cloud = None
self.rotTelPos = None
def lmst(self): return self._lmst
def lmst(self, value): self._lmst = value self._HA = None
def HA(self): if self._HA is None: self.calc_HA() return self._HA
self._HA = np.radians(self._lmst*360./24.) - self.ra self._HA[np.where(self._HA < 0)] += 2.*np.pi
def cloud_map(self): return self._cloud_map
def cloud_map(self, value): self._cloud_map = match_hp_resolution(value, nside_out=self.nside)
def slewtime(self): return self._slewtime
def slewtime(self, value): # Using 0 for start of night if np.size(value) == 1: self._slewtime = value else: self._slewtime = match_hp_resolution(value, nside_out=self.nside)
def airmass(self): return self._airmass
def airmass(self, value): self._airmass = match_hp_resolution(value, nside_out=self.nside) self._M5Depth = None
def pa(self): if self._pa is None: self.calc_pa() return self._pa
y = np.sin(-self.az)*np.cos(self.site.latitude_rad) x = np.cos(self.alt)*np.sin(self.site.latitude_rad) - np.sin(self.alt)*np.cos(self.site.latitude_rad)*np.cos(-self.az) pa = np.arctan2(y, x) # Make it run from 0-360 deg insteaof of -180 to 180 to_flip = np.where(pa < 0) pa[to_flip] = np.pi - pa[to_flip] self._pa = pa
def alt(self): if self._alt is None: self.calc_altAz() return self._alt
def az(self): if self._az is None: self.calc_altAz() return self._az
self._alt, self._az = _approx_RaDec2AltAz(self.ra, self.dec, self.site.latitude_rad, self.site.longitude_rad, self._mjd)
def mjd(self): return self._mjd
def mjd(self, value): self._mjd = value # Set things that need to be recalculated to None self._az = None self._alt = None self._pa = None self._HA = None self._lmst = None
def skybrightness(self): return self._skybrightness
def skybrightness(self, indict): for key in indict:
self._skybrightness[key] = match_hp_resolution(indict[key], nside_out=self.nside) # If sky brightness changes, need to recalc M5 depth. self._M5Depth = None
def FWHMeff(self): return self._FWHMeff
def FWHMeff(self, indict): for key in indict: self._FWHMeff[key] = match_hp_resolution(indict[key], nside_out=self.nside) self._M5Depth = None
def M5Depth(self): if self._M5Depth is None: self.calc_M5Depth() return self._M5Depth
self._M5Depth = {} for filtername in self._skybrightness: good = ~np.isnan(self._skybrightness[filtername]) self._M5Depth[filtername] = self.nan_map.copy() self._M5Depth[filtername][good] = m5_flat_sed(filtername, self._skybrightness[filtername][good], self._FWHMeff[filtername][good], self.exptime, self._airmass[good]) |