コード例 #1
0
 def test_snowmelt_wo_temperature(self):
     """Test snowmelt -- without temperature"""
     # -- I do no think daily temperature has to be provided for this
     # --Once temperature is defined this passes
     test_text = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     SNOWMELT 2 0.5 0.6 0.0 50 0
     """
     my_options = TemperatureReader.read(test_text)
     actual_text = TemperatureWriter.as_text(my_options)
     msg = '\nSet:' + test_text + '\nGet:' + actual_text
     self.assertTrue(match(actual_text, test_text), msg)
コード例 #2
0
 def test_file_wt_date(self):
     """Test daily temperature in tepmerature.txt(file name with space) and start date"""
     # Will failed if SNOW_MELT not given
     test_text = "[TEMPERATURE]\n" \
                 " ;;Parameter  Fname (Start)\n" \
                 " FILE daily temperature 1-1-1999.txt 2/2/2012\n"\
                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     my_options = TemperatureReader.read(test_text)
     actual_text = TemperatureWriter.as_text(my_options)
     msg = '\nSet:' + test_text + '\nGet:' + actual_text
     self.assertTrue(match(actual_text, test_text), msg)
コード例 #3
0
 def test_snowmelt_wo_adc(self):
     """Test snowmelt -- Remove both ADCs"""
     test_text = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES daily_temperature.txt
     WINDSPEED FILE
     SNOWMELT 2 0.5 0.6 0.0 50 0
     """
     my_options = TemperatureReader.read(test_text)
     actual_text = TemperatureWriter.as_text(my_options)
     msg = '\nSet:' + test_text + '\nGet:' + actual_text
     self.assertTrue(match(actual_text, test_text), msg)
コード例 #4
0
 def test_timeseries(self):
     """Test daily temperature in time series
      Must have SNOW_MELT, otherwise will fail
      because SNOW_MELT default values are written """
     test_time_series = "[TEMPERATURE]\n" \
                        " ;;Parameter  TSeries\n" \
                        " TIMESERIES TS1\n" \
                        " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                        " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                        " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     my_options = TemperatureReader.read(test_time_series)
     actual_text = TemperatureWriter.as_text(my_options)
     msg = '\nSet:' + test_time_series + '\nGet:' + actual_text
     self.assertTrue(match(actual_text, test_time_series), msg)
コード例 #5
0
 def test_windspeed_file_wt_temperature(self):
     """Test windspeed file wt temperature"""
     # --Will fail if snow_melt not provided, same issue as above
     # --Will fail if temperature not defined
     test_text = "[TEMPERATURE]\n" \
                 ";;Parameter  Monthly Adjustments\n" \
                 "FILE daily_tmperature.txt\n" \
                 "WINDSPEED FILE\n"\
                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     my_options = TemperatureReader.read(test_text)
     actual_text = TemperatureWriter.as_text(my_options)
     msg = '\nSet:' + test_text + '\nGet:' + actual_text
     self.assertTrue(match(actual_text, test_text), msg)
コード例 #6
0
 def test_snowmelt(self):
     """Test snowmelt"""
     # --Once temperature is defined this passes
     test_text = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES daily_temperature.txt
     WINDSPEED FILE
     SNOWMELT 2 0.5 0.6 0.0 50 0
     ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
     ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
     """
     my_options = TemperatureReader.read(test_text)
     actual_text = TemperatureWriter.as_text(my_options)
     msg = '\nSet:' + test_text + '\nGet:' + actual_text
     self.assertTrue(match(actual_text, test_text), msg)
コード例 #7
0
 def test_windspeed_monthly(self):
     """Test WindSpeed monthly"""
     # --Will fail if snow_melt not provided, same issue as above
     # --Will fail because get_text created empty string if only WINDSPEED
     # Note: WINDSPEED must be provided along with temperature for evaporation calculation
     test_text = "[TEMPERATURE]\n" \
                 " ;;Parameter  Monthly Adjustments\n" \
                 " FILE daily temperature 1-1-1999.txt 2/2/2012\n" \
                 " WINDSPEED MONTHLY   1.0    1.0    3.0    2.0    2.0" \
                 "    2.0    2.0    2.0    2.0    2.0    1.0    0.0\n"\
                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     my_options = TemperatureReader.read(test_text)
     actual_text = TemperatureWriter.as_text(my_options)
     msg = '\nSet:' + test_text + '\nGet:' + actual_text
     self.assertTrue(match(actual_text, test_text), msg)
コード例 #8
0
 def test_file(self):
     """Test daily temperature in file daily_temperature.txt"""
     # Will failed if SNOW_MELT not given
     test_text = "[TEMPERATURE]\n" \
                 " ;;Parameter  Fname (Start)\n" \
                 " FILE daily_tmperature.txt\n" \
                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     my_options = TemperatureReader.read(test_text)
     actual_text = TemperatureWriter.as_text(my_options)
     msg = '\nSet:' + test_text + '\nGet:' + actual_text
     keywords_ = [
         "[TEMPERATURE]", "FILE", "SNOWMELT", "ADC IMPERVIOUS",
         "ADC PERVIOUS"
     ]
     self.assertTrue(match_keyword_lines(actual_text, test_text, keywords_),
                     msg)
コード例 #9
0
 def test_windspeed_file_fail(self):
     """Test windspeed file - 2"""
     # -- This should report fail because Windspeed file should be the same climate file used for air temperature
     # -- in this case the air temperature is not provided as file
     # --Once temperature is defined this passes
     test_text = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES TS1
     WINDSPEED FILE
     """
     try:
         my_options = TemperatureReader.read(test_text)
         actual_text = TemperatureWriter.as_text(my_options)
         msg = '\nSet:' + test_text + '\nGet:' + actual_text
         msg = "\nRule not enforced: Windspeed file should be the same climate file used for air temperature"
         find_error = False
     except Exception as e:
         msg = "\nSet:" + test_text + '\nGet:' + str(e)
         find_error = True
     self.assertTrue(find_error, msg)
コード例 #10
0
 def test_snowmelt_fail(self):
     """Test snowmelt wo one ADC PERVIOUS, assert failed
       Should both be specified. It should allow two or none"""
     test_text = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES daily_temperature.txt
     WINDSPEED FILE
     SNOWMELT 2 0.5 0.6 0.0 50 0
     ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
     """
     try:
         my_options = TemperatureReader.read(test_text)
         actual_text = TemperatureWriter.as_text(my_options)
         msg = '\nSet:' + test_text + '\nGet:' + actual_text
         msg = "\nRule not enforced: Snowmelt should allow two or no ADC PERVIOUS, allowed one."
         find_error = False
     except Exception as e:
         msg = "\nSet:" + test_text + '\nGet:' + str(e)
         find_error = True
     self.assertTrue(find_error, msg)