Coverage for python/lsst/sims/skybrightness/utils.py : 24%

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
1from __future__ import print_function
2import numpy as np
3import ephem
6def wrapRA(ra):
7 """
8 Wrap only RA values into 0-2pi (using mod).
9 """
10 ra = ra % (2.0*np.pi)
11 return ra
14def mjd2djd(inDate):
15 """
16 Convert Modified Julian Date to Dublin Julian Date (what pyephem uses).
17 """
18 if not hasattr(mjd2djd, 'doff'):
19 mjd2djd.doff = ephem.Date(0)-ephem.Date('1858/11/17')
20 djd = inDate-mjd2djd.doff
21 return djd
24def robustRMS(array, missing=0.):
25 """
26 Use the interquartile range to compute a robust approximation of the RMS.
27 if passed an array smaller than 2 elements, return missing value
28 """
29 if np.size(array) < 2:
30 rms = missing
31 else:
32 iqr = np.percentile(array, 75)-np.percentile(array, 25)
33 rms = iqr/1.349 # approximation
34 return rms
37def ut2Mjd(dateString):
38 obs = ephem.Observer()
39 obs.date = dateString
40 doff = ephem.Date(0)-ephem.Date('1858/11/17')
41 mjd = obs.date+doff
42 return mjd
45def mjd2ut(mjd):
46 obs = ephem.Observer()
47 doff = ephem.Date(0)-ephem.Date('1858/11/17')
48 djd = mjd-doff
49 obs.date = djd
50 return obs.date