In [1]:
import time
import numpy as np
import pandas as pd

In [2]:
import lsst.sims.skybrightness as sb
from lsst.sims.utils import Site
import ephem
from obscond import SkyCalculations as sm

In [3]:
from opsimsummary import SynOpSim


Some imports failed, which implies some dependencies are missing as described below
No module named 'mpl_toolkits.basemap'
Visulization functions based on maps will not work

In [4]:
from obscond.observingPotential import ObservationPotential

In [5]:
from lsst.sims.utils import angularSeparation

In [6]:
from scipy.interpolate import interp1d

In [7]:
%matplotlib inline 
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
sns.set_context('notebook')

In [8]:
import obscond

In [9]:
print(obscond.__version__)


0.5.1dev3

DC2 DDF design


In [10]:
# uDDF center Design DC2 Run1 Note
rauDDF = np.radians(53.125)
decuDDF =  np.radians(-28.100)

Example For Block 2 :

These are the observations we want for the block of 7 to 10 years


In [11]:
op = ObservationPotential(rauDDF, decuDDF)

In [12]:
# 60 sec intervals of mjd values between 7 and 10 years 
t0 = 59580 + 7 * 365 
sec = 1.0 / 24.0 /60. /60.
hr = 60. * 60. * sec
t2 = np.arange(t0, t0 + 365 *3, 60 * sec)

In [13]:
opdf = op.potential_obscond(t2, fieldRA=rauDDF, fieldDec=decuDDF)

In [14]:
len(opdf)/ np.pi /1.0e7


Out[14]:
0.05019113468444874

In [15]:
opdf.head()


Out[15]:
mjd alt az sunAlt moonRA moonDec moonAlt night moonDist
0 62135.000000 50.539905 313.845214 -1.936863 77.162288 25.866353 16.955501 2555 97.299443
1 62135.000694 50.383315 313.537720 -2.067200 77.169862 25.867593 17.102845 2555 97.306363
2 62135.001389 50.225927 313.232245 -2.200801 77.177425 25.868828 17.249769 2555 97.313271
3 62135.002083 50.067750 312.928776 -2.340170 77.184975 25.870058 17.396272 2555 97.320168
4 62135.002778 49.908795 312.627297 -2.489150 77.192513 25.871284 17.542347 2555 97.327053

In [16]:
# new
constraints = 'alt > 30 and alt < 85 and sunAlt < -12 and moonDist > 30'
availabletimes = op.available_times(opdf, constraints=constraints)

In [17]:
#new
len(availabletimes)


Out[17]:
172579

In [18]:
# new
fig, ax = plt.subplots()
#ax0, ax1 = ax
#dff = opdf.query('alt < 85. and alt > 20.')
ax.plot(opdf.mjd, opdf.sunAlt, label='sun Alt')
ax.plot(availabletimes.mjd, availabletimes.sunAlt, label='field constraints')
ax.axhline(-12.0, ls='dashed', lw=2)
ax.set_xlabel('MJD (day)')
ax.set_ylabel('sun Altitude (deg)')
fig.savefig('availabletimes_block2.png')


Baseline Expectations


In [19]:
synopsim = SynOpSim.fromOpSimDB('/Users/rbiswas/data/LSST/OpSimData/minion_1016_sqlite.db',
                                 subset='ddf', opsimversion='lsstv3')


 reading from database sqlite:////Users/rbiswas/data/LSST/OpSimData/minion_1016_sqlite.db
Not doing all observations here 
56 ddf
SELECT * FROM Summary WHERE propID in (56)
We have filterNull set to False
checking that summary table read in

Reading in raw tables successful
replacing names works
dropping duplicates works
joining dithers works
Keeping units for lsstv3 from radians
check that the format matches the expectation

In [20]:
all_baseline_visits = synopsim.pointings.query('fieldID == 1427')

Block 2


In [21]:
baseline_block2 = synopsim.pointings.query('fieldID == 1427 and night > 365*7')

In [22]:
unights = baseline_block2.query('filter == "u"').night.unique()

In [23]:
baseline_nights_2 = baseline_block2.query('filter != "u"').night.unique()

In [24]:
print('Number of nights using grizy filters is {}'.format(baseline_nights_2.size))


Number of nights using grizy filters is 61

In [25]:
ratio_sampling  = 0.5 # See DC2 design note (0.75)
required_nights = np.ceil(baseline_nights_2.size / ratio_sampling).astype(np.int)

In [26]:
print('Given the requirement of the cadence being {0}, the number of nights is {1}'.format(ratio_sampling, required_nights))


Given the requirement of the cadence being 0.5, the number of nights is 122

In [27]:
times = availabletimes.query('night in @baseline_nights_2').groupby('night').agg(dict(mjd=ObservationPotential.timerange)).rename(columns=dict(mjd='time'))

In [28]:
fig, ax = plt.subplots()
_ = times.time.hist(bins=np.arange(2., 10, 0.25), histtype='step',
                    lw=2, ax=ax)
ax.axvline(5.0, color='k', ls='dashed')
ax.set_ylabel('nights')
ax.set_xlabel('hours of night available per night')
ax.set_title('Hours/night for minion DDF nights in yrs 4-7')
fig.savefig('block_2_hours_pernight.png')


Choosing nights


In [29]:
len(availabletimes)


Out[29]:
172579

In [37]:
synopsim.pointings.index.values.max()


Out[37]:
2443910

We want to select nights longer than 5 hours


In [29]:
shortnight = availabletimes.groupby('night').agg(dict(mjd=ObservationPotential.timerange))
shortnights = shortnight.query('mjd < 5').index.unique()
print(len(shortnights))


351

In [30]:
unights = baseline_block2.query('filter == "u"').night.unique()

In [31]:
target_nights = availabletimes.query('night not in @shortnights').query('night not in @unights').night.unique()

In [32]:
rng = np.random.RandomState(1)
target_nights.sort()
chosen_nights = rng.choice(target_nights, replace=False, size=required_nights)
chosen_nights.sort()

In [33]:
nstats = op.nightStats(availabletimes)
st_times = op.start_times(nstats, chosen_nights, rng)

In [34]:
dc2_visits_block2 = op.dc2_visits(st_times, year_block=2, pointings=all_baseline_visits)

In [35]:
dc2_visits_block2.groupby('filter').agg(dict(expMJD='count'))


Out[35]:
expMJD
filter
g 610
i 1220
r 1220
y 1220
z 1586

In [37]:
fig, ax = plt.subplots()
dc2_visits_block2.rawSeeing.hist(ax=ax,**dict(histtype='step', normed=1))
all_baseline_visits.rawSeeing.hist(ax=ax, **dict(histtype='step', normed=1))


/Users/rbiswas/soft/lsst_stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
/Users/rbiswas/soft/lsst_stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
Out[37]:
<matplotlib.axes._subplots.AxesSubplot at 0x1a4c0a92b0>

In [39]:
dc2_visits_block2['obsHistID'] = np.arange(len(dc2_visits_block2)) +  2500000 + 20000

In [63]:
dc2_visits_block2.to_csv('dc2_blocks2_v2.csv', index=False)

Block 1 :


In [41]:
# 60 sec intervals of mjd values between 7 and 10 years 
t0 = 59580 + 4 * 365 
sec = 1.0 / 24.0 /60. /60.
hr = 60. * 60. * sec
t01 = np.arange(t0, t0 + 365 *3, 60 * sec)

In [42]:
opdf = op.potential_obscond(t01, fieldRA=rauDDF, fieldDec=decuDDF)

In [43]:
# new
constraints_1 = 'alt > 30 and alt < 85 and sunAlt < -12 and moonDist > 30'
availabletimes_1 = op.available_times(opdf, constraints=constraints)

In [44]:
(availabletimes_1.mjd.min() - 59580)/365


Out[44]:
4.000093226788736

In [45]:
shortnight_1 = availabletimes_1.groupby('night').agg(dict(mjd=ObservationPotential.timerange))
shortnights_1 = shortnight_1.query('mjd < 5').index.unique()
print(len(shortnights_1))


347

In [46]:
baseline_block1 = synopsim.pointings.query('fieldID == 1427 and night < 365*7 and night > 365*4')

In [47]:
unights_1 = baseline_block1.query('filter == "u"').night.unique()

In [48]:
target_nights_1 = availabletimes_1.query('night not in @shortnights_1').query('night not in @unights_1').night.unique()

In [49]:
baseline_nights_1 = baseline_block1.query('filter != "u"').night.unique()

In [50]:
ratio_sampling_1  = 0.75 # See DC2 design note (0.75)
required_nights_1 = np.ceil(baseline_nights_1.size / ratio_sampling).astype(np.int)

In [51]:
required_nights_1


Out[51]:
114

In [52]:
rng = np.random.RandomState(1)
target_nights_1.sort()
chosen_nights_1 = rng.choice(target_nights_1, replace=False, size=required_nights_1)
chosen_nights_1.sort()

In [53]:
nstats_1 = op.nightStats(availabletimes_1)
st_times_1 = op.start_times(nstats_1, chosen_nights_1, rng)

In [54]:
dc2_visits_block1 = op.dc2_visits(st_times_1, year_block=1, pointings=baseline_block1)

In [69]:
dc2_visits_block1.groupby('filter').agg(dict(expMJD='count'))


Out[69]:
expMJD
filter
g 912
i 1710
r 1710
y 1710
z 2280

In [58]:
dc2_visits_block1.columns


Out[58]:
Index(['expMJD', 'filter', 'night', 'rawSeeing'], dtype='object')

In [60]:
dc2_visits_block1['obsHistID'] = np.arange(len(dc2_visits_block1)) +  2500000

In [64]:
dc2_visits_block1.to_csv('dc2_blocks1_v2.csv', index=False)

In [59]:
len(dc2_visits_block1)


Out[59]:
8322

In [60]:
len(dc2_visits_block2)


Out[60]:
5856

In [61]:
dc2_visits_block1.night = dc2_visits_block1.night.astype(int)

In [62]:
np.bincount(baseline_block1.sort_values(by='night').night.diff()[1:].astype(np.int))


Out[62]:
array([6952,   75,    1,   38,    7,    3,    3,    2,    3,    0,    1,
          0,    2,    0,    2,    0,    1,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    1,    0,    0,    0,    1,    0,    0,
          0,    0,    0,    1])

In [107]:
np.bincount(dc2_visits_block1.sort_values(by='night').night.diff()[1:].astype(np.int))


Out[107]:
array([8208,   43,   21,   15,    6,    4,    7,    5,    1,    2,    3,
          4,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
          0,    0,    0,    0,    1,    0,    0,    0,    0,    0,    1])

In [71]:
!head dc2_block1.csv


expMJD,filter,night,rawSeeing
61235.391948194854,r,1655.0,0.535141
61235.39238800967,r,1655.0,0.535141
61235.392827824486,r,1655.0,0.535141
61235.3932676393,r,1655.0,0.535141
61235.39370745411,r,1655.0,0.535141
61235.394147268926,r,1655.0,0.535141
61235.39458708374,r,1655.0,0.535141
61235.39502689856,r,1655.0,0.535141
61235.39546671337,r,1655.0,0.535141

Scratch


In [ ]:


In [ ]:


In [182]:
dc2_visits_block1 = op.dc2_visits(st_times.iloc[0], 1)

In [ ]:


In [140]:
st_times.iloc[0]


Out[140]:
62330.31910791294

In [68]:
dc2_visits_block2.to_csv('dc2_visits_block2.csv')

In [138]:
dc2_visits_block2[0].sort_values(by='expMJD').expMJD


Out[138]:
0     62330.319108
1     62330.319548
2     62330.319988
3     62330.320427
14    62330.320867
4     62330.320867
5     62330.321307
6     62330.321747
13    62330.321851
7     62330.322187
15    62330.322603
8     62330.322626
16    62330.322655
17    62330.322706
18    62330.322758
19    62330.322809
12    62330.322835
20    62330.322860
21    62330.322912
22    62330.322963
23    62330.323015
47    62330.323066
9     62330.323066
24    62330.323066
46    62330.323406
45    62330.323745
11    62330.323819
44    62330.324085
37    62330.324386
36    62330.324420
43    62330.324424
35    62330.324455
34    62330.324490
33    62330.324525
32    62330.324559
31    62330.324594
30    62330.324629
29    62330.324663
28    62330.324698
27    62330.324733
42    62330.324764
26    62330.324768
25    62330.324802
10    62330.324802
41    62330.325103
40    62330.325443
39    62330.325782
38    62330.326122
Name: expMJD, dtype: float64

