Skip to content

Commit

Permalink
Merge pull request #4 from saultyevil/develop
Browse files Browse the repository at this point in the history
Update with new release
  • Loading branch information
saultyevil authored Jan 30, 2023
2 parents e1ae2dd + 3753ab3 commit 3cd6734
Show file tree
Hide file tree
Showing 34 changed files with 1,478 additions and 1,225 deletions.
29 changes: 29 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
tools:
python: "3.9"
# You can also specify other tool versions:
# nodejs: "16"
# rust: "1.55"
# golang: "1.17"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
# formats:
# - pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements.txt
13 changes: 13 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sphinx
karma_sphinx_theme
numpydoc
numba==0.53.1
numpy==1.20.2
psutil==5.8.0
SQLAlchemy==1.4.15
matplotlib==3.3.4
pandas==1.2.4
dust_extinction==1.0
scipy==1.6.2
astropy==4.2.1
protobuf==3.17.3
66 changes: 3 additions & 63 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,68 +9,8 @@ pypython
.. automodule:: pypython
:members:

math
----

.. automodule:: pypython.math
:members:

math.vector
^^^^^^^^^^^

.. automodule:: pypython.math.vector
:members:

physics
-------

.. automodule:: pypython.physics
:members:

physics.accretiondisc
^^^^^^^^^^^^^^^^^^^^^

.. automodule:: pypython.physics.accretiondisc
:members:

physics.blackbody
^^^^^^^^^^^^^^^^^

.. automodule:: pypython.physics.blackbody
:members:

physics.blackhole
^^^^^^^^^^^^^^^^^

.. automodule:: pypython.physics.blackhole
:members:

physics.models
^^^^^^^^^^^^^^

.. automodule:: pypython.physics.models
.. automodule:: pypython.wind
:members:

plot
----

.. automodule:: pypython.plot
:members:

plot.misc
^^^^^^^^^

.. automodule:: pypython.plot.misc
:members:

plot.spectrum
^^^^^^^^^^^^^

.. automodule:: pypython.plot.spectrum
:members:

plot.wind
^^^^^^^^^

.. automodule:: pypython.plot.wind
:members:
.. automodule:: pypython.spectrum
:members:
49 changes: 27 additions & 22 deletions pypython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
pypython is a companion python package to handle and analyse the data which
comes out of a Python simulation.
"""

import os.path
import re
import textwrap
Expand All @@ -16,13 +17,19 @@
from subprocess import run

import numpy as np
from scipy.signal import boxcar, convolve

from pypython.constants import (BOLTZMANN, CMS_TO_KMS, PARSEC, PI, PLANCK, VLIGHT)
from pypython.error import RunError
from pypython.math import vector
from pypython.physics.blackhole import gravitational_radius
from pypython.simulation.grid import get_parameter_value
import pypython.constants as c
import pypython.error as err
import pypython.math
import pypython.observations
import pypython.physics
import pypython.plot
import pypython.simulation
import pypython.spectrum
import pypython.util
import pypython.wind

# Import all the things which will be able to be seen

# Dictionary class -------------------------------------------------------------

Expand Down Expand Up @@ -165,13 +172,13 @@ def create_run_script(commands):
file = "#!/bin/bash\n\ndeclare -a directories=(\n"
for fp in paths:
file += "\t\"{}\"\n".format(fp)
file += ")\n\ncfp=$(pfp)\nfor i in \"${directories[@]}\"\ndo\n\tcd $i\n\tpfp\n"
file += ")\n\ncwd=$(pwd)\nfor i in \"${directories[@]}\"\ndo\n\tcd $i\n\tpwd\n"
if len(commands) > 1:
for k in range(len(commands) - 1):
file += "\t{}\n".format(commands[k + 1])
else:
file += "\t# commands\n"
file += "\tcd $cfp\ndone\n"
file += "\tcd $cwd\ndone\n"

with open("commands.sh", "w") as f:
f.write(file)
Expand Down Expand Up @@ -213,7 +220,6 @@ def create_slurm_file(name, n_cores, n_hours, n_minutes, py_flags, py_run_flags,
module load conda/py3-latest
source activate pypython
python /home/ejp1n17/PythonScripts/pyrun -n {n_cores} {py_run_flags} -f='{py_flags}'
echo "Done!" > completed.txt
""")

if fp[-1] != "/":
Expand Down Expand Up @@ -255,7 +261,7 @@ def create_wind_save_tables(root, fp=".", ion_density=False, cell_spec=False, ve
files_before = listdir(fp)

if not Path(f"{fp}/data").exists():
run_command("Setup_Py_Dir", fp)
pypython.util.run_command("Setup_Py_Dir", fp)

command = [name]
if ion_density:
Expand All @@ -264,9 +270,9 @@ def create_wind_save_tables(root, fp=".", ion_density=False, cell_spec=False, ve
command.append("-xall")
command.append(root)

cmd = run_command(command, fp, verbose)
cmd = pypython.util.run_command(command, fp, verbose)
if cmd.returncode != 0:
raise RunError(
raise err.RunError(
f"windsave2table has failed to run, possibly due to an incompatible version\n{cmd.stdout.decode('utf-8')}")

files_after = listdir(fp)
Expand Down Expand Up @@ -357,7 +363,7 @@ def get_python_version():
The version string of the currently compiled Python.
"""

command = run_command(["py", "--version"])
command = pypython.util.run_command(["py", "--version"])
stdout = command.stdout.decode("utf-8").split("\n")
stderr = command.stderr.decode("utf-8")

Expand Down Expand Up @@ -467,6 +473,8 @@ def smooth_array(array, width):
smoothed: np.ndarray
The smoothed array
"""
from scipy.signal import boxcar, convolve

if width is None or width == 0:
return array

Expand All @@ -482,7 +490,7 @@ def run_py_optical_depth(root, photosphere=None, fp=".", verbose=False):
command.append(f"-p {float(photosphere)}")
command.append(root)

cmd = run_command(command, fp)
cmd = pypython.util.run_command(command, fp)
stdout, stderr = cmd.stdout, cmd.stderr

if verbose:
Expand Down Expand Up @@ -529,6 +537,9 @@ def run_py_wind(root, commands, fp="."):

# Load in all the submodules ---------------------------------------------------

Spectrum = pypython.spectrum.Spectrum
Wind = pypython.wind.Wind

__all__ = [
# functions in pypython
"check_sorted_array_ascending",
Expand All @@ -545,6 +556,7 @@ def run_py_wind(root, commands, fp="."):
"run_py_optical_depth",
"run_py_wind",
# sub-modules
"dump",
"math",
"observations",
"physics",
Expand All @@ -560,11 +572,4 @@ def run_py_wind(root, commands, fp="."):
"constants"
]

# These are put here to solve a circular dependency ----------------------------

from pypython.plot import normalize_figure_style
from pypython.spectrum import Spectrum
from pypython.util import run_command
from pypython.wind import Wind

normalize_figure_style()
pypython.plot.normalize_figure_style()
Loading

0 comments on commit 3cd6734

Please sign in to comment.