예제 #1
0
    def result_to_csv(self):
        column_header = ['Class', 'Gauge #']
        result_matrix = []
        result_matrix.append(self.gauge_class_array)
        result_matrix.append(self.gauge_number_array)

        for percent in self.exceedance_percent:
            for percentille in self.percentilles:
                column_header.append('WIN_Tim_{}_{}'.format(
                    percent, percentille))
                column_header.append('WIN_Dur_{}_{}'.format(
                    percent, percentille))
                column_header.append('WIN_Fre_{}_{}'.format(
                    percent, percentille))

                result_matrix.append(self.timing[percent][percentille])
                result_matrix.append(self.duration[percent][percentille])
                result_matrix.append(self.freq[percent][percentille])

        result_matrix = sort_matrix(result_matrix, 0)
        result_matrix = insert_column_header(result_matrix, column_header)

        np.savetxt("post_processedFiles/winter_highflow_POR_result_matrix.csv",
                   result_matrix,
                   delimiter=",",
                   fmt="%s")
예제 #2
0
    def result_to_csv(self):
        column_header = ['Class', 'Gauge', 'SP_Tim_10', 'SP_Dur_10', 'SP_Mag_10', 'SP_ROC_10', 'SP_Tim_50', 'SP_Dur_50', 'SP_Mag_50', 'SP_ROC_50', 'SP_Tim_90', 'SP_Dur_90', 'SP_Mag_90', 'SP_ROC_90']
        result_matrix = []
        result_matrix.append(self.gauge_class_array)
        result_matrix.append(self.gauge_number_array)

        for percent in self.percentilles:
            result_matrix.append(self.spring_timings[percent])
            result_matrix.append(self.spring_durations[percent])
            result_matrix.append(self.spring_magnitudes[percent])
            result_matrix.append(self.spring_rocs[percent])

        result_matrix = sort_matrix(result_matrix, 0)
        result_matrix = insert_column_header(result_matrix, column_header)

        np.savetxt("post_processedFiles/spring_transition_result_matrix.csv", result_matrix, delimiter=",", fmt="%s")
        if self.plot:
            smart_plot(result_matrix)

        """nonP plots"""
        SP_Tim = []
        SP_Mag = []
        SP_Dur = []
        SP_ROC = []

        for class_id in range(1,10):
            SP_Tim.append(self.metrics['SP_Tim'][class_id])
            SP_Mag.append(self.metrics['SP_Mag'][class_id])
            SP_Dur.append(self.metrics['SP_Dur'][class_id])
            SP_ROC.append(self.metrics['SP_ROC'][class_id])

        combined = {'SP_Tim': SP_Tim, 'SP_Mag': SP_Mag, 'SP_Dur': SP_Dur, 'SP_ROC': SP_ROC}
        if self.plot:
            nonP_box_plot(combined)
예제 #3
0
    def result_to_csv(self):
        column_header = [
            'Class', 'Gauge', 'SU_Tim_10', 'SU_BFL_Mag_10_10',
            'SU_BFL_Mag_50_10', 'SU_BFL_Dur_Flush_10', 'SU_BFL_Dur_Wet_10',
            'SU_BFL_NoFlow_10', 'SU_Tim_50', 'SU_BFL_Mag_10_50',
            'SU_BFL_Mag_50_50', 'SU_BFL_Dur_Flush_50', 'SU_BFL_Dur_Wet_50',
            'SU_BFL_NoFlow_50', 'SU_Tim_90', 'SU_BFL_Mag_10_90',
            'SU_BFL_Mag_50_90', 'SU_BFL_Dur_Flush_90', 'SU_BFL_Dur_Wet_90',
            'SU_BFL_NoFlow_90'
        ]
        result_matrix = []
        result_matrix.append(self.gauge_class_array)
        result_matrix.append(self.gauge_number_array)

        for percentile in self.percentilles:
            result_matrix.append(self.summer_timings[percentile])
            result_matrix.append(self.summer_10_magnitudes[percentile])
            result_matrix.append(self.summer_50_magnitudes[percentile])
            result_matrix.append(self.summer_flush_durations[percentile])
            result_matrix.append(self.summer_wet_durations[percentile])
            result_matrix.append(self.summer_no_flow_counts[percentile])

        result_matrix = sort_matrix(result_matrix, 0)
        result_matrix = insert_column_header(result_matrix, column_header)

        np.savetxt("post_processedFiles/summer_baseflow_result_matrix.csv",
                   result_matrix,
                   delimiter=",",
                   fmt="%s")
        if self.plot:
            smart_plot(result_matrix)
        """nonP plots"""
        SU_BFL_Tim = []
        SU_BFL_Mag_10 = []
        SU_BFL_Mag_50 = []
        SU_BFL_Dur_Fl = []
        SU_BFL_Dur_Wet = []
        SU_BFL_No_Flow = []

        for class_id in range(1, 10):
            SU_BFL_Tim.append(self.metrics['SU_BFL_Tim'][class_id])
            SU_BFL_Mag_10.append(self.metrics['SU_BFL_Mag_10'][class_id])
            SU_BFL_Mag_50.append(self.metrics['SU_BFL_Mag_50'][class_id])
            SU_BFL_Dur_Fl.append(self.metrics['SU_BFL_Dur_Fl'][class_id])
            SU_BFL_Dur_Wet.append(self.metrics['SU_BFL_Dur_Wet'][class_id])
            SU_BFL_No_Flow.append(self.metrics['SU_BFL_No_Flow'][class_id])

        combined = {
            'SU_BFL_Tim': SU_BFL_Tim,
            'SU_BFL_Mag_10': SU_BFL_Mag_10,
            'SU_BFL_Mag_50': SU_BFL_Mag_50,
            'SU_BFL_Dur_Fl, ': SU_BFL_Dur_Fl,
            'SU_BFL_Dur_Wet': SU_BFL_Dur_Wet,
            'SU_BFL_No_Flow': SU_BFL_No_Flow
        }
        if self.plot:
            nonP_box_plot(combined)
