Skip to content

Commit

Permalink
updated SIROCCO env in Python scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmatthews committed Oct 18, 2024
1 parent 7e44295 commit 39ce287
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 64 deletions.
14 changes: 7 additions & 7 deletions py_progs/autogenerate_parameter_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
Print the full text of all .yaml files that would be created to the screen.
-w / --write
Move any deprecated parameters to `$PYTHON/parameters/old/`,
then write any new parameters to in `$PYTHON/parameters/`
Move any deprecated parameters to `$SIROCCO/parameters/old/`,
then write any new parameters to in `$SIROCCO/parameters/`
Note, this will not over-write any parameters that have changed types
but not names e.g. `rdflo('thing')` to `rdint('thing')`.
-h / --help
Prints this documentation.
After the program has been run $PYTHON/parameters should contain a yaml file
After the program has been run $SIROCCO/parameters should contain a yaml file
for every possible input, and any input that has changed significantly should
be in $PYHON/parameters.old One should normally be sure to add the new yaml
files to the repository.
Expand Down Expand Up @@ -58,7 +58,7 @@
The recommendation is to:
* to clean both $PYTHON/parameters/, and $PYTHON/parameters/old/ from your
* to clean both $SIROCCO/parameters/, and $SIROCCO/parameters/old/ from your
local directories before using writing files using this routine, and then
* to add and comit all of the files that are produced before going on to other
stages of activities associated with documentation.
Expand Down Expand Up @@ -464,9 +464,9 @@ def autogenerate_parameter_docs():
"""
Function to autogenerate parameter documentation.
"""
input_folder = os.path.join(os.environ["PYTHON"], "source")
output_folder = os.path.join(os.environ["PYTHON"], "docs", "parameters")
output_old_folder = os.path.join(os.environ["PYTHON"], "docs", "parameters", "old")
input_folder = os.path.join(os.environ["SIROCCO"], "source")
output_folder = os.path.join(os.environ["SIROCCO"], "docs", "parameters")
output_old_folder = os.path.join(os.environ["SIROCCO"], "docs", "parameters", "old")

input_files = list_input_files(input_folder)
existing_documentation = list_existing_documentation(output_folder)
Expand Down
10 changes: 5 additions & 5 deletions py_progs/autogenerate_rtd_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ def autogenerate_rtd_pages(output_folder):
"""
Write the RTD files to disk and add them to git, then run sphinx-build to generate the docs.
"""
# html_folder = os.path.join(os.environ["PYTHON"], "docs", "html")
docs_folder = os.path.join(os.environ["PYTHON"], "docs")
# html_folder = os.path.join(os.environ["SIROCCO"], "docs", "html")
docs_folder = os.path.join(os.environ["SIROCCO"], "docs")
dox_all = {}

par_folder= os.path.join(os.environ["PYTHON"], "docs", "parameters")
par_folder= os.path.join(os.environ["SIROCCO"], "docs", "parameters")
print('Par folder',par_folder)

