diff --git a/docs/user_guide/auto_config.rst b/docs/user_guide/auto_config.rst index f11137eb..5770d72f 100644 --- a/docs/user_guide/auto_config.rst +++ b/docs/user_guide/auto_config.rst @@ -54,9 +54,9 @@ time | | **time_zone** -| Time zone for all times provided and how the model will be run see pytz docs for information on what is accepted +| Case sensitive time zone for all times provided and how the model will be run. See pytz docs for information on what is accepted. Full list can be found en.wikipedia.org/wiki/List_of_tz_database_time_zones | *Default: UTC* -| *Type: string* +| *Type: rawstring* | diff --git a/smrf/framework/CoreConfig.ini b/smrf/framework/CoreConfig.ini index 414339ed..4c3097fb 100755 --- a/smrf/framework/CoreConfig.ini +++ b/smrf/framework/CoreConfig.ini @@ -63,7 +63,10 @@ description = Date and time to end the data distribution that can be parsed by p time_zone: default = UTC, -description = Time zone for all times provided and how the model will be run see pytz docs for information on what is accepted +type = RawString, +description = Case sensitive time zone for all times provided and how the model will be run. See + pytz docs for information on what is accepted. Full list can be found + en.wikipedia.org/wiki/List_of_tz_database_time_zones ################################################################################ # CSV section configurations diff --git a/smrf/utils/utils.py b/smrf/utils/utils.py index de5bc5d1..097eadbc 100755 --- a/smrf/utils/utils.py +++ b/smrf/utils/utils.py @@ -1,10 +1,3 @@ - -""" -20160104 Scott Havens - -Collection of utility functions -""" - import copy import os import random @@ -26,6 +19,7 @@ from .gitinfo import __gitVersion__ + class CheckStation(CheckType): """ Custom check for ensuring our stations are always capitalized @@ -39,8 +33,7 @@ def type_func(self, value): Attempt to convert all the values to upper case. Args: - value: A single string in a a config entry representing a - station name + value: A single string in config entry representing a station name Returns: value: A single station name all upper case """ @@ -48,6 +41,26 @@ def type_func(self, value): return value.upper() +class CheckRawString(CheckType): + """ + Custom `inicheck` checker that will not change the input string + """ + + def __init__(self, **kwargs): + super(CheckRawString, self).__init__(**kwargs) + + def type_func(self, value): + """ + Do not change the passed value at all + Args: + value: A single string + Returns: + value: A single string unchanged + """ + + return value + + def find_configs(directory): """ Searches through a directory and returns all the .ini fulll filenames. @@ -282,7 +295,8 @@ def getConfigHeader(): cfg_str = ("Config File for SMRF {0}\n" "For more SMRF related help see:\n" "{1}").format( - getgitinfo(), 'http://smrf.readthedocs.io/en/latest/') + getgitinfo(), + 'http://smrf.readthedocs.io/en/latest/') return cfg_str diff --git a/tests/Lakes/config.ini b/tests/Lakes/config.ini index 05396e21..47cfddf2 100644 --- a/tests/Lakes/config.ini +++ b/tests/Lakes/config.ini @@ -27,7 +27,7 @@ filename: ./topo/topo.nc time_step: 60 start_date: 2019-10-01 15:00 end_date: 2019-10-01 17:00 -time_zone: UTC +time_zone: utc ################################################################################ diff --git a/tests/RME/config.ini b/tests/RME/config.ini index deb9ab28..8514ad0e 100644 --- a/tests/RME/config.ini +++ b/tests/RME/config.ini @@ -27,7 +27,7 @@ filename: ./topo/topo.nc time_step: 60 start_date: 1998-01-14 15:00:00 end_date: 1998-01-14 19:00:00 -time_zone: UTC +time_zone: utc ################################################################################ diff --git a/tests/test_data_gridded.py b/tests/test_data_gridded.py index 0951a829..b5af6cec 100644 --- a/tests/test_data_gridded.py +++ b/tests/test_data_gridded.py @@ -95,7 +95,8 @@ def test_grid_hrrr_local(self): }, 'time': { 'start_date': '2018-07-22 16:00', - 'end_date': '2018-07-22 20:00' + 'end_date': '2018-07-22 20:00', + 'time_zone': 'utc' }, 'system': { 'threading': False, diff --git a/tests/test_model_framework.py b/tests/test_model_framework.py index a6fa5d5a..f0b16662 100644 --- a/tests/test_model_framework.py +++ b/tests/test_model_framework.py @@ -53,15 +53,21 @@ class TestModelFrameworkMST(SMRFTestCase): """ Test timezone handling for MST. """ - TIMEZONE = pytz.timezone('US/Mountain') + TIMEZONE = pytz.timezone('MST') @classmethod def setUpClass(cls): super().setUpClass() base_config = copy.deepcopy(cls.base_config) - base_config.cfg['time']['time_zone'] = str(cls.TIMEZONE) + base_config.cfg['time']['time_zone'] = 'MST' cls.smrf = SMRF(base_config) + def test_timezone_error(self): + base_config = copy.deepcopy(self.base_config) + base_config.cfg['time']['time_zone'] = 'mst' + with self.assertRaises(Exception): + SMRF(base_config) + def test_start_date(self): self.assertEqual( self.smrf.start_date,