Skip to content

Commit b876e66

Browse files
committed
New release 0.8.6
Included '--ulevels' command line argument/ option to allow user to specify their own list of levels. It should be between 50-1000hPa levels only. Removed `_version.py` file from the source. This would be created automatically during build process. Update to Documentation to reflect two added options.
1 parent dd6dcb3 commit b876e66

13 files changed

+155
-29
lines changed

.github/workflows/release-pip.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
pip install setuptools wheel twine setuptools-git-versioning build
1919
- name: Build Package
2020
run: |
21-
#echo "Updating '_version' file with: '$(setuptools-git-versioning)'..."
22-
#echo -e "# Generated by wrfplot build file. Do not edit it manually...\n__version__ = version = '$(setuptools-git-versioning)'" > _version.py
21+
echo "Updating '_version' file with: '$(setuptools-git-versioning)'..."
22+
echo -e "# Generated by wrfplot build process. Do not edit it manually...\n__version__ = version = '$(setuptools-git-versioning)'" > _version.py
2323
python -m build --sdist
2424
- name: Publish to PyPi
2525
uses: pypa/gh-action-pypi-publish@release/v1.5

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ install_env.txt
1212
dev/
1313
test/
1414
release_check_list*
15+
16+
# Version file is generated during release process in GitHub
17+
_version.py
1518
# docs/
1619

1720
# Distribution / packaging

HISTORY.rst

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
History
33
=======
44

5+
v0.8.6 (2023-02-05)
6+
------------------------
7+
* Included '--ulevels' command line argument/ option to allow user to specify their own list of levels. It should be between 50-1000hPa levels only.
8+
* Removed `_version.py` file from the source. This would be created automatically during build process.
9+
* Update to Documentation to reflect two added options.
10+
511
v0.8.0 (2023-02-02)
612
------------------------
713
* Included '--cmap' command line argument/ option to allow user to specify their own colormap (list supported by wrfplot )

README.md