In [41]:
dc2_visits_block2 = ObservationPotential.dc2_visits(st_times, year_block=2, delta=1)

In [42]:
dc2_visits_block2.head()


Out[42]:
expMJD filter night
0 62330.262845 r 2750.0
1 62330.263285 r 2750.0
2 62330.263725 r 2750.0
3 62330.264165 r 2750.0
4 62330.264605 r 2750.0

In [48]:
dc2_visits_block2.sort_values(by='expMJD').expMJD.diff().min()*24*60*60


Out[48]:
37.99999945331365

In [50]:
dc2_visits_block2.groupby('filter').agg(dict(night='count'))


Out[50]:
night
filter
g 610
i 1220
r 1220
y 1220
z 1586

In [62]:
minion_block2 = synopsim.pointings.query('night > 365 *7 and filter != "u" and fieldID == 1427')

In [63]:
minion_block2['filter'].unique().size


Out[63]:
5

In [67]:
dc2_visits_block2.groupby(['night', 'filter']).agg(dict(expMJD='count'))


Out[67]:
expMJD
night filter
2750.0 g 5
i 10
r 10
y 10
z 13
2754.0 g 5
i 10
r 10
y 10
z 13
2761.0 g 5
i 10
r 10
y 10
z 13
2762.0 g 5
i 10
r 10
y 10
z 13
2769.0 g 5
i 10
r 10
y 10
z 13
2771.0 g 5
i 10
r 10
y 10
z 13
... ... ...
3594.0 g 5
i 10
r 10
y 10
z 13
3595.0 g 5
i 10
r 10
y 10
z 13
3596.0 g 5
i 10
r 10
y 10
z 13
3597.0 g 5
i 10
r 10
y 10
z 13
3598.0 g 5
i 10
r 10
y 10
z 13
3600.0 g 5
i 10
r 10
y 10
z 13

610 rows × 1 columns


In [59]:
dc2_visits_block2.night.unique().size


Out[59]:
122

In [64]:
minion_block2.groupby('filter').agg(dict(night='count'))


Out[64]:
night
filter
g 591
i 1180
r 1215
y 1142
z 1534

In [65]:
len(minion_block2)


Out[65]:
5662

In [66]:
len(dc2_visits_block2)


Out[66]:
5856

In [120]:
dc2_visits_block2.sort_values(by='expMJD').expMJD


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-120-ec48cf561a22> in <module>
----> 1 dc2_visits_block2.sort_values(by='expMJD').expMJD

AttributeError: 'tuple' object has no attribute 'sort_values'

In [99]:
vals = dc2_visits_block2.sort_values(by='expMJD').expMJD.diff()*24.0*60.* 60.

In [82]:
st_times


Out[82]:
night
2750    62330.319108
2754    62334.377036
2761    62341.294386
2762    62342.362502
2769    62349.355503
2771    62351.208782
2773    62353.288746
2774    62354.271757
2776    62356.213810
2782    62362.251942
2783    62363.259288
2784    62364.222906
2786    62366.141025
2788    62368.256541
2789    62369.296038
2790    62370.141528
2797    62377.148752
2798    62378.258787
2799    62379.183944
2803    62383.316846
2809    62389.275081
2813    62393.120107
2815    62395.110192
2817    62397.225695
2823    62403.077466
2825    62405.160939
2826    62406.278937
2829    62409.058003
2833    62413.022593
2834    62414.234279
            ...     
3507    63087.275316
3509    63089.335837
3511    63091.359990
3514    63094.197364
3516    63096.316612
3518    63098.197386
3524    63104.260589
3528    63108.141025
3534    63114.184773
3535    63115.109084
3540    63120.202137
3542    63122.244014
3547    63127.170755
3548    63128.143852
3555    63135.239166
3561    63141.028913
3564    63144.106796
3571    63151.105549
3572    63152.173520
3588    63168.178015
3589    63169.053056
3590    63170.155607
3591    63171.123301
3593    63173.003429
3594    63174.132306
3595    63175.107555
3596    63176.119173
3597    63177.101497
3598    63178.098460
3600    63180.062662
Length: 122, dtype: float64

In [ ]:
op.nightStats

In [31]:
availabletimes.night.unique().size


Out[31]:
653

In [32]:
availabletimes.query('night not in @shortnights').night.unique().size


Out[32]:
302

In [75]:
len(target_nights)


Out[75]:
269

In [77]:
expected_cadence = target_nights.size / np.float(required_nights)
print(expected_cadence)


2.2049180327868854

In [37]:
targets.night.unique().size


Out[37]:
269

In [38]:
rng = np.random.RandomState(1)
target_nights.sort()
chosen_nights = rng.choice(target_nights, replace=False, size=required_nights)
chosen_nights.sort()

In [39]:
chosen_nights.size


Out[39]:
122

In [ ]:
chosen_nights

In [ ]:
st_times = op.start_times(nigh)

In [40]:
baseline_nights


Out[40]:
array([2800, 2813, 2828, 2831, 2843, 2845, 2848, 2856, 2859, 2862, 2872,
       2875, 2878, 2884, 2887, 2892, 2902, 2905, 2914, 2917, 2920, 3167,
       3170, 3173, 3182, 3185, 3197, 3200, 3202, 3210, 3213, 3216, 3228,
       3232, 3239, 3242, 3245, 3255, 3258, 3270, 3273, 3276, 3285, 3288,
       3537, 3541, 3551, 3556, 3565, 3568, 3571, 3582, 3585, 3601, 3611,
       3614, 3623, 3626, 3629, 3640, 3643])

In [41]:
shortnights[:40]


Out[41]:
Int64Index([2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565,
            2566, 2567, 2568, 2569, 2570, 2680, 2686, 2687, 2688, 2689, 2690,
            2691, 2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701,
            2702, 2703, 2704, 2705, 2706, 2707, 2708],
           dtype='int64', name='night')

In [42]:
target_nights


