-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cce9d0a
commit 18a8131
Showing
7 changed files
with
81 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,61 @@ | ||
""" | ||
Blimpy Plotting Configuration | ||
This file is imported by the other plotting source files and blimpy/waterfall.py. | ||
matplotlib backends info: | ||
https://matplotlib.org/3.5.0/users/explain/backends.html#:~:text=By%20default%2C%20Matplotlib%20should%20automatically,to%20worry%20about%20the%20backend. | ||
""" | ||
import os | ||
import numpy as np | ||
|
||
# Check if $DISPLAY is set (for handling plotting on remote machines with no X-forwarding) | ||
import matplotlib | ||
|
||
if 'DISPLAY' in os.environ.keys(): | ||
import pylab as plt | ||
else: | ||
matplotlib.use('Agg') | ||
import pylab as plt | ||
# Define plt for caller. | ||
import matplotlib.pyplot as plt | ||
plt.rcParams['axes.formatter.useoffset'] = False | ||
|
||
# Define NullFormatter for caller. | ||
from matplotlib.ticker import NullFormatter | ||
|
||
plt.rcParams['axes.formatter.useoffset'] = False | ||
#Define some constants for caller. | ||
MAX_PLT_POINTS = 65536 # Max number of points in matplotlib plot | ||
MAX_IMSHOW_POINTS = (8192, 4096) # Max number of points in imshow plot | ||
|
||
|
||
MAX_PLT_POINTS = 65536 # Max number of points in matplotlib plot | ||
MAX_IMSHOW_POINTS = (8192, 4096) # Max number of points in imshow plot | ||
def ok_to_show(): | ||
""" | ||
Tell caller if the DISPLAY environment variable is set | ||
and therefore if plt.show() can be executed. | ||
Parameters | ||
---------- | ||
None. | ||
Returns | ||
------- | ||
bool | ||
Can plt.show() be executed (True/False)? | ||
""" | ||
display = os.environ.get("DISPLAY", "empty") | ||
if display == "empty": | ||
print("blimpy plotting config.py setup_plotting_backend: DISPLAY is *empty*") | ||
return False | ||
print(f"blimpy plotting config.py setup_plotting_backend: DISPLAY is {display}") | ||
return True | ||
|
||
|
||
def print_plotting_backend(arg_context): | ||
""" Show which matplotlib backend is in use.""" | ||
ok_to_show() | ||
print(f"blimpy plotting config.py ({arg_context}): matplotlib backend is {matplotlib.get_backend()}") | ||
|
||
|
||
def get_mpl_backend(): | ||
return matplotlib.get_backend() | ||
|
||
|
||
def set_mpl_backend(backend): | ||
matplotlib.use(backend) | ||
|
||
|
||
print_plotting_backend("import config.py definitions") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters