[yt-svn] commit/yt: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Mar 27 09:30:22 PDT 2014
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/a6f881ff5888/
Changeset: a6f881ff5888
Branch: yt-3.0
User: jzuhone
Date: 2014-03-27 01:48:06
Summary: Replacing direct imports of astropy-related modules with the on-demand import from the FITS frontend. Also removed some unnecessary astropy imports. Re-enabled _is_valid for the FITS frontend.
Affected #: 6 files
diff -r 3a11f1dfd9699f172b1ff73697dacd11302fdd2a -r a6f881ff5888ef240c9d4559ea1680c56e2539fd yt/analysis_modules/photon_simulator/photon_simulator.py
--- a/yt/analysis_modules/photon_simulator/photon_simulator.py
+++ b/yt/analysis_modules/photon_simulator/photon_simulator.py
@@ -33,11 +33,9 @@
from yt import units
from yt.units.yt_array import YTQuantity
import h5py
-try:
- import astropy.io.fits as pyfits
- import astropy.wcs as pywcs
-except ImportError:
- pass
+from yt.frontends.fits.data_structures import ap
+pyfits = ap.pyfits
+pywcs = ap.pywcs
comm = communication_system.communicators[-1]
diff -r 3a11f1dfd9699f172b1ff73697dacd11302fdd2a -r a6f881ff5888ef240c9d4559ea1680c56e2539fd yt/analysis_modules/photon_simulator/spectral_models.py
--- a/yt/analysis_modules/photon_simulator/spectral_models.py
+++ b/yt/analysis_modules/photon_simulator/spectral_models.py
@@ -17,13 +17,14 @@
from yt import units
import h5py
try:
- import astropy.io.fits as pyfits
import xspec
from scipy.integrate import cumtrapz
from scipy import stats
except ImportError:
pass
-
+from yt.frontends.fits.data_structures import ap
+pyfits = ap.pyfits
+
from yt.utilities.physical_constants import hcgs, clight, erg_per_keV, amu_cgs
hc = (hcgs*clight).in_units("keV*angstrom")
diff -r 3a11f1dfd9699f172b1ff73697dacd11302fdd2a -r a6f881ff5888ef240c9d4559ea1680c56e2539fd yt/frontends/fits/data_structures.py
--- a/yt/frontends/fits/data_structures.py
+++ b/yt/frontends/fits/data_structures.py
@@ -204,6 +204,8 @@
self.new_unit = self.file_unit
self.pixel_scale = self.wcs.wcs.cdelt[idx]
+ self.refine_by = 2
+
Dataset.__init__(self, fname, dataset_type)
self.storage_filename = storage_filename
@@ -269,7 +271,6 @@
@classmethod
def _is_valid(self, *args, **kwargs):
- return False
if isinstance(args[0], types.StringTypes):
ext = args[0].rsplit(".", 1)[-1]
if ext.upper() == "GZ":
diff -r 3a11f1dfd9699f172b1ff73697dacd11302fdd2a -r a6f881ff5888ef240c9d4559ea1680c56e2539fd yt/frontends/fits/io.py
--- a/yt/frontends/fits/io.py
+++ b/yt/frontends/fits/io.py
@@ -11,10 +11,6 @@
#-----------------------------------------------------------------------------
import numpy as np
-try:
- import astropy.io.fits as pyfits
-except ImportError:
- pass
from yt.utilities.math_utils import prec_accum
diff -r 3a11f1dfd9699f172b1ff73697dacd11302fdd2a -r a6f881ff5888ef240c9d4559ea1680c56e2539fd yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -14,12 +14,10 @@
from yt.funcs import mylog, iterable
from yt.visualization.fixed_resolution import FixedResolutionBuffer
from yt.data_objects.construction_data_containers import YTCoveringGridBase
-
-try:
- from astropy.io.fits import HDUList, ImageHDU
- from astropy import wcs as pywcs
-except ImportError:
- HDUList = object
+from yt.frontends.fits.data_structures import ap
+HDUList = ap.pyfits.HDUList
+ImageHDU = ap.pyfits.ImageHDU
+pywcs = ap.pywcs
class FITSImageBuffer(HDUList):
diff -r 3a11f1dfd9699f172b1ff73697dacd11302fdd2a -r a6f881ff5888ef240c9d4559ea1680c56e2539fd yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -280,16 +280,11 @@
requested.
"""
- try:
- import astropy.io.fits as pyfits
- except:
- mylog.error("You don't have AstroPy installed!")
- raise ImportError
from yt.utilities.fits_image import FITSImageBuffer
extra_fields = ['x','y','z','px','py','pz','pdx','pdy','pdz','weight_field']
if fields is None:
- fields = [field for field in self.data_source.fields
+ fields = [field[-1] for field in self.data_source.field_data
if field not in extra_fields]
fib = FITSImageBuffer(self, fields=fields, units=units)
https://bitbucket.org/yt_analysis/yt/commits/3948c2e3cedb/
Changeset: 3948c2e3cedb
Branch: yt-3.0
User: jzuhone
Date: 2014-03-27 16:48:11
Summary: Unnecessary duplication of this line
Affected #: 1 file
diff -r a6f881ff5888ef240c9d4559ea1680c56e2539fd -r 3948c2e3cedb7cb70f7f8ddd5f54567e2ca546ab yt/frontends/fits/data_structures.py
--- a/yt/frontends/fits/data_structures.py
+++ b/yt/frontends/fits/data_structures.py
@@ -209,7 +209,6 @@
Dataset.__init__(self, fname, dataset_type)
self.storage_filename = storage_filename
- self.refine_by = 2
# For plotting to APLpy
self.hdu_list = self._handle
https://bitbucket.org/yt_analysis/yt/commits/ebc01d4b5512/
Changeset: ebc01d4b5512
Branch: yt-3.0
User: jzuhone
Date: 2014-03-27 16:50:32
Summary: Merge
Affected #: 4 files
diff -r 3948c2e3cedb7cb70f7f8ddd5f54567e2ca546ab -r ebc01d4b551254ccb10ad289edf18bf5c00e4d58 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -364,11 +364,16 @@
# No string lookups here, we need an actual union.
f = self.particle_fields_by_type
fields = set_intersection([f[s] for s in union
- if s in self.particle_types_raw])
+ if s in self.particle_types_raw
+ and len(f[s]) > 0])
for field in fields:
units = set([])
for s in union:
- units.add(self.field_units.get((s, field), ""))
+ # First we check our existing fields for units
+ funits = self._get_field_info(s, field).units
+ # Then we override with field_units settings.
+ funits = self.field_units.get((s, field), funits)
+ units.add(funits)
if len(units) == 1:
self.field_units[union.name, field] = list(units)[0]
self.particle_types += (union.name,)
diff -r 3948c2e3cedb7cb70f7f8ddd5f54567e2ca546ab -r ebc01d4b551254ccb10ad289edf18bf5c00e4d58 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -498,6 +498,13 @@
raise RuntimeError
new_data[new_field] = data[field]
field_units[new_field] = field_units.pop(field)
+ known_fields = StreamFieldInfo.known_particle_fields \
+ + StreamFieldInfo.known_other_fields
+ # We do not want to override any of the known ones, if it's not
+ # overridden here.
+ if any(f[0] == new_field[1] for f in known_fields) and \
+ field_units[new_field] == "":
+ field_units.pop(new_field)
data = new_data
return field_units, data
diff -r 3948c2e3cedb7cb70f7f8ddd5f54567e2ca546ab -r ebc01d4b551254ccb10ad289edf18bf5c00e4d58 yt/frontends/stream/io.py
--- a/yt/frontends/stream/io.py
+++ b/yt/frontends/stream/io.py
@@ -52,13 +52,7 @@
raise NotImplementedError
rv = {}
for field in fields:
- ftype, fname = field
- try:
- field_units = self.field_units[fname]
- except KeyError:
- field_units = self.field_units[field]
- rv[field] = self.pf.arr(np.empty(size, dtype="float64"),
- field_units)
+ rv[field] = self.pf.arr(np.empty(size, dtype="float64"))
ng = sum(len(c.objs) for c in chunks)
mylog.debug("Reading %s cells of %s fields in %s blocks",
size, [f2 for f1, f2 in fields], ng)
diff -r 3948c2e3cedb7cb70f7f8ddd5f54567e2ca546ab -r ebc01d4b551254ccb10ad289edf18bf5c00e4d58 yt/visualization/tests/test_callbacks.py
--- a/yt/visualization/tests/test_callbacks.py
+++ b/yt/visualization/tests/test_callbacks.py
@@ -163,5 +163,4 @@
p.annotate_grids(alpha=0.7, min_pix=10, min_pix_ids=30,
draw_ids=True, periodic=False, min_level=2,
max_level=3, cmap="gist_stern")
- p.save()
-
+ p.save(prefix)
https://bitbucket.org/yt_analysis/yt/commits/1bfcd605e059/
Changeset: 1bfcd605e059
Branch: yt-3.0
User: jzuhone
Date: 2014-03-27 16:58:16
Summary: This is a little cleaner
Affected #: 1 file
diff -r ebc01d4b551254ccb10ad289edf18bf5c00e4d58 -r 1bfcd605e059963bf03f422bb2aa18f1cca77305 yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -15,11 +15,10 @@
from yt.visualization.fixed_resolution import FixedResolutionBuffer
from yt.data_objects.construction_data_containers import YTCoveringGridBase
from yt.frontends.fits.data_structures import ap
-HDUList = ap.pyfits.HDUList
-ImageHDU = ap.pyfits.ImageHDU
+pyfits = ap.pyfits
pywcs = ap.pywcs
-class FITSImageBuffer(HDUList):
+class FITSImageBuffer(pyfits.HDUList):
def __init__(self, data, fields=None, units="cm",
center=None, scale=None, wcs=None):
@@ -67,7 +66,7 @@
>>> f_deg.writeto("temp.fits")
"""
- super(HDUList, self).__init__()
+ super(pyfits.HDUList, self).__init__()
if isinstance(fields, basestring): fields = [fields]
@@ -94,10 +93,10 @@
if key not in exclude_fields:
mylog.info("Making a FITS image of field %s" % (key))
if first:
- hdu = PrimaryHDU(np.array(img_data[key]))
+ hdu = pyfits.PrimaryHDU(np.array(img_data[key]))
hdu.name = key
else:
- hdu = ImageHDU(np.array(img_data[key]), name=key)
+ hdu = pyfits.ImageHDU(np.array(img_data[key]), name=key)
self.append(hdu)
self.dimensionality = len(self[0].data.shape)
@@ -208,7 +207,7 @@
return FITSImageBuffer(new_buffer, wcs=new_wcs)
def writeto(self, fileobj, **kwargs):
- HDUList(self).writeto(fileobj, **kwargs)
+ pyfits.HDUList(self).writeto(fileobj, **kwargs)
@property
def shape(self):
https://bitbucket.org/yt_analysis/yt/commits/af24bacaa028/
Changeset: af24bacaa028
Branch: yt-3.0
User: MatthewTurk
Date: 2014-03-27 17:30:11
Summary: Merged in jzuhone/yt-3.x/yt-3.0 (pull request #774)
Fixing up AstroPy imports everywhere in yt
Affected #: 6 files
diff -r 71e1995770948d7b5c586e37cb12ce8759fbf749 -r af24bacaa028428d2726b599b0b28820d61c46e3 yt/analysis_modules/photon_simulator/photon_simulator.py
--- a/yt/analysis_modules/photon_simulator/photon_simulator.py
+++ b/yt/analysis_modules/photon_simulator/photon_simulator.py
@@ -33,11 +33,9 @@
from yt import units
from yt.units.yt_array import YTQuantity
import h5py
-try:
- import astropy.io.fits as pyfits
- import astropy.wcs as pywcs
-except ImportError:
- pass
+from yt.frontends.fits.data_structures import ap
+pyfits = ap.pyfits
+pywcs = ap.pywcs
comm = communication_system.communicators[-1]
diff -r 71e1995770948d7b5c586e37cb12ce8759fbf749 -r af24bacaa028428d2726b599b0b28820d61c46e3 yt/analysis_modules/photon_simulator/spectral_models.py
--- a/yt/analysis_modules/photon_simulator/spectral_models.py
+++ b/yt/analysis_modules/photon_simulator/spectral_models.py
@@ -17,13 +17,14 @@
from yt import units
import h5py
try:
- import astropy.io.fits as pyfits
import xspec
from scipy.integrate import cumtrapz
from scipy import stats
except ImportError:
pass
-
+from yt.frontends.fits.data_structures import ap
+pyfits = ap.pyfits
+
from yt.utilities.physical_constants import hcgs, clight, erg_per_keV, amu_cgs
hc = (hcgs*clight).in_units("keV*angstrom")
diff -r 71e1995770948d7b5c586e37cb12ce8759fbf749 -r af24bacaa028428d2726b599b0b28820d61c46e3 yt/frontends/fits/data_structures.py
--- a/yt/frontends/fits/data_structures.py
+++ b/yt/frontends/fits/data_structures.py
@@ -204,10 +204,11 @@
self.new_unit = self.file_unit
self.pixel_scale = self.wcs.wcs.cdelt[idx]
+ self.refine_by = 2
+
Dataset.__init__(self, fname, dataset_type)
self.storage_filename = storage_filename
- self.refine_by = 2
# For plotting to APLpy
self.hdu_list = self._handle
@@ -269,7 +270,6 @@
@classmethod
def _is_valid(self, *args, **kwargs):
- return False
if isinstance(args[0], types.StringTypes):
ext = args[0].rsplit(".", 1)[-1]
if ext.upper() == "GZ":
diff -r 71e1995770948d7b5c586e37cb12ce8759fbf749 -r af24bacaa028428d2726b599b0b28820d61c46e3 yt/frontends/fits/io.py
--- a/yt/frontends/fits/io.py
+++ b/yt/frontends/fits/io.py
@@ -11,10 +11,6 @@
#-----------------------------------------------------------------------------
import numpy as np
-try:
- import astropy.io.fits as pyfits
-except ImportError:
- pass
from yt.utilities.math_utils import prec_accum
diff -r 71e1995770948d7b5c586e37cb12ce8759fbf749 -r af24bacaa028428d2726b599b0b28820d61c46e3 yt/utilities/fits_image.py
--- a/yt/utilities/fits_image.py
+++ b/yt/utilities/fits_image.py
@@ -14,14 +14,11 @@
from yt.funcs import mylog, iterable
from yt.visualization.fixed_resolution import FixedResolutionBuffer
from yt.data_objects.construction_data_containers import YTCoveringGridBase
+from yt.frontends.fits.data_structures import ap
+pyfits = ap.pyfits
+pywcs = ap.pywcs
-try:
- from astropy.io.fits import HDUList, ImageHDU
- from astropy import wcs as pywcs
-except ImportError:
- HDUList = object
-
-class FITSImageBuffer(HDUList):
+class FITSImageBuffer(pyfits.HDUList):
def __init__(self, data, fields=None, units="cm",
center=None, scale=None, wcs=None):
@@ -69,7 +66,7 @@
>>> f_deg.writeto("temp.fits")
"""
- super(HDUList, self).__init__()
+ super(pyfits.HDUList, self).__init__()
if isinstance(fields, basestring): fields = [fields]
@@ -96,10 +93,10 @@
if key not in exclude_fields:
mylog.info("Making a FITS image of field %s" % (key))
if first:
- hdu = PrimaryHDU(np.array(img_data[key]))
+ hdu = pyfits.PrimaryHDU(np.array(img_data[key]))
hdu.name = key
else:
- hdu = ImageHDU(np.array(img_data[key]), name=key)
+ hdu = pyfits.ImageHDU(np.array(img_data[key]), name=key)
self.append(hdu)
self.dimensionality = len(self[0].data.shape)
@@ -210,7 +207,7 @@
return FITSImageBuffer(new_buffer, wcs=new_wcs)
def writeto(self, fileobj, **kwargs):
- HDUList(self).writeto(fileobj, **kwargs)
+ pyfits.HDUList(self).writeto(fileobj, **kwargs)
@property
def shape(self):
diff -r 71e1995770948d7b5c586e37cb12ce8759fbf749 -r af24bacaa028428d2726b599b0b28820d61c46e3 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -280,16 +280,11 @@
requested.
"""
- try:
- import astropy.io.fits as pyfits
- except:
- mylog.error("You don't have AstroPy installed!")
- raise ImportError
from yt.utilities.fits_image import FITSImageBuffer
extra_fields = ['x','y','z','px','py','pz','pdx','pdy','pdz','weight_field']
if fields is None:
- fields = [field for field in self.data_source.fields
+ fields = [field[-1] for field in self.data_source.field_data
if field not in extra_fields]
fib = FITSImageBuffer(self, fields=fields, units=units)
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list