Out[42]:
array([2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760,
       2761, 2762, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776,
       2777, 2778, 2779, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787,
       2788, 2789, 2790, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 2802,
       2803, 2804, 2808, 2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816,
       2817, 2823, 2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832,
       2833, 2834, 2842, 2843, 2844, 2850, 2851, 2852, 2853, 2854, 2855,
       2856, 2857, 2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866,
       2867, 2868, 2869, 3116, 3117, 3118, 3123, 3124, 3125, 3126, 3127,
       3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138,
       3139, 3140, 3141, 3142, 3143, 3144, 3145, 3150, 3151, 3152, 3153,
       3154, 3155, 3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164,
       3165, 3166, 3167, 3168, 3169, 3170, 3171, 3172, 3178, 3179, 3180,
       3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, 3196, 3197, 3198,
       3199, 3200, 3205, 3206, 3207, 3208, 3209, 3210, 3211, 3212, 3213,
       3214, 3215, 3216, 3217, 3218, 3225, 3226, 3227, 3233, 3234, 3481,
       3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492,
       3493, 3494, 3495, 3496, 3497, 3498, 3499, 3500, 3505, 3506, 3507,
       3508, 3509, 3510, 3511, 3512, 3513, 3514, 3515, 3516, 3517, 3518,
       3519, 3520, 3521, 3522, 3523, 3524, 3525, 3526, 3527, 3528, 3533,
       3534, 3535, 3536, 3537, 3538, 3539, 3540, 3541, 3542, 3543, 3547,
       3548, 3549, 3550, 3551, 3552, 3553, 3554, 3555, 3560, 3561, 3562,
       3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3572, 3580,
       3581, 3582, 3583, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595,
       3596, 3597, 3598, 3599, 3600])

In [43]:
unights


Out[43]:
array([2805, 2806, 2807, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2893,
       2894, 2895, 2896, 2897, 2898, 2899, 2922, 2923, 2924, 2925, 2926,
       2927, 2928, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3219, 3220,
       3221, 3222, 3223, 3224, 3247, 3248, 3249, 3250, 3251, 3252, 3253,
       3279, 3280, 3283, 3284, 3544, 3545, 3546, 3573, 3574, 3575, 3576,
       3577, 3578, 3579, 3606, 3607, 3608, 3609, 3631, 3632, 3633, 3636,
       3637, 3638])

In [46]:
_ = plt.hist(np.diff(chosen_nights), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, normed=0, label='designed')
_ = plt.hist(np.diff(np.sort(baseline_nights)), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, normed=0, label='minion')


/Users/rbiswas/soft/lsst_stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
/Users/rbiswas/soft/lsst_stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "

In [60]:
np.bincount(np.sort(np.diff(baseline_nights)))


Out[60]:
array([ 0,  0,  2, 29,  2,  2,  1,  1,  2,  5,  5,  2,  4,  1,  0,  1,  1,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1])

In [59]:
np.bincount(np.sort(np.diff(chosen_nights)))


Out[59]:
array([ 0, 47, 30,  5, 10,  7,  8,  5,  2,  1,  1,  0,  2,  0,  0,  0,  1,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1])

In [44]:
fig, ax = plt.subplots(1, 2)
_ = ax[0].hist(np.diff(chosen_nights), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, normed=0, label='designed')
_ = ax[0].hist(np.diff(np.sort(baseline_nights)), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, normed=0, label='minion')
_ = ax[1].hist(np.diff(chosen_nights), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, cumulative=1, label='designed', normed=0)
_ = ax[1].hist(np.diff(np.sort(baseline_nights)), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, cumulative=1, label='minion', normed=0)

ax[1].set_xlim(xmax=10)
plt.legend(loc='best')
fig.savefig('gap_block2.png')


/Users/rbiswas/soft/lsst_stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
/Users/rbiswas/soft/lsst_stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
/Users/rbiswas/soft/lsst_stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
/Users/rbiswas/soft/lsst_stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "

In [ ]:


In [78]:
fig, ax = plt.subplots(1, 2)
_ = ax[0].hist(np.diff(chosen_nights), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, normed=0, label='designed')
_ = ax[0].hist(np.diff(np.sort(baseline_nights)), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, normed=0, label='minion')
_ = ax[1].hist(np.diff(chosen_nights), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, cumulative=1, label='designed', normed=0)
_ = ax[1].hist(np.diff(np.sort(baseline_nights)), bins=np.arange(0, 80, 1),
            histtype='step', lw=2, cumulative=1, label='minion', normed=0)

ax[1].set_xlim(xmax=10)
plt.legend(loc='best')
fig.savefig('gap_block2.png')



In [50]:
fig, ax = plt.subplots()
ax.plot(chosen_nights[:-1], np.diff(chosen_nights), '.')
for nt in unights:
    ax.axvline(nt, ls='dashed', color='k', lw=1)
#for nt in shortnights:
#    ax.axvline(nt, ls='dashed', color='r', lw=0.1)


Choosing nights


In [62]:
availabletimes.describe()


Out[62]:
mjd alt az sunAlt moonRA moonDec moonAlt night moonDist
count 172579.000000 172579.000000 172579.000000 172579.000000 172579.000000 172579.000000 172579.000000 172579.000000 172579.000000
mean 62753.217276 48.772325 176.398199 -41.414825 154.501634 2.167519 -9.133085 3172.989379 104.259570
std 303.638793 9.322090 139.029425 16.824144 87.403443 16.813126 35.790120 303.654401 42.598460
min 62135.034028 30.001680 0.000751 -79.388402 7.211262 -24.459791 -77.096853 2555.000000 30.000031
25% 62431.047570 40.947493 45.755835 -53.864141 79.735333 -15.971037 -39.795061 2851.000000 67.113953
50% 62752.318752 50.518149 69.998414 -41.406895 151.813425 6.839546 -11.902970 3172.000000 104.608783
75% 63077.439239 57.545609 313.340367 -27.647135 227.101887 18.588453 20.542153 3497.000000 141.610819
max 63229.081254 60.246038 359.999039 -12.000204 313.407143 25.969689 76.744955 3649.000000 173.345992

In [63]:
nstats = op.nightStats(availabletimes)