예제 #4
0
    def result_to_csv(self):
        column_header = [
            'Class', 'Gauge', 'FAFL_Tim_10%', 'FAFL_Mag_10%', 'FAFL_Dur_10%',
            'FA_Tim_Wet_10%', 'FAFL_Tim_50%', 'FAFL_Mag_50%', 'FAFL_Dur_50%',
            'FA_Tim_Wet_50%', 'FAFL_Tim_90%', 'FAFL_Mag_90%', 'FAFL_Dur_90%',
            'FA_Tim_Wet_90%'
        ]
        result_matrix = []
        result_matrix.append(self.gauge_class_array)
        result_matrix.append(self.gauge_number_array)

        for percent in self.percentilles:
            result_matrix.append(self.fall_timings[percent])
            result_matrix.append(self.fall_magnitudes[percent])
            result_matrix.append(self.fall_durations[percent])
            result_matrix.append(self.fall_wet_timings[percent])

        result_matrix = sort_matrix(result_matrix, 0)
        result_matrix = insert_column_header(result_matrix, column_header)

        np.savetxt("post_processedFiles/fall_flush_result_matrix.csv",
                   result_matrix,
                   delimiter=",",
                   fmt="%s")
        if self.plot:
            smart_plot(result_matrix)
        """nonP plots"""
        FAFL_Tim = []
        FAFL_Mag = []
        FAFL_Tim_Wet = []
        FAFL_Dur = []

        for class_id in range(1, 10):
            FAFL_Tim.append(self.metrics['FAFL_Tim'][class_id])
            FAFL_Mag.append(self.metrics['FAFL_Mag'][class_id])
            FAFL_Tim_Wet.append(self.metrics['FAFL_Tim_Wet'][class_id])
            FAFL_Dur.append(self.metrics['FAFL_Dur'][class_id])

        combined = {
            'FAFL_Tim': FAFL_Tim,
            'FAFL_Mag': FAFL_Mag,
            'FAFL_Tim_Wet': FAFL_Tim_Wet,
            'FAFL_Dur': FAFL_Dur
        }
        if self.plot:
            nonP_box_plot(combined)
예제 #5
0
    def result_to_csv(self):
        column_header = [
            'Class', 'Gauge', 'Avg_10%', 'Std_10%', 'CV_10%', 'Avg_50%',
            'Std_50%', 'CV_50%', 'Avg_90%', 'Std_90%', 'CV_90%'
        ]
        result_matrix = []
        result_matrix.append(self.gauge_class_array)
        result_matrix.append(self.gauge_number_array)

        for percent in self.percentilles:
            result_matrix.append(self.average_annual_flows[percent])
            result_matrix.append(self.standard_deviations[percent])
            result_matrix.append(self.coefficient_variations[percent])

        result_matrix = sort_matrix(result_matrix, 0)
        result_matrix = insert_column_header(result_matrix, column_header)

        np.savetxt("post_processedFiles/all_year_result_matrix.csv",
                   result_matrix,
                   delimiter=",",
                   fmt="%s")

        if self.plot:
            smart_plot(result_matrix)
        """nonP plots"""
        Avg = []
        Std = []
        CV = []

        for class_id in range(1, 10):
            Avg.append(self.metrics['Avg'][class_id])
            Std.append(self.metrics['Std'][class_id])
            CV.append(self.metrics['CV'][class_id])

        combined = {'Avg': Avg, 'Std': Std, 'CV': CV}
        if self.plot:
            nonP_box_plot(combined)
