Skip to content

Commit

Permalink
removing extraneous matplotlib backend selections
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinney committed Dec 9, 2023
1 parent 70deaf4 commit 479eee8
Show file tree
Hide file tree
Showing 18 changed files with 14 additions and 132 deletions.
10 changes: 1 addition & 9 deletions omf/cymeToGridlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,9 @@
from os.path import join as pJoin
import numpy as np
from numpy.linalg import inv

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

from omf import feeder
from omf.solvers import gridlabd


m2ft = 1.0 / 0.3048 # Conversion factor for meters to feet


Expand Down Expand Up @@ -3466,6 +3457,7 @@ def _tests(keepFiles=True):
# Draw the GLM.
myGraph = feeder.treeToNxGraph(cyme_base)
feeder.latLonNxGraph(myGraph, neatoLayout=False)
from matplotlib import pyplot as plt
plt.savefig(outputDir + testFilename + ".png")
with open(pJoin(outputDir, "convResults.txt"), "a") as resultsFile:
resultsFile.write("DREW GLM FOR " + testFilename + "\n")
Expand Down
4 changes: 0 additions & 4 deletions omf/feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
import networkx as nx
from omf.solvers.opendss import dssConvert
import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# Wireframe for new OMD objects:
Expand Down
4 changes: 0 additions & 4 deletions omf/loadModelingScada.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
from os.path import join as pJoin
import numpy as np
import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt
from omf import feeder
from omf.solvers import gridlabd
Expand Down
9 changes: 1 addition & 8 deletions omf/models/cvrDynamic.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
''' Calculate CVR impacts using a targetted set of dynamic loadflows. '''

import json, os, shutil, math, calendar, platform
import json, os, shutil, math, calendar
from datetime import datetime as dt, timedelta
from os.path import join as pJoin

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# OMF feeder
from omf import feeder
from omf.solvers import gridlabd
Expand Down
4 changes: 0 additions & 4 deletions omf/models/cvrStatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
from os.path import join as pJoin

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# OMF imports
Expand Down
12 changes: 1 addition & 11 deletions omf/models/derInterconnection.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
''' perform analysis pertaining to the addition of a DER interconnection on a feeder. '''
import glob, json, os, tempfile, shutil, csv, math, warnings, random, copy, base64, platform
import glob, json, os, tempfile, shutil, csv, math, random, copy, base64
from os.path import join as pJoin
import networkx as nx

# Hack: Agg backend doesn't work for interactivity. Switch to something we can use:
import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# dateutil imports
from dateutil import parser
from dateutil.relativedelta import *

# OMF imports
from omf import feeder
from omf.solvers import gridlabd
from omf.models import __neoMetaModel__
Expand Down
4 changes: 0 additions & 4 deletions omf/models/evInterconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
import numpy as np

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt
#plt.style.use('seaborn')

Expand Down
10 changes: 1 addition & 9 deletions omf/models/faultAnalysis.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
''' Determine impacts of distribution faults. '''

import json, os, shutil, csv, warnings, base64, platform
import json, os, shutil, csv, base64
from os.path import join as pJoin

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# dateutil imports
from dateutil import parser
from dateutil.relativedelta import *

# OMF imports
Expand Down
17 changes: 2 additions & 15 deletions omf/models/flisr.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
''' Calculate FLISR, fault location isolation and restoration. '''
import random, re, datetime, json, os, tempfile, shutil, csv, math, platform, base64
import re, json, os, tempfile, shutil
from os.path import join as pJoin
import pandas as pd
import numpy as np
import scipy
from scipy import spatial
import scipy.stats as st
from sklearn.preprocessing import LabelEncoder
import plotly as py
import plotly.graph_objs as go
import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt
import networkx as nx
# OMF imports
from omf import feeder, geo, distNetViz
from omf import feeder, geo
import omf
import omf.feeder
import omf.geo
Expand Down
13 changes: 1 addition & 12 deletions omf/models/networkStructure.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
''' Reconstruct distribution network structure from meter data. '''
import json, os, tempfile, shutil, csv, math, re, base64, platform
import json, os, tempfile, shutil, csv, math, re, base64
from os.path import join as pJoin
import pandas as pd
import networkx as nx
from sklearn import svm
from sklearn import metrics
from numpy import array

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# dateutil imports
from dateutil import parser
from dateutil.relativedelta import *

