-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpaths.py
79 lines (67 loc) · 2.42 KB
/
paths.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import logging
import getpass
import platform
from pathlib import Path
class paths(object):
"""
Class holding the most important LDAS path definitions
Parameters
----------
mode : string
'LDASsa' or "GEOSldas'
root : pathlib.Path
root path to the experiment directory
exp : string
experiment name (appended to root path)
domain : string
domain name (appended to experiment path)
Attributes
----------
exp_root : string
root path for the experiment (including experiment and domain names)
scalefile_root : string
root path to the scaling files (!!currently not correct for the HPC!!)
ana : string
Path to DA analysis output
cat : string
Path to catchment model output
rc_out : string
Path to ancillary output (grid definitions, log files etc.)
rs : string
Path to restart files (for continuing processing or spin-up)
plots : string
Path to plots
"""
def __init__(self, mode, root=None, exp=None, domain=None):
if root is None:
uid = getpass.getuser()
if uid[:3] == 'vsc':
# default path on the HPC (Tier-1 and Tier-2)
self.root = Path('/') / 'scratch' / 'leuven' / uid[3:6] / uid / mode
else:
# default path on local machines
self.root = Path('~').expanduser() / 'data_sets' / f'{mode}_runs'
else:
self.root = Path(root)
# default experiment name
if exp is None:
if mode == 'GEOSldas':
exp = 'NLv4_M36_US_OL_Pcorr'
else:
exp = 'US_M36_SMAP_TB_OL_scaled_4K_obserr'
# default domain name
if domain is None:
domains = list(self.root.glob(exp+'/output/*'))
domains = [d for d in domains if d.name[0] != '.'] # remove hidden folders/files (dot-files)
if len(domains) != 1:
logging.error('Domain could not be identified.')
return
else:
domain = domains[0].name
self.exp_root = self.root / exp / 'output' / domain
self.ana = self.exp_root / 'ana'
self.cat = self.exp_root / 'cat'
self.rc_out = self.exp_root / 'rc_out'
self.rs = self.exp_root / 'rs'
# Probably not a good location, but OK for a default option
self.plots = self.exp_root / 'plots'