In [69]:
nstats.head()


Out[69]:
minmjd maxmjd availTime
night
2555.0 62135.034028 62135.076389 1.016667
2556.0 62136.034028 62136.073611 0.950000
2557.0 62137.034028 62137.070833 0.883333
2558.0 62138.034028 62138.068056 0.816667
2559.0 62139.034722 62139.065278 0.733333

In [72]:
nstats.loc[chosen_nights].head()


Out[72]:
minmjd maxmjd availTime
night
2750 62330.237501 62330.445834 5.000000
2754 62334.226390 62334.445140 5.250000
2761 62341.206945 62341.443056 5.666667
2762 62342.204862 62342.443056 5.716667
2769 62349.185417 62349.440278 6.116667

In [66]:
availabletimes.groupby('night').agg(dict(mjd='count')).describe()


Out[66]:
mjd
count 653.000000
mean 264.286371
std 143.833276
min 1.000000
25% 135.000000
50% 282.000000
75% 409.000000
max 439.000000

In [56]:
availabletimes.groupby('night').agg(dict(mjd='count')).apply(lambda x: x/60.).describe()


Out[56]:
mjd
count 942.000000
mean 4.016207
std 2.193955
min 0.016667
25% 2.187500
50% 4.283333
75% 5.779167
max 7.833333

In [57]:
nstats.loc[chosen_nights]


Out[57]:
minmjd maxmjd availTime
night
2559 62139.034722 62139.251389 5.200000
2560 62140.034722 62140.248611 5.133333
2561 62141.034722 62141.245833 5.066667
2628 62208.000000 62208.999306 23.983333
2630 62210.000000 62210.999306 23.983333
2634 62214.000000 62214.999306 23.983333
2635 62215.000000 62215.999306 23.983333
2640 62220.000000 62220.999306 23.983333
2644 62224.000000 62224.999306 23.983333
2646 62226.000000 62226.999306 23.983333
2802 62382.198612 62382.418751 5.283333
2822 62402.144445 62402.401390 6.166667
2825 62405.136112 62405.399306 6.316667
2826 62406.133334 62406.397918 6.350000
2829 62409.125001 62409.395140 6.483333
2831 62411.119445 62411.393751 6.583333
2844 62424.084029 62424.382640 7.166667
2849 62429.070140 62429.378473 7.400000
2851 62431.065279 62431.376390 7.466667
2852 62432.062501 62432.375695 7.516667
2853 62433.059723 62433.375001 7.566667
2856 62436.051390 62436.372918 7.716667
2860 62440.040279 62440.370140 7.916667
2861 62441.037501 62441.369445 7.966667
2862 62442.034723 62442.368751 8.016667
2863 62443.031945 62443.368057 8.066667
2864 62444.029168 62444.367362 8.116667
2866 62446.024307 62446.365973 8.200000
2869 62449.015973 62449.364584 8.366667
2873 62453.009029 62453.362501 8.483333
... ... ... ...
3528 63108.211114 63108.422225 5.066667
3536 63116.188892 63116.415975 5.450000
3548 63128.156253 63128.405559 5.983333
3550 63130.150698 63130.404170 6.083333
3551 63131.147920 63131.402781 6.116667
3564 63144.112503 63144.391670 6.700000
3565 63145.109726 63145.390281 6.733333
3567 63147.104864 63147.388892 6.816667
3569 63149.099309 63149.386809 6.900000
3570 63150.096531 63150.386114 6.950000
3571 63151.093753 63151.385420 7.000000
3581 63161.065976 63161.377087 7.466667
3594 63174.030559 63174.367364 8.083333
3596 63176.025698 63176.365976 8.166667
3599 63179.017365 63179.364587 8.333333
3600 63180.014587 63180.363892 8.383333
3603 63183.008337 63183.362503 8.500000
3604 63184.009031 63184.361809 8.466667
3605 63185.009726 63185.361115 8.433333
3610 63190.013198 63190.359031 8.300000
3613 63193.015281 63193.358337 8.233333
3615 63195.016670 63195.357642 8.183333
3619 63199.019448 63199.348615 7.900000
3624 63204.022920 63204.335420 7.500000
3628 63208.025003 63208.324309 7.183333
3630 63210.026392 63210.318754 7.016667
3639 63219.030559 63219.294448 6.333333
3641 63221.031254 63221.288892 6.183333
3645 63225.032642 63225.277781 5.883333
3646 63226.032642 63226.275004 5.816667

122 rows × 3 columns


In [73]:
st_times = op.start_times(nstats, chosen_nights, rng)

In [74]:
st_times


Out[74]:
night
2750    62330.262845
2754    62334.285800
2761    62341.224484
2762    62342.231525
2769    62349.374206
2771    62351.299583
2773    62353.352148
2774    62354.305277
2776    62356.236961
2782    62362.318353
2783    62363.269195
2784    62364.317903
2786    62366.178518
2788    62368.300805
2789    62369.235481
2790    62370.308400
2797    62377.299688
2798    62378.206482
2799    62379.336701
2803    62383.143663
2809    62389.078402
2813    62393.298796
2815    62395.133965
2817    62397.096253
2823    62403.044254
2825    62405.146268
2826    62406.233631
2829    62409.114390
2833    62413.163989
2834    62414.016424
            ...     
3507    63087.257281
3509    63089.312829
3511    63091.216558
3514    63094.148184
3516    63096.192805
3518    63098.142492
3524    63104.353770
3528    63108.304794
3534    63114.221452
3535    63115.092348
3540    63120.150118
3542    63122.205379
3547    63127.272321
3548    63128.099445
3555    63135.055034
3561    63141.028525
3564    63144.120908
3571    63150.995138
3572    63152.006345
3588    63168.158714
3589    63169.122590
3590    63170.147060
3591    63171.132523
3593    63173.044403
3594    63174.009952
3595    63175.051604
3596    63176.150661
3597    63177.016357
3598    63178.112627
3600    63180.035531
Length: 122, dtype: float64

In [63]:
v, vl = ObservationPotential.dc2_sequence(st_times.values[0], year_block=2)


/Users/rbiswas/soft/LSST3/python/miniconda3-4.3.21/lib/python3.6/site-packages/ipykernel_launcher.py:124: DeprecationWarning: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.

