Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions flopy/discretization/modeltime.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import calendar
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from difflib import SequenceMatcher

import numpy as np
Expand Down Expand Up @@ -479,7 +479,8 @@ def parse_datetime(
elif isinstance(datetime_obj, np.datetime64):
unix_time_0 = datetime(1970, 1, 1)
ts = (datetime_obj - np.datetime64(unix_time_0)) / np.timedelta64(1, "s")
datetime_obj = datetime.utcfromtimestamp(ts)
datetime_obj = datetime.fromtimestamp(ts, tz=timezone.utc)
datetime_obj = datetime_obj.replace(tzinfo=None)
elif isinstance(datetime_obj, pd.Timestamp):
datetime_obj = datetime_obj.to_pydatetime()
elif isinstance(datetime_obj, datetime):
Expand Down
4 changes: 2 additions & 2 deletions flopy/discretization/structuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2057,8 +2057,8 @@ def from_binary_grid_file(cls, file_path, verbose=False):
nlay, nrow, ncol = (grb_obj.nlay, grb_obj.nrow, grb_obj.ncol)
delr, delc = grb_obj.delr, grb_obj.delc
top, botm = grb_obj.top, grb_obj.bot
top.shape = (nrow, ncol)
botm.shape = (nlay, nrow, ncol)
top = top.reshape((nrow, ncol))
botm = botm.reshape((nlay, nrow, ncol))
return cls(
delc,
delr,
Expand Down
2 changes: 1 addition & 1 deletion flopy/discretization/vertexgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def from_binary_grid_file(cls, file_path, verbose=False):
nlay, ncpl = grb_obj.nlay, grb_obj.ncpl
top = np.ravel(grb_obj.top)
botm = grb_obj.bot
botm.shape = (nlay, ncpl)
botm = botm.reshape((nlay, ncpl))
vertices, cell2d = grb_obj.cell2d

return cls(
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/utils/binaryfile_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ def _reshape_binary_data(data, dtype=None):
return data
elif dtype == "V":
nodes = len(data[0][0][0])
data.shape = (time, -1, nodes)
data = data.reshape((time, -1, nodes))
elif dtype == "U":
data.shape = (time, -1)
data = data.reshape((time, -1))
else:
err = "Invalid dtype flag supplied, valid are dtype='U', dtype='V'"
raise Exception(err)
Expand Down
6 changes: 3 additions & 3 deletions flopy/mf6/utils/binarygrid_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _set_modelgrid(self):
nlay, ncpl = self.nlay, self.ncpl
vertices, cell2d = self.cell2d
top = np.ravel(top)
botm.shape = (nlay, ncpl)
botm = botm.reshape((nlay, ncpl))
modelgrid = VertexGrid(
vertices,
cell2d,
Expand All @@ -258,8 +258,8 @@ def _set_modelgrid(self):
)
delr, delc = self.delr, self.delc

top.shape = (nrow, ncol)
botm.shape = (nlay, nrow, ncol)
top.reshape((nrow, ncol))
botm = botm.reshape((nlay, nrow, ncol))
modelgrid = StructuredGrid(
delc,
delr,
Expand Down
2 changes: 1 addition & 1 deletion flopy/mf6/utils/model_splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ def reconstruct_array(self, arrays):

new_array[new_nodes] = array[old_nodes]

new_array.shape = shape
new_array = new_array.reshape(shape)
return new_array

def reconstruct_recarray(self, recarrays):
Expand Down
10 changes: 5 additions & 5 deletions flopy/plot/plotutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,11 +1482,11 @@ def saturated_thickness(head, top, botm, laytyp, mask_values=None):
head = np.copy(head)
nlay, nrow, ncol = head.shape
ncpl = nrow * ncol
head.shape = (nlay, ncpl)
top.shape = (ncpl,)
botm.shape = (nlay, ncpl)
head = head.reshape((nlay, ncpl))
top = top.reshape((ncpl,))
botm = botm.reshape((nlay, ncpl))
if laytyp.ndim == 3:
laytyp.shape = (nlay, ncpl)
laytyp = laytyp.reshape((nlay, ncpl))

else:
nrow, ncol = None, None
Expand Down Expand Up @@ -1531,7 +1531,7 @@ def saturated_thickness(head, top, botm, laytyp, mask_values=None):
sat_thk = np.where(laytyp != 0, sat_thk_unconf, sat_thk_conf)

if nrow is not None and ncol is not None:
sat_thk.shape = (nlay, nrow, ncol)
sat_thk = sat_thk.reshape((nlay, nrow, ncol))

return sat_thk

Expand Down
10 changes: 5 additions & 5 deletions flopy/utils/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ def get_specific_discharge(
modelgrid = model.modelgrid

if head is not None:
head.shape = modelgrid.shape
head = head.reshape(modelgrid.shape)

if isinstance(vectors, (list, tuple)):
classical_budget = True
Expand Down Expand Up @@ -857,7 +857,7 @@ def get_specific_discharge(
head, mask=[model.hdry, model.hnoflo]
)

saturated_thickness.shape = modelgrid.shape
saturated_thickness = saturated_thickness.reshape(modelgrid.shape)

# inform modelgrid of no-flow and dry cells
modelgrid = model.modelgrid
Expand Down Expand Up @@ -927,9 +927,9 @@ def get_specific_discharge(
qx[idx] = spdis["qx"]
qy[idx] = spdis["qy"]
qz[idx] = spdis["qz"]
qx.shape = modelgrid.shape
qy.shape = modelgrid.shape
qz.shape = modelgrid.shape
qx = qx.reshape(modelgrid.shape)
qy = qy.reshape(modelgrid.shape)
qz = qz.reshape(modelgrid.shape)

# set no-flow and dry cells to NaN
if head is not None and position == "centers":
Expand Down
2 changes: 1 addition & 1 deletion flopy/utils/rasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def resample_to_grid(
data = np.where(np.isnan(data), extrapolate, data)

# step 4: return grid to user in shape provided
data.shape = data_shape
data = data.reshape(data_shape)

# step 5: re-apply nodata values
data[np.isnan(data)] = self.nodatavals[0]
Expand Down
2 changes: 1 addition & 1 deletion flopy/utils/zonbud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,7 @@ def _read_zb_csv2(fname, add_prefix=True, aliases=None):
array = np.genfromtxt(foo, delimiter=",").T
if len(array) != len(dtype):
array = array[:-1]
array.shape = (len(dtype), -1)
array = array.reshape((len(dtype), -1))
data = {name[0]: list(array[ix]) for ix, name in enumerate(dtype)}
data["KPER"] = list(np.array(data["KPER"]) - 1)
data["KSTP"] = list(np.array(data["KSTP"]) - 1)
Expand Down
Loading