示例#1
0
    def test_rapid_to_gssha_date_range(self):
        """
        Test RAPID to GSSHA functionality with date filters
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(gssha_executable="",
                               gssha_directory=self.gssha_project_directory,
                               project_filename=self.gssha_project_file,
                               path_to_rapid_qout=self.path_to_rapid_qout,
                               connection_list_file=self.connection_list_file,
                               gssha_simulation_start=datetime(2002,8,30),
                               gssha_simulation_end=datetime(2002,8,30,23,59),
                               read_hotstart=True,  # SHOULD NOT CHANGE ANYTHING
                               )

        gr.run_forecast()

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(self.readDirectory, 'framework',
                                        'grid_standard_rapid_200208300000to200208302359_{0}.prj'.format(self.os_name))
        self._compare_files(self._generated_file_path('run_200208300000to200208302359'), compare_prj_file)
        # grid_standard.ihg
        compare_igh_file = os.path.join(self.readDirectory, "framework",
                                        "grid_standard_rapid_200208300000to200208302359.ihg")
        assert compare_csv_timeseries_files(self._generated_file_path('run_200208300000to200208302359', extension='ihg'),
                                            compare_igh_file, header=False)
        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard.cmt"),
                            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory exists
        assert os.path.exists(self._generated_file_path('run_200208300000to200208302359', extension="cmt"))
示例#2
0
    def test_rapid_to_gssha_read_hotstart(self):
        """
        Test RAPID to GSSHA functionality read hotstart
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(gssha_executable='',
                               gssha_directory=self.gssha_project_directory,
                               project_filename=self.gssha_project_file,
                               path_to_rapid_qout=self.path_to_rapid_qout,
                               connection_list_file=self.connection_list_file,
                               read_hotstart=True,
                               )
        gr.run_forecast()

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(self.readDirectory, 'framework',
                                        'grid_standard_rapid_read_hotstart_200208291800to200208311800_{0}.prj'.format(self.os_name))
        self._compare_files(self._generated_file_path('run_200208291800to200208311800'), compare_prj_file)
        # grid_standard.ihg
        compare_igh_file = os.path.join(self.readDirectory, "framework",
                                        "grid_standard_rapid_200208291800to200208311800.ihg")
        assert compare_csv_timeseries_files(self._generated_file_path('run_200208291800to200208311800', extension='ihg'),
                                            compare_igh_file, header=False)

        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard.cmt"),
                            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory exists
        assert os.path.exists(self._generated_file_path('run_200208291800to200208311800', extension="cmt"))
示例#3
0
    def test_rapid_to_gssha_date_range(self):
        """
        Test RAPID to GSSHA functionality with date filters
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(gssha_executable="",
                               gssha_directory=self.gssha_project_directory,
                               project_filename=self.gssha_project_file,
                               path_to_rapid_qout=self.path_to_rapid_qout,
                               connection_list_file=self.connection_list_file,
                               gssha_simulation_start=datetime(2002,8,30),
                               gssha_simulation_end=datetime(2002,8,30,23,59),
                               read_hotstart=True,  # SHOULD NOT CHANGE ANYTHING
                               )

        with pytest.raises(ValueError):
            gr.run_forecast()

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(self.readDirectory, 'framework',
                                        'grid_standard_rapid_200208300000to200208302359_{0}.prj'.format(self.os_name))
        self._compare_files(self._generated_file_path('run_200208300000to200208302359'), compare_prj_file)
        # grid_standard.ihg
        compare_igh_file = os.path.join(self.readDirectory, "framework",
                                        "grid_standard_rapid_200208300000to200208302359.ihg")
        assert compare_csv_timeseries_files(self._generated_file_path('run_200208300000to200208302359', extension='ihg'),
                                            compare_igh_file, header=False)
        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard.cmt"),
                            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory correct
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard_compare_run_{0}.cmt".format(self.os_name)),
                            self._generated_file_path('run_200208300000to200208302359', extension="cmt"))
示例#4
0
    def test_rapid_to_gssha_read_hotstart(self):
        """
        Test RAPID to GSSHA functionality read hotstart
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(gssha_executable='',
                               gssha_directory=self.gssha_project_directory,
                               project_filename=self.gssha_project_file,
                               path_to_rapid_qout=self.path_to_rapid_qout,
                               connection_list_file=self.connection_list_file,
                               read_hotstart=True,
                               )
        with pytest.raises(ValueError):
            gr.run_forecast()

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(self.readDirectory, 'framework',
                                        'grid_standard_rapid_read_hotstart_200208291800to200208311800_{0}.prj'.format(self.os_name))
        self._compare_files(self._generated_file_path('run_200208291800to200208311800'), compare_prj_file)
        # grid_standard.ihg
        compare_igh_file = os.path.join(self.readDirectory, "framework",
                                        "grid_standard_rapid_200208291800to200208311800.ihg")
        assert compare_csv_timeseries_files(self._generated_file_path('run_200208291800to200208311800', extension='ihg'),
                                            compare_igh_file, header=False)

        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard.cmt"),
                            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory correct
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard_compare_run_{0}.cmt".format(self.os_name)),
                            self._generated_file_path('run_200208291800to200208311800', extension="cmt"))
