Esempio n. 1
0
 def read_field_information(self, trimester=None):
     """Read in all the FLD files."""
     self.fldPar = queueTools.readAllFLDfiles(trimester)
     # Read in the colormap
     colormap = tableau_colormap.tableau20(raw=True)
     color = [tuple_to_hex(colormap[x % len(colormap)])
              for x in range(len(self.fldPar))]
     self.fldPar['color'] = color
Esempio n. 2
0
 def read_field_information(self, trimester=None):
     """Read in all the FLD files."""
     self.fldPar = queueTools.readAllFLDfiles(trimester)
     # Read in the colormap
     colormap = tableau_colormap.tableau20(raw=True)
     color = [
         tuple_to_hex(colormap[x % len(colormap)])
         for x in range(len(self.fldPar))
     ]
     self.fldPar['color'] = color
def insfocus_vs_temp(df):
    """Plot the spectrograph focus versus ambient temperature."""
    fig, ax = plt.subplots(figsize=(6, 7))
    tableau_colors = tableau20()
    # Group data by spectrograph
    groupby_spec = df.groupby(df['INSTRUME'])

    ax.set_ylim(2.0, 4.2)
    ax.set_xlim(-5, 22)

    for inst, group in groupby_spec:
        # Temperatures are integers, so we can take the mean at
        # each value with a groupby

        if inst == 'mmtbluechan':
            cc = 1
            label = "Blue Channel"
        elif inst == 'mmtredchan':
            cc = 7
            label = "Red Channel"

        groupby_temp = group.groupby(np.floor(group['TELTEMP']/2)*2)
        focus = [x["INSFOCUS"].mean() for _, x in groupby_temp]
        focus_std = [x["INSFOCUS"].std() for _, x in groupby_temp]
        temp = [x for x, _ in groupby_temp]

        ax.plot(group["TELTEMP"], group["INSFOCUS"],
                'o', alpha=0.2, markersize=2, color=tableau_colors[cc],
                label='')
        ax.errorbar(temp, focus, yerr=focus_std, fmt='D', alpha=1,
                    color=tableau_colors[cc-1],
                    label=label, markersize=5)

        # Quick linear regression
        fit = np.polyfit(group['TELTEMP'], group['INSFOCUS'], 1)
        xx = np.linspace(-5, 22, 2)
        ax.plot(xx, fit[0]*xx+fit[1], color=tableau_colors[cc-1])
        cc += 1

    ax.grid()
    ax.set_xlabel("Ambient Temperature ($^o$C)")
    ax.set_ylabel("Spectrograph Focus (V)")
    ax.legend(loc=3, prop={'size': 11}, frameon=False)
    plt.savefig("insfocus_vs_temp.pdf")
def gratingUsage(df):
    """Plot a histogram showing how often each of the gratings are used."""
    # First aggregate the data by grating
    groupby_disp = df.groupby(df['INSTDISP'])

    # Create some placeholder list
    disp = []
    count = []
    plotcolor = []
    for name, group in groupby_disp:
        disp.append(name[2:])
        count.append(len(group))
        if name[0] == 'B':
            plotcolor.append(1)     # Dark Blue in tableau20
        elif name[0] == 'R':
            plotcolor.append(7)     # Dark Red in tableau20

    # Create the histogram
    fig, ax = plt.subplots()
    tableau_color = tableau20()

    xpos = np.linspace(0, len(disp), len(disp))

    barplot = ax.barh(xpos, count, align='center')

    # Color the barplot according to instrument
    for idx, color in enumerate(plotcolor):
        barplot[idx].set_color(tableau_color[color])

    plt.xlabel("Number of Uses in Archive")

    # Hide Top and Right axis
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)
    ax.spines['left'].set_visible(False)

    # Shade the x labels (since they aren't really vital)
    ax.spines['bottom'].set_visible(False)
    ax.xaxis.label.set_color('grey')
    ax.tick_params(axis='x', colors='grey')
    plt.yticks(xpos, disp)
    plt.savefig("grating_usage.pdf")
