Skip to content

Commit

Permalink
Moved themes and images from source code directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mcuntz committed Jan 17, 2024
1 parent f801491 commit d381fd5
Show file tree
Hide file tree
Showing 230 changed files with 52 additions and 1,821 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
---------

v4.4 (??? 2024)
* Bugfix formatted string used wrong data type in `analyse_netcdf`.
* Move themes and images directories from src/ncvue to src directory.

v4.3 (Jan 2024)
* Added conda and continuous integration badges.
* Allow multiple netcdf files.
Expand Down
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
prune **
graft bin
include src/ncvue/*.py
graft src/ncvue/images
graft src/ncvue/themes/azure-2.0
graft src/images
graft src/themes/azure-2.0
graft tests

include AUTHORS.rst CHANGELOG.rst CONTRIBUTING.rst README.rst LICENSE pyproject.toml setup.cfg
Expand Down
Binary file removed src/ncvue/images/Accent.png
Binary file not shown.
Binary file removed src/ncvue/images/Blues.png
Binary file not shown.
Binary file removed src/ncvue/images/BrBG.png
Binary file not shown.
Binary file removed src/ncvue/images/BuGn.png
Binary file not shown.
Binary file removed src/ncvue/images/BuPu.png
Binary file not shown.
Binary file removed src/ncvue/images/CMRmap.png
Binary file not shown.
Binary file removed src/ncvue/images/Dark2.png
Binary file not shown.
Binary file removed src/ncvue/images/GnBu.png
Binary file not shown.
Binary file removed src/ncvue/images/Grays.png
Binary file not shown.
Binary file removed src/ncvue/images/Greens.png
Binary file not shown.
Binary file removed src/ncvue/images/Greys.png
Binary file not shown.
Binary file removed src/ncvue/images/OrRd.png
Binary file not shown.
Binary file removed src/ncvue/images/Oranges.png
Binary file not shown.
Binary file removed src/ncvue/images/PRGn.png
Binary file not shown.
Binary file removed src/ncvue/images/Paired.png
Binary file not shown.
Binary file removed src/ncvue/images/Pastel1.png
Binary file not shown.
Binary file removed src/ncvue/images/Pastel2.png
Binary file not shown.
Binary file removed src/ncvue/images/PiYG.png
Binary file not shown.
Binary file removed src/ncvue/images/PuBu.png
Binary file not shown.
Binary file removed src/ncvue/images/PuBuGn.png
Binary file not shown.
Binary file removed src/ncvue/images/PuOr.png
Binary file not shown.
Binary file removed src/ncvue/images/PuRd.png
Binary file not shown.
Binary file removed src/ncvue/images/Purples.png
Binary file not shown.
Binary file removed src/ncvue/images/RdBu.png
Binary file not shown.
Binary file removed src/ncvue/images/RdGy.png
Binary file not shown.
Binary file removed src/ncvue/images/RdPu.png
Diff not rendered.
Binary file removed src/ncvue/images/RdYlBu.png
Diff not rendered.
Binary file removed src/ncvue/images/RdYlGn.png
Diff not rendered.
Binary file removed src/ncvue/images/Reds.png
Diff not rendered.
Binary file removed src/ncvue/images/Set1.png
Diff not rendered.
Binary file removed src/ncvue/images/Set2.png
Diff not rendered.
Binary file removed src/ncvue/images/Set3.png
Diff not rendered.
Binary file removed src/ncvue/images/Spectral.png
Diff not rendered.
Binary file removed src/ncvue/images/Wistia.png
Diff not rendered.
Binary file removed src/ncvue/images/YlGn.png
Diff not rendered.
Binary file removed src/ncvue/images/YlGnBu.png
Diff not rendered.
Binary file removed src/ncvue/images/YlOrBr.png
Diff not rendered.
Binary file removed src/ncvue/images/YlOrRd.png
Diff not rendered.
Binary file removed src/ncvue/images/afmhot.png
Diff not rendered.
Binary file removed src/ncvue/images/autumn.png
Diff not rendered.
Binary file removed src/ncvue/images/binary.png
Diff not rendered.
Binary file removed src/ncvue/images/bone.png
Diff not rendered.
Binary file removed src/ncvue/images/brg.png
Diff not rendered.
Binary file removed src/ncvue/images/bwr.png
Diff not rendered.
Binary file removed src/ncvue/images/cividis.png
Diff not rendered.
Binary file removed src/ncvue/images/cool.png
Diff not rendered.
Binary file removed src/ncvue/images/coolwarm.png
Diff not rendered.
Binary file removed src/ncvue/images/copper.png
Diff not rendered.
Binary file removed src/ncvue/images/cubehelix.png
Diff not rendered.
Binary file removed src/ncvue/images/flag.png
Diff not rendered.
Binary file removed src/ncvue/images/gist_earth.png
Diff not rendered.
Binary file removed src/ncvue/images/gist_gray.png
Diff not rendered.
Binary file removed src/ncvue/images/gist_grey.png
Diff not rendered.
Binary file removed src/ncvue/images/gist_heat.png
Diff not rendered.
Binary file removed src/ncvue/images/gist_ncar.png
Diff not rendered.
Binary file removed src/ncvue/images/gist_rainbow.png
Diff not rendered.
Binary file removed src/ncvue/images/gist_stern.png
Diff not rendered.
Binary file removed src/ncvue/images/gist_yarg.png
Diff not rendered.
Binary file removed src/ncvue/images/gist_yerg.png
Diff not rendered.
Binary file removed src/ncvue/images/gnuplot.png
Diff not rendered.
Binary file removed src/ncvue/images/gnuplot2.png
Diff not rendered.
Binary file removed src/ncvue/images/gray.png
Diff not rendered.
Binary file removed src/ncvue/images/grey.png
Diff not rendered.
Binary file removed src/ncvue/images/hot.png
Diff not rendered.
Binary file removed src/ncvue/images/hsv.png
Diff not rendered.
Binary file removed src/ncvue/images/inferno.png
Diff not rendered.
Binary file removed src/ncvue/images/jet.png
Diff not rendered.
Binary file removed src/ncvue/images/magma.png
Diff not rendered.
Binary file removed src/ncvue/images/ncvue_icon.ico
Binary file not shown.
Binary file removed src/ncvue/images/ncvue_icon.png
Diff not rendered.
Binary file removed src/ncvue/images/nipy_spectral.png
Diff not rendered.
Binary file removed src/ncvue/images/ocean.png
Diff not rendered.
Binary file removed src/ncvue/images/pink.png
Diff not rendered.
Binary file removed src/ncvue/images/plasma.png
Diff not rendered.
50 changes: 0 additions & 50 deletions src/ncvue/images/plot_png_colormaps.py

This file was deleted.

Binary file removed src/ncvue/images/prism.png
Diff not rendered.
Binary file removed src/ncvue/images/rainbow.png
Diff not rendered.
Binary file removed src/ncvue/images/seismic.png
Diff not rendered.
Binary file removed src/ncvue/images/spring.png
Diff not rendered.
Binary file removed src/ncvue/images/summer.png
Diff not rendered.
Binary file removed src/ncvue/images/tab10.png
Diff not rendered.
Binary file removed src/ncvue/images/tab20.png
Diff not rendered.
Binary file removed src/ncvue/images/tab20b.png
Diff not rendered.
Binary file removed src/ncvue/images/tab20c.png
Diff not rendered.
Binary file removed src/ncvue/images/terrain.png
Diff not rendered.
Binary file removed src/ncvue/images/turbo.png
Diff not rendered.
Binary file removed src/ncvue/images/twilight.png
Diff not rendered.
Binary file removed src/ncvue/images/twilight_shifted.png
Diff not rendered.
Binary file removed src/ncvue/images/viridis.png
Diff not rendered.
Binary file removed src/ncvue/images/winter.png
Diff not rendered.
8 changes: 5 additions & 3 deletions src/ncvue/ncvcontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
* Address fi.variables[name] directly by fi[name], Jan 2024, Matthias Cuntz
* Allow groups in netcdf files, Jan 2024, Matthias Cuntz
* Allow multiple netcdf files, Jan 2024, Matthias Cuntz
* Move images/ directory from src/ncvue/ to src/ directory,
Jan 2024, Matthias Cuntz
"""
import os
Expand Down Expand Up @@ -138,12 +140,12 @@ def __init__(self, master, **kwargs):
self.cmaps = [ i for i in allcmaps if not i.endswith('_r') ]
self.cmaps.sort()
# self.imaps = [ tk.PhotoImage(file=os.path.dirname(__file__) +
# '/images/' + i + '.png')
# '/../images/' + i + '.png')
# for i in self.cmaps ]
bundle_dir = getattr(sys, '_MEIPASS',
os.path.abspath(os.path.dirname(__file__)))
self.imaps = [ tk.PhotoImage(file=bundle_dir +
'/images/' + i + '.png')
'/../images/' + i + '.png')
for i in self.cmaps ]

# 1. row
Expand Down Expand Up @@ -385,7 +387,7 @@ def newnetcdf(self):
for ii, nn in enumerate(ncfile):
self.top.fi.append(nc.Dataset(nn, 'r'))
if len(ncfile) > 1:
self.top.groups.append(f'file{ii:04d}')
self.top.groups.append(f'file{ii:03d}')
# Check groups
ianalyse = True
if len(ncfile) == 1:
Expand Down
8 changes: 5 additions & 3 deletions src/ncvue/ncvmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* Address fi.variables[name] directly by fi[name], Jan 2024, Matthias Cuntz
* Allow groups in netcdf files, Jan 2024, Matthias Cuntz
* Allow multiple netcdf files, Jan 2024, Matthias Cuntz
* Move images/ directory from src/ncvue/ to src/ directory,
Jan 2024, Matthias Cuntz
"""
import os
Expand Down Expand Up @@ -157,12 +159,12 @@ def __init__(self, master, **kwargs):
self.cmaps = [ i for i in allcmaps if not i.endswith('_r') ]
self.cmaps.sort()
# self.imaps = [ tk.PhotoImage(file=os.path.dirname(__file__) +
# '/images/' + i + '.png')
# '/../images/' + i + '.png')
# for i in self.cmaps ]
bundle_dir = getattr(sys, '_MEIPASS',
os.path.abspath(os.path.dirname(__file__)))
self.imaps = [ tk.PhotoImage(file=bundle_dir +
'/images/' + i + '.png')
'/../images/' + i + '.png')
for i in self.cmaps ]

# only projections with keyword: central_longitude
Expand Down Expand Up @@ -566,7 +568,7 @@ def newnetcdf(self):
for ii, nn in enumerate(ncfile):
self.top.fi.append(nc.Dataset(nn, 'r'))
if len(ncfile) > 1:
self.top.groups.append(f'file{ii:04d}')
self.top.groups.append(f'file{ii:03d}')
# Check groups
ianalyse = True
if len(ncfile) == 1:
Expand Down
43 changes: 20 additions & 23 deletions src/ncvue/ncvmethods.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,12 @@ def analyse_netcdf(self):
tunit = ivar.units
except AttributeError:
tunit = ''
# assure 01, etc. if values < 10
# assure 01, etc. if values < 1000, 10, 10 in year, month, day
if tunit.find('since') > 0:
tt = tunit.split()
dd = tt[2].split('-')
dd[0] = ('000' + dd[0])[-4:]
dd[1] = ('0' + dd[1])[-2:]
dd[2] = ('0' + dd[1])[-2:]
tt[2] = '-'.join(dd)
tt[2] = (f'{int(dd[0]):04d}-{int(dd[1]):02d}-'
f'{int(dd[2]):02d}')
tunit = ' '.join(tt)
try:
ivar = selvar(self, self.tvar[ig])
Expand All @@ -188,11 +186,13 @@ def analyse_netcdf(self):
dtime.append(dt.datetime.strptime(sstt, itunit))
ntime = cf.date2num(dtime,
'days since 0001-01-01 00:00:00')
self.dtime[ig] = cf.num2date(ntime,
'days since 0001-01-01 00:00:00')
self.dtime[ig] = cf.num2date(
ntime,
'days since 0001-01-01 00:00:00')
else:
try:
self.dtime[ig] = cf.num2date(time, tunit, calendar=tcal)
self.dtime[ig] = cf.num2date(time, tunit,
calendar=tcal)
except ValueError:
self.dtime[ig] = None
if self.dtime[ig] is not None:
Expand Down Expand Up @@ -226,18 +226,17 @@ def analyse_netcdf(self):
only_use_cftime_datetimes=False,
only_use_python_datetimes=True)
self.time[ig] = np.array([ dd.isoformat()
for dd in ttime ],
dtype='datetime64[ms]')
for dd in ttime ],
dtype='datetime64[ms]')
except:
self.time[ig] = None
if self.time[ig] is None:
try:
# self.time = cf.num2date(time, tunit,
ttime = cf.num2date(time, tunit,
calendar=tcal)
self.time[ig] = np.array([ dd.isoformat()
for dd in ttime ],
dtype='datetime64[ms]')
for dd in ttime ],
dtype='datetime64[ms]')
except:
self.time[ig] = None
if self.time[ig] is None:
Expand All @@ -248,8 +247,6 @@ def analyse_netcdf(self):
# e.g. if units = "months since ..."
self.time[ig] = time
self.dtime[ig] = time
# print('time: ', self.time[ig])
# print('dtime: ', self.dtime[ig])
break
#
# construct list of variable names with dimensions
Expand Down Expand Up @@ -367,7 +364,7 @@ def analyse_netcdf(self):
saxis = ''
if saxis.lower() == 'x':
self.lonvar[ig] = gname + vv
# fifth sweep: same as first but units can be "degrees"
# fifth sweep: same as first but units can be simply "degrees"
if not self.latvar[ig]:
for vv in fi.variables:
try:
Expand Down Expand Up @@ -400,7 +397,7 @@ def analyse_netcdf(self):
sunit = ''
if sunit.lower() == 'degrees':
self.lonvar[ig] = gname + vv
# sixth sweep: same as second but units can be "degrees"
# sixth sweep: same as second but units can be simply "degrees"
if not self.latvar[ig]:
for vv in fi.variables:
sname = fi[vv].name
Expand All @@ -421,7 +418,7 @@ def analyse_netcdf(self):
sunit = ''
if sunit.lower() == 'degrees':
self.lonvar[ig] = gname + vv
# seventh sweep: same as third but units can be "degrees"
# seventh sweep: same as third but units can be simply "degrees"
if not self.latvar[ig]:
for vv in fi.variables:
sname = fi[vv].name
Expand Down Expand Up @@ -452,8 +449,8 @@ def analyse_netcdf(self):
ivar = selvar(self, self.latvar[ig])
latshape = ivar.shape
if (len(latshape) < 1) or (len(latshape) > 2):
estr = 'Something went wrong determining lat/lon:'
estr += ' latitude variable is not 1D or 2D.'
estr = ('Something went wrong determining lat/lon:'
' latitude variable is not 1D or 2D.')
print(estr)
estr = 'latitude variable with dimensions:'
ldim = ivar.dimensions
Expand All @@ -469,8 +466,8 @@ def analyse_netcdf(self):
elif len(lonshape) == 2:
self.londim[ig] = ivar.dimensions[1]
else:
estr = 'Something went wrong determining lat/lon:'
estr += ' longitude variable is not 1D or 2D.'
estr = ('Something went wrong determining lat/lon:'
' longitude variable is not 1D or 2D.')
print(estr)
estr = 'longitude variable with dimensions:'
ldim = ivar.dimensions
Expand Down Expand Up @@ -683,7 +680,7 @@ def set_dim_lon(self):
self.londlblval[i].set(ll.dimensions[i])
if ll.shape[i] > 1:
tstr = "Specific dimension value: 0-{:d}\n".format(
ll.shape[i]-1)
ll.shape[i] - 1)
tstr += "or arithmetic operation on axis:\n"
tstr += " " + ", ".join(DIMMETHODS)
else:
Expand Down
2 changes: 1 addition & 1 deletion src/ncvue/ncvscatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def newnetcdf(self):
for ii, nn in enumerate(ncfile):
self.top.fi.append(nc.Dataset(nn, 'r'))
if len(ncfile) > 1:
self.top.groups.append(f'file{ii:04d}')
self.top.groups.append(f'file{ii:03d}')
# Check groups
ianalyse = True
if len(ncfile) == 1:
Expand Down
25 changes: 15 additions & 10 deletions src/ncvue/ncvue.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* Font size 13 on Windows for plots, Jun 2021, Matthias Cuntz
* Allow groups in netcdf files, Jan 2024, Matthias Cuntz
* Allow multiple netcdf files, Jan 2024, Matthias Cuntz
* Move themes/ and images/ directories from src/ncvue/ to src/ directory,
Jan 2024, Matthias Cuntz
"""
import os
Expand Down Expand Up @@ -92,34 +94,37 @@ def ncvue(ncfile=[], miss=np.nan):
top.option_add("*Font", "Helvetica 10")
plt.rc('font', size=13)
# standard Windows themes
# ('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
# ('winnative', 'clam', 'alt', 'default', 'classic', 'vista',
# 'xpnative')
# theme = 'vista'
# style = ttk.Style()
# style.theme_use(theme)

# style packages
# Download from https://sourceforge.net/projects/tcl-awthemes/
# top.tk.call('lappend', 'auto_path',
# bundle_dir + '/themes/awthemes-10.3.2')
# bundle_dir + '/../themes/awthemes-10.3.2')
# theme = 'awdark' # 'awlight', 'awdark'
# top.tk.call('package', 'require', theme)
# style = ttk.Style()
# style.theme_use(theme)

# single file styles
# 'azure' and 'azure-dark' v1.x, 'Breeze'
# top.tk.call('source', bundle_dir + '/themes/breeze/breeze.tcl')
# top.tk.call('source', bundle_dir + '/../themes/breeze/breeze.tcl')
# theme = 'Breeze'
# top.tk.call('source', bundle_dir + '/themes/azure-1.3/azure.tcl')
# top.tk.call('source', bundle_dir + '/../themes/azure-1.3/azure.tcl')
# theme = 'azure'
# top.tk.call('source', bundle_dir + '/themes/azure-1.3/azure-dark.tcl')
# top.tk.call('source', bundle_dir +
# '/../themes/azure-1.3/azure-dark.tcl')
# theme = 'azure-dark'
# style = ttk.Style()
# style.theme_use(theme)

# 'azure' v2.x, 'sun-valley', 'forest' of rdbende
top.tk.call('source', bundle_dir + '/themes/azure-2.0/azure.tcl')
# top.tk.call('source', bundle_dir + '/themes/sun-valley-1.0/sun-valley.tcl')
top.tk.call('source', bundle_dir + '/../themes/azure-2.0/azure.tcl')
# top.tk.call('source', bundle_dir +
# '/../themes/sun-valley-1.0/sun-valley.tcl')
theme = 'light' # light, dark
top.tk.call("set_theme", theme)
elif ios == 'Linux':
Expand All @@ -129,7 +134,7 @@ def ncvue(ncfile=[], miss=np.nan):
# style.theme_use(theme)

# 'azure' v2.x, 'sun-valley', 'forest' of rdbende
top.tk.call('source', bundle_dir + '/themes/azure-2.0/azure.tcl')
top.tk.call('source', bundle_dir + '/../themes/azure-2.0/azure.tcl')
theme = 'light' # light, dark
top.tk.call("set_theme", theme)

Expand All @@ -140,7 +145,7 @@ def ncvue(ncfile=[], miss=np.nan):
except NameError:
whichpy = ''
if not whichpy:
icon = tk.PhotoImage(file=bundle_dir + '/images/ncvue_icon.png')
icon = tk.PhotoImage(file=bundle_dir + '/../images/ncvue_icon.png')
top.iconphoto(True, icon) # True: apply to all future toplevels
else:
icon = None
Expand Down Expand Up @@ -177,7 +182,7 @@ def ncvue(ncfile=[], miss=np.nan):
for ii, nn in enumerate(ncfile):
top.fi.append(nc.Dataset(nn, 'r'))
if len(ncfile) > 1:
top.groups.append(f'file{ii:04d}')
top.groups.append(f'file{ii:03d}')
# Check groups
if len(ncfile) == 1:
top.groups = list(top.fi[0].groups.keys())
Expand Down
Loading

0 comments on commit d381fd5

Please sign in to comment.