示例#5
0
    def test_wrf_to_gssha_min_hotstart(self):
        """
        Test WRF to GSSHA functionality with minmal mode hotstart generation
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(gssha_executable='',
                               gssha_directory=self.gssha_project_directory,
                               project_filename=self.gssha_project_file,
                               lsm_folder=self.lsm_folder,
                               gssha_simulation_duration=timedelta(seconds=6*3600),
                               read_hotstart=True,
                               write_hotstart=True,
                               hotstart_minimal_mode=True,
                               )

        with pytest.raises(ValueError):
            gr.run_forecast()

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(self.readDirectory, 'framework',
                                        'grid_standard_wrf_minimal_hotstart_201608231600to201608232200_{0}.prj'.format(self.os_name))
        self._compare_files(self._generated_file_path('minimal_hotstart_run_201608231600to201608232200'), compare_prj_file)

        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard.cmt"),
                            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory correct
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard_compare_run_{0}.cmt".format(self.os_name)),
                            self._generated_file_path('minimal_hotstart_run_201608231600to201608232200', extension="cmt"))

        # grid_standard.gag
        self._compare_files(os.path.join(self.readDirectory, "framework", "grid_standard_wrf_201608231600to201608232200.gag"),
                            self._generated_file_path('minimal_hotstart_run_201608231600to201608232200', extension="gag"),
                            precision=5)

        # compare yml files
        self._compare_files(os.path.join(self.readDirectory, 'framework', 'gssha_event_wrf_minimal_hotstart_201608231600to201608232200.yml'),
                            os.path.join(self.gssha_project_directory, 'gsshapy_event.yml'))

        # compare HMET files
        compare_directory = os.path.join(self.readDirectory,
                                         "framework",
                                         "wrf_hmet_data_201608231600to201608240700")
        output_directory = os.path.join(self.gssha_project_directory,
                                        "hmet_data_201608231600to201608232200_hotstart")

        self._compare_directories(compare_directory,
                                  output_directory,
                                  ignore_file="hmet_file_list.txt",
                                  raster=True,
                                  precision=4)
示例#6
0
    def test_wrf_to_gssha_min_hotstart(self):
        """
        Test WRF to GSSHA functionality with minmal mode hotstart generation
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(gssha_executable='',
                               gssha_directory=self.gssha_project_directory,
                               project_filename=self.gssha_project_file,
                               lsm_folder=self.lsm_folder,
                               gssha_simulation_duration=timedelta(seconds=6*3600),
                               read_hotstart=True,
                               write_hotstart=True,
                               hotstart_minimal_mode=True,
                               )

        gr.run_forecast()

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(self.readDirectory, 'framework',
                                        'grid_standard_wrf_minimal_hotstart_201608231600to201608232200_{0}.prj'.format(self.os_name))
        self._compare_files(self._generated_file_path('minimal_hotstart_run_201608231600to201608232200'), compare_prj_file)

        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard.cmt"),
                            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory exists
        assert os.path.exists(self._generated_file_path('minimal_hotstart_run_201608231600to201608232200', extension="cmt"))
        # 3 TODO: Check to make sure generated correctly

        # grid_standard.gag
        self._compare_files(os.path.join(self.readDirectory, "framework", "grid_standard_wrf_201608231600to201608232200.gag"),
                            self._generated_file_path('minimal_hotstart_run_201608231600to201608232200', extension="gag"),
                            precision=5)

        # compare yml files
        self._compare_files(os.path.join(self.readDirectory, 'framework', 'gssha_event_wrf_minimal_hotstart_201608231600to201608232200.yml'),
                            os.path.join(self.gssha_project_directory, 'gsshapy_event.yml'))

        # compare HMET files
        compare_directory = os.path.join(self.readDirectory,
                                         "framework",
                                         "wrf_hmet_data_201608231600to201608240700")
        output_directory = os.path.join(self.gssha_project_directory,
                                        "hmet_data_201608231600to201608232200_hotstart")

        self._compare_directories(compare_directory,
                                  output_directory,
                                  ignore_file="hmet_file_list.txt",
                                  raster=True)
