diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.cpg b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.cpg new file mode 100644 index 0000000..3ad133c --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.dbf b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.dbf new file mode 100644 index 0000000..f3b98cb Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.dbf differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.prj b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.prj new file mode 100644 index 0000000..f45cbad --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.shp b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.shp new file mode 100644 index 0000000..2066748 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.shp differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.shx b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.shx new file mode 100644 index 0000000..030130e Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_10m_coastline.shx differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.cpg b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.cpg new file mode 100644 index 0000000..3ad133c --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.dbf b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.dbf new file mode 100644 index 0000000..d89c673 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.dbf differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.prj b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.prj new file mode 100644 index 0000000..b13a717 --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.shp b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.shp new file mode 100644 index 0000000..fc3f939 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.shp differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.shx b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.shx new file mode 100644 index 0000000..49cc085 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_coastline.shx differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.cpg b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.cpg new file mode 100644 index 0000000..3ad133c --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.dbf b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.dbf new file mode 100644 index 0000000..f0ee147 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.dbf differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.prj b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.prj new file mode 100644 index 0000000..b13a717 --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.shp b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.shp new file mode 100644 index 0000000..69ce127 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.shp differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.shx b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.shx new file mode 100644 index 0000000..0c82e83 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_land.shx differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.cpg b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.cpg new file mode 100644 index 0000000..3ad133c --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.dbf b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.dbf new file mode 100644 index 0000000..41b0b77 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.dbf differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.prj b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.prj new file mode 100644 index 0000000..b13a717 --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.shp b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.shp new file mode 100644 index 0000000..953e7a1 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.shp differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.shx b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.shx new file mode 100644 index 0000000..b665c27 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_110m_ocean.shx differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.cpg b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.cpg new file mode 100644 index 0000000..3ad133c --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.cpg @@ -0,0 +1 @@ +UTF-8 \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.dbf b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.dbf new file mode 100644 index 0000000..e98c7d4 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.dbf differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.prj b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.prj new file mode 100644 index 0000000..a30c00a --- /dev/null +++ b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.shp b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.shp new file mode 100644 index 0000000..3e2890d Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.shp differ diff --git a/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.shx b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.shx new file mode 100644 index 0000000..235eb40 Binary files /dev/null and b/wrfplot/data/shapefiles/natural_earth/physical/ne_50m_coastline.shx differ diff --git a/wrfplot/data/wrf_variables.ini b/wrfplot/data/wrf_variables.ini index 0a08aeb..144780d 100644 --- a/wrfplot/data/wrf_variables.ini +++ b/wrfplot/data/wrf_variables.ini @@ -1,289 +1,289 @@ [slp] -title="Mean Sea Level Pressure" -unit="hPa" -cmap="None" +title=Mean Sea Level Pressure +unit=hPa +cmap=None c_bar_extend=None -clevels="None" +clevels=None clable=True [winds] -title="10M Surface Winds" -unit="Kt" -cmap="perc2_9lev" -clevels=[10,15,20,25,30,35,40,45,50,55] -c_bar_extend="max" +title=10M Surface Winds +unit=Kt +cmap=perc2_9lev +clevels=10,15,20,25,30,35,40,45,50,55 +c_bar_extend=max clable=True [rh2] -title="2m Relative Humidity" -unit="%%" -cmap="rh_19lev" -clevels=[10,20,30,40,50,60,70,80,90,100] -c_bar_extend="neither" +title=2m Relative Humidity +unit=%% +cmap=rh_19lev +clevels=10,20,30,40,50,60,70,80,90,100 +c_bar_extend=neither clable=True [T2] -title="2m Temperature" -unit="°C" -cmap="nrl_sirkes_nowhite" -clevels=[10,14,18,22,25,28,31,34,37,40,42,44] -c_bar_extend="both" +title=2m Temperature +unit=°C +cmap=nrl_sirkes_nowhite +clevels=10,14,18,22,25,28,31,34,37,40,42,44 +c_bar_extend=both clable=True [mcape] -title="CAPE Maximum" -unit="$J kg^{1}$" -cmap="matter" -clevels="auto" -c_bar_extend="both" +title=CAPE Maximum +unit=$J kg^{1}$ +cmap=matter +clevels=auto +c_bar_extend=both clable=True [mcin] -title="Minimum Convective Inhibition " -unit="$J kg^{1}$" -cmap="WhiteBlue" -clevels="auto" -c_bar_extend="both" +title=Minimum Convective Inhibition +unit=$J kg^{1}$ +cmap=WhiteBlue +clevels=auto +c_bar_extend=both clable=True [lcl] -title="Lifting Condensation Level" -unit="Meters" -cmap="vvlt_turq3" -clevels="auto" -c_bar_extend="max" +title=Lifting Condensation Level +unit=Meters +cmap=vvlt_turq3 +clevels=auto +c_bar_extend=max clable=True [lfc] -title="Level of Free Convection" -unit="Meters" -cmap="yel3_r" -clevels="auto" -c_bar_extend="max" +title=Level of Free Convection +unit=Meters +cmap=yel3_r +clevels=auto +c_bar_extend=max clable=True [ctt] -title="Cloud Top Temperature" -unit="°C" -cmap="devon" -clevels="auto" -c_bar_extend="both" +title=Cloud Top Temperature +unit=°C +cmap=devon +clevels=auto +c_bar_extend=both clable=True [low_cloudfrac] -title="Low Cloud Coverage" -unit="%%" -cmap="nuuk_r" -clevels="auto" -c_bar_extend="both" +title=Low Cloud Coverage +unit=%% +cmap=nuuk_r +clevels=10,20,30,40,50,60,70,80,90,100 +c_bar_extend=both clable=True [mid_cloudfrac] -title="Medium Cloud Coverage" -unit="%%" -cmap="tokyo_r" -clevels="auto" -c_bar_extend="both" +title=Medium Cloud Coverage +unit=%% +cmap=tokyo_r +clevels=10,20,30,40,50,60,70,80,90,100 +c_bar_extend=both clable=True [high_cloudfrac] -title="High Cloud Coverage" -unit="%%" -cmap="c_violet1_r" -clevels="auto" -c_bar_extend="both" +title=High Cloud Coverage +unit=%% +cmap=c_violet1_r +clevels=10,20,30,40,50,60,70,80,90,100 +c_bar_extend=both clable=True [mdbz] -title="Maximum Reflectivity" -unit="dBZ" -cmap="radar_1" -clevels="auto" -c_bar_extend="both" +title=Maximum Reflectivity +unit=dBZ +cmap=radar_1 +clevels=auto +c_bar_extend=both clable=True [helicity] -title="Storm Relative Helicity" -unit="$m^{2} s^{-2}$" -cmap="thermal_r" -clevels="auto" -c_bar_extend="both" +title=Storm Relative Helicity +unit=$m^{2} s^{-2}$ +cmap=thermal_r +clevels=auto +c_bar_extend=both clable=True [pw] -title="Precipitable Water" -unit="$kg m^{-2}$" -cmap="example" -clevels="auto" -c_bar_extend="both" +title=Precipitable Water +unit=$kg m^{-2}$ +cmap=example +clevels=auto +c_bar_extend=both clable=True [td2] -title="2m Dew Point Temperature" -unit="°C" -cmap="cmp_haxby_r" -clevels="auto" -c_bar_extend="both" +title=2m Dew Point Temperature +unit=°C +cmap=cmp_haxby_r +clevels=auto +c_bar_extend=both clable=True [ppn_accum] -title="Accumulated Precipitation" -unit="mm" -cmap="cet_r_bgyr" -clevels=[2,5,10,15,20,30,40,50,80,100,200,300,400, 600] -c_bar_extend="neither" +title=Accumulated Precipitation +unit=mm +cmap=cet_r_bgyr +clevels=2,5,10,15,20,30,40,50,80,100,200,300,400, 600 +c_bar_extend=neither clable=True [ppn_conv] -title="Convective Precipitation" -unit="mm" -cmap="cmp_haxby" -clevels=[2,5,10,15,20,30,40,50,80,100,200] -c_bar_extend="neither" +title=Convective Precipitation +unit=mm +cmap=cmp_haxby +clevels=2,5,10,15,20,30,40,50,80,100,200 +c_bar_extend=neither clable=True [ppn] -title="Precipitation/ Rain" -unit="mm" -cmap="paired_12" -clevels=[2,5,10,15,20,30,40,50,80,100,200] -c_bar_extend="neither" +title=Precipitation/ Rain +unit=mm +cmap=paired_12 +clevels=2,5,10,15,20,30,40,50,80,100,200 +c_bar_extend=neither +clable=True + +[updraft_helicity] +title=Updraft Helicity +unit=$m^{2} s^{-2}$ +cmap=thermal_r +clevels=auto +c_bar_extend=both clable=True [u_theta_e] -title="Equivalent Potential Temperature" -unit="°C" -cmap="rainbow" -clevels="auto" -c_bar_extend="both" +title=Equivalent Potential Temperature +unit=°C +cmap=rainbow +clevels=auto +c_bar_extend=both clable=True [u_avo] -title="Absolute Vorticity" -unit="$10^{-5} s^{-1}$" -cmap="MPL_gist_earth" -clevels="auto" -c_bar_extend="both" +title=Absolute Vorticity +unit=$10^{-5} s^{-1}$ +cmap=MPL_gist_earth +clevels=auto +c_bar_extend=both clable=True [u_dbz] -title="Reflectivity" -unit="radar_1" -cmap="wh_bl_gr_ye_re" -clevels="auto" -c_bar_extend="both" +title=Reflectivity +unit=dBz +cmap=radar_1 +clevels=auto +c_bar_extend=both clable=True [u_geopotential] -title="Geopotential - Mass Grid" -unit="$m^{2} s^{-2}$" -cmap="thermal_r" -clevels="auto" -c_bar_extend="both" +title=Geopotential - Mass Grid +unit=$m^{2} s^{-2}$ +cmap=thermal_r +clevels=auto +c_bar_extend=both clable=True [u_omg] -title="Omega" -unit="$Pa s^{-1}s$" -cmap="cubehelix1_16_r" -clevels="auto" -c_bar_extend="both" +title=Omega +unit=$Pa s^{-1}s$ +cmap=cubehelix1_16_r +clevels=auto +c_bar_extend=both clable=True [u_pressure] -title="Full Model Pressure" -unit="hPa" -cmap="example" -clevels="auto" -c_bar_extend="both" +title=Full Model Pressure +unit=hPa +cmap=example +clevels=auto +c_bar_extend=both clable=True [u_pvo] -title="Potential Vorticity" -unit="PVU" -cmap="GMT_wysiwygcont" -clevels="auto" -c_bar_extend="both" +title=Potential Vorticity +unit=PVU +cmap=GMT_wysiwygcont +clevels=auto +c_bar_extend=both clable=True [u_td] -title="Dew Point Temperature" -unit="°C" -cmap="cmp_haxby_r" -clevels="auto" -c_bar_extend="both" +title=Dew Point Temperature +unit=°C +cmap=cmp_haxby_r +clevels=auto +c_bar_extend=both clable=True [u_rh] -title="Relative Humidity" -unit="%%" -cmap="rh_19lev" -clevels=[10,20,30,40,50,60,70,80,90,100] -c_bar_extend="neither" +title=Relative Humidity +unit=%% +cmap=rh_19lev +clevels=10,20,30,40,50,60,70,80,90,100 +c_bar_extend=neither clable=True [u_theta] -title="Potential Temperature" -unit="°C" -cmap="nrl_sirkes_nowhite" -clevels="auto" -c_bar_extend="both" +title=Potential Temperature +unit=°C +cmap=nrl_sirkes_nowhite +clevels=auto +c_bar_extend=both clable=True [u_temp] -title="Temperature" -unit="°C" -cmap="nrl_sirkes_nowhite" -clevels="auto" -c_bar_extend="both" +title=Temperature +unit=°C +cmap=nrl_sirkes_nowhite +clevels=auto +c_bar_extend=both clable=True [u_tv] -title="Virtual Temperature" -unit="°C" -cmap="nrl_sirkes_nowhite" -clevels="auto" -c_bar_extend="both" +title=Virtual Temperature +unit=°C +cmap=nrl_sirkes_nowhite +clevels=auto +c_bar_extend=both clable=True [u_twb] -title="Wet Bulb Temperature" -unit="°C" -cmap="nrl_sirkes_nowhite_r" -clevels="auto" -c_bar_extend="both" +title=Wet Bulb Temperature +unit=°C +cmap=nrl_sirkes_nowhite_r +clevels=auto +c_bar_extend=both clable=True -[u_updraft_helicity] -title="Updraft Helicity" -unit="$m^{2} s^{-2}$" -cmap="thermal_r" -clevels="auto" -c_bar_extend="both" -clable=True - [u_winds] -title="Wind Speed and Direction" -unit="Kt" -cmap="perc2_9lev" -clevels=[10,15,20,25,30,35,40,45,50,55] -c_bar_extend="max" +title=Wind Speed and Direction +unit=Kt +cmap=perc2_9lev +clevels=20,30,40,50,60,80,100,120,140 +c_bar_extend=max clable=True [u_cin] -title="Convective Inhibition" -unit="$J kg^{1}$" -cmap="WhiteBlue" -clevels="auto" -c_bar_extend="both" +title=Convective Inhibition +unit=$J kg^{1}$ +cmap=WhiteBlue +clevels=auto +c_bar_extend=both clable=True [u_cape] -title="Convective Available Potential Energy" -unit="$J kg^{1}$" -cmap="matter" -clevels="auto" -c_bar_extend="both" -clable=True \ No newline at end of file +title=Convective Available Potential Energy +unit=$J kg^{1}$ +cmap=matter +clevels=auto +c_bar_extend=both +clable=True diff --git a/wrfplot/plot.py b/wrfplot/plot.py index 0dbd8c7..240d778 100644 --- a/wrfplot/plot.py +++ b/wrfplot/plot.py @@ -127,8 +127,10 @@ def add_background(self): def add_cartopy_features(self): """Add cartopy features only for specific variables""" if self.var_name in ["slp", "mslp"]: - self.ax.add_feature(cf.LAND) - self.ax.add_feature(cf.OCEAN) + # self.ax.add_feature(cf.LAND) + # self.ax.add_feature(cf.OCEAN) + # Background colour is not made uniform. Hence removing it. + pass def add_grids(self): """Add grid lines to plot""" @@ -163,14 +165,14 @@ def get_clevels(self): """Get contour levels""" if self.clevels is not False and isinstance (self.clevels, list): return self.clevels - elif self.clevels is not False and isinstance (self.clevels, str): + elif self.clevels is not False and isinstance (self.clevels, int): self.clevels = utils.get_auto_clevel(self.data, scale=int(self.clevels)) elif self.clevels == "auto": self.clevels = utils.get_auto_clevel(self.data) def plot_title(self): """Plot title for the given variable""" - title = json.loads(self.config.get(self.var_name, "title")) + title = self.config.get(self.var_name, "title") unit = self.config.get(self.var_name, "unit").replace('"', "") if self.ulevel is not None: title_text = ( @@ -179,9 +181,9 @@ def plot_title(self): + unit + ") at " + str(self.ulevel) - + " hPa\nModel Run Hr : " + + " hPa\nCycle : " + self.cycle - + " UTC | Fcst Hr : " + + " UTC | Validity : " + self.fcst_hr + " UTC" ) @@ -190,9 +192,9 @@ def plot_title(self): title + " (" + unit - + ")\nModel Run Hr : " + + ")\nCycle : " + self.cycle - + " UTC | Fcst Hr : " + + " UTC | Validity : " + self.fcst_hr + " UTC" ) @@ -213,7 +215,7 @@ def get_cmap(self): self.cmap = utils.get_cmap(self.cmap) return True else: - cmap_name = json.loads(self.config.get(self.var_name, "cmap")) + cmap_name = self.config.get(self.var_name, "cmap") if cmap_name == "None": self.cmap = None else: diff --git a/wrfplot/utils.py b/wrfplot/utils.py index 700bc3d..6940380 100644 --- a/wrfplot/utils.py +++ b/wrfplot/utils.py @@ -25,6 +25,7 @@ import matplotlib.pyplot as plt from matplotlib import cm import os +import sys import socket import colormaps as cmaps @@ -175,7 +176,7 @@ def get_auto_clevel(data, scale=12, slp=False): Returns: list: The c_level in list and in increasing form """ - + c_levels = [] max = data.max() min = data.min() diff --git a/wrfplot/wrfplot.py b/wrfplot/wrfplot.py index a9edac7..26518e7 100644 --- a/wrfplot/wrfplot.py +++ b/wrfplot/wrfplot.py @@ -40,7 +40,7 @@ import sys import argparse from tqdm import tqdm -import netCDF4 as nc +import netCDF4 as nc import numpy as np import arguments from datetime import datetime @@ -56,6 +56,7 @@ from importlib.metadata import version, PackageNotFoundError import _version import matplotlib +from concurrent.futures import ProcessPoolExecutor, as_completed matplotlib.use("agg") warnings.filterwarnings("ignore", module="matplotlib") warnings.filterwarnings("ignore", module="datetime") @@ -98,6 +99,7 @@ def __init__( self.file = fileio.FileIO(self.input_file) self.config = ConfigParser() self.config.read(os.path.join(utils.data_dir(), "wrf_variables.ini")) + self.wrf_var_dict = {s: dict(self.config.items(s)) for s in self.config.sections()} self.dpi = dpi self.cmap = cmap self.U = None @@ -253,26 +255,21 @@ def get_time_period(self): def plot_sfc(self): """Plot only surface data""" - pbar = tqdm( - range(0, len(self.date_time)), - desc="Plotting Variable : ", - leave=False, - colour="green", - ) - pbar.write( - "\n*** Initialising plotting for variable : " - + utils.quote(self.var) - + " ***\n" - ) + pbar = tqdm(range(0, len(self.date_time)), desc="Plotting Variable : ", leave=False, colour="green") + pbar.write("\n*** Initialising plotting for variable : {_var} ***\n".format(_var=utils.quote(self.var))) data_plot = None images = [] + for index in pbar: _time = self.date_time[index] if self.var == "slp": self.var_data = smooth2d(self.var_data, 3, cenweight=4) self.clevels = utils.get_auto_clevel(self.var_data, slp=True) elif self.clevels is False: - self.clevels = json.loads(self.config.get(self.var, "clevels")) + default_clevels = self.config.get(self.var, "clevels") + if ',' in default_clevels: + default_clevels = list(map(int, default_clevels.split(','))) + self.clevels = default_clevels if data_plot is None: data_plot = self.var_data @@ -295,38 +292,24 @@ def plot_sfc(self): def plot_upper(self): """Plot only upper atmospheric data""" pressure = getvar(self.nc_fh, "pressure", ALL_TIMES) - self.clevels = json.loads(self.config.get(self.var, "clevels")) + # self.clevels = self.config.get(self.var, "clevels") + if self.clevels is False: + default_clevels = self.config.get(self.var, "clevels") + if ',' in default_clevels: + default_clevels = list(map(int, default_clevels.split(','))) + self.clevels = default_clevels u_var_data = self.var_data if self.U is not None and self.V is not None: u_var_u_data = self.U u_var_v_data = self.V - pbar_var = tqdm( - range(0, len(self.date_time)), - desc="Plotting Variable : ", - leave=False, - position=0, - colour="green", - ) - pbar_var.write( - "\n*** Initialising plotting for variable : " - + utils.quote(self.var) - + " ***\n" - ) + pbar_var = tqdm(range(0, len(self.date_time)), desc="Plotting Variable : ", leave=False, position=0, colour="green") + pbar_var.write("\n*** Initialising plotting for variable : {_var} ***\n".format(_var=utils.quote(self.var))) images = [] for index in pbar_var: _time = self.date_time[index] # Must initialise the bar inside time loop so that range is set every time entering into outer loop - pbar_lvl = tqdm( - self.ulevels, - desc="Plotting Level : ", - leave=False, - position=1, - colour="blue", - ) - - pbar_var.write( - "\tPlotting " + utils.quote(self.var) + " for Time: " + _time - ) + pbar_lvl = tqdm(self.ulevels, desc="Plotting Level : ", leave=False, position=1, colour="blue") + pbar_var.write("\tPlotting " + utils.quote(self.var) + " for Time: " + _time) pbar_var.set_description("Overall Progress :", refresh=True) for self.ulevel in pbar_lvl: self.var_data = interplevel(u_var_data, pressure, self.ulevel) @@ -423,7 +406,7 @@ def convert_unit(self, data): return convert.k_to_c(data) elif self.var in ["low_cloudfrac", "mid_cloudfrac", "high_cloudfrac"]: return np.round(data * 100) - elif self.var == "winds": + elif self.var in ["winds", 'u_winds']: return convert.ms_to_kts(data) else: return data @@ -434,7 +417,7 @@ def list_projs(self): def get_title(self, var): """Get title from config file""" - return json.loads(self.config.get(var, "title")) + return self.config.get(var, "title") def get_unit(self): """Get unit from config file"""