From 39ce287fa12dc3443124846c91c58ee349116e9a Mon Sep 17 00:00:00 2001 From: jhmatthews Date: Fri, 18 Oct 2024 14:37:36 +0100 Subject: [PATCH] updated SIROCCO env in Python scripts --- py_progs/autogenerate_parameter_docs.py | 14 +++++++------- py_progs/autogenerate_rtd_pages.py | 10 +++++----- py_progs/balmer_decrement.py | 18 +++++++++--------- py_progs/pf_check.py | 14 +++++++------- py_progs/py_error.py | 2 +- py_progs/py_plot_output.py | 2 +- py_progs/py_plot_util.py | 4 ++-- py_progs/regression.py | 20 ++++++++++---------- py_progs/regression_nsh.py | 18 +++++++++--------- py_progs/retro.py | 14 +++++++------- py_progs/test_masterfiles.py | 10 +++++----- py_progs/watchdog.py | 2 +- 12 files changed, 64 insertions(+), 64 deletions(-) diff --git a/py_progs/autogenerate_parameter_docs.py b/py_progs/autogenerate_parameter_docs.py index ab303c2c5..c265ebf44 100755 --- a/py_progs/autogenerate_parameter_docs.py +++ b/py_progs/autogenerate_parameter_docs.py @@ -18,8 +18,8 @@ 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')`. @@ -27,7 +27,7 @@ -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. @@ -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. @@ -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) diff --git a/py_progs/autogenerate_rtd_pages.py b/py_progs/autogenerate_rtd_pages.py index 4cd33c13e..3961d8d1c 100755 --- a/py_progs/autogenerate_rtd_pages.py +++ b/py_progs/autogenerate_rtd_pages.py @@ -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( @@ -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): diff --git a/py_progs/balmer_decrement.py b/py_progs/balmer_decrement.py index 7560f649d..aec0e153e 100755 --- a/py_progs/balmer_decrement.py +++ b/py_progs/balmer_decrement.py @@ -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: @@ -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 @@ -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 @@ -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): @@ -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 @@ -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) diff --git a/py_progs/pf_check.py b/py_progs/pf_check.py index d137bca98..e515ba07c 100755 --- a/py_progs/pf_check.py +++ b/py_progs/pf_check.py @@ -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 @@ -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=[] @@ -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: diff --git a/py_progs/py_error.py b/py_progs/py_error.py index ce7a13c04..c7362fbff 100755 --- a/py_progs/py_error.py +++ b/py_progs/py_error.py @@ -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: diff --git a/py_progs/py_plot_output.py b/py_progs/py_plot_output.py index 18ed12d15..46d960194 100755 --- a/py_progs/py_plot_output.py +++ b/py_progs/py_plot_output.py @@ -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): diff --git a/py_progs/py_plot_util.py b/py_progs/py_plot_util.py index 882dd0d63..2b7cc94eb 100755 --- a/py_progs/py_plot_util.py +++ b/py_progs/py_plot_util.py @@ -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 @@ -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 diff --git a/py_progs/regression.py b/py_progs/regression.py index 29b62fe9c..4f2f0d2cd 100755 --- a/py_progs/regression.py +++ b/py_progs/regression.py @@ -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 @@ -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: @@ -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: diff --git a/py_progs/regression_nsh.py b/py_progs/regression_nsh.py index e5234e6bc..fdf89b096 100755 --- a/py_progs/regression_nsh.py +++ b/py_progs/regression_nsh.py @@ -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 @@ -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: @@ -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 diff --git a/py_progs/retro.py b/py_progs/retro.py index 90252f18e..18bd0470e 100755 --- a/py_progs/retro.py +++ b/py_progs/retro.py @@ -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): @@ -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: diff --git a/py_progs/test_masterfiles.py b/py_progs/test_masterfiles.py index 17fd981b3..03a4a77b3 100755 --- a/py_progs/test_masterfiles.py +++ b/py_progs/test_masterfiles.py @@ -5,7 +5,7 @@ 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 @@ -13,7 +13,7 @@ # 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'] @@ -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) @@ -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") diff --git a/py_progs/watchdog.py b/py_progs/watchdog.py index 425639a86..8e1fa95bd 100755 --- a/py_progs/watchdog.py +++ b/py_progs/watchdog.py @@ -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: