Skip to content

Commit 560e2f0

Browse files
committed
remove some redundant code
1 parent e738e4f commit 560e2f0

2 files changed

Lines changed: 14 additions & 31 deletions

File tree

oceanval/fixers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def ignore_warning(x):
4040
return True
4141
if "coordinates variable time" in x and "be assigned" in x:
4242
return True
43+
if "time bounds unsupported by this operator" in x:
44+
return True
4345
return False
4446

4547

oceanval/matchall.py

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,10 @@ def matchup(
630630
if not isinstance(out_dir, str):
631631
raise TypeError("out_dir must be a string")
632632
out_dir = os.path.expanduser(out_dir)
633+
# full path
634+
out_dir = os.path.abspath(out_dir)
633635
# add out_dir to session_info
634-
if out_dir != "":
635-
session_info["out_dir"] = out_dir + "/"
636-
else:
637-
session_info["out_dir"] = ""
636+
session_info["out_dir"] = out_dir + "/"
638637

639638
# check if exclude is a list or str
640639
if not isinstance(exclude, list):
@@ -772,8 +771,6 @@ def matchup(
772771

773772
# if cache is True, create a cache directory in out_dir
774773
if cache:
775-
if out_dir == "":
776-
out_dir = "./"
777774
cache_dir = out_dir + "/.cache_oceanval/"
778775
if not os.path.exists(cache_dir):
779776
os.makedirs(cache_dir)
@@ -919,11 +916,7 @@ def matchup(
919916

920917
# create oceanval_matchups directory
921918
if not os.path.exists("oceanval_matchups"):
922-
if session_info["out_dir"] != "":
923-
# recusively create the directory
924-
os.makedirs(session_info["out_dir"] + "/oceanval_matchups", exist_ok=True)
925-
else:
926-
os.mkdir("oceanval_matchups")
919+
os.makedirs(session_info["out_dir"] + "/oceanval_matchups", exist_ok=True)
927920

928921
invert_thickness = False
929922
point_all = point["all"] + point["surface"]
@@ -1140,10 +1133,7 @@ def matchup(
11401133
print("Please adjust your variable names and try again")
11411134
return None
11421135

1143-
if session_info["out_dir"] != "":
1144-
out = session_info["out_dir"] + "/oceanval_matchups/mapping.csv"
1145-
else:
1146-
out = "oceanval_matchups/mapping.csv"
1136+
out = session_info["out_dir"] + "/oceanval_matchups/mapping.csv"
11471137
# check directory exists for out
11481138
out_folder = os.path.dirname(out)
11491139
if not os.path.exists(out_folder):
@@ -1272,10 +1262,7 @@ def matchup(
12721262
variable = vv
12731263
source = definitions[variable].point_source
12741264

1275-
if session_info["out_dir"] != "":
1276-
out = f"{session_info['out_dir']}/oceanval_matchups/point/{layer}/{variable}/{source}/{source}_{layer}_{variable}.csv"
1277-
else:
1278-
out = f"oceanval_matchups/point/{layer}/{variable}/{source}/{source}_{layer}_{variable}.csv"
1265+
out = f"{session_info['out_dir']}/oceanval_matchups/point/{layer}/{variable}/{source}/{source}_{layer}_{variable}.csv"
12791266

12801267
if os.path.exists(out) and not overwrite:
12811268
continue
@@ -1354,10 +1341,7 @@ def point_match(
13541341
# try finding source in definitions
13551342
source = definitions[variable].point_source
13561343

1357-
if session_info["out_dir"] != "":
1358-
out = f"{session_info['out_dir']}/oceanval_matchups/point/{layer}/{variable}/{source}/{source}_{layer}_{variable}.csv"
1359-
else:
1360-
out = f"oceanval_matchups/point/{layer}/{variable}/{source}/{source}_{layer}_{variable}.csv"
1344+
out = f"{session_info['out_dir']}/oceanval_matchups/point/{layer}/{variable}/{source}/{source}_{layer}_{variable}.csv"
13611345

13621346
for exc in exclude:
13631347
paths = [
@@ -1673,15 +1657,12 @@ def read_csv_simyears(ff, layer = None):
16731657

16741658
vv_variable = definitions[vv].long_name
16751659

1676-
if session_info["out_dir"] != "":
1677-
out = glob.glob(
1678-
session_info["out_dir"]
1679-
+ "/"
1680-
+ f"oceanval_matchups/point/all/{vv}/**_all_{vv}.csv"
1681-
)
1660+
out = glob.glob(
1661+
session_info["out_dir"]
1662+
+ "/"
1663+
+ f"oceanval_matchups/point/all/{vv}/**_all_{vv}.csv"
1664+
)
16821665

1683-
else:
1684-
out = glob.glob(f"oceanval_matchups/point/all/{vv}/**_all_{vv}.csv")
16851666
if len(out) > 0:
16861667
if session_info["overwrite"] is False:
16871668
continue

0 commit comments

Comments
 (0)