Skip to content
Open
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
25 changes: 12 additions & 13 deletions moi/Input.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
"""

# neobam
if gb_file.exists():
try :
#print('reading',gb_file)
gb = Dataset(gb_file, 'r', format="NETCDF4")
self.alg_dict["neobam"][r_id] = {
Expand All @@ -327,8 +327,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
"a0": 1.0 # TODO temp value until work out neoBAM A0
}
gb.close()

else:
except:
self.alg_dict["neobam"][r_id] = {
"s1-flpe-exists" : False ,
"q" : np.nan,
Expand All @@ -339,7 +338,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
}

# hivdi
if hv_file.exists():
try:
hv = Dataset(hv_file, 'r', format="NETCDF4")
self.alg_dict["hivdi"][r_id] = {
"s1-flpe-exists": True,
Expand All @@ -349,7 +348,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
"a0" : hv["reach"]["A0"][:].filled(np.nan)
}
hv.close()
else:
except:
self.alg_dict["hivdi"][r_id] = {
"s1-flpe-exists" : False ,
"q" : np.nan,
Expand All @@ -360,7 +359,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
}

# momma
if mo_file.exists():
try:
mo = Dataset(mo_file, 'r', format="NETCDF4")
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=RuntimeWarning)
Expand All @@ -372,7 +371,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
"Save" : np.nanmean(mo["slope"][:].filled(np.nan))
}
mo.close()
else:
except:
self.alg_dict["momma"][r_id] = {
"s1-flpe-exists" : False ,
"q" : np.nan,
Expand All @@ -384,7 +383,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
}

# sad
if sd_file.exists():
try:
sd = Dataset(sd_file, 'r', format="NETCDF4")
self.alg_dict["sad"][r_id] = {
"s1-flpe-exists": True,
Expand All @@ -393,7 +392,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
"a0" : sd["A0"][:].filled(np.nan)
}
sd.close()
else:
except:
self.alg_dict["sad"][r_id] = {
"s1-flpe-exists" : False ,
"q" : np.nan,
Expand All @@ -404,7 +403,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
}

# metroman
if mm_file.exists():
try:
mm = Dataset(mm_file, 'r', format="NETCDF4")
# index = np.where(mm["reach_id"][:] == int(r_id))
self.alg_dict["metroman"][r_id] = {
Expand All @@ -416,7 +415,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
}
mm.close()
#print('MetroMan file found. ')
else:
except:
self.alg_dict["metroman"][r_id] = {
"s1-flpe-exists" : False ,
"q" : np.nan,
Expand All @@ -429,7 +428,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
#print('MetroMan file not found. Using prior')

# sic4dvar
if sv_file.exists():
try:
sv = Dataset(sv_file, 'r', format="NETCDF4")
self.alg_dict["sic4dvar"][r_id] = {
#"q31": sv["Qalgo31"][:].filled(np.nan),#unclear which of these to use
Expand All @@ -441,7 +440,7 @@ def __extract_valid(self, r_id, gb_file, hv_file, mo_file, sd_file, mm_file, sv_
"a0": sv["A0"][:].filled(np.nan)
}
sv.close()
else:
except:
self.alg_dict["sic4dvar"][r_id] = {
"s1-flpe-exists" : False ,
"q_mm": np.nan,
Expand Down