In [64]:
dc2_visits = ObservationPotential.dc2_visits(st_times, year_block=1, delta=1)


/Users/rbiswas/soft/LSST3/python/miniconda3-4.3.21/lib/python3.6/site-packages/ipykernel_launcher.py:124: DeprecationWarning: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.

In [65]:
dc2_visits.head()


Out[65]:
expMJD filter night
0 62139.064613 r 2559.0
1 62139.065052 r 2559.0
2 62139.065492 r 2559.0
3 62139.065932 r 2559.0
4 62139.066372 r 2559.0

In [66]:
baseline_block2.expMJD.size


Out[66]:
7022

In [67]:
(dc2_visits.expMJD.size + baseline_block2.query('filter == "u"').expMJD.size)


Out[67]:
10266

In [68]:
dc2_visits['fieldRA'] = rauDDF
dc2_visits['fieldDec'] = decuDDF

In [69]:
from lsst.sims.photUtils import BandpassDict
import obscond

In [70]:
dc2_visits['FWHMeff'] = 1.0

In [71]:
TotbpDict, hwbpDict = BandpassDict.loadBandpassesFromFiles()
skycalc = obscond.SkyCalculations(photparams="LSST", hwBandpassDict=hwbpDict)

In [72]:
from lsst.sims.skybrightness import SkyModel

In [73]:
synopsim.pointings.iloc[0][['fieldRA', 'fieldDec', 'expMJD']]


Out[73]:
fieldRA     0.925184
fieldDec     -0.4789
expMJD       59580.1
Name: 230, dtype: object

In [159]:
sm = SkyModel()

In [163]:
decuDDF


Out[163]:
-0.4904375198104066

In [164]:
rauDDF


Out[164]:
0.9272061651219876

In [175]:
dc2_visits.iloc[1]


Out[175]:
expMJD       61044.1
filter             r
fieldRA     0.927206
fieldDec   -0.490438
FWHMeff            0
Name: 1, dtype: object

In [ ]:


In [84]:
#sm.setRaDecMjd(lat=-0.4904, lon=0.927, mjd=61137.5)

In [74]:
dc2_visits.to_csv('dc2_visits_block2')

In [181]:
sm.returnMags(bandpasses=hwbpDict)


Out[181]:
{'g': array([22.28796024]),
 'i': array([20.37079804]),
 'r': array([21.28913692]),
 'u': array([22.79937317]),
 'y': array([18.58355142]),
 'z': array([19.3902523])}

In [208]:
dc2_visits.iloc[293]


Out[208]:
expMJD       61137.5
filter             r
fieldRA     0.927206
fieldDec   -0.490438
FWHMeff            1
Name: 1, dtype: object

In [102]:
dc2_visits.to_csv('dc2_vists_block1.csv')

In [85]:
skycalc.calculatePointings(dc2_visits.head(293), calcDepths=False)


WARNING: ErfaWarning: ERFA function "taiutc" yielded 1 of "dubious year (Note 4)" [astropy._erfa.core]
WARNING: ErfaWarning: ERFA function "taiutc" yielded 1 of "dubious year (Note 4)" [astropy._erfa.core]
WARNING: ErfaWarning: ERFA function "utcut1" yielded 1 of "dubious year (Note 3)" [astropy._erfa.core]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-85-2cd87c54b2fe> in <module>()
----> 1 skycalc.calculatePointings(dc2_visits.head(293), calcDepths=False)

~/.local/lib/python3.6/site-packages/obscond/skybrightness.py in calculatePointings(self, pointings, raCol, decCol, bandCol, mjdCol, FWHMeffCol, calcSkyMags, calcDepths, calcPointingCoords, calcMoonSun, hwBandPassDict, sm)
    140             sm.setRaDecMjd(lon=ra, lat=dec,
    141                            filterNames=bandName, mjd=mjd,
--> 142                            degrees=False, azAlt=False)
    143             mydict = sm.getComputedVals()
    144             if calcPointingCoords:

~/soft/LSST3/stack/miniconda3-4.3.21-10a4fa6/DarwinX86/sims_skybrightness/2.4.2.sims+1/python/lsst/sims/skybrightness/skyModel.py in setRaDecMjd(self, lon, lat, mjd, degrees, azAlt, solarFlux, filterNames)
    333 
    334         # Interpolate the templates to the set paramters