+36-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
1+
Application License [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
22

3-
[![Linux](https://svgshare.com/i/Zhy.svg)](https://svgshare.com/i/Zhy.svg) [![Windows](https://svgshare.com/i/ZhY.svg)](https://svgshare.com/i/ZhY.svg)
3+
Works on both Linux [![Linux](https://svgshare.com/i/Zhy.svg)](https://svgshare.com/i/Zhy.svg) and Windows [![Windows](https://svgshare.com/i/ZhY.svg)](https://svgshare.com/i/ZhY.svg). Mac OS [![macOS](https://svgshare.com/i/ZjP.svg)](https://svgshare.com/i/ZjP.svg) support is available via `conda`.
44

5-
[![Documentation Status](https://readthedocs.org/projects/wrfplot/badge/?version=latest)](https://wrfplot.readthedocs.io/en/latest/?badge=latest)
5+
Status of Documentation [![Documentation Status](https://readthedocs.org/projects/wrfplot/badge/?version=latest)](https://wrfplot.readthedocs.io/en/latest/?badge=latest)
66

7-
[![PyPI Version](https://badge.fury.io/py/ansicolortags.svg)](https://pypi.python.org/pypi/wrfplot/) [![PyPi Downloads](https://static.pepy.tech/personalized-badge/wrfplot?period=total&units=international_system&left_color=blue&right_color=brightgreen&left_text=Pip%20Downloads)](https://pepy.tech/project/wrfplot)
7+
Details of PyPi package [![PyPI Version](https://badge.fury.io/py/ansicolortags.svg)](https://pypi.python.org/pypi/wrfplot/) [![PyPi Downloads](https://static.pepy.tech/personalized-badge/wrfplot?period=total&units=international_system&left_color=blue&right_color=brightgreen&left_text=Pip%20Downloads)](https://pepy.tech/project/wrfplot)
88

9-
![Build and Release](https://github.com/wxguy/wrfplot/actions/workflows/release-github.yaml/badge.svg) ![PyPi Package](https://github.com/wxguy/wrfplot/actions/workflows/release-pip.yaml/badge.svg)
9+
Status of builds ![Build and Release](https://github.com/wxguy/wrfplot/actions/workflows/release-github.yaml/badge.svg) ![PyPi Package](https://github.com/wxguy/wrfplot/actions/workflows/release-pip.yaml/badge.svg)
10+
11+
Conda details ![Conda Version](https://anaconda.org/conda-forge/wrfplot/badges/version.svg) ![Last updated on](https://anaconda.org/conda-forge/wrfplot/badges/latest_release_date.svg) ![Works on Windows, Linux and Mac](https://anaconda.org/conda-forge/wrfplot/badges/platforms.svg) ![Download Counts](https://anaconda.org/conda-forge/wrfplot/badges/downloads.svg)
1012

1113
## About wrfplot
1214

@@ -22,11 +24,26 @@ Documentation of this project is located at https://wrfplot.readthedocs.io.
2224

2325
A typical use case of wrfplot would be to include as part of your WRF model run framework to plotting of variables immediately after the model run is completed. The other use case would be to use it for producing publication quality 2D maps which does not much tweaking for your publication.
2426

25-
## Installation
27+
## Installation on all Platforms (Windows, Linux and Mac OS)
28+
29+
Support for all platforms is provided through `conda-forge`. If you have already conda installed, then following command is enough to install `wrfplot`:
30+
31+
```
32+
conda install -c cond-forge wrfplot
33+
```
34+
Check your installation by typing following command which should show the version number:
35+
36+
```
37+
wrfplot --version
38+
0.1.0
39+
```
40+
2641

27-
Since it is intended to be used as command line, the application is distributed as stand-alone on both Linux and Windows. You must download the correct version of application installer or setup file. Both are described below:
42+
## Binary (standalone) Installation
2843

29-
### Windows
44+
Since it is intended to be used as command line, the application is also distributed as stand-alone on both Linux and Windows. You must download the correct version of application installer or setup file. Both are described below:
45+
46+
### Windows Only
3047

3148
Go to https://github.com/wxguy/wrfplot/releases and look for latest release. The Windows setup executable will have name `wrfplot-windows-64bit.exe`. Click on the link and download it to local disk. The rest of the installation procedure is same as you do for any other windows setup files. Once installed Check if installation is successful by typing following command in `cmd` window which should not produce any errors:
3249

@@ -35,9 +52,9 @@ wrfplot --version
3552
0.1.0
3653
```
3754

38-
### Linux
55+
### Linux Only
3956

40-
Go to https://github.com/wxguy/wrfplot/releases and look for latest release. The Linux installer will have name `wrfplot-linux-64bit.run`. Click on the link and download it to local disk. Thereafter execute the below command (assuming that the Linux installer is downloaded at `~/Downloads`):
57+
You must have at least `Ubuntu 22.04` or above for this to work. There is no additional packages or admin rights are required to install this package. Go to https://github.com/wxguy/wrfplot/releases and look for latest release. The Linux installer will have name `wrfplot-linux-64bit.run`. Click on the link and download it to local disk. Thereafter execute the below command (assuming that the Linux installer is downloaded at `~/Downloads`):
4158

4259
```
4360
bash ~/Downloads/wrfplot-linux-64bit.run
@@ -65,6 +82,10 @@ wrfplot --version
6582
0.1.0
6683
```
6784

85+
### Mac OS Only
86+
87+
At the moment, Mac OS support is not available in binary format. You can install `wrfplot` using method mentioned above.
88+
6889
## How to use?
6990

7091
Please refer to https://wrfplot.readthedocs.io for complete documentation on how to use `wrfplot` application.
@@ -74,12 +95,12 @@ Please refer to https://wrfplot.readthedocs.io for complete documentation on how
7495

7596
Add following command line options:
7697

77-
* `--levels ` : To plot upper level data as per user defined levels
78-
* `--cmap` : Use user provided colour map
79-
* `--contours` : Control contour levels
98+
* ~~`--cmap` : Use user provided colour map~~
99+
* ~~`--ulevels ` : To plot upper level data as per user defined upper levels~~
100+
* `--clevels ` : Control contour levels
80101
* `--animation` : Create animation for specific variable(s) in GIF for max compatibility
81-
* `--fig-format`: Save image in specific file format
82-
* `--list-fig-format` : List all supported image file format
102+
* `--save-format`: Save image in specific file format
103+
* `--list-save-format` : List all supported image file format
83104
* `--title` : Custom title for the plot
84105
* `--title-font-size` : Specify title font size
85106

build_exe.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
geos_trgt_dir = os.path.join("shapely", "DLLs", "\\")
5959
compiler = "--mingw64"
6060
nutika_exe_name = 'wrfplot.exe' # os.path.join(output_dir, 'wrfplot.dist', 'wrfplot.exe')
61+
frozen_version_file = os.path.join(project_root, "build", "windows", "wrfplot", "_version.py")
6162

6263
elif platform.system() == "Linux":
6364
output_dir = os.path.join(project_root, 'build', 'linux')
@@ -68,6 +69,7 @@
6869
geos_trgt_dir = "shapely/.libs/"
6970
compiler = ""
7071
nutika_exe_name = 'wrfplot' #os.path.join(output_dir, 'wrfplot.dist', 'wrfplot')
72+
frozen_version_file = os.path.join(project_root, "build", "linux", "wrfplot", "_version.py")
7173

7274
# Tested on Miniconda Python 3.10.4
7375
# This is the place one need to be carefull. For wrfplot project, netcdf, shapely and pyproj modules were not detected
@@ -351,6 +353,7 @@ def main():
351353
execute_cmd("pyinstaller --noconfirm --distpath " + output_dir + " wrfplot.spec")
352354

353355
# test_wrfplt_exe()
356+
update_verion()
354357
create_makeself()
355358

356359

@@ -374,14 +377,15 @@ def build_sdist():
374377
else:
375378
sys.exit("Failure to build source distribution package.\n Please correct the issue and build the executable again.")
376379

377-
def update_varion():
380+
def update_verion():
378381
if which("setuptools-git-versioning"):
379382
VERSION = subprocess.check_output(["setuptools-git-versioning"]).strip().decode("utf-8").replace("v", "")
380383
else:
381384
VERSION = subprocess.check_output(["git", "describe", "--tags"]).strip().decode("utf-8").replace("v", "")
382385

383386
print("Updating varion information to file with :", VERSION)
384-
with open(os.path.join(project_root, "wrfplot", "_version.py"), "w") as _file:
387+
print("Version information will be updated in : " + frozen_version_file)
388+
with open(frozen_version_file, "w") as _file:
385389
_file.write("# Generated by wrfplot build file. Do not edit it manually...\n")
386390
_file.write("__version__ = version = " + quote(VERSION))
387391
_file.write('\n')
@@ -394,7 +398,6 @@ def update_varion():
394398
compile_module = "pyinstaller"
395399
# Check if we are running the script in correct filesystem
396400
check_fs()
397-
update_varion()
398401
clean_dirs()
399402
build_sdist()
400403
# sys.exit()
140 KB
Loading
291 KB
Loading

docs/examples.rst

+13
Large diffs are not rendered by default.

docs/usage.rst

+21-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
How to use wrfplot
33
==================
44

5+
Basic Usage
6+
~~~~~~~~~~~~
7+
58
The first step in plotting diagnostic variable to find what all variables are supported by ``wrfplot`` application. This is required as the application would accept variable names only in certain string format. Therefore, you should list and review the name of variable by issuing following command in terminal::
69

710
$ wrfplot --list-vars
@@ -53,7 +56,7 @@ Looking at the above output, you will understand that it looks similar to what i
5356

5457
Now, lets go ahead and start plotting the variable "2m Relative Humidity" named as "rh2"::
5558

56-
python wrfplot.py --input ../../test/wrfout_d01_2016-03-30_00_00_00 --var "rh2" --output ~/Documents/wrfplot_output
59+
python wrfplot.py --input ../../test/wrfout_d01_2016-03-30_00_00_00 --vars "rh2" --output ~/Documents/wrfplot_output
5760
5861
*** Initialising plotting for variable : "rh2" ***
5962

@@ -66,12 +69,27 @@ In the above command, we have provided three options where:
6669

6770
* ``--input`` is the path to WRF model output NetCDF file.
6871
* ``--output`` is the path to output directory where the plotted images are required to be saved. If the path to directory does not exist, then wrfplot will try to create it.
69-
* ``--var`` is the variable name we need the wrfplot to plot.
72+
* ``--vars`` is the variable name we need the wrfplot to plot.
7073

7174
When the wrfplot start plotting the variable for all times, you can see the progress of operation through progress bar at the bottom of terminal. The plotted output for variable will look like below:
7275

7376
.. image:: _static/images/rh2_30-03-2016_12_00.png
7477
:width: 800
7578
:alt: Alternative text
7679

77-
You can see from the above image that all the required fields such as title, colour map, colour bar range, model cycle and forecast validity are automatically picked up by wrfplot. Now onwards, you can only change the ``--var`` with different name to plot new variables.
80+
You can see from the above image that all the required fields such as title, colour map, colour bar range, model cycle and forecast validity are automatically picked up by wrfplot. Now onwards, you can only change the ``--vars`` with different name to plot new variables.
81+
82+
Plotting Upper Atmospheric Variables
83+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84+
85+
`wrfplot` supports a few upper atmospheric variables. These variables are indicated with ``u_`` tag for ease of identification. By default, the plot for upper atmospheric variables would be plotted for ``925, 850, 700, 600, 500, 400, 300 & 200hPa``. The upper levels can be controlled using ``--ulevels`` though. If you want to plot upper winds, you can specify the variable with following command::
86+
87+
$ wrfplot --vars "u_winds" --input ../../test/wrfout_d01_2016-03-30_00_00_00 --vars "rh2" --output ~/Documents/wrfplot_output
88+
89+
Note that the wrf output file resolution is very high. However, `wrfplot` automatically calculates the correct resolution and size to fit the wind barbs within plot area. The above command would produce the plot as indicated above. Only 400hPa level plot is indicated below to ensure that page is not loaded with only images.
90+
91+
.. image:: _static/images/u_winds_400hpa.png
92+
:width: 800
93+
:alt: Alternative text
94+
95+
You can also control various par of plotting with additional command line options. They are described in next page.

tests/test.py

+11
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ def plot_upper(input_path, output_dir):
6464
print('Failed to complete upper atmospheric plots successfully...')
6565
return False
6666

67+
def test(input_path, output_dir):
68+
cmd_options = [wrfplot_path, '--vars', 'u_winds,dummy,u_rh', '--ulevels', '900,450,dummy', '--input', input_path, '--output', output_dir]
69+
if os.system('python ' + " ".join(cmd_options)) == 0:
70+
print('Successfully completed upper atmospheric plots...')
71+
return True
72+
else:
73+
print('Failed to complete upper atmospheric plots successfully...')
74+
return False
75+
76+
6777
if __name__ == "__main__":
6878
test_file_path = os.path.realpath(__file__)
6979
wrf_input_path = os.path.join(os.path.dirname(test_file_path), '..', '..', '..', 'WRF_TEST_FILES', 'wrfout_d02_2016-03-31_00_00_00')
@@ -74,4 +84,5 @@ def plot_upper(input_path, output_dir):
7484
clean_cartopy_data_dir()
7585
plot_sfc_data(input_path=wrf_input_path, output_dir=output_plot_dir)
7686
plot_upper(input_path=wrf_input_path, output_dir=output_plot_dir)
87+
test(input_path=wrf_input_path, output_dir=output_plot_dir)
7788

wrfplot/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Generated by wrfplot build file. Do not edit it manually...
2-
__version__ = version = "0.8.1.post1+git.65aea851.dirty"
2+
__version__ = version = "0.8.5.post0+git.dd6dcb3e.dirty"

wrfplot/arguments.py

+46-1
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,49 @@ def validate_cmap(cmap):
160160
else:
161161
print("\nUsing user provided colormap :", utils.quote(cmap))
162162

163-
return cmap
163+
return cmap
164+
165+
166+
def valid_range(ulevel):
167+
""" Validate input pressure level """
168+
if ulevel > 1000:
169+
print("Upper level" + utils.quote(str(ulevel)) + " can not be more than 1000")
170+
return False
171+
elif ulevel < 50:
172+
print("Upper level" + utils.quote(str(ulevel)) + " can not be less than 1000")
173+
return False
174+
else:
175+
return True
176+
177+
178+
def validate_ulevels(ulevels):
179+
"""Validate user provided upper atmospheric levels
180+
181+
Args:
182+
ulevels (list): list of levels provided by user
183+
Results:
184+
list: List of filtered levels. None is returned if nothing compatible with wrfplot
185+
"""
186+
filtered_ulevels = []
187+
if ',' not in str(ulevels):
188+
if ulevels.isdigit():
189+
if valid_range(float(ulevels)) is True:
190+
filtered_ulevels.append(float(ulevels))
191+
elif isinstance(ulevels, str):
192+
print("Upper level can not have string in it. Omitting " + utils.quote(ulevels))
193+
else:
194+
for level in ulevels.split(','):
195+
if level.isdigit():
196+
if valid_range(float(level)) is True:
197+
filtered_ulevels.append(float(level))
198+
elif isinstance(level, str):
199+
print("Upper level can not have string in it. Omitting " + utils.quote(level))
200+
201+
if len(filtered_ulevels) > 0:
202+
output_str_lst = [str(x) for x in filtered_ulevels]
203+
print("Using user provided upper level(s) : " + utils.quote(",".join(output_str_lst)))
204+
return filtered_ulevels
205+
else:
206+
print("\nNone of the levels are valid upper levels.")
207+
print("Defaulting to levels '925, 850, 700, 600, 500, 400, 300 & 200hPa' supported by wrfplot.")
208+
return None

wrfplot/wrfplot.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def plot_upper(self):
305305
if self.U is not None and self.V is not None:
306306
self.U = interplevel(u_var_u_data, pressure, self.ulevel)
307307
self.V = interplevel(u_var_v_data, pressure, self.ulevel)
308-
tqdm.write("\t at level" + utils.quote(self.ulevel))
308+
tqdm.write("\t at level " + utils.quote(self.ulevel) + " hPa")
309309
pbar_lvl.set_description("Plotting Level :", refresh=True)
310310
self.plot_wrf_data(_time=_time, index=index, data_plot=self.var_data, level=self.ulevel)
311311
tqdm.write("\nPlotting of " + utils.quote(self.var) + " completed...\n")
@@ -409,7 +409,7 @@ def _praser():
409409
"Command line application to plot static WRF model prognostic products..."
410410
)
411411
parser = argparse.ArgumentParser(
412-
description=prog_name, epilog="\u00a9 J Sundar, wrf.guy@gmail.com, 2022"
412+
description=prog_name, epilog="\u00a9 J Sundar, wrf.guy@gmail.com, 2023"
413413
)
414414
parser.add_argument(
415415
"--list-vars", action="store_true", help="List variables supported by wrfplot."
@@ -444,7 +444,7 @@ def _praser():
444444
parser.add_argument(
445445
"--list-cmaps",
446446
action="store_true",
447-
help="List colour maps (cmaps) supported by wrfplot.",
447+
help="List colour maps (cmaps) supported by wrfplot. Refer https://pratiman-91.github.io/colormaps for information on each colourmaps.",
448448
)
449449
parser.add_argument(
450450
"--cmap",
@@ -453,6 +453,12 @@ def _praser():
453453
default=False,
454454
help="Valid colormap name to fill colors. Use '--list-cmaps' option to see list of supported colormaps. Must have minimum 11 colors, else will lead to error.",
455455
)
456+
parser.add_argument(
457+
"--ulevels",
458+
metavar="<upper-levels>",
459+
type=arguments.validate_ulevels,
460+
help="Provide custom upper level(s) when plotting upper atmospheric data. Each level is to be seperated by ',' i.e., '925,850,700'. Use '--list-vars' to know list of supported upper level variables.",
461+
)
456462
parser.add_argument(
457463
"--version",
458464
action="store_true",
@@ -478,7 +484,7 @@ def main():
478484
file = fileio.FileIO(args.input)
479485
if file.is_wrf():
480486
wrfplt = Wrfplot(
481-
input_path=args.input, output_path=args.output, dpi=args.dpi, cmap=args.cmap
487+
input_path=args.input, output_path=args.output, dpi=args.dpi, cmap=args.cmap, ulevels=args.ulevels
482488
)
483489
try:
484490
wrfplt.read_file(args.input)

0 commit comments

Comments
 (0)