Skip to content

Commit

Permalink
revert to open_dataset from open_mfdataset
Browse files Browse the repository at this point in the history
to avoid TypeError: The dtype and signature arguments to ufuncs only select the general DType and not details such as the byte order or time unit. You can avoid this error by using the scalar types np.float64 or the dtype string notation.

xarray 2022.3.0 was okay with how I handled xarray DataArrays with units (pint quantities), but xarray 2023.5.0 is not okay.
  • Loading branch information
ahijevyc committed Aug 24, 2023
1 parent e2d5693 commit 97a2c8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions metplotpy/contributed/fv3_physics_tend/cross_section_vert.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ def main():

# Read lat/lon from gfile
logging.debug(f"read lat/lon from {gfile}")
gds = xarray.open_mfdataset(gfile)
gds = xarray.open_dataset(gfile)
lont = gds[fv3["lon_name"]]
latt = gds[fv3["lat_name"]]

# Open input file
logging.debug("open %s", ifile)
fv3ds = xarray.open_mfdataset(ifile)
fv3ds = xarray.open_dataset(ifile)

if subtract:
logging.info("subtracting %s", subtract)
with xarray.set_options(keep_attrs=True):
fv3ds -= xarray.open_mfdataset(subtract)
fv3ds -= xarray.open_dataset(subtract)

datetimeindex = fv3ds.indexes['time']
if hasattr(datetimeindex, "to_datetimeindex"):
Expand Down
6 changes: 3 additions & 3 deletions metplotpy/contributed/fv3_physics_tend/planview_fv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ def main():

# Read lat/lon/area from gfile
logging.debug(f"read lat/lon/area from {gfile}")
gds = xarray.open_mfdataset(gfile)
gds = xarray.open_dataset(gfile)
lont = gds[fv3["lon_name"]]
latt = gds[fv3["lat_name"]]
area = gds["area"]

# Open input file
logging.debug("open %s", ifile)
fv3ds = xarray.open_mfdataset(ifile)
fv3ds = xarray.open_dataset(ifile)

if subtract:
logging.info("subtracting %s", subtract)
with xarray.set_options(keep_attrs=True):
fv3ds -= xarray.open_mfdataset(subtract)
fv3ds -= xarray.open_dataset(subtract)

datetimeindex = fv3ds.indexes['time']
if hasattr(datetimeindex, "to_datetimeindex"):
Expand Down
6 changes: 3 additions & 3 deletions metplotpy/contributed/fv3_physics_tend/vert_profile_fv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ def main():

# Read lat/lon/area from gfile
logging.debug(f"read lat/lon/area from {gfile}")
gds = xarray.open_mfdataset(gfile)
gds = xarray.open_dataset(gfile)
lont = gds[fv3["lon_name"]]
latt = gds[fv3["lat_name"]]
area = gds["area"]

# Open input file
logging.debug("open %s", ifile)
fv3ds = xarray.open_mfdataset(ifile)
fv3ds = xarray.open_dataset(ifile)

if subtract:
logging.info("subtracting %s", subtract)
with xarray.set_options(keep_attrs=True):
fv3ds -= xarray.open_mfdataset(subtract)
fv3ds -= xarray.open_dataset(subtract)

datetimeindex = fv3ds.indexes['time']
if hasattr(datetimeindex, "to_datetimeindex"):
Expand Down

0 comments on commit 97a2c8e

Please sign in to comment.