def grating_versus_cenwave(df):
    """Plot Central wavelength versus disperser.

    Display frequency of how often each central
    wavelength is used for each disperser.
    """
    tableau_color = tableau20()
    disperse_num = []
    displist = sorted(list(df['INSTDISP'].unique()))
    for disp in df['INSTDISP']:
        disperse_num.append(displist.index(disp))

    cenwaves = [df[df["INSTDISP"] == disp]["CENWAVE"] for disp in displist]
    xpos = np.arange(len(displist))
    fig, ax = plt.subplots()

    violins = ax.violinplot(cenwaves,
                            xpos,
                            showmedians=False, showmeans=False,
                            showextrema=False)
    for idx, pc in enumerate(violins['bodies']):
        if displist[idx][0] == 'B':
            cc = 0
        else:
            cc = 6
        pc.set_facecolor(tableau_color[cc])
        pc.set_edgecolor('none')

    ax.set_xticks(xpos)
    ax.set_xticklabels([x[2:] for x in displist], rotation=-90)
    ax.set_xlim(-1, 13)
    ax.plot(disperse_num, df['CENWAVE'], '.',
            color='grey', markersize=3)

    # Hide Top and Right axis
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)

    ax.set_ylabel("Central Wavelength")

    plt.savefig("centralwavelength_per_grating.pdf")
Esempio n. 6
0
    h, m, s = map(float, time.split(':'))
    seconds = h*3600.0 + m*60.0 + s
    return seconds / 3600.


def tuple_to_hex(rgb):
    return '#%02x%02x%02x' % rgb


fldPar = MMTQueue.read_all_fld_files('2016a')
# The ephemeris kills things later, drop it
fldPar.drop('ephem', 1, inplace=True)

schedule_df = pd.read_csv('schedule.csv', parse_dates=['start_time'])
# We will use these colors to color each group by a different color
colormap = tableau20(raw=True)
color = [tuple_to_hex(colormap[x % len(colormap)]) for x in range(len(fldPar))]
fldPar['color'] = color

schedule_df['end_time'] = [x + datetime.timedelta(seconds=float(y))
                           for x, y in zip(schedule_df['start_time'],
                                           schedule_df['duration'])]
schedule_df['mid_time'] = [x + datetime.timedelta(seconds=float(0.5*y))
                           for x, y in zip(schedule_df['start_time'],
                           schedule_df['duration'])]
schedule_df['mid_time'] = [x.hour + x.minute/60.
                           for x in schedule_df['mid_time']]
print(schedule_df['mid_time'])
mindate = schedule_df['start_time'].min()
schedule_df['start_date'] = [
    math.floor((x - mindate).total_seconds()/24.0/3600.0)
Esempio n. 7
0
    h, m, s = map(float, time.split(':'))
    seconds = h * 3600.0 + m * 60.0 + s
    return seconds / 3600.


def tuple_to_hex(rgb):
    return '#%02x%02x%02x' % rgb


fldPar = MMTQueue.read_all_fld_files('2016a')
# The ephemeris kills things later, drop it
fldPar.drop('ephem', 1, inplace=True)

schedule_df = pd.read_csv('schedule.csv', parse_dates=['start_time'])
# We will use these colors to color each group by a different color
colormap = tableau20(raw=True)
color = [tuple_to_hex(colormap[x % len(colormap)]) for x in range(len(fldPar))]
fldPar['color'] = color

schedule_df['end_time'] = [
    x + datetime.timedelta(seconds=float(y))
    for x, y in zip(schedule_df['start_time'], schedule_df['duration'])
]
schedule_df['mid_time'] = [
    x + datetime.timedelta(seconds=float(0.5 * y))
    for x, y in zip(schedule_df['start_time'], schedule_df['duration'])
]
schedule_df['mid_time'] = [
    x.hour + x.minute / 60. for x in schedule_df['mid_time']
]
print(schedule_df['mid_time'])