-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaths.py
102 lines (75 loc) · 3.5 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os
import socket
from functools import partial
import glob
'''
Common set of paths giving the location of data products.
'''
def name_return_check(filename, path, no_check=False):
full_path = os.path.join(path, filename)
if not os.path.exists(full_path) and not no_check:
raise OSError("{} does not exist.".format(full_path))
return full_path
if socket.gethostname() == 'ewk':
root = os.path.expanduser('~/Dropbox/code_development/M33_NOEMA/')
data_path = "/mnt/MyRAID/M33/"
elif "segfault" == socket.gethostname():
root = os.path.expanduser("~/Dropbox/code_development/M33_NOEMA/")
data_path = "/mnt/bigdata/ekoch/M33"
imaging_path = partial(name_return_check,
path=os.path.join(root, 'imaging'))
analysis_path = partial(name_return_check,
path=os.path.join(root, 'analysis'))
noema_path = partial(name_return_check,
path=os.path.join(data_path, 'co21_noema'))
noema_data_path = partial(name_return_check,
path=os.path.join(data_path,
'co21_noema/line_imaging'))
iram_data_path = partial(name_return_check,
path=os.path.join(data_path,
'co21'))
iram_matched_data_path = partial(name_return_check,
path=os.path.join(data_path,
'co21/noema'))
hi_14B088_data_path = partial(name_return_check,
path=os.path.join(data_path,
"VLA/14B-088/HI/full_imaging_wGBT/"))
hi_17B162_1kms_data_path = partial(name_return_check,
path=os.path.join(data_path,
"VLA/17B-162/HI/full_imaging_1kms_wGBT/"))
fig_path = os.path.expanduser("~/Dropbox/Various Plots/M33/NOEMA/")
allfigs_path = lambda x: os.path.join(fig_path, x)
def find_dataproduct_names(path):
'''
Given a path, return a dictionary of the data products with the name
convention used in this repository.
'''
search_dict = {"Moment0": "mom0",
"Moment1": "mom1",
"LWidth": "lwidth",
"Skewness": "skewness",
"Kurtosis": "kurtosis",
"PeakTemp": "peaktemps",
"PeakVels": "peakvels.",
"Cube": "pbcor.K.com_beam.fits",
"Source_Mask": "pbcor.K.com_beam_source_mask.fits",
"RotSub_Cube": "masked.rotation_corrected",
"RotSub_Mask": "masked_source_mask.rotation_corrected", }
# "CentSub_Cube": "masked.centroid_corrected",
# "CentSub_Mask": "masked_source_mask.centroid_corrected",
# "PeakSub_Cube": "masked.peakvels_corrected",
# "PeakSub_Mask": "masked_source_mask.peakvels_corrected"}
found_dict = {}
for filename in glob.glob(os.path.join(path, "*.fits")):
for key in search_dict:
if search_dict[key] in filename:
found_dict[key] = filename
search_dict.pop(key)
break
return found_dict
# Return dictionaries with names for the existing directories
noema_co21_file_dict = \
find_dataproduct_names(noema_data_path("", no_check=True))
if __name__ == "__main__":
# Append the repo directory to the path so paths is importable
os.sys.path.append(root)