From 29884a39690c3734d3df4dd798254102c2c0c0cb Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 10:55:07 +0200 Subject: [PATCH 01/13] use straight quotation marks in comment --- optool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optool.py b/optool.py index b4605ca..6fbca5d 100644 --- a/optool.py +++ b/optool.py @@ -15,7 +15,7 @@ and plot the results import optool - p = optool.particle(ā€™~/bin/optool pyr 0.8 -m ice 0.2 -na 24 -dā€™) + p = optool.particle('~/bin/optool pyr 0.8 -m ice 0.2 -na 24 -d') p.plot() Read opacity files produced earlier by a run of optool. This is From 3275e02e4e84e856ff0a0ab8f1f5d8f892cc3dbe Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 10:56:30 +0200 Subject: [PATCH 02/13] Remove deprecated distutils, avoid using reserved keywords --- optool.py | 69 +++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/optool.py b/optool.py index 6fbca5d..e68c9a6 100644 --- a/optool.py +++ b/optool.py @@ -87,7 +87,6 @@ import os import shutil import subprocess -from distutils.spawn import find_executable import tempfile class particle: @@ -243,35 +242,35 @@ def __init__(self,cmd,cache='',silent=False): cmd[0] = os.path.expanduser(cmd[0]) # Find the optool executable - bin = find_executable(cmd[0]) - if (not bin): + executable = shutil.which(cmd[0]) + if (not executable): raise RuntimeError("Executable not found: "+cmd[0]) # Wrap the main part into try - finally to make sure we clean up try: if (cache): - dir = cache + directory = cache else: # create temporary directory in /tmp/ - dir = tempfile.mkdtemp(prefix="optool_") + directory = tempfile.mkdtemp(prefix="optool_") if cmd: if cache: # make sure directory is new and empty - shutil.rmtree(dir,ignore_errors=True) - os.mkdir(dir) + shutil.rmtree(directory,ignore_errors=True) + os.mkdir(directory) # Store the command line we are using. We store the # string version of the command, not the list version. - writecmd(dir,self.cmd) + writecmd(directory,self.cmd) # tell optool to use the directory as writing desination - cmd.append('-o'); cmd.append(dir) + cmd.append('-o'); cmd.append(directory) # Run optool to produce the opacities stdout = subprocess.DEVNULL if silent else None stderr = subprocess.DEVNULL if silent else None - cmd[0] = bin; subprocess.Popen(cmd, stdout=stdout, stderr=stderr).wait() + cmd[0] = executable; subprocess.Popen(cmd, stdout=stdout, stderr=stderr).wait() # Check if there is output we can use - scat,ext,translate = check_for_output(dir) + scat,ext,translate = check_for_output(directory) self.scat = scat self.massscale = 1. @@ -283,9 +282,9 @@ def __init__(self,cmd,cache='',silent=False): for i in range(5000): if scat: - file = ("%s/dustkapscatmat_%03d.%s") % (dir,(i+1),ext) + file = ("%s/dustkapscatmat_%03d.%s") % (directory,(i+1),ext) else: - file = ("%s/dustkappa_%03d.%s") % (dir,(i+1),ext) + file = ("%s/dustkappa_%03d.%s") % (directory,(i+1),ext) file = translate.get(file,file) if (not os.path.exists(file)): break nfiles = nfiles+1 @@ -327,11 +326,11 @@ def __init__(self,cmd,cache='',silent=False): finally: if cache: if not silent: - print("Files remain available in directory: "+dir) + print("Files remain available in directory: "+directory) else: if not silent: - print("Cleaning up temporary directory "+dir) - shutil.rmtree(dir) + print("Cleaning up temporary directory "+directory) + shutil.rmtree(directory) def plot(self,minkap=1e0): """Create interactive plots of the opacities in SELF. @@ -1111,18 +1110,18 @@ def logscale_with_sign(array,bottom): array[b] = -np.log10(-array[b]+bottom) + lb return array -def check_for_output(dir): +def check_for_output(directory): # Check for and if necessary rename input files for ext in['dat','inp']: - if (os.path.exists(dir+'/dustkapscatmat_001.'+ext)): + if (os.path.exists(directory+'/dustkapscatmat_001.'+ext)): return True, ext, dict() - elif (os.path.exists(dir+'/dustkappa_001.'+ext)): + elif (os.path.exists(directory+'/dustkappa_001.'+ext)): return False, ext, dict() - elif (os.path.exists(dir+'/dustkapscatmat.'+ext)): - return True, ext, { dir+'/dustkapscatmat_001.'+ext : dir+'/dustkapscatmat.'+ext } - elif (os.path.exists(dir+'/dustkappa.'+ext)): - return False, ext, { dir+'/dustkappa_001.'+ext : dir+'/dustkappa.'+ext } - raise RuntimeError(f"No valid OpTool output files found in directory {dir}") + elif (os.path.exists(directory+'/dustkapscatmat.'+ext)): + return True, ext, { directory+'/dustkapscatmat_001.'+ext : directory+'/dustkapscatmat.'+ext } + elif (os.path.exists(directory+'/dustkappa.'+ext)): + return False, ext, { directory+'/dustkappa_001.'+ext : directory+'/dustkappa.'+ext } + raise RuntimeError(f"No valid OpTool output files found in directory {directory}") def parse_headers(headers,b): # Extract information on run parameters from headers @@ -1268,13 +1267,13 @@ def readoutputfile(file,scat,silent=False): else: return [header,lam,kabs,ksca,phase_g] -def writecmd(dir,cmd): +def writecmd(directory,cmd): """Store the CMD string in file DIR/cmd. """ - if (os.path.isdir(dir)): + if (os.path.isdir(directory)): # Directory does not exist - dir = dir.rstrip('/') - filename = dir+"/cmd" + directory = directory.rstrip('/') + filename = directory+"/cmd" try: wfile = open(filename, 'w') except: @@ -1287,23 +1286,23 @@ def writecmd(dir,cmd): else: return False -def checkcmd(dir,cmd): +def checkcmd(directory,cmd): """Check if new command line is the same as the old one. This functions checks if the directory DIR contains a file - called CMD, and if the first line in thie directory is the + called CMD, and if the first line in this directory is the same as the string passed with the DIR parameter. """ - if (not os.path.isdir(dir)): + if (not os.path.isdir(directory)): # Directory does not exist return False - if (len(os.listdir(dir))<=1): + if (len(os.listdir(directory))<=1): # There are less than one file in the directory. So either the cmd # file does not exist, or no output files are present. return False - dir = dir.rstrip('/') - filename = dir+"/cmd" - if (not os.path.exists(dir+"/cmd")): + directory = directory.rstrip('/') + filename = directory+"/cmd" + if (not os.path.exists(directory+"/cmd")): # The command file does not exist return False try: From 5f19612cd48dcf7b12d2b1c5405965eaaea36742 Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 10:57:07 +0200 Subject: [PATCH 03/13] Avoid SyntaxWarning --- optool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/optool.py b/optool.py index e68c9a6..003fb55 100644 --- a/optool.py +++ b/optool.py @@ -1,4 +1,6 @@ -"""NAME +#!/bin/sh python3 +r""" +NAME optool DESCRIPTION From c616073a8949a19935ec547a645abfa1c66b0470 Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 10:57:31 +0200 Subject: [PATCH 04/13] spelling corrections --- optool.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/optool.py b/optool.py index 003fb55..d66df61 100644 --- a/optool.py +++ b/optool.py @@ -92,7 +92,8 @@ import tempfile class particle: - """Run optool and turn output into a python object. + """ + Run optool and turn output into a python object. Provides an interface to the optool program for computing dust opacities. The optool program can be found on GitHub, at this address: @@ -186,7 +187,8 @@ class particle: Compute opacity of a size distribution of elements of SELF """ def __init__(self,cmd,cache='',silent=False): - """Create a new optool.particle opject. + """ + Create a new optool.particle object. Parameters ---------= @@ -200,7 +202,7 @@ def __init__(self,cmd,cache='',silent=False): the second parameter CACHE. cache : str, optional - The diretory to cache the optool output files in, so that + The directory to cache the optool output files in, so that they can be read instead of recomputed the next time the same command is used. The cache is automatically cleared when CMD changes between runs. @@ -227,13 +229,13 @@ def __init__(self,cmd,cache='',silent=False): # No command, just read directory if not silent: print("Reading files in directory:",cache,"...") - # Set cmd to the emty string, to signal not to run a command + # Set cmd to the empty string, to signal not to run a command cmd = '' elif (cache and checkcmd(cache,self.cmd)): # Directory was created by the exact same command - just read if not silent: print("Using result cache in directory:",cache,"...") - # Set cmd to the emty string, to signal not to run a command + # Set cmd to the empty string, to signal not to run a command cmd = '' else: # Convert command string into list if necessary @@ -442,7 +444,7 @@ def plotpi(self,ymin=None,ymax=None): def select(self,i): """Select just one bin from a multi-particle object. - A multi-particle opject is produced when running optool with + A multi-particle object is produced when running optool with a -d switch. This is useful for doing particle arithmetic, which only works for From 8b2cc9e6948938adb681cc1d88f1e1f2feb4567c Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 10:57:43 +0200 Subject: [PATCH 05/13] Add requirements.txt --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..aa094d9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +numpy +matplotlib From 039361cc527519562b34f8f7af383282ad0ed66a Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 11:43:35 +0200 Subject: [PATCH 06/13] update .gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f58549b..3dd2d16 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ __pycache__ auto/ *.html *.tex -*.tex *.aux *.log *.dvi @@ -31,4 +30,4 @@ tmp.py optool.pdf optool_sd.dat optool_lam.dat -plotsd.py \ No newline at end of file +plotsd.py From f3b20ece4bc67c0240c0c302e16e48504d83fd05 Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 13:30:08 +0200 Subject: [PATCH 07/13] move files; update .gitignore --- .gitignore | 1 + Makefile => src/optool/Makefile | 0 {code4reading => src/optool/code4reading}/Makefile | 0 {code4reading => src/optool/code4reading}/README | 0 .../optool/code4reading}/readascii.f90 | 0 .../optool/code4reading}/readascii.py | 0 .../optool/code4reading}/readfits.f90 | 0 .../optool/code4reading}/readfits.py | 0 {lnk_data => src/optool/lnk_data}/ad/README.org | 0 .../optool/lnk_data}/ad/c-gra-x-Draine2003.lnk | 0 .../optool/lnk_data}/ad/c-gra-y-Draine2003.lnk | 0 .../optool/lnk_data}/ad/c-gra-z-Draine2003.lnk | 0 .../optool/lnk_data}/ad/ol-c-mg00-x-Fabian2001.lnk | 0 .../optool/lnk_data}/ad/ol-c-mg00-y-Fabian2001.lnk | 0 .../optool/lnk_data}/ad/ol-c-mg00-z-Fabian2001.lnk | 0 .../optool/lnk_data}/ad/ol-c-mg100-x-Suto2006.lnk | 0 .../optool/lnk_data}/ad/ol-c-mg100-y-Suto2006.lnk | 0 .../optool/lnk_data}/ad/ol-c-mg100-z-Suto2006.lnk | 0 .../optool/lnk_data}/ad/ol-c-mg95-x-Fabian2001.lnk | 0 .../optool/lnk_data}/ad/ol-c-mg95-y-Fabian2001.lnk | 0 .../optool/lnk_data}/ad/ol-c-mg95-z-Fabian2001.lnk | 0 .../optool/lnk_data}/ad/pyr-c-mg96-x-Jaeger1998.lnk | 0 .../optool/lnk_data}/ad/pyr-c-mg96-y-Jaeger1998.lnk | 0 .../optool/lnk_data}/ad/pyr-c-mg96-z-Jaeger1998.lnk | 0 .../optool/lnk_data}/astrosil-Draine2003.lnk | 0 .../optool/lnk_data}/c-gra-Draine2003.lnk | 0 .../optool/lnk_data}/c-nano-Mutschke2004.lnk | 0 .../optool/lnk_data}/c-org-Henning1996.lnk | 0 .../optool/lnk_data}/c-p-Preibisch1993.lnk | 0 {lnk_data => src/optool/lnk_data}/c-z-Zubko1996.lnk | 0 .../optool/lnk_data}/ch3oh-a-Gerakines2020.lnk | 0 .../optool/lnk_data}/ch3oh-c-Gerakines2020.lnk | 0 .../optool/lnk_data}/ch4-a-Gerakines2020.lnk | 0 .../optool/lnk_data}/ch4-c-Gerakines2020.lnk | 0 .../optool/lnk_data}/co-a-Palumbo2006.lnk | 0 .../optool/lnk_data}/co2-a-Gerakines2020.lnk | 0 .../optool/lnk_data}/co2-c-Gerakines2020.lnk | 0 .../optool/lnk_data}/co2-w-Warren1986.lnk | 0 .../optool/lnk_data}/cor-c-Koike1995.lnk | 0 .../optool/lnk_data}/fe-c-Henning1996.lnk | 0 .../optool/lnk_data}/fes-Henning1996.lnk | 0 .../optool/lnk_data}/h2o-a-Hudgins1993.lnk | 0 .../optool/lnk_data}/h2o-w-Warren2008.lnk | 0 {lnk_data => src/optool/lnk_data}/lnk-help.txt | 0 .../optool/lnk_data}/nh3-m-Martonchik1983.lnk | 0 .../optool/lnk_data}/ol-c-mg00-Fabian2001.lnk | 0 .../optool/lnk_data}/ol-c-mg100-Suto2006.lnk | 0 .../optool/lnk_data}/ol-c-mg95-Fabian2001.lnk | 0 .../optool/lnk_data}/ol-mg40-Dorschner1995.lnk | 0 .../optool/lnk_data}/ol-mg50-Dorschner1995.lnk | 0 .../optool/lnk_data}/pyr-c-mg96-Jaeger1998.lnk | 0 .../optool/lnk_data}/pyr-mg100-Dorschner1995.lnk | 0 .../optool/lnk_data}/pyr-mg40-Dorschner1995.lnk | 0 .../optool/lnk_data}/pyr-mg50-Dorschner1995.lnk | 0 .../optool/lnk_data}/pyr-mg60-Dorschner1995.lnk | 0 .../optool/lnk_data}/pyr-mg70-Dorschner1995.lnk | 0 .../optool/lnk_data}/pyr-mg80-Dorschner1995.lnk | 0 .../optool/lnk_data}/pyr-mg95-Dorschner1995.lnk | 0 {lnk_data => src/optool/lnk_data}/retired/README | 0 .../lnk_data}/retired/ol-c-mg100-Steyer1974.lnk | 0 .../optool/lnk_data}/sic-Draine1993.lnk | 0 .../optool/lnk_data}/sio2-Kitamura2007.lnk | 0 {maint => src/optool/maint}/RELEASE | 0 {maint => src/optool/maint}/all_k.pdf | Bin {maint => src/optool/maint}/bake_manual.el | 0 {maint => src/optool/maint}/bake_manual.pl | 0 {maint => src/optool/maint}/ingestlnk.pl | 0 {maint => src/optool/maint}/inspect.png | Bin {maint => src/optool/maint}/notes.org | 0 {maint => src/optool/maint}/plotall.py | 0 {maint => src/optool/maint}/ref_ind.template | 0 {maint => src/optool/maint}/run_examples | 0 {maint => src/optool/maint}/selftest.pl | 0 optool-complete => src/optool/optool-complete | 0 optool.bib => src/optool/optool.bib | 0 optool.f90 => src/optool/optool.f90 | 0 optool.py => src/optool/optool.py | 0 optool2tex => src/optool/optool2tex | 0 optool_fractal.f90 => src/optool/optool_fractal.f90 | 0 .../optool/optool_geofractal.f90 | 0 optool_guts.f90 => src/optool/optool_guts.f90 | 0 optool_manual.f90 => src/optool/optool_manual.f90 | 0 optool_refind.f90 => src/optool/optool_refind.f90 | 0 83 files changed, 1 insertion(+) rename Makefile => src/optool/Makefile (100%) rename {code4reading => src/optool/code4reading}/Makefile (100%) rename {code4reading => src/optool/code4reading}/README (100%) rename {code4reading => src/optool/code4reading}/readascii.f90 (100%) rename {code4reading => src/optool/code4reading}/readascii.py (100%) rename {code4reading => src/optool/code4reading}/readfits.f90 (100%) rename {code4reading => src/optool/code4reading}/readfits.py (100%) rename {lnk_data => src/optool/lnk_data}/ad/README.org (100%) rename {lnk_data => src/optool/lnk_data}/ad/c-gra-x-Draine2003.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/c-gra-y-Draine2003.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/c-gra-z-Draine2003.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/ol-c-mg00-x-Fabian2001.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/ol-c-mg00-y-Fabian2001.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/ol-c-mg00-z-Fabian2001.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/ol-c-mg100-x-Suto2006.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/ol-c-mg100-y-Suto2006.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/ol-c-mg100-z-Suto2006.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/ol-c-mg95-x-Fabian2001.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/ol-c-mg95-y-Fabian2001.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/ol-c-mg95-z-Fabian2001.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/pyr-c-mg96-x-Jaeger1998.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/pyr-c-mg96-y-Jaeger1998.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ad/pyr-c-mg96-z-Jaeger1998.lnk (100%) rename {lnk_data => src/optool/lnk_data}/astrosil-Draine2003.lnk (100%) rename {lnk_data => src/optool/lnk_data}/c-gra-Draine2003.lnk (100%) rename {lnk_data => src/optool/lnk_data}/c-nano-Mutschke2004.lnk (100%) rename {lnk_data => src/optool/lnk_data}/c-org-Henning1996.lnk (100%) rename {lnk_data => src/optool/lnk_data}/c-p-Preibisch1993.lnk (100%) rename {lnk_data => src/optool/lnk_data}/c-z-Zubko1996.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ch3oh-a-Gerakines2020.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ch3oh-c-Gerakines2020.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ch4-a-Gerakines2020.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ch4-c-Gerakines2020.lnk (100%) rename {lnk_data => src/optool/lnk_data}/co-a-Palumbo2006.lnk (100%) rename {lnk_data => src/optool/lnk_data}/co2-a-Gerakines2020.lnk (100%) rename {lnk_data => src/optool/lnk_data}/co2-c-Gerakines2020.lnk (100%) rename {lnk_data => src/optool/lnk_data}/co2-w-Warren1986.lnk (100%) rename {lnk_data => src/optool/lnk_data}/cor-c-Koike1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/fe-c-Henning1996.lnk (100%) rename {lnk_data => src/optool/lnk_data}/fes-Henning1996.lnk (100%) rename {lnk_data => src/optool/lnk_data}/h2o-a-Hudgins1993.lnk (100%) rename {lnk_data => src/optool/lnk_data}/h2o-w-Warren2008.lnk (100%) rename {lnk_data => src/optool/lnk_data}/lnk-help.txt (100%) rename {lnk_data => src/optool/lnk_data}/nh3-m-Martonchik1983.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ol-c-mg00-Fabian2001.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ol-c-mg100-Suto2006.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ol-c-mg95-Fabian2001.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ol-mg40-Dorschner1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/ol-mg50-Dorschner1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/pyr-c-mg96-Jaeger1998.lnk (100%) rename {lnk_data => src/optool/lnk_data}/pyr-mg100-Dorschner1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/pyr-mg40-Dorschner1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/pyr-mg50-Dorschner1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/pyr-mg60-Dorschner1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/pyr-mg70-Dorschner1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/pyr-mg80-Dorschner1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/pyr-mg95-Dorschner1995.lnk (100%) rename {lnk_data => src/optool/lnk_data}/retired/README (100%) rename {lnk_data => src/optool/lnk_data}/retired/ol-c-mg100-Steyer1974.lnk (100%) rename {lnk_data => src/optool/lnk_data}/sic-Draine1993.lnk (100%) rename {lnk_data => src/optool/lnk_data}/sio2-Kitamura2007.lnk (100%) rename {maint => src/optool/maint}/RELEASE (100%) rename {maint => src/optool/maint}/all_k.pdf (100%) rename {maint => src/optool/maint}/bake_manual.el (100%) rename {maint => src/optool/maint}/bake_manual.pl (100%) rename {maint => src/optool/maint}/ingestlnk.pl (100%) rename {maint => src/optool/maint}/inspect.png (100%) rename {maint => src/optool/maint}/notes.org (100%) rename {maint => src/optool/maint}/plotall.py (100%) rename {maint => src/optool/maint}/ref_ind.template (100%) rename {maint => src/optool/maint}/run_examples (100%) rename {maint => src/optool/maint}/selftest.pl (100%) rename optool-complete => src/optool/optool-complete (100%) rename optool.bib => src/optool/optool.bib (100%) rename optool.f90 => src/optool/optool.f90 (100%) rename optool.py => src/optool/optool.py (100%) rename optool2tex => src/optool/optool2tex (100%) rename optool_fractal.f90 => src/optool/optool_fractal.f90 (100%) rename optool_geofractal.f90 => src/optool/optool_geofractal.f90 (100%) rename optool_guts.f90 => src/optool/optool_guts.f90 (100%) rename optool_manual.f90 => src/optool/optool_manual.f90 (100%) rename optool_refind.f90 => src/optool/optool_refind.f90 (100%) diff --git a/.gitignore b/.gitignore index 3dd2d16..3b10be6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +env/ optool optool.dSYM optool.egg-info diff --git a/Makefile b/src/optool/Makefile similarity index 100% rename from Makefile rename to src/optool/Makefile diff --git a/code4reading/Makefile b/src/optool/code4reading/Makefile similarity index 100% rename from code4reading/Makefile rename to src/optool/code4reading/Makefile diff --git a/code4reading/README b/src/optool/code4reading/README similarity index 100% rename from code4reading/README rename to src/optool/code4reading/README diff --git a/code4reading/readascii.f90 b/src/optool/code4reading/readascii.f90 similarity index 100% rename from code4reading/readascii.f90 rename to src/optool/code4reading/readascii.f90 diff --git a/code4reading/readascii.py b/src/optool/code4reading/readascii.py similarity index 100% rename from code4reading/readascii.py rename to src/optool/code4reading/readascii.py diff --git a/code4reading/readfits.f90 b/src/optool/code4reading/readfits.f90 similarity index 100% rename from code4reading/readfits.f90 rename to src/optool/code4reading/readfits.f90 diff --git a/code4reading/readfits.py b/src/optool/code4reading/readfits.py similarity index 100% rename from code4reading/readfits.py rename to src/optool/code4reading/readfits.py diff --git a/lnk_data/ad/README.org b/src/optool/lnk_data/ad/README.org similarity index 100% rename from lnk_data/ad/README.org rename to src/optool/lnk_data/ad/README.org diff --git a/lnk_data/ad/c-gra-x-Draine2003.lnk b/src/optool/lnk_data/ad/c-gra-x-Draine2003.lnk similarity index 100% rename from lnk_data/ad/c-gra-x-Draine2003.lnk rename to src/optool/lnk_data/ad/c-gra-x-Draine2003.lnk diff --git a/lnk_data/ad/c-gra-y-Draine2003.lnk b/src/optool/lnk_data/ad/c-gra-y-Draine2003.lnk similarity index 100% rename from lnk_data/ad/c-gra-y-Draine2003.lnk rename to src/optool/lnk_data/ad/c-gra-y-Draine2003.lnk diff --git a/lnk_data/ad/c-gra-z-Draine2003.lnk b/src/optool/lnk_data/ad/c-gra-z-Draine2003.lnk similarity index 100% rename from lnk_data/ad/c-gra-z-Draine2003.lnk rename to src/optool/lnk_data/ad/c-gra-z-Draine2003.lnk diff --git a/lnk_data/ad/ol-c-mg00-x-Fabian2001.lnk b/src/optool/lnk_data/ad/ol-c-mg00-x-Fabian2001.lnk similarity index 100% rename from lnk_data/ad/ol-c-mg00-x-Fabian2001.lnk rename to src/optool/lnk_data/ad/ol-c-mg00-x-Fabian2001.lnk diff --git a/lnk_data/ad/ol-c-mg00-y-Fabian2001.lnk b/src/optool/lnk_data/ad/ol-c-mg00-y-Fabian2001.lnk similarity index 100% rename from lnk_data/ad/ol-c-mg00-y-Fabian2001.lnk rename to src/optool/lnk_data/ad/ol-c-mg00-y-Fabian2001.lnk diff --git a/lnk_data/ad/ol-c-mg00-z-Fabian2001.lnk b/src/optool/lnk_data/ad/ol-c-mg00-z-Fabian2001.lnk similarity index 100% rename from lnk_data/ad/ol-c-mg00-z-Fabian2001.lnk rename to src/optool/lnk_data/ad/ol-c-mg00-z-Fabian2001.lnk diff --git a/lnk_data/ad/ol-c-mg100-x-Suto2006.lnk b/src/optool/lnk_data/ad/ol-c-mg100-x-Suto2006.lnk similarity index 100% rename from lnk_data/ad/ol-c-mg100-x-Suto2006.lnk rename to src/optool/lnk_data/ad/ol-c-mg100-x-Suto2006.lnk diff --git a/lnk_data/ad/ol-c-mg100-y-Suto2006.lnk b/src/optool/lnk_data/ad/ol-c-mg100-y-Suto2006.lnk similarity index 100% rename from lnk_data/ad/ol-c-mg100-y-Suto2006.lnk rename to src/optool/lnk_data/ad/ol-c-mg100-y-Suto2006.lnk diff --git a/lnk_data/ad/ol-c-mg100-z-Suto2006.lnk b/src/optool/lnk_data/ad/ol-c-mg100-z-Suto2006.lnk similarity index 100% rename from lnk_data/ad/ol-c-mg100-z-Suto2006.lnk rename to src/optool/lnk_data/ad/ol-c-mg100-z-Suto2006.lnk diff --git a/lnk_data/ad/ol-c-mg95-x-Fabian2001.lnk b/src/optool/lnk_data/ad/ol-c-mg95-x-Fabian2001.lnk similarity index 100% rename from lnk_data/ad/ol-c-mg95-x-Fabian2001.lnk rename to src/optool/lnk_data/ad/ol-c-mg95-x-Fabian2001.lnk diff --git a/lnk_data/ad/ol-c-mg95-y-Fabian2001.lnk b/src/optool/lnk_data/ad/ol-c-mg95-y-Fabian2001.lnk similarity index 100% rename from lnk_data/ad/ol-c-mg95-y-Fabian2001.lnk rename to src/optool/lnk_data/ad/ol-c-mg95-y-Fabian2001.lnk diff --git a/lnk_data/ad/ol-c-mg95-z-Fabian2001.lnk b/src/optool/lnk_data/ad/ol-c-mg95-z-Fabian2001.lnk similarity index 100% rename from lnk_data/ad/ol-c-mg95-z-Fabian2001.lnk rename to src/optool/lnk_data/ad/ol-c-mg95-z-Fabian2001.lnk diff --git a/lnk_data/ad/pyr-c-mg96-x-Jaeger1998.lnk b/src/optool/lnk_data/ad/pyr-c-mg96-x-Jaeger1998.lnk similarity index 100% rename from lnk_data/ad/pyr-c-mg96-x-Jaeger1998.lnk rename to src/optool/lnk_data/ad/pyr-c-mg96-x-Jaeger1998.lnk diff --git a/lnk_data/ad/pyr-c-mg96-y-Jaeger1998.lnk b/src/optool/lnk_data/ad/pyr-c-mg96-y-Jaeger1998.lnk similarity index 100% rename from lnk_data/ad/pyr-c-mg96-y-Jaeger1998.lnk rename to src/optool/lnk_data/ad/pyr-c-mg96-y-Jaeger1998.lnk diff --git a/lnk_data/ad/pyr-c-mg96-z-Jaeger1998.lnk b/src/optool/lnk_data/ad/pyr-c-mg96-z-Jaeger1998.lnk similarity index 100% rename from lnk_data/ad/pyr-c-mg96-z-Jaeger1998.lnk rename to src/optool/lnk_data/ad/pyr-c-mg96-z-Jaeger1998.lnk diff --git a/lnk_data/astrosil-Draine2003.lnk b/src/optool/lnk_data/astrosil-Draine2003.lnk similarity index 100% rename from lnk_data/astrosil-Draine2003.lnk rename to src/optool/lnk_data/astrosil-Draine2003.lnk diff --git a/lnk_data/c-gra-Draine2003.lnk b/src/optool/lnk_data/c-gra-Draine2003.lnk similarity index 100% rename from lnk_data/c-gra-Draine2003.lnk rename to src/optool/lnk_data/c-gra-Draine2003.lnk diff --git a/lnk_data/c-nano-Mutschke2004.lnk b/src/optool/lnk_data/c-nano-Mutschke2004.lnk similarity index 100% rename from lnk_data/c-nano-Mutschke2004.lnk rename to src/optool/lnk_data/c-nano-Mutschke2004.lnk diff --git a/lnk_data/c-org-Henning1996.lnk b/src/optool/lnk_data/c-org-Henning1996.lnk similarity index 100% rename from lnk_data/c-org-Henning1996.lnk rename to src/optool/lnk_data/c-org-Henning1996.lnk diff --git a/lnk_data/c-p-Preibisch1993.lnk b/src/optool/lnk_data/c-p-Preibisch1993.lnk similarity index 100% rename from lnk_data/c-p-Preibisch1993.lnk rename to src/optool/lnk_data/c-p-Preibisch1993.lnk diff --git a/lnk_data/c-z-Zubko1996.lnk b/src/optool/lnk_data/c-z-Zubko1996.lnk similarity index 100% rename from lnk_data/c-z-Zubko1996.lnk rename to src/optool/lnk_data/c-z-Zubko1996.lnk diff --git a/lnk_data/ch3oh-a-Gerakines2020.lnk b/src/optool/lnk_data/ch3oh-a-Gerakines2020.lnk similarity index 100% rename from lnk_data/ch3oh-a-Gerakines2020.lnk rename to src/optool/lnk_data/ch3oh-a-Gerakines2020.lnk diff --git a/lnk_data/ch3oh-c-Gerakines2020.lnk b/src/optool/lnk_data/ch3oh-c-Gerakines2020.lnk similarity index 100% rename from lnk_data/ch3oh-c-Gerakines2020.lnk rename to src/optool/lnk_data/ch3oh-c-Gerakines2020.lnk diff --git a/lnk_data/ch4-a-Gerakines2020.lnk b/src/optool/lnk_data/ch4-a-Gerakines2020.lnk similarity index 100% rename from lnk_data/ch4-a-Gerakines2020.lnk rename to src/optool/lnk_data/ch4-a-Gerakines2020.lnk diff --git a/lnk_data/ch4-c-Gerakines2020.lnk b/src/optool/lnk_data/ch4-c-Gerakines2020.lnk similarity index 100% rename from lnk_data/ch4-c-Gerakines2020.lnk rename to src/optool/lnk_data/ch4-c-Gerakines2020.lnk diff --git a/lnk_data/co-a-Palumbo2006.lnk b/src/optool/lnk_data/co-a-Palumbo2006.lnk similarity index 100% rename from lnk_data/co-a-Palumbo2006.lnk rename to src/optool/lnk_data/co-a-Palumbo2006.lnk diff --git a/lnk_data/co2-a-Gerakines2020.lnk b/src/optool/lnk_data/co2-a-Gerakines2020.lnk similarity index 100% rename from lnk_data/co2-a-Gerakines2020.lnk rename to src/optool/lnk_data/co2-a-Gerakines2020.lnk diff --git a/lnk_data/co2-c-Gerakines2020.lnk b/src/optool/lnk_data/co2-c-Gerakines2020.lnk similarity index 100% rename from lnk_data/co2-c-Gerakines2020.lnk rename to src/optool/lnk_data/co2-c-Gerakines2020.lnk diff --git a/lnk_data/co2-w-Warren1986.lnk b/src/optool/lnk_data/co2-w-Warren1986.lnk similarity index 100% rename from lnk_data/co2-w-Warren1986.lnk rename to src/optool/lnk_data/co2-w-Warren1986.lnk diff --git a/lnk_data/cor-c-Koike1995.lnk b/src/optool/lnk_data/cor-c-Koike1995.lnk similarity index 100% rename from lnk_data/cor-c-Koike1995.lnk rename to src/optool/lnk_data/cor-c-Koike1995.lnk diff --git a/lnk_data/fe-c-Henning1996.lnk b/src/optool/lnk_data/fe-c-Henning1996.lnk similarity index 100% rename from lnk_data/fe-c-Henning1996.lnk rename to src/optool/lnk_data/fe-c-Henning1996.lnk diff --git a/lnk_data/fes-Henning1996.lnk b/src/optool/lnk_data/fes-Henning1996.lnk similarity index 100% rename from lnk_data/fes-Henning1996.lnk rename to src/optool/lnk_data/fes-Henning1996.lnk diff --git a/lnk_data/h2o-a-Hudgins1993.lnk b/src/optool/lnk_data/h2o-a-Hudgins1993.lnk similarity index 100% rename from lnk_data/h2o-a-Hudgins1993.lnk rename to src/optool/lnk_data/h2o-a-Hudgins1993.lnk diff --git a/lnk_data/h2o-w-Warren2008.lnk b/src/optool/lnk_data/h2o-w-Warren2008.lnk similarity index 100% rename from lnk_data/h2o-w-Warren2008.lnk rename to src/optool/lnk_data/h2o-w-Warren2008.lnk diff --git a/lnk_data/lnk-help.txt b/src/optool/lnk_data/lnk-help.txt similarity index 100% rename from lnk_data/lnk-help.txt rename to src/optool/lnk_data/lnk-help.txt diff --git a/lnk_data/nh3-m-Martonchik1983.lnk b/src/optool/lnk_data/nh3-m-Martonchik1983.lnk similarity index 100% rename from lnk_data/nh3-m-Martonchik1983.lnk rename to src/optool/lnk_data/nh3-m-Martonchik1983.lnk diff --git a/lnk_data/ol-c-mg00-Fabian2001.lnk b/src/optool/lnk_data/ol-c-mg00-Fabian2001.lnk similarity index 100% rename from lnk_data/ol-c-mg00-Fabian2001.lnk rename to src/optool/lnk_data/ol-c-mg00-Fabian2001.lnk diff --git a/lnk_data/ol-c-mg100-Suto2006.lnk b/src/optool/lnk_data/ol-c-mg100-Suto2006.lnk similarity index 100% rename from lnk_data/ol-c-mg100-Suto2006.lnk rename to src/optool/lnk_data/ol-c-mg100-Suto2006.lnk diff --git a/lnk_data/ol-c-mg95-Fabian2001.lnk b/src/optool/lnk_data/ol-c-mg95-Fabian2001.lnk similarity index 100% rename from lnk_data/ol-c-mg95-Fabian2001.lnk rename to src/optool/lnk_data/ol-c-mg95-Fabian2001.lnk diff --git a/lnk_data/ol-mg40-Dorschner1995.lnk b/src/optool/lnk_data/ol-mg40-Dorschner1995.lnk similarity index 100% rename from lnk_data/ol-mg40-Dorschner1995.lnk rename to src/optool/lnk_data/ol-mg40-Dorschner1995.lnk diff --git a/lnk_data/ol-mg50-Dorschner1995.lnk b/src/optool/lnk_data/ol-mg50-Dorschner1995.lnk similarity index 100% rename from lnk_data/ol-mg50-Dorschner1995.lnk rename to src/optool/lnk_data/ol-mg50-Dorschner1995.lnk diff --git a/lnk_data/pyr-c-mg96-Jaeger1998.lnk b/src/optool/lnk_data/pyr-c-mg96-Jaeger1998.lnk similarity index 100% rename from lnk_data/pyr-c-mg96-Jaeger1998.lnk rename to src/optool/lnk_data/pyr-c-mg96-Jaeger1998.lnk diff --git a/lnk_data/pyr-mg100-Dorschner1995.lnk b/src/optool/lnk_data/pyr-mg100-Dorschner1995.lnk similarity index 100% rename from lnk_data/pyr-mg100-Dorschner1995.lnk rename to src/optool/lnk_data/pyr-mg100-Dorschner1995.lnk diff --git a/lnk_data/pyr-mg40-Dorschner1995.lnk b/src/optool/lnk_data/pyr-mg40-Dorschner1995.lnk similarity index 100% rename from lnk_data/pyr-mg40-Dorschner1995.lnk rename to src/optool/lnk_data/pyr-mg40-Dorschner1995.lnk diff --git a/lnk_data/pyr-mg50-Dorschner1995.lnk b/src/optool/lnk_data/pyr-mg50-Dorschner1995.lnk similarity index 100% rename from lnk_data/pyr-mg50-Dorschner1995.lnk rename to src/optool/lnk_data/pyr-mg50-Dorschner1995.lnk diff --git a/lnk_data/pyr-mg60-Dorschner1995.lnk b/src/optool/lnk_data/pyr-mg60-Dorschner1995.lnk similarity index 100% rename from lnk_data/pyr-mg60-Dorschner1995.lnk rename to src/optool/lnk_data/pyr-mg60-Dorschner1995.lnk diff --git a/lnk_data/pyr-mg70-Dorschner1995.lnk b/src/optool/lnk_data/pyr-mg70-Dorschner1995.lnk similarity index 100% rename from lnk_data/pyr-mg70-Dorschner1995.lnk rename to src/optool/lnk_data/pyr-mg70-Dorschner1995.lnk diff --git a/lnk_data/pyr-mg80-Dorschner1995.lnk b/src/optool/lnk_data/pyr-mg80-Dorschner1995.lnk similarity index 100% rename from lnk_data/pyr-mg80-Dorschner1995.lnk rename to src/optool/lnk_data/pyr-mg80-Dorschner1995.lnk diff --git a/lnk_data/pyr-mg95-Dorschner1995.lnk b/src/optool/lnk_data/pyr-mg95-Dorschner1995.lnk similarity index 100% rename from lnk_data/pyr-mg95-Dorschner1995.lnk rename to src/optool/lnk_data/pyr-mg95-Dorschner1995.lnk diff --git a/lnk_data/retired/README b/src/optool/lnk_data/retired/README similarity index 100% rename from lnk_data/retired/README rename to src/optool/lnk_data/retired/README diff --git a/lnk_data/retired/ol-c-mg100-Steyer1974.lnk b/src/optool/lnk_data/retired/ol-c-mg100-Steyer1974.lnk similarity index 100% rename from lnk_data/retired/ol-c-mg100-Steyer1974.lnk rename to src/optool/lnk_data/retired/ol-c-mg100-Steyer1974.lnk diff --git a/lnk_data/sic-Draine1993.lnk b/src/optool/lnk_data/sic-Draine1993.lnk similarity index 100% rename from lnk_data/sic-Draine1993.lnk rename to src/optool/lnk_data/sic-Draine1993.lnk diff --git a/lnk_data/sio2-Kitamura2007.lnk b/src/optool/lnk_data/sio2-Kitamura2007.lnk similarity index 100% rename from lnk_data/sio2-Kitamura2007.lnk rename to src/optool/lnk_data/sio2-Kitamura2007.lnk diff --git a/maint/RELEASE b/src/optool/maint/RELEASE similarity index 100% rename from maint/RELEASE rename to src/optool/maint/RELEASE diff --git a/maint/all_k.pdf b/src/optool/maint/all_k.pdf similarity index 100% rename from maint/all_k.pdf rename to src/optool/maint/all_k.pdf diff --git a/maint/bake_manual.el b/src/optool/maint/bake_manual.el similarity index 100% rename from maint/bake_manual.el rename to src/optool/maint/bake_manual.el diff --git a/maint/bake_manual.pl b/src/optool/maint/bake_manual.pl similarity index 100% rename from maint/bake_manual.pl rename to src/optool/maint/bake_manual.pl diff --git a/maint/ingestlnk.pl b/src/optool/maint/ingestlnk.pl similarity index 100% rename from maint/ingestlnk.pl rename to src/optool/maint/ingestlnk.pl diff --git a/maint/inspect.png b/src/optool/maint/inspect.png similarity index 100% rename from maint/inspect.png rename to src/optool/maint/inspect.png diff --git a/maint/notes.org b/src/optool/maint/notes.org similarity index 100% rename from maint/notes.org rename to src/optool/maint/notes.org diff --git a/maint/plotall.py b/src/optool/maint/plotall.py similarity index 100% rename from maint/plotall.py rename to src/optool/maint/plotall.py diff --git a/maint/ref_ind.template b/src/optool/maint/ref_ind.template similarity index 100% rename from maint/ref_ind.template rename to src/optool/maint/ref_ind.template diff --git a/maint/run_examples b/src/optool/maint/run_examples similarity index 100% rename from maint/run_examples rename to src/optool/maint/run_examples diff --git a/maint/selftest.pl b/src/optool/maint/selftest.pl similarity index 100% rename from maint/selftest.pl rename to src/optool/maint/selftest.pl diff --git a/optool-complete b/src/optool/optool-complete similarity index 100% rename from optool-complete rename to src/optool/optool-complete diff --git a/optool.bib b/src/optool/optool.bib similarity index 100% rename from optool.bib rename to src/optool/optool.bib diff --git a/optool.f90 b/src/optool/optool.f90 similarity index 100% rename from optool.f90 rename to src/optool/optool.f90 diff --git a/optool.py b/src/optool/optool.py similarity index 100% rename from optool.py rename to src/optool/optool.py diff --git a/optool2tex b/src/optool/optool2tex similarity index 100% rename from optool2tex rename to src/optool/optool2tex diff --git a/optool_fractal.f90 b/src/optool/optool_fractal.f90 similarity index 100% rename from optool_fractal.f90 rename to src/optool/optool_fractal.f90 diff --git a/optool_geofractal.f90 b/src/optool/optool_geofractal.f90 similarity index 100% rename from optool_geofractal.f90 rename to src/optool/optool_geofractal.f90 diff --git a/optool_guts.f90 b/src/optool/optool_guts.f90 similarity index 100% rename from optool_guts.f90 rename to src/optool/optool_guts.f90 diff --git a/optool_manual.f90 b/src/optool/optool_manual.f90 similarity index 100% rename from optool_manual.f90 rename to src/optool/optool_manual.f90 diff --git a/optool_refind.f90 b/src/optool/optool_refind.f90 similarity index 100% rename from optool_refind.f90 rename to src/optool/optool_refind.f90 From 529837adcd4ea3a9510f61b6a3db9f9cb01ca229 Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 14:38:34 +0200 Subject: [PATCH 08/13] update setup files --- MANIFEST.in | 1 + pyproject.toml | 31 +++++++++++++++++++++++++++++++ setup.py | 10 ---------- 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 MANIFEST.in create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..149b4e2 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include src/optool * diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d414c88 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,31 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "Optool" +version = "2028.10.03" +# dynamic = ["version"] +dependencies = [ + "numpy", + "matplotlib", +] +requires-python = ">= 3.7" +authors = [ + {name = "Carsten Dominik", email = "c.dominik@uva.nl"}, +] +description = "Optool" +readme = {file = "README.org", content-type = "text/plain"} +license = {file = "LICENSE"} +keywords = ["astrophysics"] + +[project.urls] +Repository = "https://github.com/cdominik/optool" + +[tool.hatch.build.targets.sdist] +include = [ + "src/optool", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/optool"] diff --git a/setup.py b/setup.py deleted file mode 100644 index edf01de..0000000 --- a/setup.py +++ /dev/null @@ -1,10 +0,0 @@ -from setuptools import setup - -setup( - name='optool', - version='1.9.4', - py_modules=['optool'], - install_requires=[ - 'numpy','matplotlib' - ] -) From 928728e15de41df1bb5a42e7ee1eb59ade245c27 Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 16:24:41 +0200 Subject: [PATCH 09/13] package with setuptools, run Make if no executable found --- .gitignore | 1 - pyproject.toml | 9 +++++---- src/optool/__init__.py | 27 +++++++++++++++++++++++++++ src/optool/optool.py | 6 ++++++ 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/optool/__init__.py diff --git a/.gitignore b/.gitignore index 3b10be6..7cb2aad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ env/ -optool optool.dSYM optool.egg-info penmp diff --git a/pyproject.toml b/pyproject.toml index d414c88..f10a8e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" [project] name = "Optool" @@ -23,8 +23,9 @@ keywords = ["astrophysics"] Repository = "https://github.com/cdominik/optool" [tool.hatch.build.targets.sdist] -include = [ - "src/optool", +exclude = [ + "/.github", + "/env", ] [tool.hatch.build.targets.wheel] diff --git a/src/optool/__init__.py b/src/optool/__init__.py new file mode 100644 index 0000000..f15ff42 --- /dev/null +++ b/src/optool/__init__.py @@ -0,0 +1,27 @@ +import os +import pathlib +import shutil +import subprocess +from .optool import * + + +MODULE_PATH = pathlib.Path(__file__).parent.resolve() +OPTOOL = shutil.which(f"{MODULE_PATH}/optool") + + +def make_optool(options=None): + os.chdir(MODULE_PATH) + cmd = ["make",] + if options is not None: + cmd.append(options) + subprocess.Popen(cmd).wait() + + +if OPTOOL is None: + q = input( + "Cannot find 'optool' executable, shall I try to compile it using " + "default options (make clean; make multi)? (y/n)" + ) + if q.lower() == "y": + make_optool(options="clean") + make_optool(options="multi") diff --git a/src/optool/optool.py b/src/optool/optool.py index d66df61..923dacf 100644 --- a/src/optool/optool.py +++ b/src/optool/optool.py @@ -90,6 +90,8 @@ import shutil import subprocess import tempfile +import pathlib + class particle: """ @@ -248,6 +250,10 @@ def __init__(self,cmd,cache='',silent=False): # Find the optool executable executable = shutil.which(cmd[0]) if (not executable): + # Probably the executable is in the same directory as the module + module_path = pathlib.Path(__file__).parent.resolve() + executable = shutil.which(f"{module_path}/{cmd[0]}") + if (not executable): raise RuntimeError("Executable not found: "+cmd[0]) # Wrap the main part into try - finally to make sure we clean up From bd696b7aaf800872c2a37ba1837520083c6eb0cf Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Thu, 3 Oct 2024 16:25:20 +0200 Subject: [PATCH 10/13] update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 7cb2aad..6452740 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ optool.pdf optool_sd.dat optool_lam.dat plotsd.py +*.swp +dist From e6ffd3344f4ee5533627ee9e3e699068bd69887d Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Fri, 4 Oct 2024 14:34:29 +0200 Subject: [PATCH 11/13] update file locations --- CONTENT | 55 ++++++++++++++++++++++++------------------------ requirements.txt | 2 -- 2 files changed, 28 insertions(+), 29 deletions(-) delete mode 100644 requirements.txt diff --git a/CONTENT b/CONTENT index 57d65c7..7316034 100644 --- a/CONTENT +++ b/CONTENT @@ -1,32 +1,33 @@ List of files in the optool distribution ======================================== -CONTENT This file -INSTALL Brief installation instructions (also in UserGuide) -LICENSE License information -Makefile Makefile to aid compilation and installation -README.org Short introduction, source for githup site -UserGuide.org The User guide, an Emacs Org-mode file -UserGuide.pdf PDF version of UserGuide.org -code4reading Directory with code snippets to read optool output -codemeta.jason Matadata for optool -lnk_data Directory with refractive index data -maint Directory with scripts aiding maintenance -optool.f90 Main code file for optool -optool_guts.f90 Code that does the grunt work for computing opacities -optool_fractal.f90 Code implementing modified mean field theory -optool_geofractal.f90 Code computing geometric aggregate cross sections -optool_manual.f90 The Manual extracted from UserGuide.org, baked into f90 -optool_refind.f90 Refractive index data as fortran code -optool Binary program, only present after running "make" -optool.py Python module for working with optool -setup.py Code for python module installation -optool2tex Perl program to turn optool command into LaTeX text -optool-complete Code for shell-completion of switches and arguments -optool.bib BibTeX file with all relevant references +CONTENT This file +INSTALL Brief installation instructions (also in UserGuide) +LICENSE License information +README.org Short introduction, source for github site +UserGuide.org The User guide, an Emacs Org-mode file +UserGuide.pdf PDF version of UserGuide.org +codemeta.jason Metadata for optool +pyproject.toml Code for python module installation +src/optool/Makefile Makefile to aid compilation and installation +src/optool/__init__.py Python file for initializing the module +src/optool/code4reading Directory with code snippets to read optool output +src/optool/lnk_data Directory with refractive index data +src/optool/maint Directory with scripts aiding maintenance +src/optool/optool.f90 Main code file for optool +src/optool/optool_guts.f90 Code that does the grunt work for computing opacities +src/optool/optool_fractal.f90 Code implementing modified mean field theory +src/optool/optool_geofractal.f90 Code computing geometric aggregate cross sections +src/optool/optool_manual.f90 The Manual extracted from UserGuide.org, baked into f90 +src/optool/optool_refind.f90 Refractive index data as fortran code +src/optool/optool Binary program, only present after running "make" +src/optool/optool.py Python module for working with optool +src/optool/optool2tex Perl program to turn optool command into LaTeX text +src/optool/optool-complete Code for shell-completion of switches and arguments +src/optool/optool.bib BibTeX file with all relevant references -In directory maint +In directory src/optool/maint ================== RELEASE Description of how to produce a release all_k.pdf Plot of k values, made with plotall.py, used in manual @@ -41,7 +42,7 @@ run_examples Script running all examples from the manual selftest.pl Perl program to run a bunch of tests with optool -In directory code4reading +In directory src/optool/code4reading ========================= Makefile Makefile to compile the fortran snippets README Information about how to use the snippets @@ -51,12 +52,12 @@ readfits.f90 Fortran program to read FITS output readfits.py Python program to read FITS output -In directory lnk_data +In directory src/optool/lnk_data ===================== lnk-help.txt The help screen shown by optool -c retired Directory with retired datasets -The refractive index datasets in the lnk_data directory +The refractive index datasets in the src/optool/lnk_data directory ------------------------------------------------------- astrosil-Draine2003.lnk astronomical silicate c-gra-Draine2003.lnk graphite (crystalline) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index aa094d9..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -numpy -matplotlib From 690a127f254e80145b9e87f138adbdb661c93b6f Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Fri, 4 Oct 2024 14:40:01 +0200 Subject: [PATCH 12/13] update metadata --- pyproject.toml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f10a8e1..ea797f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,15 +4,17 @@ build-backend = "setuptools.build_meta" [project] name = "Optool" -version = "2028.10.03" +version = "1.9.5" # dynamic = ["version"] dependencies = [ - "numpy", - "matplotlib", + "numpy >= 1.18", + "matplotlib >= 2.0", ] requires-python = ">= 3.7" authors = [ {name = "Carsten Dominik", email = "c.dominik@uva.nl"}, + {name = "Michiel Min", email = "M.Min@sron.nl"}, + {name = "Ryo Tazaki", email = "ryo.tazaki1205@gmail.com"}, ] description = "Optool" readme = {file = "README.org", content-type = "text/plain"} @@ -20,13 +22,5 @@ license = {file = "LICENSE"} keywords = ["astrophysics"] [project.urls] +Issues = "https://github.com/cdominik/optool/issues" Repository = "https://github.com/cdominik/optool" - -[tool.hatch.build.targets.sdist] -exclude = [ - "/.github", - "/env", -] - -[tool.hatch.build.targets.wheel] -packages = ["src/optool"] From 0ac3f4c2e2431afcf04ce23e3fafdfd4d2f6d6df Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Fri, 4 Oct 2024 14:55:40 +0200 Subject: [PATCH 13/13] Change name due to pre-existing optool package --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ea797f3..510fa3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools >= 61.0"] build-backend = "setuptools.build_meta" [project] -name = "Optool" +name = "astro-optool" version = "1.9.5" # dynamic = ["version"] dependencies = [