wrfrun 0.2.0__py3-none-any.whl → 0.3.0__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 (66) hide show
  1. wrfrun/__init__.py +8 -3
  2. wrfrun/cli.py +69 -29
  3. wrfrun/core/__init__.py +27 -10
  4. wrfrun/core/_config.py +308 -0
  5. wrfrun/core/_constant.py +236 -0
  6. wrfrun/core/_exec_db.py +105 -0
  7. wrfrun/core/_namelist.py +287 -0
  8. wrfrun/core/_record.py +178 -0
  9. wrfrun/core/_resource.py +172 -0
  10. wrfrun/core/base.py +132 -406
  11. wrfrun/core/core.py +196 -0
  12. wrfrun/core/error.py +28 -2
  13. wrfrun/core/replay.py +10 -96
  14. wrfrun/core/server.py +52 -27
  15. wrfrun/core/type.py +171 -0
  16. wrfrun/data.py +304 -139
  17. wrfrun/extension/goos_sst/__init__.py +2 -2
  18. wrfrun/extension/goos_sst/core.py +9 -14
  19. wrfrun/extension/goos_sst/res/__init__.py +0 -1
  20. wrfrun/extension/goos_sst/utils.py +50 -44
  21. wrfrun/extension/littler/core.py +105 -88
  22. wrfrun/extension/utils.py +4 -3
  23. wrfrun/log.py +117 -0
  24. wrfrun/model/__init__.py +11 -7
  25. wrfrun/model/constants.py +52 -0
  26. wrfrun/model/palm/__init__.py +30 -0
  27. wrfrun/model/palm/core.py +145 -0
  28. wrfrun/model/palm/namelist.py +33 -0
  29. wrfrun/model/plot.py +99 -119
  30. wrfrun/model/type.py +116 -0
  31. wrfrun/model/utils.py +9 -20
  32. wrfrun/model/wrf/__init__.py +4 -9
  33. wrfrun/model/wrf/core.py +246 -161
  34. wrfrun/model/wrf/exec_wrap.py +13 -12
  35. wrfrun/model/wrf/geodata.py +116 -100
  36. wrfrun/model/wrf/log.py +103 -0
  37. wrfrun/model/wrf/namelist.py +90 -73
  38. wrfrun/model/wrf/plot.py +102 -0
  39. wrfrun/model/wrf/scheme.py +108 -52
  40. wrfrun/model/wrf/utils.py +39 -25
  41. wrfrun/model/wrf/vtable.py +35 -3
  42. wrfrun/plot/__init__.py +20 -0
  43. wrfrun/plot/wps.py +90 -73
  44. wrfrun/res/__init__.py +103 -5
  45. wrfrun/res/config/config.template.toml +8 -0
  46. wrfrun/res/config/palm.template.toml +23 -0
  47. wrfrun/run.py +105 -77
  48. wrfrun/scheduler/__init__.py +1 -0
  49. wrfrun/scheduler/lsf.py +3 -2
  50. wrfrun/scheduler/pbs.py +3 -2
  51. wrfrun/scheduler/script.py +17 -5
  52. wrfrun/scheduler/slurm.py +3 -2
  53. wrfrun/scheduler/utils.py +14 -2
  54. wrfrun/utils.py +88 -199
  55. wrfrun/workspace/__init__.py +8 -5
  56. wrfrun/workspace/core.py +20 -12
  57. wrfrun/workspace/palm.py +137 -0
  58. wrfrun/workspace/wrf.py +16 -15
  59. wrfrun-0.3.0.dist-info/METADATA +240 -0
  60. wrfrun-0.3.0.dist-info/RECORD +78 -0
  61. wrfrun/core/config.py +0 -923
  62. wrfrun/model/base.py +0 -14
  63. wrfrun-0.2.0.dist-info/METADATA +0 -68
  64. wrfrun-0.2.0.dist-info/RECORD +0 -62
  65. {wrfrun-0.2.0.dist-info → wrfrun-0.3.0.dist-info}/WHEEL +0 -0
  66. {wrfrun-0.2.0.dist-info → wrfrun-0.3.0.dist-info}/entry_points.txt +0 -0