示例#7
0
    def test_rapid_to_gssha(self):
        """
        Test RAPID to GSSHA functionality
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(gssha_executable='',
                               gssha_directory=self.gssha_project_directory,
                               project_filename=self.gssha_project_file,
                               path_to_rapid_qout=self.path_to_rapid_qout,
                               connection_list_file=self.connection_list_file)
        with pytest.raises(ValueError):
            gr.run_forecast()

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(
            self.readDirectory, 'framework',
            'grid_standard_rapid_200208291800to200208311800_{0}.prj'.format(
                self.os_name))
        self._compare_files(
            self._generated_file_path('run_200208291800to200208311800'),
            compare_prj_file)
        # grid_standard.ihg
        compare_igh_file = os.path.join(
            self.readDirectory, "framework",
            "grid_standard_rapid_200208291800to200208311800.ihg")
        assert compare_csv_timeseries_files(self._generated_file_path(
            'run_200208291800to200208311800', extension='ihg'),
                                            compare_igh_file,
                                            header=False)

        # compare yml files
        self._compare_files(
            os.path.join(self.readDirectory, 'framework',
                         'gssha_event_rapid_200208291800to200208311800.yml'),
            os.path.join(self.gssha_project_directory, 'gsshapy_event.yml'))

        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(
            os.path.join(self.readDirectory, "gssha_project",
                         "grid_standard.cmt"),
            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory correct
        self._compare_files(
            os.path.join(
                self.readDirectory, "gssha_project",
                "grid_standard_compare_run_{0}.cmt".format(self.os_name)),
            self._generated_file_path('run_200208291800to200208311800',
                                      extension="cmt"))
示例#8
0
    def test_rapid_to_gssha_min_hotstart(self):
        """
        Test RAPID to GSSHA functionality with minmal mode hotstart generation
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(gssha_executable="",
                               gssha_directory=self.gssha_project_directory,
                               project_filename=self.gssha_project_file,
                               path_to_rapid_qout=self.path_to_rapid_qout,
                               connection_list_file=self.connection_list_file,
                               gssha_simulation_duration=timedelta(seconds=6*3600),
                               write_hotstart=True,
                               hotstart_minimal_mode=True,
                               )
        with pytest.raises(ValueError):
            gr.run_forecast()

        # check folder exists
        assert os.path.exists(os.path.join(self.gssha_project_directory, "hotstart"))

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(self.readDirectory, 'framework',
                                        'grid_standard_rapid_minimal_hotstart_200208291800to200208300000_{0}.prj'.format(self.os_name))
        self._compare_files(self._generated_file_path('minimal_hotstart_run_200208291800to200208300000'), compare_prj_file)
        # grid_standard.ihg
        compare_igh_file = os.path.join(self.readDirectory, "framework",
                                        "grid_standard_rapid_hotstart_200208291800to2002083000.ihg")
        assert compare_csv_timeseries_files(self._generated_file_path('minimal_hotstart_run_200208291800to200208300000', extension='ihg'),
                                            compare_igh_file, header=False)

        # compare yml files
        self._compare_files(os.path.join(self.readDirectory, 'framework', 'gssha_event_rapid_hotstart_200208291800to200208300000.yml'),
                            os.path.join(self.gssha_project_directory, 'gsshapy_event.yml'))
        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard.cmt"),
                            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory correct
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard_compare_run_{0}.cmt".format(self.os_name)),
                            self._generated_file_path('minimal_hotstart_run_200208291800to200208300000', extension="cmt"))
