Hide keyboard shortcuts

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

from builtins import str 

from .baseMetric import BaseMetric 

from .simpleMetrics import Coaddm5Metric 

import numpy as np 

import warnings 

 

__all__ = ['OptimalM5Metric'] 

 

 

class OptimalM5Metric(BaseMetric): 

"""Compare the co-added depth of the survey to one where 

all the observations were taken on the meridian. 

 

Parameters 

---------- 

m5Col : str ('fiveSigmaDepth') 

Column name that contains the five-sigma limiting depth of 

each observation 

optM5Col : str ('m5Optimal') 

The column name of the five-sigma-limiting depth if the 

observation had been taken on the meridian. 

normalize : bool (False) 

If False, metric returns how many more observations would need 

to be taken to reach the optimal depth. If True, the number 

is normalized by the total number of observations already taken 

at that position. 

magDiff : bool (False) 

If True, metric returns the magnitude difference between the 

achieved coadded depth and the optimal coadded depth. 

 

Returns 

-------- 

numpy.array 

 

If magDiff is True, returns the magnitude difference between the 

optimal and actual coadded depth. If normalize is False 

(default), the result is the number of additional observations 

(taken at the median depth) the survey needs to catch up to 

optimal. If normalize is True, the result is divided by the 

number of observations already taken. So if a 10-year survey 

returns 20%, it would need to run for 12 years to reach the same 

depth as a 10-year meridian survey. 

 

""" 

 

def __init__(self, m5Col='fiveSigmaDepth', optM5Col='m5Optimal', 

filterCol='filter', magDiff=False, normalize=False, **kwargs): 

 

if normalize: 

self.units = '% behind' 

else: 

self.units = 'N visits behind' 

if magDiff: 

self.units = 'mags' 

super(OptimalM5Metric, self).__init__(col=[m5Col, optM5Col,filterCol], 

units=self.units, **kwargs) 

self.m5Col = m5Col 

self.optM5Col = optM5Col 

self.normalize = normalize 

self.filterCol = filterCol 

self.magDiff = magDiff 

self.coaddRegular = Coaddm5Metric(m5Col=m5Col) 

self.coaddOptimal = Coaddm5Metric(m5Col=optM5Col) 

 

def run(self, dataSlice, slicePoint=None): 

 

filters = np.unique(dataSlice[self.filterCol]) 

if np.size(filters) > 1: 

warnings.warn("OptimalM5Metric does not make sense mixing filters. Currently using filters " + 

str(filters)) 

regularDepth = self.coaddRegular.run(dataSlice) 

optimalDepth = self.coaddOptimal.run(dataSlice) 

if self.magDiff: 

return optimalDepth-regularDepth 

 

medianSingle = np.median(dataSlice[self.m5Col]) 

 

# Number of additional median observations to get as deep as optimal 

result = (10.**(0.8 * optimalDepth)-10.**(0.8 * regularDepth)) / \ 

(10.**(0.8 * medianSingle)) 

 

if self.normalize: 

result = result/np.size(dataSlice)*100. 

 

return result