예제 #6
0
    def create_result_csv(self):
        self.all_year()
        self.start_of_summer()
        self.fall_flush_timings_durations()
        self.summer_baseflow_durations_magnitude()
        self.winter_highflow_annual()
        self.spring_transition_timing_magnitude()
        self.spring_transition_duration()
        self.spring_transition_roc()
        self.fall_winter_baseflow()

        """Convert offset dates to non-offset dates"""
        spring_timings = []
        summer_timings = []
        fall_timings = []
        fall_wet_timings = []
        for index, year in enumerate(self.year_ranges):
            julian_start_date = datetime.strptime("{}/{}".format(self.start_date, year), "%m/%d/%Y").timetuple().tm_yday
            spring_timings.append(remove_offset_from_julian_date(self.spring_timings[index], julian_start_date))
            summer_timings.append(remove_offset_from_julian_date(self.summer_timings[index], julian_start_date))
            fall_timings.append(remove_offset_from_julian_date(self.fall_timings[index], julian_start_date))
            fall_wet_timings.append(remove_offset_from_julian_date(self.fall_wet_timings[index], julian_start_date))

        winter_timings = {}
        for percent in self.exceedance_percent:
            winter_timings[percent] = []
            for index, year in enumerate(self.year_ranges):
                julian_start_date = datetime.strptime("{}/{}".format(self.start_date, year), "%m/%d/%Y").timetuple().tm_yday
                winter_timings[percent].append(remove_offset_from_julian_date(self.winter_timings[percent][index], julian_start_date))


        low_end = general_params['annual_result_low_Percentille_filter']
        high_end = general_params['annual_result_high_Percentille_filter']

        """Filter data only to contain from low_end to high_end"""
        self.average_annual_flows = [np.nan if ele < np.nanpercentile(self.average_annual_flows, low_end) or ele > np.nanpercentile(self.average_annual_flows, high_end) else ele for index, ele in enumerate(self.average_annual_flows)]
        self.standard_deviations = [np.nan if ele < np.nanpercentile(self.standard_deviations, low_end) or ele > np.nanpercentile(self.standard_deviations, high_end) else ele for index, ele in enumerate(self.standard_deviations)]
        self.coefficient_variations = [np.nan if ele < np.nanpercentile(self.coefficient_variations, low_end) or ele > np.nanpercentile(self.coefficient_variations, high_end) else ele for index, ele in enumerate(self.coefficient_variations)]
        spring_timings = [np.nan if ele < np.nanpercentile(spring_timings, low_end) or ele > np.nanpercentile(spring_timings, high_end) else ele for index, ele in enumerate(spring_timings)]
        self.spring_magnitudes = [np.nan if ele < np.nanpercentile(self.spring_magnitudes, low_end) or ele > np.nanpercentile(self.spring_magnitudes, high_end) else ele for index, ele in enumerate(self.spring_magnitudes)]
        self.spring_durations = [np.nan if ele < np.nanpercentile(self.spring_durations, low_end) or ele > np.nanpercentile(self.spring_durations, high_end) else ele for index, ele in enumerate(self.spring_durations)]
        self.spring_rocs = [np.nan if ele < np.nanpercentile(self.spring_rocs, low_end) or ele > np.nanpercentile(self.spring_rocs, high_end) else ele for index, ele in enumerate(self.spring_rocs)]
        summer_timings = [np.nan if ele < np.nanpercentile(summer_timings, low_end) or ele > np.nanpercentile(summer_timings, high_end) else ele for index, ele in enumerate(summer_timings)]
        self.summer_10_magnitudes = [np.nan if ele < np.nanpercentile(self.summer_10_magnitudes, low_end) or ele > np.nanpercentile(self.summer_10_magnitudes, high_end) else ele for index, ele in enumerate(self.summer_10_magnitudes)]
        self.summer_50_magnitudes = [np.nan if ele < np.nanpercentile(self.summer_50_magnitudes, low_end) or ele > np.nanpercentile(self.summer_50_magnitudes, high_end) else ele for index, ele in enumerate(self.summer_50_magnitudes)]
        self.summer_flush_durations = [np.nan if ele < np.nanpercentile(self.summer_flush_durations, low_end) or ele > np.nanpercentile(self.summer_flush_durations, high_end) else ele for index, ele in enumerate(self.summer_flush_durations)]
        self.summer_wet_durations = [np.nan if ele < np.nanpercentile(self.summer_wet_durations, low_end) or ele > np.nanpercentile(self.summer_wet_durations, high_end) else ele for index, ele in enumerate(self.summer_wet_durations)]
        self.summer_no_flow_counts = [np.nan if ele < np.nanpercentile(self.summer_no_flow_counts, low_end) or ele > np.nanpercentile(self.summer_no_flow_counts, high_end) else ele for index, ele in enumerate(self.summer_no_flow_counts)]
        fall_timings = [np.nan if ele < np.nanpercentile(fall_timings, low_end) or ele > np.nanpercentile(fall_timings, high_end) else ele for index, ele in enumerate(fall_timings)]
        self.fall_magnitudes = [np.nan if ele < np.nanpercentile(self.fall_magnitudes, low_end) or ele > np.nanpercentile(self.fall_magnitudes, high_end) else ele for index, ele in enumerate(self.fall_magnitudes)]
        fall_wet_timings = [np.nan if ele < np.nanpercentile(fall_wet_timings, low_end) or ele > np.nanpercentile(fall_wet_timings, high_end) else ele for index, ele in enumerate(fall_wet_timings)]
        self.fall_durations = [np.nan if ele < np.nanpercentile(self.fall_durations, low_end) or ele > np.nanpercentile(self.fall_durations, high_end) else ele for index, ele in enumerate(self.fall_durations)]
        self.wet_baseflows = [np.nan if ele < np.nanpercentile(self.wet_baseflows, low_end) or ele > np.nanpercentile(self.wet_baseflows, high_end) else ele for index, ele in enumerate(self.wet_baseflows)]
        for percent in self.exceedance_percent:
            winter_timings[percent] = [np.nan if ele < np.nanpercentile(winter_timings[percent], low_end) or ele > np.nanpercentile(winter_timings[percent], high_end) else ele for index, ele in enumerate(winter_timings[percent])]
            self.winter_durations[percent] = [np.nan if ele < np.nanpercentile(self.winter_durations[percent], low_end) or ele > np.nanpercentile(self.winter_durations[percent], high_end) else ele for index, ele in enumerate(self.winter_durations[percent])]
            self.winter_frequencys[percent] = [np.nan if ele < np.nanpercentile(self.winter_frequencys[percent], low_end) or ele > np.nanpercentile(self.winter_frequencys[percent], high_end) else ele for index, ele in enumerate(self.winter_frequencys[percent])]
            self.winter_magnitudes[percent] = [np.nan if ele < np.nanpercentile(self.winter_magnitudes[percent], low_end) or ele > np.nanpercentile(self.winter_magnitudes[percent], high_end) else ele for index, ele in enumerate(self.winter_magnitudes[percent])]

        """result to CSV"""
        result_matrix = []
        result_matrix.append(self.year_ranges)
        result_matrix.append(self.average_annual_flows)
        result_matrix.append(self.standard_deviations)
        result_matrix.append(self.coefficient_variations)
        result_matrix.append(spring_timings)
        result_matrix.append(self.spring_magnitudes)
        result_matrix.append(self.spring_durations)
        result_matrix.append(self.spring_rocs)
        result_matrix.append(summer_timings)
        result_matrix.append(self.summer_10_magnitudes)
        result_matrix.append(self.summer_50_magnitudes)
        result_matrix.append(self.summer_flush_durations)
        result_matrix.append(self.summer_wet_durations)
        result_matrix.append(self.summer_no_flow_counts)
        result_matrix.append(fall_timings)
        result_matrix.append(self.fall_magnitudes)
        result_matrix.append(fall_wet_timings)
        result_matrix.append(self.fall_durations)
        result_matrix.append(self.wet_baseflows)
        for percent in self.exceedance_percent:
            result_matrix.append(winter_timings[percent])
            result_matrix.append(self.winter_durations[percent])
            result_matrix.append(self.winter_frequencys[percent])
            result_matrix.append(self.winter_magnitudes[percent])

        column_header = ['Year', 'Avg', 'Std', 'CV', 'SP_Tim', 'SP_Mag', 'SP_Dur', 'SP_ROC', 'SU_BFL_Tim', 'SU_BFL_Mag_10', 'SU_BFL_Mag_50', 'SU_BFL_Dur_Fl', 'SU_BFL_Dur_Wet', 'SU_BFL_No_Flow', 'FAFL_Tim', 'FAFL_Mag', 'FAFL_Tim_Wet', 'FAFL_Dur', 'Wet_BFL_Mag', 'WIN_Tim_2', 'WIN_Dur_2', 'WIN_Fre_2', 'WIN_Mag_2', 'WIN_Tim_5', 'WIN_Dur_5', 'WIN_Fre_5', 'WIN_Mag_5', 'WIN_Tim_10', 'WIN_Dur_10', 'WIN_Fre_10', 'WIN_Mag_10', 'WIN_Tim_20', 'WIN_Dur_20', 'WIN_Fre_20', 'WIN_Mag_20', 'WIN_Tim_50', 'WIN_Dur_50', 'WIN_Fre_50', 'WIN_Mag_50']

        # column_header = ['Year', 'Avg', 'Std', 'CV', 'SP_Tim', 'SP_Mag', 'SP_Dur', 'SP_ROC', 'SU_Tim', 'SU_Mag_10', 'SU_Mag_50', 'SU_Dur_Fl', 'SU_Dur_Wet', 'SU_No_Flow', 'FA_Tim', 'FA_Mag', 'FA_Tim_Wet', 'FA_Dur', 'Wet_BFL_Mag', 'Tim_2', 'Dur_2', 'Fre_2', 'Mag_2', 'Tim_5', 'Dur_5', 'Fre_5', 'Mag_5','Tim_10', 'Dur_10', 'Fre_10', 'Mag_10', 'Tim_20', 'Dur_20', 'Fre_20', 'Mag_20', 'Tim_50', 'Dur_50', 'Fre_50', 'Mag_50']

        new_result_matrix = []
        for index, row in enumerate(result_matrix):
            new_result_matrix.append(list(result_matrix[index]))

        if len(new_result_matrix) == len(column_header):
            new_result_matrix = insert_column_header(new_result_matrix, column_header)
        else:
            print('Column header does not have the same dimension as result matrix')

        np.savetxt("post_processedFiles/{}_annual_result_matrix.csv".format(
            int(self.gauge_number)), new_result_matrix, delimiter=",", fmt="%s")
