Skip to content
Snippets Groups Projects
Select Git revision
  • a25cc7123bdeb356c5f48dc6a2d4630d30081a33
  • master default protected
  • 551-init-broker-service-permissions
  • dev protected
  • release-1.10 protected
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • release-1.9 protected
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • 518-spark-doesn-t-map-the-headers-correct
  • 485-fixity-checks
  • 530-various-schema-problems-with-subsets
  • release-1.7 protected
  • fix/auth-service
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
  • v1.9.2 protected
  • v1.9.2-rc0 protected
  • v1.9.1 protected
41 results

build-docs.sh

Blame
  • test_inputnml.py 1.97 KiB
    import os, shutil
    import datetime as dt
    
    from dartwrf import dart_nml
    
    
    
    def test_input_nml():
        test_input = './input.nml.original'
        test_output = './input.nml.output'
        desired_output = './input.nml.desired_output'
    
        # read an existing input.nml
        nml = dart_nml.read_namelist(test_input)
    
        # modify one parameter
        nml['&filter_nml']['ens_size'] = [[999,]]
        nml['&filter_nml']['num_output_state_members'] = [[999,]]
        nml['&filter_nml']['num_output_obs_members'] = [[999,]]
        nml['&filter_nml']['compute_posterior'] = [['.false.']]
    
        # save the configuration as input.nml
        dart_nml.write_namelist_from_dict(nml, test_output)
    
        # compare the saved input.nml to the true input.nml
        # by reading both and comparing the dictionaries
        nml_desired = dart_nml.read_namelist(desired_output)
        nml_test = dart_nml.read_namelist(test_output)
    
        # section e.g. '&preprocess_nml'
        for section, _ in nml_desired.items():
    
            # param e.g. 'filter_kind'
            for param, value in nml_desired[section].items():
    
                should_have = nml_desired[section][param]
                have = nml_test[section][param]
    
                for i, line in enumerate(should_have):
    
                    for j, expected in enumerate(line):
    
                        if expected != have[i][j]:
    
                            # if one has "wrfinput" and other has 'wrfinput'
                            # thats ok
                            this = "'"+have[i][j].strip('"')+"'"
                            if this == expected:
                                pass
                                # print(this, expected)
                            else:
                                raise ValueError('expected', expected, 'got', have[i][j])
        
        os.remove(test_output)
    
    def test_get_list_of_localizations():
    
        output = dart_nml._get_list_of_localizations()
        assert (['SYNOP_TEMPERATURE'], [0.0015698587127158557], [1274000.0], [-1]) == output
    
    
    if __name__ == '__main__':
        test_input_nml()
    
        test_get_list_of_localizations()