Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up imports #58

Merged
merged 6 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,12 @@ jobs:
name: test
strategy:
matrix:
os: [ubuntu-20.04, macos-11]
os: [ubuntu-20.04, macos-14]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Detect platform
id: detect
run: |
if [[ "${RUNNER_ARCH}" == "X64" ]]; then
if [[ "${RUNNER_OS}" == "Linux" ]]; then
echo '::set-output name=platform::linux-64' && exit 0
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
echo '::set-output name=platform::osx-64' && exit 0
fi
fi
echo "Unsupported platform ${RUNNER_OS} ${RUNNER_ARCH}"
exit 1

- uses: actions/checkout@v2

- name: Set up conda environment
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ notebooks/**/*.pdf
notebooks/**/*.fits
notebooks/**/.ipynb_checkpoints
.vscode
env*
6 changes: 3 additions & 3 deletions conda-recipes/nusigma/nusigma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ._nusigma import *

# set path to table directory
from os.path import dirname, realpath, expandvars
from os.path import dirname, expandvars, realpath

from ._nusigma import *

basedir = dirname(realpath(expandvars(__file__))) + "/"
nusetup(basedir)
Expand Down
3 changes: 1 addition & 2 deletions conda-recipes/nusigma/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from numpy.distutils.core import setup
from numpy.distutils.core import Extension
from numpy.distutils.core import Extension, setup

