From f83bd3e33bd29b1a96dc10680f86d8ec7380582d Mon Sep 17 00:00:00 2001 From: Christian Glaser Date: Wed, 7 Feb 2024 14:40:17 +0000 Subject: [PATCH 1/3] fix outdated syntax --- radiotools/plthelpers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/radiotools/plthelpers.py b/radiotools/plthelpers.py index f3716e9..c76832f 100644 --- a/radiotools/plthelpers.py +++ b/radiotools/plthelpers.py @@ -14,7 +14,7 @@ def get_discrete_cmap(N, base_cmap='viridis'): cmap = plt.get_cmap(base_cmap, N) colors = [] - N = np.int(N) + N = int(N) for i in range(N): if(i % 2 == 0): colors.append(cmap.colors[i // 2]) @@ -302,7 +302,7 @@ def get_histograms(histograms, bins=None, xlabels=None, ylabels=None, stats=True for i in range(N): xlabel = "" if xlabels: - if(type(xlabels) != np.str): + if(type(xlabels) != str): xlabel = xlabels[i] else: xlabel = xlabels @@ -317,7 +317,7 @@ def get_histograms(histograms, bins=None, xlabels=None, ylabels=None, stats=True if titles: title = titles[i] if bins is not None: - if(type(bins) == np.int): + if(type(bins) == int): tbin = bins else: if (isinstance(bins[0], float) or isinstance(bins[0], int)): From a0f8e56cb8db4dd338311fb5c54696222c4ff0ee Mon Sep 17 00:00:00 2001 From: Christian Glaser Date: Fri, 23 Feb 2024 00:55:42 +0000 Subject: [PATCH 2/3] remove python2 residuals --- pyproject.toml | 6 +++++- radiotools/atmosphere/models.py | 17 ++++++----------- radiotools/coreas/generate_coreas_sim.py | 6 ++---- radiotools/helper.py | 1 - 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0e6eb56..a483746 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,10 @@ module = "radiotools" author = "Christian Glaser" author-email = "work@c-glaser.de" home-page = "https://github.com/nu-radio/radiotools" -requires-python=">3.4" +requires-python=">=3.6" classifiers = ["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"] +requires = [ + "numpy", + "scipy", +] \ No newline at end of file diff --git a/radiotools/atmosphere/models.py b/radiotools/atmosphere/models.py index 95f89d3..e996151 100644 --- a/radiotools/atmosphere/models.py +++ b/radiotools/atmosphere/models.py @@ -1,9 +1,4 @@ -# Python 2 and 3: backward-compatible -from __future__ import absolute_import, division, print_function # , unicode_literals -from past.builtins import xrange - from scipy import optimize, interpolate, integrate - import numpy as np import os import sys @@ -484,7 +479,7 @@ def __init__(self, model=17, n0=(1 + 292e-6), n_taylor=5, curved=True, number_of zeniths = np.arccos(np.linspace(0, 1, self.number_of_zeniths)) mask = zeniths < np.deg2rad(90) - self.a_funcs = [interpolate.interp1d(zeniths[mask], self.a[..., i][mask], kind='cubic') for i in xrange(5)] + self.a_funcs = [interpolate.interp1d(zeniths[mask], self.a[..., i][mask], kind='cubic') for i in range(5)] else: self.a = self.__calculate_a() @@ -680,7 +675,7 @@ def _get_atmosphere(self, zenith, h_low=0., h_up=np.infty, observation_level=0): def __get_a_from_interpolation(self, zeniths): a = np.zeros((len(zeniths), 5)) - for i in xrange(5): + for i in range(5): a[..., i] = self.a_funcs[i](zeniths) return a @@ -702,7 +697,7 @@ def plot_a(self): ax.legend() plt.tight_layout() - for i in xrange(5): + for i in range(5): y = self.a[..., i][mask] f2 = interpolate.interp1d(x, y, kind='cubic') xxx = np.linspace(0, 81, 100) @@ -745,7 +740,7 @@ def _get_atmosphere_numeric(self, zenith, h_low=0, h_up=np.infty, observation_le zenith = np.array(zenith) tmp = np.zeros_like(zenith) - for i in xrange(len(tmp)): + for i in range(len(tmp)): t_h_low = h_low if np.array(h_low).size == 1 else h_low[i] t_h_up = h_up if np.array(h_up).size == 1 else h_up[i] @@ -818,7 +813,7 @@ def ftmp(d, zenith, xmax): dtmp = tmp - xmax return dtmp - for i in xrange(len(height)): + for i in range(len(height)): x0 = get_distance_for_height_above_ground(self._get_vertical_height_flat(zenith[i], X[i]), zenith[i]) # finding root e.g., distance for given xmax (when difference is 0) @@ -843,7 +838,7 @@ def ftmp(d, zenith, xmax): dtmp = tmp - xmax return dtmp - for i in xrange(len(height)): + for i in range(len(height)): if(X[i] < 0): X[i] = 0 diff --git a/radiotools/coreas/generate_coreas_sim.py b/radiotools/coreas/generate_coreas_sim.py index 814b4c9..10605f4 100644 --- a/radiotools/coreas/generate_coreas_sim.py +++ b/radiotools/coreas/generate_coreas_sim.py @@ -1,10 +1,8 @@ -from __future__ import absolute_import, division, print_function # , unicode_literals import os import stat import numpy as np from radiotools import coordinatesystems from radiotools import helper as hp -from past.builtins import xrange # $_CONDOR_SCRATCH_DIR @@ -242,7 +240,7 @@ def write_list_star_pattern(filename, zen, az, append=False, obs_level=1564.0, o slices = np.array(slices) if(slicing_method == "distance"): slices *= 100 - for iSlice in xrange(len(slices) - 1): + for iSlice in range(len(slices) - 1): name = "pos_%i_%i_slice%i" % (rs[i], np.rad2deg(azimuths[j]), iSlice) if gammacut is None: fout.write('AntennaPosition = {0} {1} {2} {3} {4} {5} {6}\n'.format(x, y, z, name, slicing_method, slices[iSlice] * 100., slices[iSlice + 1] * 100.)) @@ -310,7 +308,7 @@ def write_list_star_pattern(filename, zen, az, append=False, obs_level=1564.0, o # slices = np.array(slices) # if(slicing_method == "distance"): # slices *= 100 -# for iSlice in xrange(len(slices) - 1): +# for iSlice in range(len(slices) - 1): # fout.write('AntennaPosition = {0} {1} {2} {3} {4} {5} {6}\n'.format(x, y, z, name, slicing_method, slices[iSlice] * 100., slices[iSlice + 1] * 100.)) # fout.close() diff --git a/radiotools/helper.py b/radiotools/helper.py index 59fa3cc..ef71c70 100644 --- a/radiotools/helper.py +++ b/radiotools/helper.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function # , unicode_literals from radiotools.atmosphere import models as atm import numpy as np import sys From 9a77d2675fe459ce68155505210aa47e21fc4350 Mon Sep 17 00:00:00 2001 From: Christian Glaser Date: Fri, 23 Feb 2024 01:04:47 +0000 Subject: [PATCH 3/3] update version number in anticipation of a new release --- radiotools/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radiotools/__init__.py b/radiotools/__init__.py index d18595b..0185bdd 100644 --- a/radiotools/__init__.py +++ b/radiotools/__init__.py @@ -2,4 +2,4 @@ """A tool package for cosmic-ray and neutrino radio detectors.""" -__version__ = '0.2.1' +__version__ = '0.2.2'