wrfrun/model/type.py ADDED
@@ -0,0 +1,116 @@
1
+ """
2
+ wrfrun.model.type
3
+ #################
4
+
5
+ Definition of types used in ``wrfrun.model``.
6
+
7
+ .. autosummary::
8
+ :toctree: generated/
9
+
10
+ DomainSetting
11
+ """
12
+
13
+ from typing import Literal, TypedDict, Union
14
+
15
+
16
+ class DomainSetting(TypedDict):
17
+ """
18
+ Domain settings which can be used to create a projection.
19
+
20
+ .. py:attribute:: resolution_x
21
+ :type: int
22
+
23
+ Spacing of the domain 1 grid points along the longitude direction, unit: meter.
24
+
25
+ .. py:attribute:: resolution_y
26
+ :type: int
27
+
28
+ Spacing of the domain 1 grid points along the latitude direction, unit: meter.
29
+
30
+ .. py:attribute:: points_x
31
+ :type: Union[list[int], tuple[int]]
32
+
33
+ Number of the grid points along the longitude direction of each domain.
34
+
35
+ .. py:attribute:: points_y
36
+ :type: Union[list[int], tuple[int]]
37
+
38
+ Number of the grid points along the latitude direction of each domain.
39
+
40
+ .. py:attribute:: x_parent_index
41
+ :type: Union[list[int], tuple[int]]
42
+
43
+ Corresponding x index in the parent grid of the first point.
44
+
45
+ .. py:attribute:: y_parent_index
46
+ :type: Union[list[int], tuple[int]]
47
+
48
+ Corresponding y index in the parent grid of the first point.
49
+
50
+ .. py:attribute:: domain_num
51
+ :type: int
52
+
53
+ Domain number.
54
+
55
+ .. py:attribute:: grid_spacing_ratio
56
+ :type: Union[list[int], tuple[int]]
57
+
58
+ Ratio of the grid resolution of each domain compared to the domain 1.
59
+
60
+ .. py:attribute:: projection_type
61
+ :type: Literal["lambert", "polar", "mercator", "lat-lon"]
62
+
63
+ Projection type.
64
+
65
+ .. py:attribute:: reference_lat
66
+ :type: Union[int, float]
67
+
68
+ Reference latitude.
69
+
70
+ .. py:attribute:: reference_lon
71
+ :type: Union[int, float]
72
+
73
+ Reference longitude.
74
+
75
+ .. py:attribute:: true_lat1
76
+ :type: Union[int, float]
77
+
78
+ True latitude (1:1 scale).
79
+
80
+ .. py:attribute:: true_lat2
81
+ :type: Union[int, float]
82
+
83
+ True latitude (1:1 scale).
84
+
85
+ .. py:attribute:: stand_lon
86
+ :type: Union[int, float]
87
+
88
+ Standard longitude.
89
+ """
90
+
91
+ # generally refers to the spacing of the parent grid points along the latitude, unit: meter
92
+ resolution_x: int
93
+ # spacing of the parent grid points along the longitude, unit: meter
94
+ resolution_y: int
95
+ # generally refers to the number of the grid points along the latitude.
96
+ points_x: Union[list[int], tuple[int]]
97
+ # number of the grid points along the longitude.
98
+ points_y: Union[list[int], tuple[int]]
99
+ # corresponding index in the parent grid of the first point.
100
+ x_parent_index: Union[list[int], tuple[int]]
101
+ y_parent_index: Union[list[int], tuple[int]]
102
+ # domain number
103
+ domain_num: int
104
+ # ratio of the grid point spacing.
105
+ grid_spacing_ratio: Union[list[int], tuple[int]]
106
+ # projection type
107
+ projection_type: Literal["lambert", "polar", "mercator", "lat-lon"]
108
+ # reference point, true longitude and latitude
109
+ reference_lat: Union[int, float]
110
+ reference_lon: Union[int, float]
111
+ true_lat1: Union[int, float]
112
+ true_lat2: Union[int, float]
113
+ stand_lon: Union[int, float]
114
+
115
+
116
+ __all__ = ["DomainSetting"]
wrfrun/model/utils.py CHANGED
@@ -10,12 +10,8 @@ Utility functions used by models.
10
10
  clear_model_logs