# OMF imports
import omf
from omf import feeder, geo
from omf.models import __neoMetaModel__
Expand Down
9 changes: 1 addition & 8 deletions omf/models/phaseId.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
''' Identify phasing from meter data.'''
import json, datetime, csv, os, shutil, re, warnings, itertools, base64, platform
import datetime, csv, os, shutil, re, itertools, base64, platform
from os.path import join as pJoin
from base64 import b64decode
from zipfile import ZipFile
Expand All @@ -11,14 +11,7 @@
from scipy.stats import linregress
from sklearn import preprocessing
from sklearn.metrics import confusion_matrix

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

from omf.models import __neoMetaModel__
from omf.models.__neoMetaModel__ import *
from omf.solvers import sandia_ami_phase_id
Expand Down
11 changes: 2 additions & 9 deletions omf/models/resilientDist.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
''' Run micot-GFM, micot-RDT, and GridLAB-D to determine an optimal distribution resiliency investment. '''

import json, os, shutil, subprocess, datetime, re, random, copy, warnings, base64, platform
import json, os, shutil, subprocess, datetime, random, copy, base64, platform
import os.path
from os.path import join as pJoin
import numpy as np
import networkx as nx

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# OMF imports
import omf
from omf import feeder, weather, distNetViz
from omf.models import __neoMetaModel__
Expand Down Expand Up @@ -128,7 +121,7 @@ def changeCellSize(self, cellSize):
self.hazardObj["cellsize"] = cellSize

def mapValue(self, value, fromMin, fromMax, toMin=.7, toMax=1):
newValue = float(value - fromMind) / float(fromMax-fromMin)
newValue = float(value - fromMin) / float(fromMax-fromMin)
return toMin + (newValue * (toMax-toMin))

def mapRanges(self, values, fromMin, fromMax):
Expand Down
5 changes: 0 additions & 5 deletions omf/models/smartSwitching.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
import plotly.graph_objs as go
from plotly.tools import make_subplots
import networkx as nx

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# dateutil imports
Expand Down
10 changes: 1 addition & 9 deletions omf/models/solarConsumer.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
''' Calculate solar costs and benefits for consumers. '''

import shutil, datetime, platform
import shutil, datetime
from os.path import join as pJoin

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# OMF imports
from omf import weather
from omf.solvers import nrelsam2013
from omf.models import __neoMetaModel__
Expand Down
5 changes: 0 additions & 5 deletions omf/models/solarEngineering.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
from matplotlib import pyplot as plt
from matplotlib import animation
from matplotlib.animation import FuncAnimation
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
# plt.rcParams['animation.ffmpeg_path'] = '/usr/local/bin/ffmpeg'
else:
matplotlib.use('Agg')
from omf import feeder, weather
from omf.solvers import gridlabd
from omf.models import __neoMetaModel__
Expand Down
8 changes: 1 addition & 7 deletions omf/models/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
Tested on Linux and macOS.
'''

import json, os, shutil, subprocess, math, platform, base64
import json, os, shutil, platform, base64
from os.path import join as pJoin

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import pandapower as ppow

from omf import transmission as network
from omf.models import __neoMetaModel__
from omf.models.__neoMetaModel__ import *
Expand Down
9 changes: 1 addition & 8 deletions omf/models/voltageDrop.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
''' Graph the voltage drop on a feeder. '''
import json, os, tempfile, shutil, csv, math, warnings, base64, platform
import json, os, tempfile, shutil, csv, math, base64
from os.path import join as pJoin
import networkx as nx

import matplotlib
if platform.system() == 'Darwin':
matplotlib.use('TkAgg')
else:
matplotlib.use('Agg')
from matplotlib import pyplot as plt

# dateutil imports
from dateutil import parser
from dateutil.relativedelta import *

# OMF imports
import omf
from omf import feeder
Expand Down
2 changes: 1 addition & 1 deletion omf/runOmf.command
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Command to start up the OMF web server locally. Works on Unix, macOS.
script_dir=$(dirname "$0")
cd "$script_dir"
python web.py
python3 web.py
read -n1 -r -p "Server stopped. Press space to continue..." key

0 comments on commit 479eee8

Please sign in to comment.