예제 #7
0
    def create_result_csv(self):
        self.all_year()
        self.start_of_summer()
        self.fall_flush_timings_durations()
        self.summer_baseflow_durations_magnitude()
        self.winter_highflow_annual()
        self.spring_transition_timing_magnitude()
        self.spring_transition_duration()
        self.spring_transition_roc()
        self.fall_winter_baseflow()
        """Convert offset dates to non-offset dates"""
        spring_timings_julian = []
        summer_timings_julian = []
        fall_timings_julian = []
        fall_wet_timings_julian = []
        for index, year in enumerate(self.year_ranges):
            julian_start_date = datetime.strptime(
                "{}/{}".format(self.start_date, year),
                "%m/%d/%Y").timetuple().tm_yday
            spring_timings_julian.append(
                remove_offset_from_julian_date(self.spring_timings[index],
                                               julian_start_date))
            summer_timings_julian.append(
                remove_offset_from_julian_date(self.summer_timings[index],
                                               julian_start_date))
            fall_timings_julian.append(
                remove_offset_from_julian_date(self.fall_timings[index],
                                               julian_start_date))
            fall_wet_timings_julian.append(
                remove_offset_from_julian_date(self.fall_wet_timings[index],
                                               julian_start_date))

        low_end = general_params['annual_result_low_Percentille_filter']
        high_end = general_params['annual_result_high_Percentille_filter']
        """Filter data only to contain from low_end to high_end"""
        self.average_annual_flows = [
            np.nan
            if ele < np.nanpercentile(self.average_annual_flows, low_end)
            or ele > np.nanpercentile(self.average_annual_flows, high_end) else
            ele for index, ele in enumerate(self.average_annual_flows)
        ]
        self.standard_deviations = [
            np.nan if ele < np.nanpercentile(self.standard_deviations, low_end)
            or ele > np.nanpercentile(self.standard_deviations, high_end) else
            ele for index, ele in enumerate(self.standard_deviations)
        ]
        self.coefficient_variations = [
            np.nan
            if ele < np.nanpercentile(self.coefficient_variations, low_end)
            or ele > np.nanpercentile(self.coefficient_variations, high_end)
            else ele for index, ele in enumerate(self.coefficient_variations)
        ]
        spring_timings = [
            np.nan if ele < np.nanpercentile(self.spring_timings, low_end)
            or ele > np.nanpercentile(self.spring_timings, high_end) else ele
            for index, ele in enumerate(self.spring_timings)
        ]
        spring_timings_julian = [
            np.nan if ele < np.nanpercentile(spring_timings_julian, low_end)
            or ele > np.nanpercentile(spring_timings_julian, high_end) else ele
            for index, ele in enumerate(spring_timings_julian)
        ]
        self.spring_magnitudes = [
            np.nan if ele < np.nanpercentile(self.spring_magnitudes, low_end)
            or ele > np.nanpercentile(self.spring_magnitudes, high_end) else
            ele for index, ele in enumerate(self.spring_magnitudes)
        ]
        self.spring_durations = [
            np.nan if ele < np.nanpercentile(self.spring_durations, low_end)
            or ele > np.nanpercentile(self.spring_durations, high_end) else ele
            for index, ele in enumerate(self.spring_durations)
        ]
        self.spring_rocs = [
            np.nan if ele < np.nanpercentile(self.spring_rocs, low_end)
            or ele > np.nanpercentile(self.spring_rocs, high_end) else ele
            for index, ele in enumerate(self.spring_rocs)
        ]
        summer_timings = [
            np.nan if ele < np.nanpercentile(self.summer_timings, low_end)
            or ele > np.nanpercentile(self.summer_timings, high_end) else ele
            for index, ele in enumerate(self.summer_timings)
        ]
        summer_timings_julian = [
            np.nan if ele < np.nanpercentile(summer_timings_julian, low_end)
            or ele > np.nanpercentile(summer_timings_julian, high_end) else ele
            for index, ele in enumerate(summer_timings_julian)
        ]
        self.summer_90_magnitudes = [
            np.nan
            if ele < np.nanpercentile(self.summer_90_magnitudes, low_end)
            or ele > np.nanpercentile(self.summer_90_magnitudes, high_end) else
            ele for index, ele in enumerate(self.summer_90_magnitudes)
        ]
        self.summer_50_magnitudes = [
            np.nan
            if ele < np.nanpercentile(self.summer_50_magnitudes, low_end)
            or ele > np.nanpercentile(self.summer_50_magnitudes, high_end) else
            ele for index, ele in enumerate(self.summer_50_magnitudes)
        ]
        self.summer_flush_durations = [
            np.nan
            if ele < np.nanpercentile(self.summer_flush_durations, low_end)
            or ele > np.nanpercentile(self.summer_flush_durations, high_end)
            else ele for index, ele in enumerate(self.summer_flush_durations)
        ]
        self.summer_wet_durations = [
            np.nan
            if ele < np.nanpercentile(self.summer_wet_durations, low_end)
            or ele > np.nanpercentile(self.summer_wet_durations, high_end) else
            ele for index, ele in enumerate(self.summer_wet_durations)
        ]
        self.summer_no_flow_counts = [
            np.nan
            if ele < np.nanpercentile(self.summer_no_flow_counts, low_end)
            or ele > np.nanpercentile(self.summer_no_flow_counts, high_end)
            else ele for index, ele in enumerate(self.summer_no_flow_counts)
        ]
        fall_timings = [
            np.nan if ele < np.nanpercentile(self.fall_timings, low_end)
            or ele > np.nanpercentile(self.fall_timings, high_end) else ele
            for index, ele in enumerate(self.fall_timings)
        ]
        fall_timings_julian = [
            np.nan if ele < np.nanpercentile(fall_timings_julian, low_end)
            or ele > np.nanpercentile(fall_timings_julian, high_end) else ele
            for index, ele in enumerate(fall_timings_julian)
        ]
        self.fall_magnitudes = [
            np.nan if ele < np.nanpercentile(self.fall_magnitudes, low_end)
            or ele > np.nanpercentile(self.fall_magnitudes, high_end) else ele
            for index, ele in enumerate(self.fall_magnitudes)
        ]
        fall_wet_timings = [
            np.nan if ele < np.nanpercentile(self.fall_wet_timings, low_end)
            or ele > np.nanpercentile(self.fall_wet_timings, high_end) else ele
            for index, ele in enumerate(self.fall_wet_timings)
        ]
        fall_wet_timings_julian = [
            np.nan if ele < np.nanpercentile(fall_wet_timings_julian, low_end)
            or ele > np.nanpercentile(fall_wet_timings_julian, high_end) else
            ele for index, ele in enumerate(fall_wet_timings_julian)
        ]
        self.fall_durations = [
            np.nan if ele < np.nanpercentile(self.fall_durations, low_end)
            or ele > np.nanpercentile(self.fall_durations, high_end) else ele
            for index, ele in enumerate(self.fall_durations)
        ]
        self.wet_baseflows_10 = [
            np.nan if ele < np.nanpercentile(self.wet_baseflows_10, low_end)
            or ele > np.nanpercentile(self.wet_baseflows_10, high_end) else ele
            for index, ele in enumerate(self.wet_baseflows_10)
        ]
        self.wet_baseflows_50 = [
            np.nan if ele < np.nanpercentile(self.wet_baseflows_50, low_end)
            or ele > np.nanpercentile(self.wet_baseflows_50, high_end) else ele
            for index, ele in enumerate(self.wet_baseflows_50)
        ]
        self.wet_bfl_durs = [
            np.nan if ele < np.nanpercentile(self.wet_bfl_durs, low_end)
            or ele > np.nanpercentile(self.wet_bfl_durs, high_end) else ele
            for index, ele in enumerate(self.wet_bfl_durs)
        ]
        all_exceedances = [2, 5, 10, 20, 50, 12, 15, 110, 120]
        for percent in all_exceedances:
            # self.winter_timings[percent] = [np.nan if ele < np.nanpercentile(self.winter_timings[percent], low_end) or ele > np.nanpercentile(
            #     self.winter_timings[percent], high_end) else ele for index, ele in enumerate(self.winter_timings[percent])]
            self.winter_durations[percent] = [
                np.nan if
                ele < np.nanpercentile(self.winter_durations[percent], low_end)
                or ele > np.nanpercentile(self.winter_durations[percent],
                                          high_end) else ele
                for index, ele in enumerate(self.winter_durations[percent])
            ]
            self.winter_frequencys[percent] = [
                np.nan if ele < np.nanpercentile(
                    self.winter_frequencys[percent], low_end)
                or ele > np.nanpercentile(self.winter_frequencys[percent],
                                          high_end) else ele
                for index, ele in enumerate(self.winter_frequencys[percent])
            ]
            self.winter_magnitudes[percent] = [
                np.nan if ele < np.nanpercentile(
                    self.winter_magnitudes[percent], low_end)
                or ele > np.nanpercentile(self.winter_magnitudes[percent],
                                          high_end) else ele
                for index, ele in enumerate(self.winter_magnitudes[percent])
            ]
        """result to CSV"""
        result_matrix = []
        self.year_ranges = [year + 1 for year in self.year_ranges]
        result_matrix.append(self.year_ranges)
        result_matrix.append(self.average_annual_flows)
        result_matrix.append(self.standard_deviations)
        result_matrix.append(self.coefficient_variations)
        result_matrix.append(spring_timings)
        # result_matrix.append(spring_timings_julian)
        result_matrix.append(self.spring_magnitudes)
        result_matrix.append(self.spring_durations)
        result_matrix.append(self.spring_rocs)
        result_matrix.append(summer_timings)
        # result_matrix.append(summer_timings_julian)
        result_matrix.append(self.summer_90_magnitudes)
        result_matrix.append(self.summer_50_magnitudes)
        # result_matrix.append(self.summer_flush_durations)
        result_matrix.append(self.summer_wet_durations)
        result_matrix.append(self.summer_no_flow_counts)
        result_matrix.append(fall_timings)
        # result_matrix.append(fall_timings_julian)
        result_matrix.append(self.fall_magnitudes)
        result_matrix.append(fall_wet_timings)
        # result_matrix.append(fall_wet_timings_julian)
        result_matrix.append(self.fall_durations)
        result_matrix.append(self.wet_baseflows_10)
        result_matrix.append(self.wet_baseflows_50)
        result_matrix.append(self.wet_bfl_durs)

        # all_exceedances = [2, 5, 10, 20, 50, 12, 15, 110, 120] # only ouput peak flows
        all_exceedances = [2, 5, 10, 20, 50]

        for percent in all_exceedances:
            # result_matrix.append(self.winter_timings[percent])
            result_matrix.append(self.winter_durations[percent])
            result_matrix.append(self.winter_frequencys[percent])
            result_matrix.append(self.winter_magnitudes[percent])

        column_header = [
            'Year', 'Avg', 'Std', 'CV', 'SP_Tim', 'SP_Mag', 'SP_Dur', 'SP_ROC',
            'DS_Tim', 'DS_Mag_90', 'DS_Mag_50', 'DS_Dur_WS', 'DS_No_Flow',
            'FA_Tim', 'FA_Mag', 'Wet_Tim', 'FA_Dur', 'Wet_BFL_Mag_10',
            'Wet_BFL_Mag_50', 'Wet_BFL_Dur', 'Peak_Dur_2', 'Peak_Fre_2',
            'Peak_2', 'Peak_Dur_5', 'Peak_Fre_5', 'Peak_5', 'Peak_Dur_10',
            'Peak_Fre_10', 'Peak_10', 'Peak_Dur_20', 'Peak_Fre_20', 'Peak_20',
            'Peak_Dur_50', 'Peak_Fre_50', 'Peak_50'
        ]

        # OMG not me again....
        # column_header = ['Year', 'Avg', 'Std', 'CV', 'SP_Tim', 'SP_Mag', 'SP_Dur', 'SP_ROC', 'SU_Tim', 'SU_Mag_10', 'SU_Mag_50', 'SU_Dur_Fl', 'SU_Dur_Wet', 'SU_No_Flow', 'FA_Tim', 'FA_Mag', 'FA_Tim_Wet', 'FA_Dur',
        #                  'Wet_BFL_Mag', 'Tim_2', 'Dur_2', 'Fre_2', 'Mag_2', 'Tim_5', 'Dur_5', 'Fre_5', 'Mag_5', 'Tim_10', 'Dur_10', 'Fre_10', 'Mag_10', 'Tim_20', 'Dur_20', 'Fre_20', 'Mag_20', 'Tim_50', 'Dur_50', 'Fre_50', 'Mag_50']

        wateryear_type_matrix = create_wateryear_labels(result_matrix)
        np.savetxt("post_processedFiles/Wateryear_Type/{}.csv".format(
            int(self.gauge_number)),
                   wateryear_type_matrix,
                   delimiter=",",
                   fmt="%s")

        new_result_matrix = []
        for index, _ in enumerate(result_matrix):
            new_result_matrix.append(list(result_matrix[index]))

        if len(new_result_matrix) == len(column_header):
            new_result_matrix = insert_column_header(new_result_matrix,
                                                     column_header)
        else:
            print(
                'Column header does not have the same dimension as result matrix'
            )

        np.savetxt(
            "post_processedFiles/Class-{}/{}_annual_result_matrix.csv".format(
                int(self.class_number), int(self.gauge_number)),
            new_result_matrix,
            delimiter=",",
            fmt="%s")
        '''File format for FFC QA data input'''