11
11
  """
12
12
 
13
- from os import listdir
14
- from shutil import move
15
-
16
- from ..core import get_wrfrun_config
17
- from ..utils import check_path, logger
18
- from ..workspace.wrf import get_wrf_workspace_path
13
+ from ..core import WRFRUN
14
+ from .wrf.log import clear_wrf_logs
19
15
 
20
16
 
21
17
  def clear_model_logs():
@@ -23,22 +19,15 @@ def clear_model_logs():
23
19
  This function can automatically collect unsaved log files,
24
20
  and save them to the corresponding output directory of the ``Executable``.
25
21
  """
26
- WRFRUNConfig = get_wrfrun_config()
27
- work_status = WRFRUNConfig.WRFRUN_WORK_STATUS
28
- work_path = WRFRUNConfig.parse_resource_uri(get_wrf_workspace_path("wrf"))
29
-
30
- log_files = [x for x in listdir(work_path) if x.startswith("rsl.") or x.endswith(".log")]
31
-
32
- if len(log_files) > 0:
33
- logger.warning(f"Found unprocessed log files of {work_status}")
34
-
35
- log_save_path = f"{WRFRUNConfig.parse_resource_uri(WRFRUNConfig.WRFRUN_OUTPUT_PATH)}/{work_status}/logs"
36
- check_path(log_save_path)
22
+ WRFRUNConfig = WRFRUN.config
37
23
 
38
- for _file in log_files:
39
- move(f"{work_path}/{_file}", f"{log_save_path}/{_file}")
24
+ func_map = {
25
+ "wrf": clear_wrf_logs
26
+ }
40
27
 
41
- logger.warning(f"Unprocessed log files of {work_status} has been saved to {log_save_path}, check it")
28
+ for _model in func_map:
29
+ if _model in WRFRUNConfig["model"] and WRFRUNConfig["model"][_model]["use"]:
30
+ func_map[_model]()
42
31
 
43
32
 
44
33
  __all__ = ["clear_model_logs"]
@@ -8,34 +8,29 @@ Submodules
8
8
  **********
9
9
 
10
10
  ============================================ ==================================================================================
11
- :doc:`_metgrid </api/model.wrf._metgrid>` Utility functions used by :class:`MetGrid <core.MetGrid>`.
12
- :doc:`_ndown </api/model.wrf._ndown>` Utility functions used by :class:`NDown <core.NDown>`.
13
11
  :doc:`core </api/model.wrf.core>` Core implementation of WRF model.
14
12
  :doc:`exec_wrap </api/model.wrf.exec_wrap>` Function wrappers for ``Executable`` defined in :doc:`core </api/model.wrf.core>`.
15
13
  :doc:`geodata </api/model.wrf.geodata>` Utility functions to read / write geographical static datas.
14
+ :doc:`log </api/model.wrf.log>` Functions to parse and clear WPS/WRF model logs.
16
15
  :doc:`namelist </api/model.wrf.namelist>` Functions to process WPS / WRF namelist files.
17
16
  :doc:`plot </api/model.wrf.plot>` Functions to create projection from namelist settings to plot simulation domain.
18
17
  :doc:`scheme </api/model.wrf.scheme>` Scheme ``dataclass``.
18
+ :doc:`utils </api/model.wrf.utils>` Utility functions used by wrf model part.
19
19
  :doc:`vtable </api/model.wrf.vtable>` Vtable files ``dataclass``.
20
20
  ============================================ ==================================================================================
21
21
 
22
- .. autosummary::
23
- :toctree: generated/
24
-
25
- prepare_namelist
26
-
27
22
  .. toctree::
28
23
  :maxdepth: 1
29
24
  :hidden:
30
25
 
31
- _metgrid <model.wrf._metgrid>
32
- _ndown <model.wrf._ndown>
33
26
  core <model.wrf.core>
34
27
  exec_wrap <model.wrf.exec_wrap>
35
28
  geodata <model.wrf.geodata>
29
+ log <model.wrf.log>
36
30
  namelist <model.wrf.namelist>
37
31
  plot <model.wrf.plot>
38
32
  scheme <model.wrf.scheme>
33
+ utils <model.wrf.utils>
39
34
  vtable <model.wrf.vtable>
40
35
  """
41
36