--> 335         self._interpSky()
    336 
    337     def setRaDecAltAzMjd(self, ra, dec, alt, az, mjd, degrees=False, solarFlux=130.,

~/soft/LSST3/stack/miniconda3-4.3.21-10a4fa6/DarwinX86/sims_skybrightness/2.4.2.sims+1/python/lsst/sims/skybrightness/skyModel.py in _interpSky(self)
    615         for key in self.components:
    616             if self.components[key]:
--> 617                 result = self.interpObjs[key](self.points[self.goodPix], filterNames=self.filterNames)
    618                 # Make sure the component has something
    619                 if np.size(result['spec']) == 0:

~/soft/LSST3/stack/miniconda3-4.3.21-10a4fa6/DarwinX86/sims_skybrightness/2.4.2.sims+1/python/lsst/sims/skybrightness/interpComponents.py in __call__(self, intepPoints, filterNames)
    161             return self.interpMag(intepPoints, filterNames=filterNames)
    162         else:
--> 163             return self.interpSpec(intepPoints)
    164 
    165     def indxAndWeights(self, points, grid):

~/soft/LSST3/stack/miniconda3-4.3.21-10a4fa6/DarwinX86/sims_skybrightness/2.4.2.sims+1/python/lsst/sims/skybrightness/interpComponents.py in interpSpec(self, interpPoints)
    214 
    215     def interpSpec(self, interpPoints):
--> 216         result = self._weighting(interpPoints, self.logSpec)
    217         mask = np.where(result == 0.)
    218         result = 10.**result

~/soft/LSST3/stack/miniconda3-4.3.21-10a4fa6/DarwinX86/sims_skybrightness/2.4.2.sims+1/python/lsst/sims/skybrightness/interpComponents.py in _weighting(self, interpPoints, values)
    517 
    518         # Check that moonAltitude is in range, otherwise return zero array
--> 519         if np.max(interpPoints['moonAltitude']) < np.min(self.dimDict['moonAltitude']):
    520             return result
    521 

~/soft/LSST3/python/miniconda3-4.3.21/lib/python3.6/site-packages/numpy/core/fromnumeric.py in amax(a, axis, out, keepdims)
   2318 
   2319     return _methods._amax(a, axis=axis,
-> 2320                           out=out, **kwargs)
   2321 
   2322 

~/soft/LSST3/python/miniconda3-4.3.21/lib/python3.6/site-packages/numpy/core/_methods.py in _amax(a, axis, out, keepdims)
     24 # small reductions
     25 def _amax(a, axis=None, out=None, keepdims=False):
---> 26     return umr_maximum(a, axis, None, out, keepdims)
     27 
     28 def _amin(a, axis=None, out=None, keepdims=False):

ValueError: zero-size array to reduction operation maximum which has no identity

In [132]:
from obscond.historicalWeatherData import SeeingFile

In [143]:
seeing = synopsim.pointings[['expMJD', 'rawSeeing']].sort_values(by='expMJD')

In [142]:
from scipy.interpolate import interp1d

In [144]:
rawSeeing = interp1d(seeing.expMJD, seeing.rawSeeing)

In [149]:
seeing.iloc[5:10]['rawSeeing']


Out[149]:
obsHistID
235    0.859965
236    0.859965
237    0.859965
238    0.859965
239    0.859965
Name: rawSeeing, dtype: float64

In [145]:
rawSeeing(seeing.expMJD.iloc[5:10])


Out[145]:
array([0.859965, 0.859965, 0.859965, 0.859965, 0.859965])

In [140]:
dc2_visits.expMJD.values


Out[140]:
array([61044.09996707, 61044.10040689, 61044.1008467 , ...,
       62132.07094641, 62132.07066533, 62132.07038424])

In [116]:
dc2_visits['night'] = np.floor(dc2_visits.expMJD - 59580)

In [117]:
dc2_visits


Out[117]:
76

In [282]:
df = availabletimes.groupby('night').agg(dict(mjd=(min, max, timerange))).reset_index()

In [285]:
df.values.shape


Out[285]:
(977, 4)

In [286]:
df = pd.DataFrame(df.values, columns=('night', 'minmjd', 'maxmjd', 'timerange'))

In [287]:
df.timediff = (df.maxmjd - df.minmjd)* 24


/Users/rbiswas/soft/LSST3/python/miniconda3-4.3.21/lib/python3.6/site-packages/ipykernel_launcher.py:1: UserWarning: Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access
  """Entry point for launching an IPython kernel.

In [289]:
all(df.timerange == df.timediff)


Out[289]:
True

In [ ]:

Methods


In [88]:
def mintime(series):
    return np.remainder(min(series), 1.0) * 24.0

In [ ]:
x = dff.groupby('night').aggregate(dict(alt='count')).reset_index()

Baseline Expectations


In [ ]:

Scratch


In [ ]:
1480 +

In [102]:
np.degrees(op.sunAlt_singleTime(61040.0))


Out[102]:
4.03231444775151

In [103]:
op.obs


Out[103]:
<ephem.Observer date='2025/12/31 00:00:00' epoch='2000/1/1 12:00:00' lon='0:00:00.0' lat='-70:44:57.8' elevation=2650.0m horizon=0:00:00.0 temp=15.0C pressure=1010.0mBar>

In [104]:
op.doff


Out[104]:
15019.5

In [107]:
s = ephem.Sun()

In [109]:
op.obs.date = 61040. - op.doff

In [ ]:
sun.compute(lsstObs)
    return sun.alt

In [110]:
s.compute(op.obs)

In [111]:
s.alt


Out[111]:
0.0703771635890007

In [140]:
op.sunAlt_singleTime(61040.)


Out[140]:
-0.03337714821100235

In [113]:
from lsst.sims.utils import Site

In [114]:
site = Site('LSST')

In [115]:
import ephem

In [116]:
sun = ephem.Sun()

In [117]:
lsstObs = ephem.Observer()
lsstObs.lat = np.radians(site.latitude)
lsstObs.lon = np.radians(site.longitude)
lsstObs.elevation = site.height

In [118]:
lsstObs.date = 61040 - doff

In [120]:
sun.compute(lsstObs)

In [122]:
sun.alt


Out[122]:
-0.03337714821100235

In [124]:
lsstObs.lat


Out[124]:
-0.527864360290173

In [125]:
op.obs.lat


Out[125]:
-1.234809973810476

In [126]:
lsstObs.long


Out[126]:
-1.234809973810476

In [127]:
lsstObs.lat


Out[127]:
-0.527864360290173

In [265]:
1480 + 59580


Out[265]:
61060

In [266]:
opdf.query('night > 1479 and night < 1520')


Out[266]:
alt az mjd moonAlt moonDec moonRA night sunAlt moonDist
28800 85.534854 62.409998 61060.000000 6.963303 -18.475540 315.808737 1480 -1.996018 87.551695
28801 85.725500 60.939025 61060.000695 6.765085 -18.471209 315.817644 1480 -2.132110 87.546388
28802 85.913325 59.337531 61060.001389 6.567147 -18.466878 315.826565 1480 -2.272920 87.541067
28803 86.097920 57.589058 61060.002083 6.369501 -18.462548 315.835501 1480 -2.421856 87.535734
28804 86.278806 55.674881 61060.002778 6.172159 -18.458218 315.844452 1480 -2.584568 87.530388
28805 86.455411 53.573817 61060.003472 5.975133 -18.453888 315.853418 1480 -2.771692 87.525029
28806 86.627064 51.262103 61060.004167 5.778438 -18.449559 315.862399 1480 -3.007011 87.519656
28807 86.792968 48.713439 61060.004861 5.582089 -18.445230 315.871395 1480 -3.358057 87.514271
28808 86.952183 45.899308 61060.005556 5.386101 -18.440902 315.880405 1480 -3.918340 87.508872
28809 87.103606 42.789730 61060.006250 5.190495 -18.436574 315.889431 1480 -4.401330 87.503460
28810 87.245949 39.354704 61060.006945 4.995287 -18.432246 315.898471 1480 -4.758977 87.498036
28811 87.377733 35.566576 61060.007639 4.800501 -18.427919 315.907526 1480 -5.057864 87.492598
28812 87.497289 31.403615 61060.008333 4.606159 -18.423592 315.916596 1480 -5.325100 87.487147
28813 87.602786 26.854880 61060.009028 4.412314 -18.419266 315.925681 1480 -5.572899 87.481683
28814 87.692295 21.926113 61060.009722 4.218942 -18.414940 315.934781 1480 -5.807654 87.476206
28815 87.763894 16.645749 61060.010417 4.026099 -18.410615 315.943895 1480 -6.033174 87.470716
28816 87.815822 11.069358 61060.011111 3.833818 -18.406290 315.953024 1480 -6.251851 87.465212
28817 87.846653 5.280332 61060.011806 3.642135 -18.401966 315.962168 1480 -6.465292 87.459696
28818 87.855479 359.385032 61060.012500 3.451090 -18.397642 315.971327 1480 -6.674623 87.454166
28819 87.842029 353.502277 61060.013195 3.260728 -18.393319 315.980501 1480 -6.880682 87.448624
28820 87.806712 347.749380 61060.013889 3.071097 -18.388997 315.989689 1480 -7.084012 87.443068
28821 87.750559 342.228619 61060.014583 2.882252 -18.384675 315.998892 1480 -7.285115 87.437499
28822 87.675079 337.017794 61060.015278 2.694250 -18.380354 316.008110 1480 -7.484341 87.431917
28823 87.582082 332.166613 61060.015972 2.507157 -18.376034 316.017342 1480 -7.681968 87.426322
28824 87.473502 327.698340 61060.016667 2.321043 -18.371714 316.026589 1480 -7.878215 87.420714
28825 87.351255 323.614733 61060.017361 2.135986 -18.367395 316.035851 1480 -8.073258 87.415093
28826 87.217142 319.902145 61060.018056 1.952073 -18.363077 316.045128 1480 -8.265527 87.409458
28827 87.072794 316.537253 61060.018750 1.769396 -18.358760 316.054419 1480 -8.453975 87.403811
28828 86.919650 313.491665 61060.019445 1.588056 -18.354443 316.063725 1480 -8.642163 87.398150
28829 86.758957 310.735222 61060.020139 1.408165 -18.350127 316.073045 1480 -8.830087 87.392476
... ... ... ... ... ... ... ... ... ...
86370 66.020560 268.238028 61099.979167 18.176843 21.259618 132.715690 1519 -2.171975 91.274991
86371 65.804106 268.127124 61099.979861 18.340636 21.257314 132.723002 1519 -2.328178 91.279760
86372 65.587666 268.016990 61099.980556 18.504070 21.255006 132.730301 1519 -2.496380 91.284517
86373 65.371241 267.907603 61099.981250 18.667143 21.252694 132.737587 1519 -2.686235 91.289261
86374 65.154830 267.798943 61099.981945 18.829848 21.250377 132.744859 1519 -2.918774 91.293993
86375 64.938436 267.690989 61099.982639 18.992185 21.248057 132.752118 1519 -3.253734 91.298712
86376 64.722057 267.583720 61099.983334 19.154150 21.245732 132.759364 1519 -3.830585 91.303419
86377 64.505696 267.477117 61099.984028 19.315743 21.243403 132.766597 1519 -4.379802 91.308114
86378 64.289352 267.371161 61099.984722 19.476955 21.241070 132.773817 1519 -4.773385 91.312796
86379 64.073027 267.265834 61099.985417 19.637788 21.238732 132.781024 1519 -5.097827 91.317466
86380 63.856720 267.161119 61099.986111 19.798236 21.236391 132.788218 1519 -5.386912 91.322124
86381 63.640434 267.056999 61099.986806 19.958298 21.234045 132.795399 1519 -5.654870 91.326770
86382 63.424167 266.953457 61099.987500 20.117969 21.231695 132.802567 1519 -5.909080 91.331403
86383 63.207921 266.850477 61099.988195 20.277245 21.229340 132.809722 1519 -6.153714 91.336024
86384 62.991696 266.748043 61099.988889 20.436127 21.226981 132.816865 1519 -6.391383 91.340633
86385 62.775494 266.646141 61099.989584 20.594610 21.224618 132.823995 1519 -6.623815 91.345230
86386 62.559313 266.544756 61099.990278 20.752690 21.222250 132.831112 1519 -6.852234 91.349815
86387 62.343156 266.443874 61099.990972 20.910363 21.219878 132.838216 1519 -7.077429 91.354387
86388 62.127023 266.343482 61099.991667 21.067626 21.217502 132.845308 1519 -7.300079 91.358948
86389 61.910913 266.243565 61099.992361 21.224478 21.215121 132.852387 1519 -7.520656 91.363496
86390 61.694828 266.144112 61099.993056 21.380915 21.212735 132.859454 1519 -7.739520 91.368032
86391 61.478769 266.045109 61099.993750 21.536934 21.210346 132.866509 1519 -7.956956 91.372557
86392 61.262735 265.946544 61099.994445 21.692529 21.207951 132.873550 1519 -8.173184 91.377069
86393 61.046727 265.848406 61099.995139 21.847699 21.205553 132.880580 1519 -8.383717 91.381570
86394 60.830747 265.750683 61099.995834 22.002442 21.203149 132.887597 1519 -8.593374 91.386059
86395 60.614793 265.653365 61099.996528 22.156751 21.200742 132.894602 1519 -8.802909 91.390536
86396 60.398868 265.556439 61099.997222 22.310627 21.198329 132.901595 1519 -9.012319 91.395001
86397 60.182970 265.459895 61099.997917 22.464064 21.195913 132.908575 1519 -9.221603 91.399454
86398 59.967102 265.363724 61099.998611 22.617058 21.193491 132.915544 1519 -9.430761 91.403895
86399 59.751263 265.267916 61099.999306 22.769607 21.191065 132.922500 1519 -9.639789 91.408325

57600 rows × 9 columns


In [211]:
synopsim.pointings.airmass.hist()


Out[211]:
<matplotlib.axes._subplots.AxesSubplot at 0x115c8e9e8>

In [ ]: