wrfrun 0.1.7__py3-none-any.whl → 0.1.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. wrfrun/cli.py +128 -0
  2. wrfrun/core/__init__.py +33 -0
  3. wrfrun/core/base.py +246 -75
  4. wrfrun/core/config.py +286 -236
  5. wrfrun/core/error.py +47 -17
  6. wrfrun/core/replay.py +65 -32
  7. wrfrun/core/server.py +139 -79
  8. wrfrun/data.py +10 -5
  9. wrfrun/extension/__init__.py +28 -0
  10. wrfrun/extension/goos_sst/__init__.py +67 -0
  11. wrfrun/extension/goos_sst/core.py +111 -0
  12. wrfrun/extension/goos_sst/res/Vtable.ERA_GOOS_SST +7 -0
  13. wrfrun/extension/goos_sst/res/__init__.py +26 -0
  14. wrfrun/extension/goos_sst/utils.py +97 -0
  15. wrfrun/extension/littler/__init__.py +57 -1
  16. wrfrun/extension/littler/{utils.py → core.py} +326 -40
  17. wrfrun/extension/utils.py +22 -21
  18. wrfrun/model/__init__.py +24 -1
  19. wrfrun/model/plot.py +253 -35
  20. wrfrun/model/utils.py +17 -8
  21. wrfrun/model/wrf/__init__.py +41 -0
  22. wrfrun/model/wrf/core.py +218 -102
  23. wrfrun/model/wrf/exec_wrap.py +49 -35
  24. wrfrun/model/wrf/namelist.py +82 -11
  25. wrfrun/model/wrf/scheme.py +85 -1
  26. wrfrun/model/wrf/{_metgrid.py → utils.py} +36 -2
  27. wrfrun/model/wrf/vtable.py +2 -1
  28. wrfrun/plot/wps.py +66 -58
  29. wrfrun/res/__init__.py +8 -5
  30. wrfrun/res/config/config.template.toml +50 -0
  31. wrfrun/res/{config.toml.template → config/wrf.template.toml} +10 -47
  32. wrfrun/res/run.template.sh +10 -0
  33. wrfrun/res/scheduler/lsf.template +5 -0
  34. wrfrun/res/{job_scheduler → scheduler}/pbs.template +1 -1
  35. wrfrun/res/{job_scheduler → scheduler}/slurm.template +2 -1
  36. wrfrun/run.py +19 -23
  37. wrfrun/scheduler/__init__.py +35 -0
  38. wrfrun/scheduler/env.py +44 -0
  39. wrfrun/scheduler/lsf.py +47 -0
  40. wrfrun/scheduler/pbs.py +48 -0
  41. wrfrun/scheduler/script.py +70 -0
  42. wrfrun/scheduler/slurm.py +48 -0
  43. wrfrun/scheduler/utils.py +14 -0
  44. wrfrun/utils.py +8 -3
  45. wrfrun/workspace/__init__.py +38 -0
  46. wrfrun/workspace/core.py +92 -0
  47. wrfrun/workspace/wrf.py +121 -0
  48. {wrfrun-0.1.7.dist-info → wrfrun-0.1.9.dist-info}/METADATA +4 -3
  49. wrfrun-0.1.9.dist-info/RECORD +62 -0
  50. wrfrun-0.1.9.dist-info/entry_points.txt +3 -0
  51. wrfrun/model/wrf/_ndown.py +0 -39
  52. wrfrun/pbs.py +0 -86
  53. wrfrun/res/run.sh.template +0 -16
  54. wrfrun/workspace.py +0 -88
  55. wrfrun-0.1.7.dist-info/RECORD +0 -46
  56. {wrfrun-0.1.7.dist-info → wrfrun-0.1.9.dist-info}/WHEEL +0 -0
