Exemplo n.º 1
0
def main():

    roloroot = '/home/sbraden/Dropbox/calibration/ROLO/datasetChips/'
    feature = 'serenitatis' 
    
    # Read in ROLO data and process into I/F reflectance
    lookup = caltools.get_filter_lookup(roloroot) # filter_id => band lookup table
    chips = caltools.process_rolo_data(roloroot, feature, lookup)

    # STEP 3: (optional) appy the Lommel-Seeliger correction
    incidence = chips[feature+'_incidence']
    emission = chips[feature+'_emission']
    LS = caltools.lommel_seeliger(incidence, emission)
    chips['LS'] = pd.Series(LS.values)
    #chips[feature] = chips[feature]*LS # apply LS

    # STEP 4: set data to only the appropriate phases by setting others to nan
    # Negative phase angle values correspond to waxing lunar phases
    chips.topo_phase[chips.topo_phase > 0] = np.nan
    chips.topo_phase = abs(chips.topo_phase.values)

    # Plotting
    index = 24 #695 nm 17 => 353 nm
    band = int(lookup.loc[index].values)
    plt.figure()
    chips[chips['filter_id'] == index].plot(x='topo_phase', y=feature, marker='o', lw=0)
    title = feature+'-phase-curve-ROLO-band-'+str(band)
    plt.title(title)
    plt.ylabel('I/F')
    plt.savefig(title+'.png', dpi=200)
    plt.show()
    plt.close
Exemplo n.º 2
0
def main():

    WAC_root = '/home/sbraden/data/rolo_chip_cal/'

    ROLO_root = '/home/sbraden/Dropbox/calibration/ROLO/datasetChips/'
    feature = 'serenitatis' 

    # Read in ROLO data and process into I/F reflectance
    lookup = caltools.get_filter_lookup(roloroot) # filter_id => band lookup table
    chips = caltools.process_rolo_data(roloroot, feature, lookup)

    # STEP 3: (optional) appy the Lommel-Seeliger correction
    incidence = chips[feature+'_incidence']
    emission = chips[feature+'_emission']
    LS = caltools.lommel_seeliger(incidence, emission)
    chips['LS'] = pd.Series(LS.values)
    #chips[feature] = chips[feature]*LS # apply LS

    # STEP 4: set data to only the appropriate phases by setting others to nan
    # Negative phase angle values correspond to waxing lunar phases
    chips.topo_phase[chips.topo_phase > 0] = np.nan
    chips.topo_phase = abs(chips.topo_phase.values)

    ###########################################

    # groups for phase angles
    phase_groups = [15, 20, 25, 30, 35, 40]
    # STEP 3: all values for the chip of interest are in I/F, 
    # index chips by filter_id
    # df=pd.DataFrame(chips, index=chips['filter_id'])
    # sort by phase, bin by phase?, then group/aggregate, interp to WAC bands

    # see if I can replace this loop by some other kind of selection
    data = []
    columns = ['band','phase','avg','stdev','num']

    for phase in phase_groups:
        group = subchip[(subchip['real_phase'] > phase-2) & (subchip['real_phase'] < phase+2)]
        output = band, phase, chip_rad.mean(), chip_rad.std(), len(chip_rad.index)
        data.append(output)

    all_data = pd.DataFrame(data, columns=columns)
    grouped = all_data.groupby(['phase', 'band']) # indexed by phase group then band
    # print all_data.groupby(['band', 'phase']).mean().avg
    # print all_data.groupby(['band', 'phase']).mean().std
 
    # create a MultiIndex from the groups through Aggregation
    # This averages multiple observations in the same filter together
    avg_multi_index = grouped.aggregate(np.mean)
    averages = avg_multi_index['avg']
    stdevs = avg_multi_index['stdev']

    # READ IN AND PROCESS WAC Data
    wac_dataframe = read_WAC(WAC_root, feature)
    # print wac_dataframe

    # not the best way to define this... ok for now
    #customized
    rolo_bands = [353, 405, 413, 467, 476, 550, 545, 555, 667, 695, 706]

    for phase in phase_groups:
        # interpolate data and stdev to WAC bands
        rolo_iof_interp = caltools.interp2wacbands(rolo_bands, iof_df.values)
        rolo_iof_stdev_interp = caltools.interp2wacbands(rolo_bands,
            iof_df_stdev.values)
        cal_factor = wac_dataframe.loc[phase].avg/rolo_iof_interp

        x = cal_factor.index
        y = cal_factor.values
        p = rolo_iof_interp
        p_stdev = rolo_iof_stdev_interp
        r = wac_dataframe.loc[phase].avg
        r_stdev = wac_dataframe.loc[phase].stdev
        u = np.power(p_stdev/p, 2)
        w = np.power(r_stdev/r, 2)
        yerr = y * np.power(u+w, 0.5)
        plt.errorbar(x, y, yerr=yerr, marker='o', label=str(phase), 
            c=colorloop.next())
        # print phase, cal_factor

    plt.legend(loc='best')
    plt.xlabel('WAC bands [nm]', fontsize=14)
    plt.ylabel('ROLO-derived calibration factor', fontsize=14)
    filename = feature+ '_cal_factor_abs'
    plt.title(filename)
    plt.savefig(filename+'.png', dpi=200)
    plt.close