Skip to content

Commit

Permalink
Removed unused variables, module and apply suggestions from Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKurek committed Jul 25, 2024
1 parent fdfeb6c commit d123d04
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions post_processing/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def plot_ortho(data_in,costheta,fig, ax, cax, latcen=45, loncen=0, nyz=512, colo

##################################3
# Finally, plot the bounding circle
sf=0.99
# sf=0.99
hp = 1/nyz
yplot = numpy.linspace(-1,1,nplot,dtype='float64')
yplot = yplot-hp*0
Expand Down Expand Up @@ -318,7 +318,7 @@ def plot_ortho(data_in,costheta,fig, ax, cax, latcen=45, loncen=0, nyz=512, colo



ax_center_x = ax_xmin + 0.5*ax_delta_x
# ax_center_x = ax_xmin + 0.5*ax_delta_x


cbar_aspect = 1./10.
Expand Down
60 changes: 30 additions & 30 deletions post_processing/rayleigh_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ def set(self,nml="",var="",val="", force = False):
var_lower = var.strip().lower()

if (force):
if (not (nml_lower in self.namelists)):
if nml_lower not in self.namelists:
self.vals[nml_lower] = OrderedDict()
self.namelists = list(self.vals.keys())

var_names = list(self.vals[nml_lower].keys())

if (not (var_lower in var_names)):
if var_lower not in var_names:
self.vals[nml_lower][var_lower]=""

if nml_lower in self.namelists:
Expand Down Expand Up @@ -135,13 +135,13 @@ def write(self, verbose = False, file=None, ndecimal=6, namelist=None):
"""

if (type(ndecimal) != type(6)):
if type(ndecimal) is not type(6):
ndecimal = 6
dstr = str(ndecimal)

lprint = print
endl=""
if (file != None):
if file is not None:
fd = open(file, "w")
lprint = fd.write
endl="\n"
Expand All @@ -159,18 +159,18 @@ def write(self, verbose = False, file=None, ndecimal=6, namelist=None):

for var in self.vals[nml].keys():
val = self.vals[nml][var]
if (type(val) == type(3.14)):
if type(val) is type(3.14):
fstring = "{:."+dstr+"e}"
val = fstring.format(val)
if (type(val) != type('astring')):
if type(val) is not type('astring'):
val = str(val)
if ((val != "") or verbose):
val_line = var+' = '+val+endl
lprint(val_line)

lprint("/"+endl)

if (file != None):
if file is not None:
fd.close()

def read_file_lines(self,filename):
Expand Down Expand Up @@ -242,7 +242,7 @@ def read(self, infile):
# Update the namelist list as we go.

nml_name = nextline[1:].split('namelist')[0][:-1]
if (not nml_name in self.namelists):
if nml_name not in self.namelists:
self.vals[nml_name] = OrderedDict()
self.namelists = list(self.vals.keys())

Expand Down Expand Up @@ -950,7 +950,7 @@ def read_data(self,qcodes = []):
if (len(qcodes) == 0):
self.vals[:,:] = fdata['fdata']['vals'][0,:,:]
else:
nqfile = self.nq # number of quantity codes in the file
# nqfile = self.nq # number of quantity codes in the file
qget = np.array(qcodes,dtype='int32')
self.qv = qget # Don't update the lookup table yet
self.nq = len(self.qv) # number of quantity codes we will extract
Expand Down Expand Up @@ -1073,7 +1073,7 @@ def __init__(self,filename='none',path='Shell_Avgs/', ofile=None, qcodes=[],time
#(a)
multiple_files = False
mainfile=filename
if (ofile != None):
if ofile is not None:
multiple_files = True

#(b)
Expand All @@ -1100,7 +1100,7 @@ def __init__(self,filename='none',path='Shell_Avgs/', ofile=None, qcodes=[],time
else:
self.time_average_files(filename, qcodes = qcodes,path=path, ntheta=ntheta, nfiles = nfiles, dt = dt)

if (ofile != None):
if ofile is not None:
self.write(ofile)


Expand Down Expand Up @@ -1382,7 +1382,7 @@ def read_data(self,qcodes = [],ntheta=0):
if (len(qcodes) == 0):
self.vals = vals
else:
nqfile = self.nq # number of quantity codes in the file
# nqfile = self.nq # number of quantity codes in the file
qget = np.array(qcodes,dtype='int32')
self.qv = qget # Don't update the lookup table yet
self.nq = len(self.qv) # number of quantity codes we will extract
Expand Down Expand Up @@ -1533,7 +1533,7 @@ def __init__(self,filename='none',path='AZ_Avgs/', ofile=None, qcodes=[],time_av
#(a)
multiple_files = False
mainfile=filename
if (ofile != None):
if ofile is not None:
multiple_files = True

#(b)
Expand All @@ -1560,7 +1560,7 @@ def __init__(self,filename='none',path='AZ_Avgs/', ofile=None, qcodes=[],time_av
else:
self.time_average_files(filename, qcodes = qcodes,path=path, dt = dt, nfiles = nfiles)

if (ofile != None):
if ofile is not None:
self.write(ofile)


Expand Down Expand Up @@ -1892,8 +1892,8 @@ def __init__(self,filename='none',path='Point_Probes/'):
self.ntheta = ntheta
self.nphi = nphi

hsize = (nr+ntheta+nphi)*12 + nq*4 + 8 + 16+4
recsize = nq*nphi*ntheta*nr*8 + 12
# hsize = (nr+ntheta+nphi)*12 + nq*4 + 8 + 16+4
# recsize = nq*nphi*ntheta*nr*8 + 12

self.qv = np.reshape(swapread(fd,dtype='int32',count=nq,swap=bs),(nq), order = 'F')

Expand Down Expand Up @@ -2700,13 +2700,13 @@ def Compile_GlobalAverages(file_list,ofile):
# and use the nrecs + nq in the file to create our combined array
a = G_Avgs(file_list[0], path = '')
nfiles = len(file_list)
niter_estimate = a.niter*nfiles
nq = a.nq
combined = np.zeros((niter_estimate,a.nq),dtype='float64')
time = np.zeros(niter_estimate,dtype='float64')
iters = np.zeros(niter_estimate,dtype='int32')
ncount = 0 # total number of iterations read so far
ind = 0
# niter_estimate = a.niter*nfiles
# nq = a.nq
# combined = np.zeros((niter_estimate,a.nq),dtype='float64')
# time = np.zeros(niter_estimate,dtype='float64')
# iters = np.zeros(niter_estimate,dtype='int32')
# ncount = 0 # total number of iterations read so far
# ind = 0

# We open the file that we want to store the compiled time traces into and write a header
fd = open(ofile,'wb') #w = write, b = binary
Expand Down Expand Up @@ -2750,8 +2750,8 @@ def TimeAvg_AZAverages(file_list,ofile):
ntheta = a.ntheta
nq = a.nq
tmp = np.zeros((ntheta,nr,nq),dtype='float64')
simtime = np.zeros(1,dtype='float64')
iteration = np.zeros(1,dtype='int32')
# simtime = np.zeros(1,dtype='float64')
# iteration = np.zeros(1,dtype='int32')
icount = np.zeros(1,dtype='int32')
ifinal = np.zeros(1,dtype='int32')
tfinal = np.zeros(1,dtype='float64')
Expand Down Expand Up @@ -2808,8 +2808,8 @@ def TimeAvg_ShellAverages(file_list,ofile):
tmp = np.zeros((nr,nq),dtype='float64')
else:
tmp = np.zeros((nr,4,nq),dtype='float64')
simtime = np.zeros(1,dtype='float64')
iteration = np.zeros(1,dtype='int32')
# simtime = np.zeros(1,dtype='float64')
# iteration = np.zeros(1,dtype='int32')
icount = np.zeros(1,dtype='int32')
ifinal = np.zeros(1,dtype='int32')
tfinal = np.zeros(1,dtype='float64')
Expand Down Expand Up @@ -2961,7 +2961,7 @@ def __init__(self,name=None,varnames=None,varfiles=None, rayleigh_root=None,
self.rayleigh_root=rayleigh_root
self.nxyz=nxyz
self.grid_file=grid_file
if (force == True):
if force:
print('Parameter "force" is set to true.')
print('Removing: '+self.vaporfile+' > /dev/null')
print('Removing: '+self.data_dir+' > /dev/null')
Expand Down Expand Up @@ -3057,7 +3057,7 @@ def rayleigh_vector_to_cube(self,vfiles, mag=False):

def cube_to_vdc(self,ofile,timeind,varind):
import subprocess as sp
if (type(varind) == type(1)):
if type(varind) is type(1):
varname=self.varnames[varind]
else:
varname=varind # string was passed
Expand Down Expand Up @@ -3128,7 +3128,7 @@ def plot_azav(fig,ax,field,radius,costheta,sintheta,r_bcz=0.71,mini=-1,maxi=-1,m
import numpy as np
import pylab as p
import matplotlib.pyplot as plt
from matplotlib import ticker, font_manager
from matplotlib import ticker #, font_manager
#Modified version of Antoine Strukarek's routine
#r = radius/6.9599e10
r = radius/np.max(radius)
Expand Down
2 changes: 1 addition & 1 deletion post_processing/reference_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def compute_heating_profile(hpars, radius, htype=0, pressure = 0):
# We normalize it such that it's integral over the volume is 1
# This way, we can set the luminosity via a constant in the input file

qint = 0
# qint = 0
lq = numpy.zeros(nr)
integrand= numpy.pi*4*radius*radius*profile
# First pass, compute integral to normalize
Expand Down

0 comments on commit d123d04

Please sign in to comment.