@@ -0,0 +1,92 @@
1
+ """
2
+ wrfrun.workspace.core
3
+ #####################
4
+
5
+ Core functions to prepare ``wrfrun`` workspace.
6
+
7
+ .. autosummary::
8
+ :toctree: generated/
9
+
10
+ prepare_workspace
11
+ """
12
+
13
+ from os.path import exists
14
+ from shutil import rmtree
15
+
16
+ from wrfrun import WRFRUNConfig
17
+ from wrfrun.utils import check_path, logger
18
+ from .wrf import prepare_wrf_workspace, check_wrf_workspace
19
+
20
+
21
+ def prepare_workspace():
22
+ """
23
+ Initialize ``wrfrun`` workspace.
24
+
25
+ This function will check following paths,
26
+ and create them if them don't exist:
27
+
28
+ 1. ``/tmp/wrfrun``
29
+ 2. ``$HOME/.config/wrfrun``
30
+ 3. ``$HOME/.config/wrfrun/replay``
31
+ 4. ``$HOME/.config/wrfrun/model``
32
+
33
+ It will call other responding functions to initialize workspace for numerical models:
34
+
35
+ 1. :doc:`WPS/WRF model </api/workspace.wrf>`
36
+ """
37
+ logger.info(f"Initialize main workspace.")
38
+
39
+ wrfrun_temp_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_TEMP_PATH)
40
+ workspace_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_WORKSPACE_ROOT)
41
+ replay_work_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_WORKSPACE_REPLAY)
42
+ output_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_OUTPUT_PATH)
43
+
44
+ if exists(workspace_path):
45
+ logger.info(f"Remove old files in workspace.")
46
+ rmtree(workspace_path)
47
+
48
+ # check folder
49
+ check_path(wrfrun_temp_path)
50
+ check_path(replay_work_path)
51
+ check_path(output_path)
52
+
53
+ func_map = {
54
+ "wrf": prepare_wrf_workspace
55
+ }
56
+ model_configs = WRFRUNConfig["model"]
57
+
58
+ for model_name in model_configs:
59
+ func_map[model_name](model_configs[model_name])
60
+
61
+
62
+ def check_workspace() -> bool:
63
+ """
64
+ Check if workspace exists.
65
+
66
+ :return: ``True`` if workspace exists, ``False`` otherwise.
67
+ :rtype: bool
68
+ """
69
+
70
+ wrfrun_temp_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_TEMP_PATH)
71
+ workspace_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_WORKSPACE_ROOT)
72
+ replay_work_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_WORKSPACE_REPLAY)
73
+ output_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_OUTPUT_PATH)
74
+
75
+ flag = True
76
+ flag = flag & exists(wrfrun_temp_path) & exists(replay_work_path) & exists(output_path) & exists(workspace_path)
77
+
78
+ func_map = {
79
+ "wrf": check_wrf_workspace
80
+ }
81
+ model_configs = WRFRUNConfig["model"]
82
+
83
+ for model_name in model_configs:
84
+ if model_name == "debug_level":
85
+ continue
86
+
87
+ flag = flag & func_map[model_name](model_configs[model_name])
88
+
89
+ return True
90
+
91
+
92
+ __all__ = ["prepare_workspace", "check_workspace"]
@@ -0,0 +1,121 @@
1
+ """
2
+ wrfrun.workspace.wrf
3
+ ####################
4
+
5
+ Functions to prepare workspace for WPS/WRF model.
6
+
7
+ .. autosummary::
8
+ :toctree: generated/
9
+
10
+ prepare_wrf_workspace
11
+ check_wrf_workspace
12
+ """
13
+
14
+ from os import listdir, makedirs, symlink
15
+ from os.path import exists
16
+
17
+ from wrfrun.core import WRFRUNConfig
18
+ from wrfrun.utils import logger, check_path
19
+
20
+
21
+ WORKSPACE_MODEL_WPS = f"{WRFRUNConfig.WRFRUN_WORKSPACE_MODEL}/WPS"
22
+ WORKSPACE_MODEL_WRF = f"{WRFRUNConfig.WRFRUN_WORKSPACE_MODEL}/WRF"
23
+ WORKSPACE_MODEL_WRFDA = f"{WRFRUNConfig.WRFRUN_WORKSPACE_MODEL}/WRFDA"
24
+
25
+
26
+ def prepare_wrf_workspace(model_config: dict):
27
+ """
28
+ Initialize workspace for WPS/WRF model.
29
+
30
+ This function will check following paths,
31
+ and create them or delete old files inside:
32
+
33
+ 1. ``$HOME/.config/wrfrun/model/WPS``
34
+ 2. ``$HOME/.config/wrfrun/model/WRF``
35
+ 3. ``$HOME/.config/wrfrun/model/WRFDA``
36
+
37
+ :param model_config: Model config.
38
+ :type model_config: dict
39
+ """
40
+ logger.info(f"Initialize workspace for WPS/WRF.")
41
+
42
+ wps_path = model_config["wps_path"]
43
+ wrf_path = model_config["wrf_path"]
44
+ wrfda_path = model_config["wrfda_path"]
45
+
46
+ if not (wps_path and wrf_path):
47
+ logger.warning(f"No WPS/WRF model installation path given, skip initialization.")
48
+ return
49
+
50
+ if wps_path:
51
+ if not exists(wps_path):
52
+ logger.error(f"Your WPS path is wrong.")
53
+ raise FileNotFoundError(f"Your WPS path is wrong.")
54
+
55
+ wps_work_path = WRFRUNConfig.parse_resource_uri(WORKSPACE_MODEL_WPS)
56
+ check_path(wps_work_path, f"{wps_work_path}/outputs", force=True)
57
+
58
+ file_list = [x for x in listdir(wps_path) if x not in ["geogrid", "namelist.wps"]]
59
+ _ = [symlink(f"{wps_path}/{file}", f"{wps_work_path}/{file}") for file in file_list]
60
+ makedirs(f"{wps_work_path}/geogrid")
61
+ symlink(f"{wps_path}/geogrid/GEOGRID.TBL", f"{wps_work_path}/geogrid/GEOGRID.TBL")
62
+
63
+ if wrf_path:
64
+ if not exists(wrf_path):
65
+ logger.error(f"Your WRF path is wrong.")
66
+ raise FileNotFoundError(f"Your WRF path is wrong.")
67
+
68
+ wrf_work_path = WRFRUNConfig.parse_resource_uri(WORKSPACE_MODEL_WRF)
69
+ check_path(wrf_work_path, force=True)
70
+
71
+ file_list = [x for x in listdir(f"{wrf_path}/run") if not x.startswith("namelist")]
72
+ _ = [symlink(f"{wrf_path}/run/{file}", f"{wrf_work_path}/{file}") for file in file_list]
73
+
74
+ if wrfda_path:
75
+ if not exists(wrfda_path):
76
+ logger.error(f"Your WRFDA path is wrong.")
77
+ raise FileNotFoundError(f"Your WRFDA path is wrong.")
78
+
79
+ wrfda_work_path = WRFRUNConfig.parse_resource_uri(WORKSPACE_MODEL_WRFDA)
80
+ check_path(wrfda_work_path, force=True)
81
+
82
+ file_list = ["da_wrfvar.exe", "da_update_bc.exe"]
83
+ _ = [symlink(f"{wrfda_path}/var/build/{file}", f"{wrfda_work_path}/{file}") for file in file_list]
84
+
85
+ file_list = listdir(f"{wrfda_path}/var/run")
86
+ _ = [symlink(f"{wrfda_path}/var/run/{file}", f"{wrfda_work_path}/{file}") for file in file_list]
87
+
88
+ symlink(f"{wrfda_path}/run/LANDUSE.TBL", f"{wrfda_work_path}/LANDUSE.TBL")
89
+
90
+
91
+ def check_wrf_workspace(model_config: dict) -> bool:
92
+ """
93
+ Check if WPS/WRF workspace exists.
94
+
95
+ :param model_config: Model config.
96
+ :type model_config: dict
97
+ :return: ``True`` if WPS/WRF workspace exists, ``False`` otherwise.
98
+ :rtype: bool
99
+ """
100
+ wps_path = model_config["wps_path"]
101
+ wrf_path = model_config["wrf_path"]
102
+ wrfda_path = model_config["wrfda_path"]
103
+
104
+ flag = True
105
+
106
+ if wps_path:
107
+ wps_work_path = WRFRUNConfig.parse_resource_uri(WORKSPACE_MODEL_WPS)
108
+ flag = flag & exists(wps_work_path)
109
+
110
+ if wrf_path:
111
+ wrf_work_path = WRFRUNConfig.parse_resource_uri(WORKSPACE_MODEL_WRF)
112
+ flag = flag & exists(wrf_work_path)
113
+
114
+ if wrfda_path:
115
+ wrfda_work_path = WRFRUNConfig.parse_resource_uri(WORKSPACE_MODEL_WRFDA)
116
+ flag = flag & exists(wrfda_work_path)
117
+
118
+ return flag
119
+
120
+
121
+ __all__ = ["prepare_wrf_workspace", "WORKSPACE_MODEL_WRF", "WORKSPACE_MODEL_WPS", "WORKSPACE_MODEL_WRFDA", "check_wrf_workspace"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wrfrun
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: wrfrun is a comprehensive toolkit for managing and using WRF
5
5
  Keywords: WRF
6
6
  Author-Email: Syize <syizeliu@gmail.com>
@@ -10,8 +10,8 @@ Project-URL: homepage, https://github.com/Syize/wrfrun
10
10
  Project-URL: repository, https://github.com/Syize/wrfrun
11
11
  Project-URL: documentation, https://wrfrun.syize.cn
12
12
  Project-URL: Bug Tracker, https://github.com/Syize/wrfrun/issues
13
- Requires-Python: <3.13
14
- Requires-Dist: numpy<2.0.0
13
+ Requires-Python: >=3.10
14
+ Requires-Dist: numpy
15
15
  Requires-Dist: xarray
16
16
  Requires-Dist: netCDF4
17
17
  Requires-Dist: rich
@@ -24,6 +24,7 @@ Requires-Dist: wrf-python
24
24
  Requires-Dist: cfgrib
25
25
  Requires-Dist: tomli
26
26
  Requires-Dist: tomli-w
27
+ Requires-Dist: haversine
27
28
  Description-Content-Type: text/markdown
28
29
 
29
30
  # wrfrun: A toolkit to control WRF
@@ -0,0 +1,62 @@
1
+ wrfrun-0.1.9.dist-info/METADATA,sha256=RPtBDS1Ctr0OatYSqezZsgRqGj621sS-dijdt4oN2Vk,2932
2
+ wrfrun-0.1.9.dist-info/WHEEL,sha256=5J4neoE7k6LMgx4Fz1FHgBiO3YevhJGtNQ3muDrdLQM,75
3
+ wrfrun-0.1.9.dist-info/entry_points.txt,sha256=G3358n6wW1qZF3hSH9umxrWHJewN-6N1BUloacN2tks,50
4
+ wrfrun/__init__.py,sha256=l2zGk2qDWa3EXIlwvzqBYZHOU9273TN75Rmvx_7PAYM,58
5
+ wrfrun/cli.py,sha256=xaMxiHQCHvgHWKlPavYXkC9hGIo7JpUZaIsV8ZKr_SM,4300
6
+ wrfrun/data.py,sha256=W6IhopHpp0lhvVo-beuO6NsbfsGDmN5MNf8Bqkt7xsA,14845
7
+ wrfrun/run.py,sha256=aYRQ-YqjIt5g4MQEnphmZIwanT9TBlYCddcyXxtgD_s,8918
8
+ wrfrun/utils.py,sha256=BdGP5u2Y2e3tqU0dawfHsTeqZ0q4Ic4MCGR8RU4FJ90,8388
9
+ wrfrun/core/__init__.py,sha256=zsitfcmbO_Qf_Uh0FzZ4rceZAo3WEYev32jSjgRjtkw,1325
10
+ wrfrun/core/base.py,sha256=LXtol0AQlDiZYMZeQT3qRZVcQ-F0ETE7sMXdI1jriLw,30324
11
+ wrfrun/core/config.py,sha256=gljrE1j8qFNJb_VVJwhQ3E2pmapT9cFUg1pyWizEvjA,27457
12
+ wrfrun/core/error.py,sha256=etnImryyqDUggfZOKK1ynOm71GRSFJVGGOwhuiZahTI,2383
13
+ wrfrun/core/replay.py,sha256=jZWN68IgUroxuCzg7EO0FXxe2zwokxJnquu4t81hp7Y,4782
14
+ wrfrun/core/server.py,sha256=Kns4an_wqnrYsi0PJxJgQJY8ShjNDnvrxY5V7gsbDec,8660
15
+ wrfrun/extension/__init__.py,sha256=YDYCS0KD3e-uLvf1K08ktNfP2sUSKpbgkHrvXj21EPQ,913
16
+ wrfrun/extension/utils.py,sha256=mmcyqxOEVGSBu8t8ukB2SeRp9X_PLR0kWvfptBC_WWo,2458
17
+ wrfrun/extension/goos_sst/__init__.py,sha256=QsVheVVL5K0_k-eg8-xe2MLAJ845iivXzGHbp2qARh4,2101
18
+ wrfrun/extension/goos_sst/core.py,sha256=_s53vq0nAwnwWxExD8-73p5seCWLO1XVzRh5T8JofAw,3870
19
+ wrfrun/extension/goos_sst/utils.py,sha256=bomXbhpOuNOYm2rL1SiOeSxVbSaKWfVxX51KoODgBn0,3469
20
+ wrfrun/extension/goos_sst/res/__init__.py,sha256=-Ey6iFHzQYZNOGhVrSkMjOwiXVgt3P6eaumq7pOmh_E,511
21
+ wrfrun/extension/goos_sst/res/Vtable.ERA_GOOS_SST,sha256=UfbzWKEE2pnQO4Q2mkMmkl7pv_bDSxVGaN2jEYfMVzE,534
22
+ wrfrun/extension/littler/__init__.py,sha256=bLiGIpB_FpTyio44CjIzwwcahyFWxGW-gECfBOIG9Y8,2032
23
+ wrfrun/extension/littler/core.py,sha256=0Si4phAUiCwgjEQnDfWKSOvtnyitWYmrDWkB6_2VjUg,34173
24
+ wrfrun/model/__init__.py,sha256=PYA6ZUwL4u3heRIMX_qkLvAA6jDrY4kugD8rCvnl-2Y,803
25
+ wrfrun/model/base.py,sha256=WnVNu12ICJgThfZR7kK6_XLCQWVYFsHrdyAz8wl_YRc,218
26
+ wrfrun/model/plot.py,sha256=SvD5_2sLaLqYvuvcZVX1x3XTrgMW_bsGP-Npr6RKHVU,10335
27
+ wrfrun/model/utils.py,sha256=5_ffMJCPi_n3-Mgaci9F2eMk2fY7_UrcjmK0JSsZZr0,1206
28
+ wrfrun/model/wrf/__init__.py,sha256=KJij1JMTcj3i5e2LcJJJudA99LrsJIVHeMj9ktT9Y_4,1752
29
+ wrfrun/model/wrf/core.py,sha256=Ykw6ElY3mUelWOThDFT--ChnwY7zgcbyooLuJNhGqV4,35627
30
+ wrfrun/model/wrf/exec_wrap.py,sha256=REOtNLCc6IcM2yaaSXoXGgXFA-xjMHmoTiA9B3ZezEA,4418
31
+ wrfrun/model/wrf/geodata.py,sha256=X9OUOm0__5NI7sl2z1F9_ur5wZ4P0HkpBNcRZQYKof0,9740
32
+ wrfrun/model/wrf/namelist.py,sha256=ksxHlh-LtxDBF73cCe8J0wpyGrSvM1dBgPgwK2XseGo,16918
33
+ wrfrun/model/wrf/scheme.py,sha256=8y85Dbu-GajwjHr3Spw8_tN21xAloD-SnmxJd11nXKE,11254
34
+ wrfrun/model/wrf/utils.py,sha256=DuKghfqBT77p_beDKJ3EyyPMuRmBJCgCElvs3YheWak,3709
35
+ wrfrun/model/wrf/vtable.py,sha256=1el_TctQfPVTYnZn0nJNgfDvVXy6q5ZzVIyUgWRfFUs,2478
36
+ wrfrun/plot/__init__.py,sha256=9Kn0IgkX10sHEqHJwk7mZV-dP14XMNcvXN8znO89FIw,19
37
+ wrfrun/plot/wps.py,sha256=pvkxbh5760AAM4KaPteMzhFniZZFtkYF31xhzSBa7lo,5552
38
+ wrfrun/res/__init__.py,sha256=cIjX9Was6nhms-aBLUY0V1393of-LzoSRcWcD_HGgn0,1437
39
+ wrfrun/res/run.template.sh,sha256=k-r4lOOarscmSdiBXGHPnv3oeiRe-qW-VhOBia27ZGU,101
40
+ wrfrun/res/config/config.template.toml,sha256=DjtFjy2sL_P6w63XfLDkmDWhWKyo6qrlwBy69cnbvXA,1378
41
+ wrfrun/res/config/wrf.template.toml,sha256=qQS3OHAXBMaKWgj2qT7jLeDu6tyngPgin7Q-XcE3ZkQ,3189
42
+ wrfrun/res/extension/plotgrids.ncl,sha256=B0mvH1H1j_w7EEana9HmU1XJZtG0w9IccQ54zXpbQG0,7546
43
+ wrfrun/res/namelist/namelist.input.da_wrfvar.template,sha256=Cwc-XPu_spJeQte4duWrulPBOLRMEBtn0mIn0pgMmKY,4912
44
+ wrfrun/res/namelist/namelist.input.dfi.template,sha256=E7MVbIvMopkAM7xGUC4vniC1WOUVbIbdLfkTKHqzX_o,6591
45
+ wrfrun/res/namelist/namelist.input.real.template,sha256=DDUiArtBFmzBwVjkZW4NOrBR34eIOk1vV0VsyL0stsk,6214
46
+ wrfrun/res/namelist/namelist.input.wrf.template,sha256=myrKi79sQ8ABBsmQJkcgN0WLbWJdtMVPIjuAC1MTMuM,6213
47
+ wrfrun/res/namelist/namelist.wps.template,sha256=HlA7-SHs4C-cKRb3h6D0Kl1Y-5VSJ1Lw9hLiXWGAN0Q,1017
48
+ wrfrun/res/namelist/parame.in.template,sha256=vR8JSix20FAKGqj6jK8QuEAeWkGvg8_iptdVlzjPX6o,259
49
+ wrfrun/res/scheduler/lsf.template,sha256=KorLfqTFTqTTctDE9Edgkixi7JLWrcDNRpZknXuxbEQ,111
50
+ wrfrun/res/scheduler/pbs.template,sha256=kP4pGMAq2uz0OZUAWii7dO4ECLC924c8SnciFeBL5QY,155
51
+ wrfrun/res/scheduler/slurm.template,sha256=sQNjkKzOftipDD4kYmzhZkh8fg0M9uaQsdLjDakCVwA,336
52
+ wrfrun/scheduler/__init__.py,sha256=pOqnCAl2-_yC7zPS2VQL5RMltQN4zc0koYS_MESKtHo,1130
53
+ wrfrun/scheduler/env.py,sha256=N_K5yZFRXMEXvW3yjSideEDPWZzoWpbRhFS9LJoZ3R8,1262
54
+ wrfrun/scheduler/lsf.py,sha256=E_sKUk4_RZMBSkHctzDi2sEAy8UrteZvgpbuU2zeSvo,1158
55
+ wrfrun/scheduler/pbs.py,sha256=fqGqoIWG4lh2bT_NqxPxL3XIdPo8keWG2MFqZmOMKpI,1174
56
+ wrfrun/scheduler/script.py,sha256=si2pzrKCOutICcke4t1c5kmCnVlTS9PZJF5MJTp3YTk,2403
57
+ wrfrun/scheduler/slurm.py,sha256=Y3a4MAt5omDgVUtONaL2ajV609HbOZl2opjIGkHUa7g,1196
58
+ wrfrun/scheduler/utils.py,sha256=5BGPEB-oMn4ifo3XZOkDOwAvjWXi69UHLR5HMabwUAM,206
59
+ wrfrun/workspace/__init__.py,sha256=e7ijFWaYRMmBbso0pXnsAc0oUnkQ3t3UguhY3a0U6Qk,1456
60
+ wrfrun/workspace/core.py,sha256=wj9f8XzafazpxXuO_wtConOEhkHwJLyPTwhubXrn20s,2617
61
+ wrfrun/workspace/wrf.py,sha256=wp5pQgKB9B-7JGc2psRIyj_pI7iG344jphBBB0b6PsY,4098
62
+ wrfrun-0.1.9.dist-info/RECORD,,
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ wrfrun = wrfrun.cli:main_entry
3
+
@@ -1,39 +0,0 @@
1
- from wrfrun.core import WRFRUNConfig
2
- from wrfrun.utils import logger
3
-
4
-
5
- def process_after_ndown():
6
- """
7
- After running ndown.exe, namelist settings are supposed to be changed,
8
- so WRF can simulate a higher resolution domain according to `WRF User's Guide <https://www2.mmm.ucar.edu/wrf/users/wrf_users_guide/build/html/running_wrf.html#wrf-nesting>`_.
9
- `wrfrun` provide this function to help you change these settings which have multiple values for each domain.
10
- The first value will be removed to ensure the value of higher resolution domain is the first value.
11
-
12
- :return:
13
- """
14
- namelist_data = WRFRUNConfig.get_namelist("wrf")
15
-
16
- for section in namelist_data:
17
- if section in ["bdy_control", "namelist_quilt"]:
18
- continue
19
-
20
- for key in namelist_data[section]:
21
- if key in ["grid_id", "parent_id", "i_parent_start", "j_parent_start", "parent_grid_ratio", "parent_time_step_ratio", "eta_levels"]:
22
- continue
23
-
24
- if isinstance(namelist_data[section][key], list):
25
-
26
- if len(namelist_data[section][key]) > 1:
27
- namelist_data[section][key] = namelist_data[section][key][1:]
28
-
29
- namelist_data["domains"]["max_dom"] = 1
30
-
31
- time_ratio = namelist_data["domains"]["parent_time_step_ratio"][1]
32
- namelist_data["domains"]["time_step"] = namelist_data["domains"]["time_step"] // time_ratio
33
-
34
- WRFRUNConfig.update_namelist(namelist_data, "wrf")
35
-
36
- logger.info(f"Update namelist after running ndown.exe")
37
-
38
-
39
- __all__ = ["process_after_ndown"]
wrfrun/pbs.py DELETED
@@ -1,86 +0,0 @@
1
- from os import environ
2
- from os.path import exists, dirname, abspath
3
-
4
- from .core import WRFRUNConfig
5
- from .res import TASKSYS_PBS_TEMPLATE
6
- from .utils import logger
7
-
8
-
9
- def prepare_pbs_script(main_file_path: str):
10
- """Prepare the bash script to be submitted to PBS work system.
11
-
12
- Args:
13
- main_file_path (str): The path of main Python file.
14
- """
15
- # check main file
16
- if not exists(main_file_path):
17
- logger.error(f"Wrong path of main Python file: {main_file_path}")
18
- raise FileNotFoundError
19
-
20
- # get absolute path of parent directory
21
- dir_path = abspath(dirname(main_file_path))
22
-
23
- # read log path and PBS setting from config
24
- log_path = WRFRUNConfig.get_log_path()
25
- PBS_setting = WRFRUNConfig.get_job_scheduler_config()
26
-
27
- # set PBS log path
28
- stdout_log_path = f"{log_path}/PBS.log"
29
- stderr_log_path = f"{log_path}/PBS.log"
30
-
31
- # set environment parameter
32
- env_settings = ''
33
- if len(PBS_setting["env_settings"]) != 0:
34
- for key in PBS_setting["env_settings"]:
35
- env_settings += f"{key}={PBS_setting['env_settings'][key]}\n"
36
-
37
- # set command
38
- exec_cmd = f"{PBS_setting['python_interpreter']} {main_file_path}"
39
-
40
- # read template and write to file
41
- pbs_template_path = WRFRUNConfig.parse_resource_uri(TASKSYS_PBS_TEMPLATE)
42
- with open(f"{dir_path}/run.sh", "w") as f:
43
-
44
- with open(pbs_template_path, "r") as f_template:
45
- template = f_template.read()
46
-
47
- template = template.format(
48
- STDOUT_LOG_PATH=stdout_log_path,
49
- STDERR_LOG_PATH=stderr_log_path,
50
- NODE_NUM=PBS_setting["node_num"],
51
- CORE_NUM=PBS_setting["core_num"],
52
- ENV_SETTINGS=env_settings,
53
- WORK_PATH=dir_path,
54
- WORK_COMMAND=exec_cmd
55
- )
56
-
57
- f.write(template)
58
-
59
- logger.info(
60
- f"PBS script has been generated and write to file {dir_path}/run.sh. Check it and submit it to PBS system to run wrfrun.")
61
-
62
-
63
- def get_core_num() -> int:
64
- """Read core num from config.
65
-
66
- Returns:
67
- int: Core number.
68
- """
69
- return WRFRUNConfig["core_num"]
70
-
71
-
72
- def in_pbs() -> bool:
73
- """Check if we're in a PBS work.
74
-
75
- Returns:
76
- bool: True if we're in, False is we aren't.
77
- """
78
- # check if we're a PBS task
79
- if "PBS_ENVIRONMENT" in environ:
80
- # we're in a PBS task
81
- return True
82
- else:
83
- return False
84
-
85
-
86
- __all__ = ["prepare_pbs_script", "get_core_num", "in_pbs"]
@@ -1,16 +0,0 @@
1
- #!/bin/bash
2
- #PBS -q batch
3
- ##PBS -q odasc
4
- #PBS -N py-wrfrun
5
- #PBS -o {STDOUT_LOG_PATH}
6
- #PBS -e {STDERR_LOG_PATH}
7
- #PBS -l nodes={NODE_NUM}:ppn={CORE_NUM}
8
- #PBS -l walltime=9999:00:00
9
-
10
- ulimit -s unlimited
11
-
12
- {ENV_SETTINGS}
13
-
14
- cd {WORK_PATH}
15
-
16
- {WORK_COMMAND}
wrfrun/workspace.py DELETED
@@ -1,88 +0,0 @@
1
- """
2
- This file contains functions to interact with WRF workspace
3
- """
4
-
5
- from os import listdir, makedirs, symlink
6
- from os.path import exists
7
-
8
- from .core import WRFRUNConfig
9
- from .utils import check_path, logger
10
-
11
-
12
- def prepare_workspace():
13
- """Initialize workspace
14
-
15
- """
16
- logger.info(f"Initialize workspace...")
17
-
18
- # extract WRF path
19
- wrf_config = WRFRUNConfig.get_model_config("wrf")
20
- wps_path = wrf_config["wps_path"]
21
- wrf_path = wrf_config["wrf_path"]
22
- wrfda_path = wrf_config["wrfda_path"]
23
-
24
- WRFRUN_TEMP_PATH = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_TEMP_PATH)
25
- WORK_PATH = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_WORKSPACE_PATH)
26
- REPLAY_WORK_PATH = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_REPLAY_WORK_PATH)
27
- WPS_WORK_PATH = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WPS_WORK_PATH)
28
- WRF_WORK_PATH = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRF_WORK_PATH)
29
- WRFDA_WORK_PATH = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFDA_WORK_PATH)
30
- output_path = WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_OUTPUT_PATH)
31
-
32
- # check folder
33
- check_path(WRFRUN_TEMP_PATH)
34
- check_path(REPLAY_WORK_PATH, force=True)
35
- check_path(output_path)
36
-
37
- if exists(wrfda_path):
38
- WRFRUNConfig.USE_WRFDA = True
39
-
40
- # create folder to run WPS, and WRF
41
- # check the path
42
- if not (exists(wps_path) and exists(wrf_path)):
43
- logger.error(f"Your WPS or WRF path is wrong")
44
- raise FileNotFoundError(f"Your WPS or WRF path is wrong")
45
-
46
- # remove old file
47
- if exists(WORK_PATH):
48
- logger.info(f"Remove old files...")
49
- check_path(WPS_WORK_PATH, f"{WPS_WORK_PATH}/outputs",
50
- WRF_WORK_PATH, WRFDA_WORK_PATH, force=True)
51
- logger.info(f"Link essential files...")
52
-
53
- # link {wps_path}/*
54
- # collect file except folder geogrid
55
- file_list = [
56
- x for x in listdir(wps_path) if x not in ["geogrid", "namelist.wps"]
57
- ]
58
- for file in file_list:
59
- symlink(f"{wps_path}/{file}", f"{WPS_WORK_PATH}/{file}")
60
-
61
- # create folder geogrid and link default GEOGRID file
62
- makedirs(f"{WPS_WORK_PATH}/geogrid")
63
- symlink(
64
- f"{wps_path}/geogrid/GEOGRID.TBL", f"{WPS_WORK_PATH}/geogrid/GEOGRID.TBL"
65
- )
66
-
67
- # # link {wrf_path}/run/*, except namelist.input
68
- file_list = [x for x in listdir(
69
- f"{wrf_path}/run") if not x.startswith("namelist")]
70
- for file in file_list:
71
- symlink(f"{wrf_path}/run/{file}", f"{WRF_WORK_PATH}/{file}")
72
-
73
- if WRFRUNConfig.USE_WRFDA:
74
- # # link {wrfda_path}/bin/*.exe
75
- file_list = ["da_wrfvar.exe", "da_update_bc.exe"]
76
- for file in file_list:
77
- symlink(f"{wrfda_path}/var/build/{file}", f"{WRFDA_WORK_PATH}/{file}")
78
-
79
- # # link {wrfda_path}/var/run/*
80
- file_list = listdir(f"{wrfda_path}/var/run")
81
- for file in file_list:
82
- symlink(f"{wrfda_path}/var/run/{file}", f"{WRFDA_WORK_PATH}/{file}")
83
-
84
- # # link {wrfda_path}/run/LANDUSE.TBL
85
- symlink(f"{wrfda_path}/run/LANDUSE.TBL", f"{WRFDA_WORK_PATH}/LANDUSE.TBL")
86
-
87
-
88
- __all__ = ["prepare_workspace"]
@@ -1,46 +0,0 @@
1
- wrfrun-0.1.7.dist-info/METADATA,sha256=nrPBmS0UxcjIiCN9wLyL798-r3OKpirBJUPlWrzobw8,2912
2
- wrfrun-0.1.7.dist-info/WHEEL,sha256=5J4neoE7k6LMgx4Fz1FHgBiO3YevhJGtNQ3muDrdLQM,75
3
- wrfrun/__init__.py,sha256=l2zGk2qDWa3EXIlwvzqBYZHOU9273TN75Rmvx_7PAYM,58
4
- wrfrun/data.py,sha256=AjkDSZqkLROnWLw9qDOBUctoQmJ3R1bkfjnPzLMjPfs,14751
5
- wrfrun/pbs.py,sha256=gzRHbYqpU-c8lynu39TUKNvmPntvrPwfQVxK337yvjw,2454
6
- wrfrun/run.py,sha256=0mvuI98gLjq1gP1eaLUZiU1LJMCjtL668aKZTwu3n2g,9114
7
- wrfrun/utils.py,sha256=v3ZRu3Rd8-pZjo7I0PrJtgBN1zIBAt_nVPs0BP_DFwY,8118
8
- wrfrun/workspace.py,sha256=5tWIIFxwAE4hkdg_wJALGDc3P0bfwb_IRTIyPIjN-tE,3105
9
- wrfrun/core/__init__.py,sha256=bf9Fp6VS5i9xB10lazYBOkJapF2jnQpyiB6qucVjp0I,107
10
- wrfrun/core/base.py,sha256=S9Mqr3LOpos0CP0TsFwtCQl0tLIObIhjX7VxjS0LRDY,23172
11
- wrfrun/core/config.py,sha256=v7zdhAthlMmjv_BWINxkmgNHLvKZdzQhgM5B-Nlsl7M,23795
12
- wrfrun/core/error.py,sha256=fCWVC4-GTyDH2obzu9-D_bzF8_uzqZoUi7Ffy0B5qoc,1324
13
- wrfrun/core/replay.py,sha256=oyV9QppZG99GbAksQqoRxeBQ3jjXU-7YqkpxHRyfBvc,3229
14
- wrfrun/core/server.py,sha256=KK_yj4J-5F_s-rKO5FK7e8WojsnuZMbhWtMceWYbaBY,6524
15
- wrfrun/extension/__init__.py,sha256=alIDGBnxWH4JvP-UW-7N99seBBi0r1GV1h8f1ERFBec,21
16
- wrfrun/extension/utils.py,sha256=OBIAlAXakbh1QhrF2BFlYAFV062ZfJjX0mYJkmcU_RI,2751
17
- wrfrun/extension/littler/__init__.py,sha256=pG-YPVG0gJIJ6s4xcAz9S_CnUxpUcz33wl9eNUSgxGk,20
18
- wrfrun/extension/littler/utils.py,sha256=TsN3GiAFszPWF7RNM_hYdARRY_OLL8mYm87UyZupUtU,21615
19
- wrfrun/model/__init__.py,sha256=lQNNnh3evXZytLAjdnhlIEFWerP1L0XAgDAUQhqIRyE,119
20
- wrfrun/model/base.py,sha256=WnVNu12ICJgThfZR7kK6_XLCQWVYFsHrdyAz8wl_YRc,218
21
- wrfrun/model/plot.py,sha256=ATG5nl5kV8YfoeNFIPLCUnnIQIrfIFNGPb9d8raM6S0,1582
22
- wrfrun/model/utils.py,sha256=Pyj9D9NMKw3wQcZcM7pJaLG09Vov447AxFKoVeZZU2s,1155
23
- wrfrun/model/wrf/__init__.py,sha256=T3S1BD9QDoW4uq871QW4_8-2BvCRWYEecz71EcdbMaI,136
24
- wrfrun/model/wrf/core.py,sha256=FEzRXUKK5dENxev3wR_GON5n1Zxq4Hj-Bs_BNP7P_ok,32134
25
- wrfrun/model/wrf/exec_wrap.py,sha256=gIsGZDAjzRzxt24eo8t-laIK4UBiyKf_ysfAZLlE1og,3918
26
- wrfrun/model/wrf/geodata.py,sha256=X9OUOm0__5NI7sl2z1F9_ur5wZ4P0HkpBNcRZQYKof0,9740
27
- wrfrun/model/wrf/_metgrid.py,sha256=i2qILM_1LkdnBZqXXL3swVhMRvhFvq4bOcRPGI6kSzg,2248
28
- wrfrun/model/wrf/namelist.py,sha256=t_JuWYj4oNNVwzTMKo6BNlv2LIq4t3JC7ZgVkaKfNbA,14923
29
- wrfrun/model/wrf/_ndown.py,sha256=ZcWttGXiT5FzGCAohmbeNU6bi8GUOUleiTK0ivn2BaI,1548
30
- wrfrun/model/wrf/scheme.py,sha256=F7HxoaNkkPpjkse5t9sGS3CJDvn_yBdHoaCG7WLdbqY,8524
31
- wrfrun/model/wrf/vtable.py,sha256=0V4fo0Limnx4oJ2NByq_eHPzj8L4mnHNlrKL34Buw1A,2432
32
- wrfrun/plot/__init__.py,sha256=9Kn0IgkX10sHEqHJwk7mZV-dP14XMNcvXN8znO89FIw,19
33
- wrfrun/plot/wps.py,sha256=AQ1B6llNUrPU3PR8XKNLSzs_H-v60a0Wep-8Mcto6NM,5319
34
- wrfrun/res/__init__.py,sha256=YBcVaM2EZZJkDDvyKdk-WZmcFQoTFENZKCwcIQzEf3I,1133
35
- wrfrun/res/config.toml.template,sha256=aVXCSzhbV3P-MQCZOk2g-y0auRmqgr3jW920W3wks9g,4386
36
- wrfrun/res/run.sh.template,sha256=ZN7k0a9ONOtZUQ67JiTva-0DNVJG5O7BdOXQ8-LCscs,247
37
- wrfrun/res/extension/plotgrids.ncl,sha256=B0mvH1H1j_w7EEana9HmU1XJZtG0w9IccQ54zXpbQG0,7546
38
- wrfrun/res/namelist/namelist.input.da_wrfvar.template,sha256=Cwc-XPu_spJeQte4duWrulPBOLRMEBtn0mIn0pgMmKY,4912
39
- wrfrun/res/namelist/namelist.input.dfi.template,sha256=E7MVbIvMopkAM7xGUC4vniC1WOUVbIbdLfkTKHqzX_o,6591
40
- wrfrun/res/namelist/namelist.input.real.template,sha256=DDUiArtBFmzBwVjkZW4NOrBR34eIOk1vV0VsyL0stsk,6214
41
- wrfrun/res/namelist/namelist.input.wrf.template,sha256=myrKi79sQ8ABBsmQJkcgN0WLbWJdtMVPIjuAC1MTMuM,6213
42
- wrfrun/res/namelist/namelist.wps.template,sha256=HlA7-SHs4C-cKRb3h6D0Kl1Y-5VSJ1Lw9hLiXWGAN0Q,1017
43
- wrfrun/res/namelist/parame.in.template,sha256=vR8JSix20FAKGqj6jK8QuEAeWkGvg8_iptdVlzjPX6o,259
44
- wrfrun/res/job_scheduler/pbs.template,sha256=m7eyvZkzQRpjs43CvSeZ1biHYNyEJJkgXt3IU5ZhCmg,148
45
- wrfrun/res/job_scheduler/slurm.template,sha256=BrKL8DcHfpFfv0y0z7Qe_cqjwfzMyF-3V6vM72ehr9Y,312
46
- wrfrun-0.1.7.dist-info/RECORD,,
File without changes