dox_all = read_yaml(
Expand Down Expand Up @@ -296,8 +296,8 @@ def steer(argv):
This is just a steering routine to enable better control of the program
'''

outdir= os.path.join(os.environ["PYTHON"], "docs", "rst", "parameters")
xdir= os.path.join(os.environ["PYTHON"], "docs","sphinx")
outdir= os.path.join(os.environ["SIROCCO"], "docs", "rst", "parameters")
xdir= os.path.join(os.environ["SIROCCO"], "docs","sphinx")

i=1
while i< len(argv):
Expand Down
18 changes: 9 additions & 9 deletions py_progs/balmer_decrement.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
'''
Runs tests of the Balmer decrement for a one zone thin shell Python model.
Runs tests of the Balmer decrement for a one zone thin shell Sirocco model.
Involves running py_wind on a wind_save file and reading some output files.
Involves running swind on a wind_save file and reading some output files.
Compares to Osterbrock values.
Usage:
Expand All @@ -14,7 +14,7 @@
py_wind
numpy
matplotlib
py_plot_util, py_read_output from $PYTHON/py_progs in the python path
py_plot_util, py_read_output from $SIROCCO/py_progs in the python path
Notes:
This routine is a routine to check the results of running a one zone
Expand All @@ -26,8 +26,8 @@

# Do not call this when we're on ReadTheDocs
if not os.environ.get('READTHEDOCS'):
PYTHON = os.environ["PYTHON"]
sys.path.append("$PYTHON/py_progs/")
SIROCCO = os.environ["SIROCCO"]
sys.path.append("$SIROCCO/py_progs/")

import py_plot_util as util
import py_read_output as rd
Expand All @@ -48,7 +48,7 @@ def BalmerTest(root, plotit=True):

print ("Running Balmer Test for run {}...".format(root))

# create the list of commands to run in py wind
# create the list of commands to run in swind
nlevels = 8
cmds = ["1","s","n","i","1","1","1","1","2","0","M","2"]
for i in range(nlevels):
Expand All @@ -57,8 +57,8 @@ def BalmerTest(root, plotit=True):
cmds.append("q")

# run py wind. pass the command to run for situations in CI where we can't get the path working
py_wind_cmd = "{}/bin/py_wind".format(PYTHON)
isys, logfile_contents = util.run_py_wind(root, cmds=cmds, py_wind_cmd = py_wind_cmd, return_output = True)
swind_cmd = "{}/bin/swind".format(SIROCCO)
isys, logfile_contents = util.run_py_wind(root, cmds=cmds, py_wind_cmd = swind_cmd, return_output = True)
print (isys)

# these could be in principle be used to check absolute emissivity values
Expand All @@ -74,7 +74,7 @@ def BalmerTest(root, plotit=True):
for i in range(nlevels):
ratios[i] = rd.read_pywind("{}.lev{}_emiss.dat".format(root,i+3), mode="1d")[2][1]
except FileNotFoundError:
print("Error reading py_wind output. Logfile follows...")
print("Error reading swind output. Logfile follows...")
print (logfile_contents)


Expand Down
14 changes: 7 additions & 7 deletions py_progs/pf_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
pf_check_directory_date
The full path names to directories in the `$PYTHON/examples`
The full path names to directories in the `$SIROCCO/examples`
do not need to be given, so for example::
pf_check.py beta
will test the parameter files in `$PYTHON/examples/beta`.
will test the parameter files in `$SIROCCO/examples/beta`.
After running Python in -i mode for each of the files,
the routine diffs the .out.pf file with the original.pf
Expand Down Expand Up @@ -95,9 +95,9 @@ def travis():
Return a special set of commands when dealing with the travis directory
'''

PYTHON=os.environ['PYTHON']
SIROCCO=os.environ['SIROCCO']

x=open('%s/.travis.yml' % (PYTHON))
x=open('%s/.travis.yml' % (SIROCCO))
z=yaml.load(x)
print(z['script'])
commands=[]
Expand Down Expand Up @@ -132,9 +132,9 @@ def doit(directory):
if os.path.isdir(directory):
xdir=directory
else:
# Get the PYTHON environment variable
PYTHON=os.environ['PYTHON']
ydir='%s/examples/%s' % (PYTHON,directory)
# Get the SIROCCO environment variable
SIROCCO=os.environ['SIROCCO']
ydir='%s/examples/%s' % (SIROCCO,directory)
if os.path.isdir(ydir):
xdir=ydir
else:
Expand Down
2 changes: 1 addition & 1 deletion py_progs/py_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Post-run parser for error logs from parallel simulation runs.
This is the post-processing code to deal with the error logs in
PYTHON's parallel mode. It basically sums the number of errors
SIROCCO's parallel mode. It basically sums the number of errors
in the various diagnostic files
usage and arguments:
Expand Down
2 changes: 1 addition & 1 deletion py_progs/py_plot_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def make_spec_plot(s, fname, smooth_factor = 10, angles = True, components = Fal
print ("Making a {} by {} plot, {} spectra".format(nx, ny, nspecs))

if with_composite:
lambda_composite, f_composite, errors = np.loadtxt("%s/examples/telfer_qso_composite_hst.asc" % (os.environ["PYTHON"]), unpack=True, comments="#")
lambda_composite, f_composite, errors = np.loadtxt("%s/examples/telfer_qso_composite_hst.asc" % (os.environ["SIROCCO"]), unpack=True, comments="#")

for i in range(nspecs):

Expand Down
4 changes: 2 additions & 2 deletions py_progs/py_plot_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def read_pywind_smart(filename, return_inwind=False):

values = d[2].reshape(xshape, zshape)

# these are the values of inwind PYTHON spits out
# these are the values of inwind SIROCCO spits out
inwind = d[3].reshape(xshape, zshape)

# create an inwind boolean to use to create mask
Expand Down Expand Up @@ -211,7 +211,7 @@ def wind_to_masked(d, value_string, return_inwind=False, mode="2d", ignore_parti

values = d[value_string].reshape(xshape, zshape)

# these are the values of inwind PYTHON spits out
# these are the values of inwind SIROCCO spits out
inwind = d["inwind"].reshape(xshape, zshape)

# create an inwind boolean to use to create mask
Expand Down
20 changes: 10 additions & 10 deletions py_progs/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
the number of processors with which to run (default 3)
`-pf_dir test`
the directory containing all of the .pf files which will be run
The defaults is `$PYTHON/examples/regress`. One does not need
The defaults is `$SIROCCO/examples/regress`. One does not need
to provide the full path name to the directory. The routine doit
first searches the current workind directory for the directory and then
looks in `$PYTHON/examples/`
looks in `$SIROCCO/examples/`
`-x '-v/c'`
Extra switches to be applied to the run, such as using linear Doppler
shifts. Note that these will be applied to everything except the
Expand Down Expand Up @@ -207,7 +207,7 @@ def doit(version='py',pf_dir='',out_dir='',np=3,switches='',outputfile='Summary.
Notes:
The routine looks for the input directory first as a subdirectory
of the directory from which regression is run, and then in $PYTHON/examples/
of the directory from which regression is run, and then in $SIROCCO/examples/
History:
Expand Down Expand Up @@ -235,22 +235,22 @@ def doit(version='py',pf_dir='',out_dir='',np=3,switches='',outputfile='Summary.

print(date)

# Get the PYTHON environment variable
# Get the SIROCCO environment variable

PYTHON=os.environ['PYTHON']
print(PYTHON)
SIROCCO=os.environ['SIROCCO']
print(SIROCCO)

if pf_dir=='':
pf_dir=PYTHON+'/examples/regress'
pf_dir=SIROCCO+'/examples/regress'

if os.path.isdir(pf_dir):
pf_files=glob(pf_dir+'/*pf')
txt_files=glob(pf_dir+'/*.txt')
dat_files=glob(pf_dir+'/*.dat')
wind_save=glob(pf_dir+'/*.wind_save')
elif os.path.isdir('%s/examples/%s' % (PYTHON,pf_dir)):
pf_files=glob('%s/examples/%s/*pf' % (PYTHON,pf_dir))
txt_files=glob('%s/examples/%s/*.txt' % (PYTHON,pf_dir))
elif os.path.isdir('%s/examples/%s' % (SIROCCO,pf_dir)):
pf_files=glob('%s/examples/%s/*pf' % (SIROCCO,pf_dir))
txt_files=glob('%s/examples/%s/*.txt' % (SIROCCO,pf_dir))
dat_files=glob(pf_dir+'/*.dat')
wind_save=glob(pf_dir+'/*.wind_save')
else:
Expand Down
18 changes: 9 additions & 9 deletions py_progs/regression_nsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
the number of processors with which to run (default 3)
-pf_dir test
the directory containing all of the .pf files which will be run
The defaults is $PYTHON/examples/regress. One does not need
The defaults is $SIROCCO/examples/regress. One does not need
to provide the full path name to the directory. The routine doit
first searches the current workind directory for the directory and then
looks in $PYTHON/examples/
looks in $SIROCCO/examples/
-out_dir foo
The directory (below the current working directory) where the
tests will run. The defauld is constructed for the version and the data
Expand Down Expand Up @@ -162,7 +162,7 @@ def doit(version='py',pf_dir='',out_dir='',np=3,outputfile='Summary.txt'):
Notes:
The routine looks for the input directory first as a subdirectory
of the directory from which regression is run, and then in $PYTHON/examples/
of the directory from which regression is run, and then in $SIROCCO/examples/
History:
Expand All @@ -183,18 +183,18 @@ def doit(version='py',pf_dir='',out_dir='',np=3,outputfile='Summary.txt'):

print(date)

# Get the PYTHON environment variable
# Get the SIROCCO environment variable

PYTHON=os.environ['PYTHON']
print(PYTHON)
SIROCCO=os.environ['SIROCCO']
print(SIROCCO)

if pf_dir=='':
pf_dir=PYTHON+'/examples/regress'
pf_dir=SIROCCO+'/examples/regress'

if os.path.isdir(pf_dir):
pf_files=glob(pf_dir+'/*pf')
elif os.path('%s/%s' % (PYTHON,pf_dir)):
pf_files=glob('%s/%s' % (PYTHON,pf_dir))
elif os.path('%s/%s' % (SIROCCO,pf_dir)):
pf_files=glob('%s/%s' % (SIROCCO,pf_dir))
else:
print('Error: The pf directory %s does not appear to exist' % pf_dir)
return
Expand Down
14 changes: 7 additions & 7 deletions py_progs/retro.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,20 @@ def log2table(logfile='commits.txt',masterfile='retro_master.txt'):

return SUCCESS

PYTHON_SOURCE_DIRECTORY=''
SIROCCO_SOURCE_DIRECTORY=''

def get_python_source_directory():
global PYTHON_SOURCE_DIRECTORY
global SIROCCO_SOURCE_DIRECTORY

result=subprocess.run(['which','py'],capture_output=True,text=True)
location=str(result.stdout)
x=location.strip()
xx=x.replace('bin/py','source/')

PYTHON_SOURCE_DIRECTORY=xx
print('Set Python source directory to :',PYTHON_SOURCE_DIRECTORY)
SIROCCO_SOURCE_DIRECTORY=xx
print('Set Python source directory to :',SIROCCO_SOURCE_DIRECTORY)

return PYTHON_SOURCE_DIRECTORY
return SIROCCO_SOURCE_DIRECTORY


def compile_one(commit='a77ec180c017244cb56f41b50178daf81541748a',number=35,print_output=False):
Expand All @@ -215,9 +215,9 @@ def compile_one(commit='a77ec180c017244cb56f41b50178daf81541748a',number=35,prin

# cwd=os.getcwd()

if PYTHON_SOURCE_DIRECTORY=='':
if SIROCCO_SOURCE_DIRECTORY=='':
get_python_source_directory()
os.chdir(PYTHON_SOURCE_DIRECTORY)
os.chdir(SIROCCO_SOURCE_DIRECTORY)

result=subprocess.run(['git', 'checkout', commit],capture_output=True,text=True)
if result.returncode:
Expand Down
10 changes: 5 additions & 5 deletions py_progs/test_masterfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
needs python to be compiled.
Usage:
test_masterfiles.py [PYTHON VERSION]
test_masterfiles.py [SIROCCO VERSION]
'''
import py_read_output as rd
import subprocess, os, sys

# set env variable
# Do not call this when we're on ReadTheDocs
if not os.environ.get('READTHEDOCS'):
PYTHON = os.environ["PYTHON"]
SIROCCO = os.environ["SIROCCO"]

# change these if you want to test different files. These are all in data/ as of October 2019
macro_files = ['h20', 'h10_hetop_lohe1_standard80', 'h10_standard80', 'h10_hetop_standard80', 'h20_hetop_standard80']
Expand All @@ -33,7 +33,7 @@ def run_file(pf_template, masterfile, version=""):
rd.write_pf("_tmp.pf", pf)

# run process
process = subprocess.run("{}/bin/py{} -i _tmp.pf".format(PYTHON, version), shell=True, stdout=subprocess.PIPE)
process = subprocess.run("{}/bin/py{} -i _tmp.pf".format(SIROCCO, version), shell=True, stdout=subprocess.PIPE)

subprocess.run("/bin/rm -f _tmp.sig _tmp.out.pf logfile _tmp.out.pf.old _tmp.pf", shell=True, stdout=subprocess.PIPE)
subprocess.run("/bin/rm -rf diag__tmp", shell=True, stdout=subprocess.PIPE)
Expand All @@ -60,8 +60,8 @@ def run_test(VERSION):
run the test.
'''

macro_template = rd.read_pf("{}/examples/extended/cv_macro_benchmark.pf".format(PYTHON))
std_template = rd.read_pf("{}/examples/basic/cv_standard.pf".format(PYTHON))
macro_template = rd.read_pf("{}/examples/extended/cv_macro_benchmark.pf".format(SIROCCO))
std_template = rd.read_pf("{}/examples/basic/cv_standard.pf".format(SIROCCO))

subprocess.run("Setup_Py_Dir")

Expand Down
2 changes: 1 addition & 1 deletion py_progs/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
During-run parser for error logs from parallel simulation runs.
This is the during-processing watchdog code to deal with the error logs in
PYTHON's parallel mode. Very similar to py_error.py
SIROCCO's parallel mode. Very similar to py_error.py
usage and arguments:
Expand Down

0 comments on commit 39ce287

Please sign in to comment.