setup(
name="nusigma",
Expand Down
21 changes: 11 additions & 10 deletions notebooks/data preparation/PSF fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@
"outputs": [],
"source": [
"%matplotlib inline\n",
"import os\n",
"import warnings\n",
"\n",
"import autograd\n",
"import autograd.numpy as n\n",
"import matplotlib.pyplot as plt\n",
"import tables\n",
"import pandas as pd\n",
"import numpy as np\n",
"from toolz import memoize\n",
"from toise import plotting, surfaces, util, effective_areas, angular_resolution\n",
"\n",
"import pandas as pd\n",
"import photospline\n",
"from scipy import optimize\n",
"import tables\n",
"from autograd.misc.flatten import flatten_func\n",
"import autograd\n",
"import autograd.numpy as n\n",
"import os\n",
"import warnings\n",
"from scipy import optimize\n",
"from toolz import memoize\n",
"\n",
"from toise import angular_resolution, effective_areas, plotting, surfaces, util\n",
"\n",
"warnings.filterwarnings(\"ignore\") # turn off warnings"
]
Expand Down
9 changes: 5 additions & 4 deletions notebooks/paper plots/Fictive optical detector.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"metadata": {},
"outputs": [],
"source": [
"from toise import effective_areas, angular_resolution\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.gridspec as gridspec\n",
"from matplotlib.ticker import NullFormatter\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from matplotlib import style"
"from matplotlib import style\n",
"from matplotlib.ticker import NullFormatter\n",
"\n",
"from toise import angular_resolution, effective_areas"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions notebooks/paper plots/radio_demo_plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
"metadata": {},
"outputs": [],
"source": [
"from toise import radio_response\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"from toise import radio_response\n",
"\n",
"plt.rcParams[\"figure.dpi\"] = 300\n",
"plt.rcParams[\"figure.figsize\"] = (6, 5)"
Expand Down
6 changes: 4 additions & 2 deletions notebooks/tutorials/001-Framework_Introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import warnings\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"warnings.filterwarnings(\"ignore\") # turn off warnings"
]
},
Expand Down Expand Up @@ -44,6 +45,7 @@
],
"source": [
"import numpy\n",
"\n",
"from toise import factory\n",
"\n",
"factory.set_kwargs(psi_bins={k: [0, numpy.pi] for k in (\"tracks\", \"cascades\", \"radio\")})"
Expand Down Expand Up @@ -325,8 +327,8 @@
}
],
"source": [
"from scipy.optimize import bisect\n",
"from scipy import stats\n",
"from scipy.optimize import bisect\n",
"\n",
"# test statistic between astro = f and astro = 0\n",
"ts = lambda f: -2 * (llh.llh(**llh.fit(astro=f)) - llh.llh(**llh.fit(astro=0)))\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
"from matplotlib import style\n",
"\n",
"style.use(\"../../figures/toise.mplstyle\")\n",
"import numpy as np\n",
"from functools import partial\n",
"from toise import factory, diffuse, surface_veto, pointsource, grb, multillh, plotting\n",
"import warnings\n",
"from functools import partial\n",
"\n",
"import numpy as np\n",
"\n",
"from toise import diffuse, factory, grb, multillh, plotting, pointsource, surface_veto\n",
"\n",
"warnings.filterwarnings(\"ignore\") # turn off warnings"
]
Expand Down
4 changes: 3 additions & 1 deletion notebooks/tutorials/003-Effective_Areas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
],
"source": [
"%matplotlib inline\n",
"import warnings\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"from toise import factory, plotting\n",
"import warnings\n",
"\n",
"warnings.filterwarnings(\"ignore\") # turn off warnings"
]
Expand Down
8 changes: 4 additions & 4 deletions notebooks/tutorials/004-Radio_Event_Distributions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import toise\n",
"from toise import radio_aeff_generation\n",
"from toise import factory\n",
"from toise import factory, radio_aeff_generation\n",
"from toise.util import constants"
]
},
Expand Down Expand Up @@ -574,9 +574,9 @@
}
],
"source": [
"from toise import diffuse\n",
"from matplotlib.colors import LogNorm # logarithmic coloring\n",
"\n",
"from toise import diffuse\n",
"\n",
"astro = diffuse.DiffuseAstro(radio_aeff, nyears).expectations()\n",
"\n",
Expand Down Expand Up @@ -750,7 +750,7 @@
}
],
"source": [
"from toise.diffuse import AhlersGZKFlux, VanVlietGZKFlux, ReasonableGZKFlux\n",
"from toise.diffuse import AhlersGZKFlux, ReasonableGZKFlux, VanVlietGZKFlux\n",
"\n",
"logEmin = 7\n",
"logEmax = 10\n",
Expand Down
2 changes: 1 addition & 1 deletion resources/docs/plots/angular_resolution.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import matplotlib.pyplot as plt
import numpy as np
from icecube.toise import angular_resolution, plotting
from matplotlib.gridspec import GridSpec
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
from icecube.toise import plotting, angular_resolution

configs = [
("IceCube", None),
Expand Down
6 changes: 3 additions & 3 deletions resources/docs/plots/cascade_production_density.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import matplotlib.pyplot as plt
import numpy as np
import itertools

import matplotlib.pyplot as plt
from icecube.toise import effective_areas, plotting, util
from matplotlib.gridspec import GridSpec
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
from icecube.toise import plotting, effective_areas, util

# get muon production efficiency
edges, muprod = effective_areas.get_cascade_production_density()
Expand Down
5 changes: 2 additions & 3 deletions resources/docs/plots/cascade_volume.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.gridspec import GridSpec
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
from toise import plotting, effective_areas

from toise import effective_areas, plotting

configs = [
("IceCube", 125.0),
Expand Down
6 changes: 2 additions & 4 deletions resources/docs/plots/geometries.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import matplotlib.pyplot as plt
import numpy as np
import itertools
from icecube.toise import plotting, surfaces
from matplotlib.gridspec import GridSpec
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
from icecube.toise import plotting, surfaces, effective_areas
from icecube import icetray, dataclasses, dataio


def string_heads(gcdfile):
from icecube import icetray, dataio, dataclasses
from icecube import dataclasses, dataio, icetray # noqa: F401

f = dataio.I3File(gcdfile)
omgeo = f.pop_frame(icetray.I3Frame.Geometry)["I3Geometry"].omgeo
Expand Down
6 changes: 3 additions & 3 deletions resources/docs/plots/muon_production_efficiency.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import matplotlib.pyplot as plt
import numpy as np
import itertools

import matplotlib.pyplot as plt
from icecube.toise import effective_areas, plotting, util
from matplotlib.gridspec import GridSpec
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
from icecube.toise import plotting, effective_areas, util

# get muon production efficiency
edges, muprod = effective_areas.get_muon_production_efficiency()
Expand Down
14 changes: 8 additions & 6 deletions resources/docs/plots/ps_sensitivity_demo.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.gridspec import GridSpec
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
from icecube.toise import (
plotting,
effective_areas,

from toise import (
angular_resolution,
diffuse,
pointsource,
effective_areas,
energy_resolution,
multillh,
plotting,
pointsource,
surface_veto,
)
from icecube.toise import angular_resolution, energy_resolution


def create_aeff(
Expand Down
2 changes: 1 addition & 1 deletion resources/docs/plots/selection_efficiency.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import matplotlib.pyplot as plt
import numpy as np
from icecube.toise import effective_areas, plotting
from matplotlib.gridspec import GridSpec
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
from icecube.toise import plotting, effective_areas

configs = [
("IceCube", 125.0),
Expand Down
26 changes: 10 additions & 16 deletions resources/scripts/2021_midscale/calc_radio_sens.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
from toise import (
effective_areas,
diffuse,
pointsource,
angular_resolution,
grb,
surface_veto,
multillh,
plotting,
)
from toise import factory, figures_of_merit, util, figures
from toise.util import data_dir, center
from tqdm import tqdm
import numpy as np
from collections import OrderedDict, defaultdict
import json
from collections import OrderedDict

import numpy as np
from tqdm import tqdm

# generate aeff for radio
from toise import radio_aeff_generation
from toise import (
factory,
figures,
figures_of_merit,
radio_aeff_generation,
)

# this file is basically a copy/strip down of the figures.pointsource.flare.sensitivity workbook

Expand Down
20 changes: 8 additions & 12 deletions resources/scripts/2021_midscale/calc_sens.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import json
from collections import OrderedDict

from tqdm import tqdm

from toise import (
effective_areas,
diffuse,
pointsource,
angular_resolution,
grb,
surface_veto,
multillh,
plotting,
factory,
figures,
figures_of_merit,
)
from toise import factory, figures_of_merit, util, figures
from toise.util import data_dir, center
from tqdm import tqdm
from collections import OrderedDict, defaultdict
import json

# this file is basically a copy/strip down of the figures.pointsource.flare.sensitivity workbook

Expand Down
6 changes: 3 additions & 3 deletions resources/scripts/2021_midscale/count_events.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"outputs": [],
"source": [
"import numpy\n",
"from toise import factory, diffuse, plotting, effective_areas\n",
"\n",
"%matplotlib inline\n",
"import matplotlib.pyplot as plt"
"from toise import diffuse, effective_areas, factory\n",
"\n",
"%matplotlib inline"
]
},
{
Expand Down
Loading
Loading