From 47e3f99f021e6da2348c7518ab21cd45f8f94bd9 Mon Sep 17 00:00:00 2001 From: Tony Wong Date: Wed, 23 Dec 2020 21:10:17 -0600 Subject: [PATCH] Deal with astropy and h5py deprecation issues. --- astrodendro/flux.py | 2 +- astrodendro/io/hdf5.py | 8 ++++---- astrodendro/io/util.py | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/astrodendro/flux.py b/astrodendro/flux.py index d780f05..7a27657 100644 --- a/astrodendro/flux.py +++ b/astrodendro/flux.py @@ -154,7 +154,7 @@ def compute_flux(input_quantities, output_unit, wavelength=None, spatial_scale=N # Convert input quantity to Fnu in Jy # Implicitly, this equivalency gives the Janskys in a single beam, so we make this explicit by dividing out a beam jansky_per_beam = input_quantities.to(u.Jy, - equivalencies=u.brightness_temperature(omega_beam, nu)) / u.beam + equivalencies=u.brightness_temperature(nu, beam_area=omega_beam)) / u.beam q = jansky_per_beam * beams_per_pixel diff --git a/astrodendro/io/hdf5.py b/astrodendro/io/hdf5.py index df439b9..8a27f51 100644 --- a/astrodendro/io/hdf5.py +++ b/astrodendro/io/hdf5.py @@ -59,9 +59,9 @@ def dendro_import_hdf5(filename): log.debug('Loading HDF5 file from disk...') with h5py.File(filename, 'r') as h5f: - newick = h5f['newick'].value - data = h5f['data'].value - index_map = h5f['index_map'].value + newick = h5f['newick'][()] + data = h5f['data'][()] + index_map = h5f['index_map'][()] params = {} if 'min_value' in h5f.attrs: @@ -70,7 +70,7 @@ def dendro_import_hdf5(filename): params['min_npix'] = h5f.attrs['min_npix'] try: - wcs = WCS(h5f['wcs_header'].value) + wcs = WCS(h5f['wcs_header'][()]) except KeyError: wcs = None diff --git a/astrodendro/io/util.py b/astrodendro/io/util.py index 93ee349..b48f330 100644 --- a/astrodendro/io/util.py +++ b/astrodendro/io/util.py @@ -7,6 +7,12 @@ def parse_newick(string): + # Convert bytestring if needed + try: + string = string.decode('utf-8') + except (UnicodeDecodeError, AttributeError): + pass + items = {} # Find maximum level