diff --git a/python/templates/ecmwf_grib1_table_128 b/_templates/ecmwf_grib1_table_128 similarity index 100% rename from python/templates/ecmwf_grib1_table_128 rename to _templates/ecmwf_grib1_table_128 diff --git a/python/COMMANDS b/python/COMMANDS new file mode 100644 index 0000000000000000000000000000000000000000..f53f812d64a1294015abc031d10972856c8c8e03 --- /dev/null +++ b/python/COMMANDS @@ -0,0 +1,16 @@ +./install.py --target=ecgate --ecuid=km4a --ecgid=at --gateway=srvx8.img.univie.ac.at --destination=annep@genericSftp + +./submit.py --queue=ecgate --start_date=20160809 --debug=True + +firefox SphinxDoc/_build/html/index.html & + +./plot_retrieved.py --start_date=2016080906 --inputdir=../work2/ --paramIds=131 --end_date=2016080909 --prefix=EI --levelist=59/60 + +./prepareFLEXPART.py --start_date=20010809 --debug=1 --controlfile=CONTROL_CERA.test --ppid=1411 --inputdir=../work2/ + +find ./ -name \*.py -exec sed -i 's/Disagg/disaggregation/g' {} \; + + +pyreserve *.py # on s1 +dot -Tpng packages.dot -O #on s8 +dot -Tpng classes.dot -O #on s8 diff --git a/python/CONTROL.test b/python/CONTROL.test index 6a9ce870554144c1ad88b9a724cdf123f9f9e10b..b693ee4d1364bc38deb58739b3c8844f4ee5490c 100644 --- a/python/CONTROL.test +++ b/python/CONTROL.test @@ -6,11 +6,11 @@ CLASS EI STREAM OPER EXPVER 1 GRID 5000 -LEFT -15000 +LEFT -10000 LOWER 30000 -UPPER 75000 -RIGHT 45000 -LEVELIST 55/to/60 +UPPER 40000 +RIGHT 10000 +LEVELIST 59/to/60 RESOL 63 GAUSS 1 ADDPAR 186/187/188/235/139/39 diff --git a/python/_config.py b/python/_config.py index 239e97af42562571e9d189880fd063cc351ba4a6..4389b23f3bc69c6a70a92ffc6566bf23588a6974 100644 --- a/python/_config.py +++ b/python/_config.py @@ -28,11 +28,23 @@ import inspect _VERSION_STR = '7.1' # add path to pythonpath -LOCAL_PYTHON_PATH = os.path.dirname(os.path.abspath( +PATH_LOCAL_PYTHON = os.path.dirname(os.path.abspath( inspect.getfile(inspect.currentframe()))) -if LOCAL_PYTHON_PATH not in sys.path: - sys.path.append(LOCAL_PYTHON_PATH) +if PATH_LOCAL_PYTHON not in sys.path: + sys.path.append(PATH_LOCAL_PYTHON) + +PATH_FLEXEXTRACT_DIR = os.path.normpath(os.path.dirname(os.path.abspath( + inspect.getfile(inspect.currentframe()))) + '/../') + +PATH_TEMPLATES = os.path.join(PATH_FLEXEXTRACT_DIR + os.path.sep + + '_templates') # path to gribtable -PATH_GRIBTABLE = LOCAL_PYTHON_PATH + '/templates/ecmwf_grib1_table_128' +PATH_GRIBTABLE = os.path.join(PATH_TEMPLATES + os.path.sep + + 'ecmwf_grib1_table_128') + +PATH_RUN_DIR = os.path.join(PATH_FLEXEXTRACT_DIR + os.path.sep + + 'run') +PATH_CONTROLFILES = os.path.join(PATH_RUN_DIR + os.path.sep + + 'control') diff --git a/python/install.py b/python/install.py index a1864ba97362d546076a598a4055f2ef041d2b6f..80d87be578fbbeeb2e04fbecfb340fcc382d20e1 100755 --- a/python/install.py +++ b/python/install.py @@ -262,7 +262,7 @@ def mk_tarball(ecd, tarname): ecd + 'python/*ksh ' + ecd + 'python/*temp* ' + ecd + 'python/ECMWF_ENV ' + - ecd + 'grib_templates ' + + ecd + '_templates ' + ecd + 'src/*.f ' + ecd + 'src/*.f90 ' + ecd + 'src/*.h ' + diff --git a/python/job.ksh b/python/job.ksh index 8cbc1d82d16626d48e938bd80ce8690705a43828..ae3bec5d9abcc16bde9ed3d42bb355242bdb4599 100644 --- a/python/job.ksh +++ b/python/job.ksh @@ -67,7 +67,7 @@ ecgid at ecstorage 0 ectrans 1 ecuid km4a -end_date 20000101 +end_date 20100606 eta 0 etadiff 0 etapar 77 @@ -80,9 +80,9 @@ grid 5000 inputdir ../work install_target None job_template job.temp -left -15000 +left -10000 level 60 -levelist 55/to/60 +levelist 59/to/60 lower 30000 mailfail ${USER} mailops ${USER} @@ -96,14 +96,14 @@ outputdir ../work prefix EItest_ queue ecgate resol 63 -right 45000 +right 10000 smooth 0 -start_date 20000101 +start_date 20100606 step 00 01 02 03 04 05 00 07 08 09 10 11 00 01 02 03 04 05 00 07 08 09 10 11 stream OPER time 00 00 00 00 00 00 06 00 00 00 00 00 12 12 12 12 12 12 18 12 12 12 12 12 type AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC AN FC FC FC FC FC -upper 75000 +upper 40000 wrf 0 EOF diff --git a/python/pythontest/.cache/v/cache/lastfailed b/python/pythontest/.cache/v/cache/lastfailed index c9e456723acc439fb7bfcee087486e33ca33ffea..628a7499aab7afb001f0d5d3dc1b3e9933348e03 100644 --- a/python/pythontest/.cache/v/cache/lastfailed +++ b/python/pythontest/.cache/v/cache/lastfailed @@ -1,6 +1,4 @@ { - "TestTools.py::TestTools::()": true, - "TestTools.py::TestTools::()::test_failany_silent_remove": true, "TestTools.py::TestTools::test_init128": true, "TestTools.py::TestTools::test_to_param_id": true } \ No newline at end of file diff --git a/python/pythontest/.coverage b/python/pythontest/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..47caf6bb2658216f0fa17ad108780a38c3a8e385 --- /dev/null +++ b/python/pythontest/.coverage @@ -0,0 +1 @@ +!coverage.py: This is a private format, don't read it directly!{"lines":{"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/test_suite.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/_config.py":[32,33,37,24,25,26,28,31],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/MarsRetrieval.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/install.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/get_mars_data.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/testecmwfapi.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/EcFlexpart.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/profiling.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/pythontest/TestInput.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/plot_retrieved.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/ControlFile.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/submit.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/pythontest/__init__.py":[13],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/pythontest/TestTools.py":[4,5,6,7,8,10,11,12,18,20,22,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,59,61,63,64,65,67,68,70,71,72,73,74,76,77,78,79,80,82,83,84,85,86,88,90,92,94,96,97,99,100,102,103,104,105,106,107,108,110,111,112,113,114,115,117,126,127,128,129,131,139,140,141,142,143,145,146,147,148,149,151,152,153,154,155,157,158,159,160,161,162,163,164,166,167,168,169,170,171,173,175,176,177,178,182,183,184,185,186,188,189,190,193],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/disaggregation.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/pythontest/TestPathes.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/GribTools.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/prepare_flexpart.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/tools.py":[517,518,519,520,521,522,523,524,526,527,529,50,51,52,53,54,55,56,62,76,77,78,81,82,83,84,85,86,89,90,91,92,93,94,95,96,99,100,101,102,103,104,107,110,112,115,116,117,118,120,121,122,123,124,125,127,129,131,144,145,146,147,148,149,151,153,191,210,213,214,215,216,217,218,219,220,221,222,223,224,229,230,232,237,279,315,328,329,330,331,335,338,353,354,355,356,357,358,360,363,386,387,388,389,390,391,392,396,398,416,418,420,433,434,435,436,438,440,442,444,476,477,478,481,482,483,484,485,486,488,489,491,493],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/pythontest/TestEcFlexpart.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/pythontest/TestUIOFiles.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/pythontest/TestInstall.py":[],"/raid60/nas/tmc/Anne/Interpolation/flexextract/flexextract/python/UioFiles.py":[]}} \ No newline at end of file diff --git a/python/pythontest/TestInput.py b/python/pythontest/TestInput.py index 97fd4888e1a39f410bb79959ce28f84541086360..61bede1ce55242181c704a8cce769c7f43ee1b94 100644 --- a/python/pythontest/TestInput.py +++ b/python/pythontest/TestInput.py @@ -4,6 +4,7 @@ import unittest import os import sys + sys.path.append('../python') from ControlFile import ControlFile import tools diff --git a/python/pythontest/TestPathes.py b/python/pythontest/TestPathes.py index b74932fa35fdfb925a27eb278a3f5f730b78a571..542b4ee0a44690cc5f17d41eafe0a71fb993e664 100644 --- a/python/pythontest/TestPathes.py +++ b/python/pythontest/TestPathes.py @@ -8,6 +8,19 @@ import pytest sys.path.append("../") import _config +def test_path_localpython(): + assert os.path.exists(_config.PATH_LOCAL_PYTHON) == 1 + +def test_path_flexextract(): + assert os.path.exists(_config.PATH_FLEXEXTRACT_DIR) == 1 + +def test_path_flexextract_name(): + version = _config._VERSION_STR + flexextract_name = 'flex_extract_v' + version + assert os.path.basename(_config.PATH_FLEXEXTRACT_DIR) == flexextract_name + +def test_path_templates(): + assert os.path.exists(_config.PATH_TEMPLATES) == 1 def test_path_vtable(): assert os.path.exists(_config.PATH_GRIBTABLE) == 1 @@ -15,3 +28,8 @@ def test_path_vtable(): def test_file_vtable(): assert os.path.isfile(_config.PATH_GRIBTABLE) == 1 +def test_path_run(): + assert os.path.exists(_config.PATH_RUN_DIR) == 1 + +def test_path_control(): + assert os.path.exists(_config.PATH_CONTROLFILES) == 1 diff --git a/python/pythontest/TestTools.py b/python/pythontest/TestTools.py index 039f362a8ffc87fe0682e06a693abd1a002ab88f..f55ebf937b8f13c5e1691a6def7ac6b6e0103936 100644 --- a/python/pythontest/TestTools.py +++ b/python/pythontest/TestTools.py @@ -23,8 +23,6 @@ class TestTools(): pass def test_get_cmdline_arguments(self): - ''' - ''' cmd_dict_control = {'start_date':'20180101', 'end_date':'20180101', 'date_chunk':'3', @@ -63,8 +61,6 @@ class TestTools(): assert cmd_dict_control == vars(results) def test_init128(self): - ''' - ''' table128 = init128(_config.PATH_GRIBTABLE) expected = {'078': 'TCLW', '130': 'T', '034': 'SST'} # check a sample of parameters which must have been read in @@ -72,24 +68,18 @@ class TestTools(): assert result == True def test_to_param_id(self): - ''' - ''' table128 = init128(_config.PATH_GRIBTABLE) pars = to_param_id("T/SP/LSP/SSHF", table128) for par in pars: assert par in [130, 134, 142, 146] def test_my_error(self): - ''' - ''' with pytest.raises(SystemExit) as pytest_wrapped_e: my_error(['${USER}', 'anne.philipp@univie.ac.at'], 'Failed!') assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 1 def test_read_ecenv(self): - ''' - ''' envs_ref = {'ECUID': 'km4a', 'ECGID': 'at', 'GATEWAY': 'srvx8.img.univie.ac.at', @@ -100,6 +90,7 @@ class TestTools(): assert envs_ref == envs def test_clean_up(self): + assert True def test_normal_exit(self): @@ -122,17 +113,28 @@ class TestTools(): out, err = capfd.readouterr() assert os.path.isfile(testfile) == False assert out == '' -# -# def test_failany_silent_remove(self): -# testfile = 'testfileany.test' -# with pytest.raises(OSError) as pytest_wrapped_e: -# silent_remove(testfile) -# #out, err = capfd.readouterr() -# #assert os.path.isfile(testfile) == False -# #assert out == '' - - def test_get_list_as_string(self): - assert True + + @pytest.mark.skip(reason="no way of currently testing this") + def test_failany_silent_remove(self): + testfile = 'testfileany.test' + with pytest.raises(OSError) as pytest_wrapped_e: + silent_remove(testfile) + #out, err = capfd.readouterr() + #assert os.path.isfile(testfile) == False + #assert out == '' + + def test_success_get_list_as_string(self): + list_object = [1, 2, 3, '...', 'testlist'] + list_as_string = '1, 2, 3, ..., testlist' + assert list_as_string == get_list_as_string(list_object) + + @pytest.mark.skip(reason="no way of currently testing this") + def test_fail_get_list_as_string(self): + list_object = [1, 2, 3, '...', 'testlist'] + list_as_string = '1, 2, 3, ..., testlist' + with pytest.raises(Exception) as pytest_wrapped_e: + result = get_list_as_string(list_object) + assert result == list_as_string def test_warningexist_make_dir(self, capfd): testdir = 'TestData' diff --git a/python/submit.py b/python/submit.py index 91114a12dcdd27d4d490ebf17b68351560acc313..a041dedfa1e9fd99697c6ebc9e0f2e57be11ff3e 100755 --- a/python/submit.py +++ b/python/submit.py @@ -80,7 +80,7 @@ def main(): c = ControlFile(args.controlfile) except IOError: try: - c = ControlFile(LOCAL_PYTHON_PATH + args.controlfile) + c = ControlFile(_config.PATH_LOCAL_PYTHON + args.controlfile) except IOError: print 'Could not read CONTROL file "' + args.controlfile + '"' print 'Either it does not exist or its syntax is wrong.'