예제 #8
0
    def result_to_csv(self):
        column_header = ['Class', 'Gauge #']
        result_matrix = []
        result_matrix.append(self.gauge_class_array)
        result_matrix.append(self.gauge_number_array)

        # only output percentiles 10, 20, 50
        for percent in [50, 20, 10]:
            for percentille in self.percentilles:
                # Exceedance percentiles translated to recurrence intervals for output: exc_50 -> peak_2, exc_20 -> peak_5, exc_10 -> peak_10
                if percent == 50:
                    name = 2
                if percent == 20:
                    name = 5
                if percent == 10:
                    name = 10
                # column_header.append('Peak_Tim_{}_{}'.format(name, percentille))
                column_header.append('Peak_Dur_{}_{}'.format(
                    name, percentille))
                column_header.append('Peak_Fre_{}_{}'.format(
                    name, percentille))
                column_header.append('Peak{}_{}'.format(name, percentille))
                # result_matrix.append(self.timing[percent][percentille])
                result_matrix.append(self.duration[percent][percentille])
                result_matrix.append(self.freq[percent][percentille])
                result_matrix.append(self.mag[percent][percentille])

        result_matrix = sort_matrix(result_matrix, 0)
        result_matrix = insert_column_header(result_matrix, column_header)

        np.savetxt("post_processedFiles/winter_highflow_result_matrix.csv",
                   result_matrix,
                   delimiter=",",
                   fmt="%s")

        if self.plot:
            smart_plot(result_matrix)
        """nonP plots"""
        WIN_Tim_2 = []
        WIN_Dur_2 = []
        WIN_Fre_2 = []
        WIN_Mag_2 = []
        WIN_Tim_5 = []
        WIN_Dur_5 = []
        WIN_Fre_5 = []
        WIN_Mag_5 = []
        WIN_Tim_10 = []
        WIN_Dur_10 = []
        WIN_Fre_10 = []
        WIN_Mag_10 = []
        WIN_Tim_20 = []
        WIN_Dur_20 = []
        WIN_Fre_20 = []
        WIN_Mag_20 = []
        WIN_Tim_50 = []
        WIN_Dur_50 = []
        WIN_Fre_50 = []
        WIN_Mag_50 = []

        for class_id in range(1, 10):
            WIN_Tim_2.append(self.metrics['WIN_Tim_2'][class_id])
            WIN_Dur_2.append(self.metrics['WIN_Dur_2'][class_id])
            WIN_Fre_2.append(self.metrics['WIN_Fre_2'][class_id])
            WIN_Fre_2.append(self.metrics['WIN_Mag_2'][class_id])
            WIN_Tim_5.append(self.metrics['WIN_Tim_5'][class_id])
            WIN_Dur_5.append(self.metrics['WIN_Dur_5'][class_id])
            WIN_Fre_5.append(self.metrics['WIN_Fre_5'][class_id])
            WIN_Fre_5.append(self.metrics['WIN_Mag_5'][class_id])
            WIN_Tim_10.append(self.metrics['WIN_Tim_10'][class_id])
            WIN_Dur_10.append(self.metrics['WIN_Dur_10'][class_id])
            WIN_Fre_10.append(self.metrics['WIN_Fre_10'][class_id])
            WIN_Fre_10.append(self.metrics['WIN_Mag_10'][class_id])
            WIN_Tim_20.append(self.metrics['WIN_Tim_20'][class_id])
            WIN_Dur_20.append(self.metrics['WIN_Dur_20'][class_id])
            WIN_Fre_20.append(self.metrics['WIN_Fre_20'][class_id])
            WIN_Fre_20.append(self.metrics['WIN_Mag_20'][class_id])
            WIN_Tim_50.append(self.metrics['WIN_Tim_50'][class_id])
            WIN_Dur_50.append(self.metrics['WIN_Dur_50'][class_id])
            WIN_Fre_50.append(self.metrics['WIN_Fre_50'][class_id])
            WIN_Fre_50.append(self.metrics['WIN_Mag_50'][class_id])

        combined = {
            'WIN_Tim_2': WIN_Tim_2,
            'WIN_Dur_2': WIN_Dur_2,
            'WIN_Fre_2': WIN_Fre_2,
            'WIN_Mag_2': WIN_Mag_2,
            'WIN_Tim_5': WIN_Tim_5,
            'WIN_Dur_5': WIN_Dur_5,
            'WIN_Fre_5': WIN_Fre_5,
            'WIN_Mag_5': WIN_Mag_5,
            'WIN_Tim_10': WIN_Tim_10,
            'WIN_Dur_10': WIN_Dur_10,
            'WIN_Fre_10': WIN_Fre_10,
            'WIN_Mag_10': WIN_Mag_10,
            'WIN_Tim_20': WIN_Tim_20,
            'WIN_Dur_20': WIN_Dur_20,
            'WIN_Fre_20': WIN_Fre_20,
            'WIN_Mag_20': WIN_Mag_20,
            'WIN_Tim_50': WIN_Tim_50,
            'WIN_Dur_50': WIN_Dur_50,
            'WIN_Fre_50': WIN_Fre_50,
            'WIN_Mag_50': WIN_Mag_50
        }

        if self.plot:
            nonP_box_plot(combined)
예제 #9
0
    def create_result_csv(self):
        self.all_year()
        self.start_of_summer()
        self.fall_flush_timings_durations()
        self.summer_baseflow_durations_magnitude()
        self.winter_highflow_annual()
        self.spring_transition_timing_magnitude()
        self.spring_transition_duration()
        self.spring_transition_roc()
        self.fall_winter_baseflow()
        """Convert offset dates to non-offset dates"""
        spring_timings = []
        summer_timings = []
        fall_timings = []
        fall_wet_timings = []
        for index, year in enumerate(self.year_ranges):
            julian_start_date = datetime.strptime(
                "{}/{}".format(self.start_date, year),
                "%m/%d/%Y").timetuple().tm_yday
            spring_timings.append(
                remove_offset_from_julian_date(self.spring_timings[index],
                                               julian_start_date))
            summer_timings.append(
                remove_offset_from_julian_date(self.summer_timings[index],
                                               julian_start_date))
            fall_timings.append(
                remove_offset_from_julian_date(self.fall_timings[index],
                                               julian_start_date))
            fall_wet_timings.append(
                remove_offset_from_julian_date(self.fall_wet_timings[index],
                                               julian_start_date))

        winter_timings = {}
        for percent in self.exceedance_percent:
            winter_timings[percent] = []
            for index, year in enumerate(self.year_ranges):
                julian_start_date = datetime.strptime(
                    "{}/{}".format(self.start_date, year),
                    "%m/%d/%Y").timetuple().tm_yday
                winter_timings[percent].append(
                    remove_offset_from_julian_date(
                        self.winter_timings[percent][index],
                        julian_start_date))

        low_end = general_params['annual_result_low_Percentille_filter']
        high_end = general_params['annual_result_high_Percentille_filter']
        #sigma = summer_params['sigma']
        """Filter data only to contain from low_end to high_end"""
        self.average_annual_flows = [
            np.nan
            if ele < np.nanpercentile(self.average_annual_flows, low_end)
            or ele > np.nanpercentile(self.average_annual_flows, high_end) else
            ele for index, ele in enumerate(self.average_annual_flows)
        ]
        self.standard_deviations = [
            np.nan if ele < np.nanpercentile(self.standard_deviations, low_end)
            or ele > np.nanpercentile(self.standard_deviations, high_end) else
            ele for index, ele in enumerate(self.standard_deviations)
        ]
        self.coefficient_variations = [
            np.nan
            if ele < np.nanpercentile(self.coefficient_variations, low_end)
            or ele > np.nanpercentile(self.coefficient_variations, high_end)
            else ele for index, ele in enumerate(self.coefficient_variations)
        ]
        spring_timings = [
            np.nan if ele < np.nanpercentile(spring_timings, low_end)
            or ele > np.nanpercentile(spring_timings, high_end) else ele
            for index, ele in enumerate(spring_timings)
        ]
        self.spring_magnitudes = [
            np.nan if ele < np.nanpercentile(self.spring_magnitudes, low_end)
            or ele > np.nanpercentile(self.spring_magnitudes, high_end) else
            ele for index, ele in enumerate(self.spring_magnitudes)
        ]
        self.spring_durations = [
            np.nan if ele < np.nanpercentile(self.spring_durations, low_end)
            or ele > np.nanpercentile(self.spring_durations, high_end) else ele
            for index, ele in enumerate(self.spring_durations)
        ]
        self.spring_rocs = [
            np.nan if ele < np.nanpercentile(self.spring_rocs, low_end)
            or ele > np.nanpercentile(self.spring_rocs, high_end) else ele
            for index, ele in enumerate(self.spring_rocs)
        ]
        summer_timings = [
            np.nan if ele < np.nanpercentile(summer_timings, low_end)
            or ele > np.nanpercentile(summer_timings, high_end) else ele
            for index, ele in enumerate(summer_timings)
        ]
        self.summer_10_magnitudes = [
            np.nan
            if ele < np.nanpercentile(self.summer_10_magnitudes, low_end)
            or ele > np.nanpercentile(self.summer_10_magnitudes, high_end) else
            ele for index, ele in enumerate(self.summer_10_magnitudes)
        ]
        self.summer_50_magnitudes = [
            np.nan
            if ele < np.nanpercentile(self.summer_50_magnitudes, low_end)
            or ele > np.nanpercentile(self.summer_50_magnitudes, high_end) else
            ele for index, ele in enumerate(self.summer_50_magnitudes)
        ]
        self.summer_flush_durations = [
            np.nan
            if ele < np.nanpercentile(self.summer_flush_durations, low_end)
            or ele > np.nanpercentile(self.summer_flush_durations, high_end)
            else ele for index, ele in enumerate(self.summer_flush_durations)
        ]
        self.summer_wet_durations = [
            np.nan
            if ele < np.nanpercentile(self.summer_wet_durations, low_end)
            or ele > np.nanpercentile(self.summer_wet_durations, high_end) else
            ele for index, ele in enumerate(self.summer_wet_durations)
        ]
        self.summer_no_flow_counts = [
            np.nan
            if ele < np.nanpercentile(self.summer_no_flow_counts, low_end)
            or ele > np.nanpercentile(self.summer_no_flow_counts, high_end)
            else ele for index, ele in enumerate(self.summer_no_flow_counts)
        ]
        fall_timings = [
            np.nan if ele < np.nanpercentile(fall_timings, low_end)
            or ele > np.nanpercentile(fall_timings, high_end) else ele
            for index, ele in enumerate(fall_timings)
        ]
        self.fall_magnitudes = [
            np.nan if ele < np.nanpercentile(self.fall_magnitudes, low_end)
            or ele > np.nanpercentile(self.fall_magnitudes, high_end) else ele
            for index, ele in enumerate(self.fall_magnitudes)
        ]
        fall_wet_timings = [
            np.nan if ele < np.nanpercentile(fall_wet_timings, low_end)
            or ele > np.nanpercentile(fall_wet_timings, high_end) else ele
            for index, ele in enumerate(fall_wet_timings)
        ]
        self.fall_durations = [
            np.nan if ele < np.nanpercentile(self.fall_durations, low_end)
            or ele > np.nanpercentile(self.fall_durations, high_end) else ele
            for index, ele in enumerate(self.fall_durations)
        ]
        self.wet_baseflows = [
            np.nan if ele < np.nanpercentile(self.wet_baseflows, low_end)
            or ele > np.nanpercentile(self.wet_baseflows, high_end) else ele
            for index, ele in enumerate(self.wet_baseflows)
        ]
        for percent in self.exceedance_percent:
            winter_timings[percent] = [
                np.nan
                if ele < np.nanpercentile(winter_timings[percent], low_end)
                or ele > np.nanpercentile(winter_timings[percent], high_end)
                else ele for index, ele in enumerate(winter_timings[percent])
            ]
            self.winter_durations[percent] = [
                np.nan if
                ele < np.nanpercentile(self.winter_durations[percent], low_end)
                or ele > np.nanpercentile(self.winter_durations[percent],
                                          high_end) else ele
                for index, ele in enumerate(self.winter_durations[percent])
            ]
            self.winter_frequencys[percent] = [
                np.nan if ele < np.nanpercentile(
                    self.winter_frequencys[percent], low_end)
                or ele > np.nanpercentile(self.winter_frequencys[percent],
                                          high_end) else ele
                for index, ele in enumerate(self.winter_frequencys[percent])
            ]
            self.winter_magnitudes[percent] = [
                np.nan if ele < np.nanpercentile(
                    self.winter_magnitudes[percent], low_end)
                or ele > np.nanpercentile(self.winter_magnitudes[percent],
                                          high_end) else ele
                for index, ele in enumerate(self.winter_magnitudes[percent])
            ]
        """result to CSV"""
        result_matrix = []
        self.year_ranges = [year + 1 for year in self.year_ranges]
        result_matrix.append(self.year_ranges)
        result_matrix.append(self.average_annual_flows)
        result_matrix.append(self.standard_deviations)
        result_matrix.append(self.coefficient_variations)
        result_matrix.append(spring_timings)
        result_matrix.append(self.spring_magnitudes)
        result_matrix.append(self.spring_durations)
        result_matrix.append(self.spring_rocs)
        result_matrix.append(summer_timings)
        result_matrix.append(self.summer_10_magnitudes)
        result_matrix.append(self.summer_50_magnitudes)
        result_matrix.append(self.summer_flush_durations)
        result_matrix.append(self.summer_wet_durations)
        result_matrix.append(self.summer_no_flow_counts)
        result_matrix.append(fall_timings)
        result_matrix.append(self.fall_magnitudes)
        result_matrix.append(fall_wet_timings)
        result_matrix.append(self.fall_durations)
        result_matrix.append(self.wet_baseflows)
        for percent in self.exceedance_percent:
            result_matrix.append(winter_timings[percent])
            result_matrix.append(self.winter_durations[percent])
            result_matrix.append(self.winter_frequencys[percent])
            result_matrix.append(self.winter_magnitudes[percent])

        column_header = [
            'Year', 'Avg', 'Std', 'CV', 'SP_Tim', 'SP_Mag', 'SP_Dur', 'SP_ROC',
            'DS_Tim', 'DS_Mag_10', 'DS_Mag_50', 'DS_Dur_WSI', 'DS_Dur_WS',
            'DS_No_Flow', 'WSI_Tim', 'WSI_Mag', 'Wet_Tim', 'WSI_Dur',
            'Wet_BFL_Mag', 'Peak_Tim_2', 'Peak_Dur_2', 'Peak_Fre_2',
            'Peak_Mag_2', 'Peak_Tim_5', 'Peak_Dur_5', 'Peak_Fre_5',
            'Peak_Mag_5', 'Peak_Tim_10', 'Peak_Dur_10', 'Peak_Fre_10',
            'Peak_Mag_10', 'Peak_Tim_20', 'Peak_Dur_20', 'Peak_Fre_20',
            'Peak_Mag_20', 'Peak_Tim_50', 'Peak_Dur_50', 'Peak_Fre_50',
            'Peak_Mag_50'
        ]

        # OMG not me again....
        # column_header = ['Year', 'Avg', 'Std', 'CV', 'SP_Tim', 'SP_Mag', 'SP_Dur', 'SP_ROC', 'SU_Tim', 'SU_Mag_10', 'SU_Mag_50', 'SU_Dur_Fl', 'SU_Dur_Wet', 'SU_No_Flow', 'FA_Tim', 'FA_Mag', 'FA_Tim_Wet', 'FA_Dur',
        #                  'Wet_BFL_Mag', 'Tim_2', 'Dur_2', 'Fre_2', 'Mag_2', 'Tim_5', 'Dur_5', 'Fre_5', 'Mag_5', 'Tim_10', 'Dur_10', 'Fre_10', 'Mag_10', 'Tim_20', 'Dur_20', 'Fre_20', 'Mag_20', 'Tim_50', 'Dur_50', 'Fre_50', 'Mag_50']

        wateryear_type_matrix = create_wateryear_labels(result_matrix)
        np.savetxt("post_processedFiles/Wateryear_Type/{}.csv".format(
            int(self.gauge_number)),
                   wateryear_type_matrix,
                   delimiter=",",
                   fmt="%s")

        new_result_matrix = []
        for index, _ in enumerate(result_matrix):
            new_result_matrix.append(list(result_matrix[index]))

        if len(new_result_matrix) == len(column_header):
            new_result_matrix = insert_column_header(new_result_matrix,
                                                     column_header)
        else:
            print(
                'Column header does not have the same dimension as result matrix'
            )
        # remove 50 percentile values from final matrix. Will need to update this code if variables are added or deleted.
        if len(new_result_matrix) > 35:
            new_result_matrix = new_result_matrix[:-4]

        np.savetxt(
            "post_processedFiles/{}_sigma{}_annual_result_matrix.csv".format(
                int(self.gauge_number), int(sigmaa)),
            new_result_matrix,
            delimiter=",",
            fmt="%s")
        #1/29/2019 adding sigma to the name in the two lines above
        '''File format for FFC QA data input'''
