Skip to content

Commit

Permalink
Merge pull request #813 from petiay/pkg_resources_replace
Browse files Browse the repository at this point in the history
replace pkg_resources with importlib_resources
  • Loading branch information
karllark committed May 23, 2024
2 parents bcc8cb5 + e4e2fce commit 150bd4e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
7 changes: 3 additions & 4 deletions beast/physicsmodel/stars/ezmist/mist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:author: MF
"""

from pkg_resources import resource_filename
from importlib_resources import files

from urllib import request
from urllib.request import urlopen
Expand All @@ -20,12 +20,11 @@

py3k = True

localpath = resource_filename("beast", "physicsmodel/stars/ezmist")
localpath = str(files('beast.physicsmodel.stars.ezmist').joinpath('mist.json'))

with open(localpath + "/mist.json") as f:
with open(localpath) as f:
_cfg = json.load(f)


# Help messages
# -------------

Expand Down
6 changes: 3 additions & 3 deletions beast/physicsmodel/stars/ezpadova/parsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:author: MF
"""

from pkg_resources import resource_filename
from importlib_resources import files

from urllib.parse import urlencode
from urllib import request
Expand All @@ -21,9 +21,9 @@

py3k = True

localpath = resource_filename("beast", "physicsmodel/stars/ezpadova")
localpath = str(files('beast.physicsmodel.stars.ezpadova').joinpath('parsec.json'))

with open(localpath + "/parsec.json") as f:
with open(localpath) as f:
_cfg = json.load(f)
map_carbon_stars = _cfg["map_carbon_stars"]
map_phot = _cfg["map_phot"]
Expand Down
14 changes: 7 additions & 7 deletions beast/tools/compare_spec_type.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import numpy as np
from collections import defaultdict
from scipy.interpolate import RegularGridInterpolator
import pkg_resources
from importlib_resources import files

from astropy.table import Table
from astropy.coordinates import SkyCoord
from astropy import units as u

import beast.plotting.plot_compare_spec_type as plot_match

__all__ = ["compare_spec_type"]


def compare_spec_type(
phot_cat_file,
Expand Down Expand Up @@ -258,9 +260,8 @@ def setup_teff_table():
function to interpolate across the T_eff table
"""

# read in the table
data_path = pkg_resources.resource_filename("beast", "tools/data/")
teff_table = Table.read(data_path + "effective_temperature.txt", format="ascii")
data_path = str(files("beast.tools.data").joinpath("effective_temperature.txt"))
teff_table = Table.read(data_path, format="ascii")
# make each row a number rather than a letter+number
teff_table["row_id"] = np.zeros(len(teff_table))
for i in range(len(teff_table)):
Expand Down Expand Up @@ -299,9 +300,8 @@ def setup_logg_table():
function to interpolate across the log(g) table
"""

# read in the table
data_path = pkg_resources.resource_filename("beast", "tools/data/")
logg_table = Table.read(data_path + "surface_gravity.txt", format="ascii")
data_path = str(files("beast.tools.data").joinpath("surface_gravity.txt"))
logg_table = Table.read(data_path, format="ascii")
# make each row a number rather than a letter+number
logg_table["row_id"] = np.zeros(len(logg_table))
for i in range(len(logg_table)):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ install_requires =
asdf
stsynphot
pandeia.engine
importlib_resources

[options.entry_points]
console_scripts =
Expand Down

0 comments on commit 150bd4e

Please sign in to comment.