def load_new(self, fname=None):
     """
     Read power curve from file, either default or user-provided.
     Store power curve as dict in self.power_curve
     """
     if fname is None:
         from windrevenue.UI import UI
         fname = UI.get_user_input("Please provide a power curve file:\n")
     print("Reading power curve file: ", fname)
     try:
         self.power_curve = pd.read_table(fname, sep="\t")
     except FileNotFoundError:
         print("File not found, no data loaded.")
         return
Example #2
0
 def parse_met_file(self, fname=None):
     """
     Read met data file, store in data frame and store sensor choice
     """
     if fname is None:
         from windrevenue.UI import UI
         prompt_string = "Please specify the met time series file:\n"
         fname = UI.get_user_input(prompt_string)
     try:
         self.load_new(fname)
     except FileNotFoundError:
         print("File not found, no data loaded.")
         return
     except TypeError:  # TODO
         print(self, fname)
         raise
     self.sensorInfo = self.parse_sensor_information(self.metdf)
     self.windVar = self.locate_highest_anemometer(self.sensorInfo)
    def load_new(self, fname=None):
        """
        Read pricing time series data from file, provided or default.
        Store all pricing data as data frame, and select first
        substation as the powerVar.
        """
        if fname is None:
            from windrevenue.UI import UI
            fname = UI.get_user_input("Please specify pricing file:\n")

        print("Reading electicity pricing file: ", fname)
        try:
            powerdf = pd.read_table(fname,
                                    skiprows=0,
                                    index_col=0,
                                    parse_dates=True,
                                    infer_datetime_format=True)
        except FileNotFoundError:
            print("File not found, no data loaded.")
            return
        powerdf.index.name = 'DateTime'
        colnames = list(powerdf)
        self.powerdf = powerdf
        self.powerVar = colnames[0]
Example #4
0
 def test_invalid_select_action(self, mocked_input):
     argdict = {"1": self.hi, "2": self.bye}
     output = UI().select_action(argdict, "3")
     assert output is False
Example #5
0
 def test_select_action(self, mocked_input):
     argdict = {"1": self.hi, "2": self.bye}
     output = UI().select_action(argdict, "1")
     assert output == "hi"
Example #6
0
 def test_return_to_menu(self, mocked_input):
     assert UI().return_to_menu() is True
Example #7
0
 def test_get_user_input(self, mocked_input):
     UI().get_user_input("Some prompt")
     mocked_input.assert_called_once_with("Some prompt")