예제 #10
0
    def result_to_csv(self):
        column_header = ['Class', 'Gauge #']
        result_matrix = []
        result_matrix.append(self.gauge_class_array)
        result_matrix.append(self.gauge_number_array)

        for percent in self.exceedance_percent:
            for percentille in self.percentilles:
                column_header.append('WIN_Tim_{}_{}'.format(
                    percent, percentille))
                column_header.append('WIN_Dur_{}_{}'.format(
                    percent, percentille))
                column_header.append('WIN_Fre_{}_{}'.format(
                    percent, percentille))
                column_header.append('WIN_Mag_{}_{}'.format(
                    percent, percentille))

                result_matrix.append(self.timing[percent][percentille])
                result_matrix.append(self.duration[percent][percentille])
                result_matrix.append(self.freq[percent][percentille])
                result_matrix.append(self.mag[percent][percentille])

        result_matrix = sort_matrix(result_matrix, 0)
        result_matrix = insert_column_header(result_matrix, column_header)

        np.savetxt("post_processedFiles/winter_highflow_result_matrix.csv",
                   result_matrix,
                   delimiter=",",
                   fmt="%s")

        if self.plot:
            smart_plot(result_matrix)
        """nonP plots"""
        WIN_Tim_2 = []
        WIN_Dur_2 = []
        WIN_Fre_2 = []
        WIN_Mag_2 = []
        WIN_Tim_5 = []
        WIN_Dur_5 = []
        WIN_Fre_5 = []
        WIN_Mag_5 = []
        WIN_Tim_10 = []
        WIN_Dur_10 = []
        WIN_Fre_10 = []
        WIN_Mag_10 = []
        WIN_Tim_20 = []
        WIN_Dur_20 = []
        WIN_Fre_20 = []
        WIN_Mag_20 = []
        WIN_Tim_50 = []
        WIN_Dur_50 = []
        WIN_Fre_50 = []
        WIN_Mag_50 = []

        for class_id in range(1, 10):
            WIN_Tim_2.append(self.metrics['WIN_Tim_2'][class_id])
            WIN_Dur_2.append(self.metrics['WIN_Dur_2'][class_id])
            WIN_Fre_2.append(self.metrics['WIN_Fre_2'][class_id])
            WIN_Fre_2.append(self.metrics['WIN_Mag_2'][class_id])
            WIN_Tim_5.append(self.metrics['WIN_Tim_5'][class_id])
            WIN_Dur_5.append(self.metrics['WIN_Dur_5'][class_id])
            WIN_Fre_5.append(self.metrics['WIN_Fre_5'][class_id])
            WIN_Fre_5.append(self.metrics['WIN_Mag_5'][class_id])
            WIN_Tim_10.append(self.metrics['WIN_Tim_10'][class_id])
            WIN_Dur_10.append(self.metrics['WIN_Dur_10'][class_id])
            WIN_Fre_10.append(self.metrics['WIN_Fre_10'][class_id])
            WIN_Fre_10.append(self.metrics['WIN_Mag_10'][class_id])
            WIN_Tim_20.append(self.metrics['WIN_Tim_20'][class_id])
            WIN_Dur_20.append(self.metrics['WIN_Dur_20'][class_id])
            WIN_Fre_20.append(self.metrics['WIN_Fre_20'][class_id])
            WIN_Fre_20.append(self.metrics['WIN_Mag_20'][class_id])
            WIN_Tim_50.append(self.metrics['WIN_Tim_50'][class_id])
            WIN_Dur_50.append(self.metrics['WIN_Dur_50'][class_id])
            WIN_Fre_50.append(self.metrics['WIN_Fre_50'][class_id])
            WIN_Fre_50.append(self.metrics['WIN_Mag_50'][class_id])

        combined = {
            'WIN_Tim_2': WIN_Tim_2,
            'WIN_Dur_2': WIN_Dur_2,
            'WIN_Fre_2': WIN_Fre_2,
            'WIN_Mag_2': WIN_Mag_2,
            'WIN_Tim_5': WIN_Tim_5,
            'WIN_Dur_5': WIN_Dur_5,
            'WIN_Fre_5': WIN_Fre_5,
            'WIN_Mag_5': WIN_Mag_5,
            'WIN_Tim_10': WIN_Tim_10,
            'WIN_Dur_10': WIN_Dur_10,
            'WIN_Fre_10': WIN_Fre_10,
            'WIN_Mag_10': WIN_Mag_10,
            'WIN_Tim_20': WIN_Tim_20,
            'WIN_Dur_20': WIN_Dur_20,
            'WIN_Fre_20': WIN_Fre_20,
            'WIN_Mag_20': WIN_Mag_20,
            'WIN_Tim_50': WIN_Tim_50,
            'WIN_Dur_50': WIN_Dur_50,
            'WIN_Fre_50': WIN_Fre_50,
            'WIN_Mag_50': WIN_Mag_50
        }

        if self.plot:
            nonP_box_plot(combined)