In [1]:
import os
import numpy as np
In [2]:
from lsst.utils import getPackageDir
In [3]:
twinklesDir = getPackageDir('twinkles')
runMetaDataFile = os.path.join(twinklesDir, 'data/run1_metadata_v6.csv')
#InputVisitsFile = os.path.join(twinklesDir, 'data/SelectedKrakenVisits.csv')
In [4]:
import pandas as pd
In [5]:
runMetaDataFile
Out[5]:
In [6]:
from desc.monitor.dbConnection import dbInterface
In [7]:
dbConn = dbInterface(database='DESC_Twinkles_Level_2',
host='127.0.0.1', port='3307',
driver='mysql')
In [8]:
# Find the tables on the database
tables = dbConn._dbo.get_table_names()
print(tables)
In [9]:
# Find the columns in the table CcdVisit
colNames = dbConn._dbo.get_column_names('CcdVisit')
#print(colNames)
In [10]:
obsHistIDsSuccess = set(dbConn._dbo.execute_arbitrary('SELECT visitId from CcdVisit')['visitId'])
# print(obsHistIDsSuccess)
In [11]:
# From https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues/229 provided by @tony-johnson
DMFailures = set([681808, 1417225, 1957025, 2166623])
In [12]:
bandnames = 'ugrizy'
In [13]:
# PhoSim Failures (See Run1CPUTimes.ipynb notebook for detail. This is part of @sethdigel 's investigation)
run1meta = pd.read_csv(runMetaDataFile,index_col=0,usecols=["obshistid","expmjd","filter","rotskypos","altitude",\
"rawseeing","airmass","sunalt","moonalt","moonphase","dist2moon","cputime",\
"runlimit", "hostname"])
run1meta.rename(columns={'filter':'band'}, inplace=True)
run1meta['band'] = run1meta.band.apply(lambda x: bandnames[x])
phoSimFailedObsHistIDs = set(run1meta.query('runlimit==1').index.values)
In [14]:
print('Number of phosim run failures due to Wall Clock Limit = {}'.format(len(phoSimFailedObsHistIDs)))
In [15]:
phosimFailures = run1meta.query('runlimit == 1')
In [16]:
grouped = phosimFailures.groupby('band')
In [17]:
phosimFailures.columns
Out[17]:
In [18]:
grouped.agg({'expmjd':len, 'moonphase': [np.min, np.median, np.max], 'sunalt': [np.min, np.median, np.max]})
Out[18]:
In [19]:
import seaborn as sns
sns.set()
In [20]:
%matplotlib inline
import matplotlib.pyplot as plt
In [21]:
sns.jointplot(x='moonphase', y='moonalt', data=phosimFailures)
Out[21]:
In [22]:
sns.pairplot(phosimFailures[['sunalt', 'moonphase', 'dist2moon', 'altitude', 'band']], hue='band')
Out[22]:
In [42]:
sns.pairplot(run1meta[['sunalt', 'moonphase', 'moonalt', 'band']], hue='band')
Out[42]:
In [24]:
print('Total number of Observations = {}'.format(len(run1meta)))
In [25]:
InputVisits = set(run1meta.index.values)
In [26]:
failures = InputVisits - obsHistIDsSuccess
In [27]:
assert len(failures) == len(InputVisits) -len(obsHistIDsSuccess)
In [28]:
failures == phoSimFailedObsHistIDs.union(DMFailures)
Out[28]:
In [29]:
failures - phoSimFailedObsHistIDs - DMFailures
Out[29]:
In [30]:
missingObs = set([709569, 726636, 732065])
In [31]:
missingObs.intersection(phoSimFailedObsHistIDs) == missingObs
Out[31]:
In [32]:
run1meta.head()
Out[32]:
In [33]:
run1meta.ix[[709569, 726636, 732065]]
Out[33]:
In [34]:
obs = pd.read_csv(os.path.join(twinklesDir, 'data/SelectedKrakenVisits.csv'), index_col='obsHistID')
In [39]:
obs.ix[[709569, 726636, 732065]][['moonPhase', 'filtSkyBrightness', 'moonAlt', 'sunAlt', 'dist2Moon']]
Out[39]:
In [ ]: