Skip to content

Commit

Permalink
fixing np issues
Browse files Browse the repository at this point in the history
  • Loading branch information
taddyb committed Feb 20, 2024
1 parent ecbd3ba commit a27af89
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*__pycache__*
*mypy_cache*
output/
.idea/
hydroDL.egg-info/
2 changes: 1 addition & 1 deletion example/PUR/testPUR-Reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
for k in range(len(filePathLst)):
filePath = filePathLst[k]
dataPred[:, :, k] = pd.read_csv(
filePath, dtype=np.float64 header=None
filePath, dtype=float, header=None
).values
# transform back to the original observation
temppred = camels.transNormbyDic(
Expand Down
8 changes: 4 additions & 4 deletions hydroDL/data/dbCsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def readDBinfo(*, rootDB, subset):
indSub = dfSubset.values.flatten()

crdFile = os.path.join(rootDB, rootName, "crd.csv")
crdRoot = pd.read_csv(crdFile, dtype=np.float64 header=None).values
crdRoot = pd.read_csv(crdFile, dtype=float, header=None).values

indAll = np.arange(0, crdRoot.shape[0], dtype=np.int64)
if np.array_equal(indSub, np.array([-1])):
Expand Down Expand Up @@ -162,7 +162,7 @@ def readDataTS(*, rootDB, rootName, indSub, indSkip, yrLst, fieldName):
t1 = time.time()
dataFile = os.path.join(rootDB, rootName, str(yr), fieldName + ".csv")
dataTemp = pd.read_csv(
dataFile, dtype=np.float64 skiprows=indSkip, header=None
dataFile, dtype=float, skiprows=indSkip, header=None
).values
k2 = k1 + dataTemp.shape[1]
data[:, k1:k2] = dataTemp
Expand All @@ -176,7 +176,7 @@ def readDataConst(*, rootDB, rootName, indSub, indSkip, fieldName):
# read data
dataFile = os.path.join(rootDB, rootName, "const", fieldName + ".csv")
data = pd.read_csv(
dataFile, dtype=np.float64 skiprows=indSkip, header=None
dataFile, dtype=float, skiprows=indSkip, header=None
).values.flatten()
data[np.where(data == -9999)] = np.nan
return data
Expand All @@ -189,7 +189,7 @@ def readStat(*, rootDB, fieldName, isConst=False):
statFile = os.path.join(
rootDB, "Statistics", "const_" + fieldName + "_stat.csv"
)
stat = pd.read_csv(statFile, dtype=np.float64 header=None).values.flatten()
stat = pd.read_csv(statFile, dtype=float, header=None).values.flatten()
return stat


Expand Down
4 changes: 2 additions & 2 deletions hydroDL/data/load_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def load_all_csv(self, var_s, var_type, select_date_list, csv_date_list):
path_xdata = os.path.join(
self.csv_path_s, str(year_int), var_s + ".csv"
)
df = pd.read_csv(path_xdata, dtype=np.float64, header=None) # pixel, time
df = pd.read_csv(path_xdata, dtype=float, header=None) # pixel, time

df_a = df.values # pixel, time
if ndx_year == 0:
Expand All @@ -102,7 +102,7 @@ def load_all_csv(self, var_s, var_type, select_date_list, csv_date_list):

elif var_type in ["var_c"]:
path_cData = os.path.join(self.csv_path_s, "const", var_s + ".csv")
df = pd.read_csv(path_cData, dtype=np.float64, header=None,) # pixel,
df = pd.read_csv(path_cData, dtype=float, header=None,) # pixel,

df_a = df.values # pixel,
data = df_a
Expand Down
6 changes: 3 additions & 3 deletions hydroDL/master/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def namePred(out, tRange, subset, epoch=None, doMC=False, suffix=None):
# for k in range(len(filePathLst)):
# filePath = filePathLst[k]
# dataPred[:, :, k] = pd.read_csv(
# filePath, dtype=np.float64 header=None).values
# filePath, dtype=float, header=None).values
# isSigmaX = False
# if mDict['loss']['name'] == 'hydroDL.model.crit.SigmaLoss':
# isSigmaX = True
Expand Down Expand Up @@ -737,7 +737,7 @@ def test(
doMC=doMC,
)
# read predicted results
dataPred = pd.read_csv(tempfilePath, dtype=np.float64 header=None).values
dataPred = pd.read_csv(tempfilePath, dtype=float, header=None).values
updateData = np.full(initobs.shape, 0.0)
updateData[:, 1:, 0] = dataPred[:, 0:-1]
updateData[:, fixIndex, :] = initobs[:, fixIndex, :]
Expand All @@ -761,7 +761,7 @@ def test(
dataPred = np.ndarray([obs.shape[0], obs.shape[1], len(filePathLst)])
for k in range(len(filePathLst)):
filePath = filePathLst[k]
dataPred[:, :, k] = pd.read_csv(filePath, dtype=np.float64 header=None).values
dataPred[:, :, k] = pd.read_csv(filePath, dtype=float, header=None).values
isSigmaX = False
if mDict["loss"]["name"] == "hydroDL.model.crit.SigmaLoss" or doMC is not False:
isSigmaX = True
Expand Down
2 changes: 1 addition & 1 deletion hydroDL/utils/norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def trans_norm(
if stat is None:
# stat = [90 percentile,10 percentile, mean,std]

stat = pd.read_csv(csv_path_s, dtype=np.float64 header=None).values.flatten()
stat = pd.read_csv(csv_path_s, dtype=float, header=None).values.flatten()

if from_raw:
data_out = (data - stat[2]) / stat[3]
Expand Down

0 comments on commit a27af89

Please sign in to comment.