示例#9
0
    def test_rapid_to_gssha_min_hotstart(self):
        """
        Test RAPID to GSSHA functionality with minmal mode hotstart generation
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(gssha_executable="",
                               gssha_directory=self.gssha_project_directory,
                               project_filename=self.gssha_project_file,
                               path_to_rapid_qout=self.path_to_rapid_qout,
                               connection_list_file=self.connection_list_file,
                               gssha_simulation_duration=timedelta(seconds=6*3600),
                               write_hotstart=True,
                               hotstart_minimal_mode=True,
                               )
        gr.run_forecast()

        # check folder exists
        assert os.path.exists(os.path.join(self.gssha_project_directory, "hotstart"))

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(self.readDirectory, 'framework',
                                        'grid_standard_rapid_minimal_hotstart_200208291800to200208300000_{0}.prj'.format(self.os_name))
        self._compare_files(self._generated_file_path('minimal_hotstart_run_200208291800to200208300000'), compare_prj_file)
        # grid_standard.ihg
        compare_igh_file = os.path.join(self.readDirectory, "framework",
                                        "grid_standard_rapid_hotstart_200208291800to2002083000.ihg")
        assert compare_csv_timeseries_files(self._generated_file_path('minimal_hotstart_run_200208291800to200208300000', extension='ihg'),
                                            compare_igh_file, header=False)

        # compare yml files
        self._compare_files(os.path.join(self.readDirectory, 'framework', 'gssha_event_rapid_hotstart_200208291800to200208300000.yml'),
                            os.path.join(self.gssha_project_directory, 'gsshapy_event.yml'))
        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(os.path.join(self.readDirectory, "gssha_project", "grid_standard.cmt"),
                            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory exists
        assert os.path.exists(self._generated_file_path('minimal_hotstart_run_200208291800to200208300000', extension="cmt"))
示例#10
0
    def test_wrf_to_gssha_date_range(self):
        """
        Test WRF to GSSHA functionality with date filters
        """
        # INITIALIZE CLASS AND RUN
        gr = GSSHAWRFFramework(
            gssha_executable='',
            gssha_directory=self.gssha_project_directory,
            project_filename=self.gssha_project_file,
            lsm_folder=self.lsm_folder,
            gssha_simulation_start=datetime(2016, 8, 23),
            gssha_simulation_end=datetime(2002, 8, 24, 3, 59),
            read_hotstart=True,
            write_hotstart=True,
        )

        with pytest.raises(ValueError):
            gr.run_forecast()

        # COMPARE FILES
        # grid_standard.prj
        compare_prj_file = os.path.join(
            self.readDirectory, 'framework',
            'grid_standard_wrf_hotstart_201608230000to200208240359_{0}.prj'.
            format(self.os_name))
        self._compare_files(
            self._generated_file_path('run_201608230000to200208240359'),
            compare_prj_file)

        # grid_standard.cmt
        # 1 file in main directory not modified
        self._compare_files(
            os.path.join(self.readDirectory, "gssha_project",
                         "grid_standard.cmt"),
            os.path.join(self.gssha_project_directory, "grid_standard.cmt"))
        # 2 file in working directory correct
        self._compare_files(
            os.path.join(
                self.readDirectory, "gssha_project",
                "grid_standard_compare_run_{0}.cmt".format(self.os_name)),
            self._generated_file_path('run_201608230000to200208240359',
                                      extension="cmt"))

        # grid_standard.gag
        self._compare_files(
            os.path.join(self.readDirectory, "framework",
                         "grid_standard_wrf_201608230000to200208240359.gag"),
            self._generated_file_path('run_201608230000to200208240359',
                                      extension="gag"),
            precision=5)

        # compare yml files
        self._compare_files(
            os.path.join(self.readDirectory, 'framework',
                         'gssha_event_wrf_201608230000to200208240359.yml'),
            os.path.join(self.gssha_project_directory, 'gsshapy_event.yml'))

        # compare HMET files
        compare_directory = os.path.join(
            self.readDirectory, "framework",
            "wrf_hmet_data_201608231600to201608240700")
        output_directory = os.path.join(
            self.gssha_project_directory,
            "hmet_data_201608230000to200208240359")

        self._compare_directories(compare_directory,
                                  output_directory,
                                  ignore_file="hmet_file_list.txt",
                                  raster=True,
                                  precision=4)