forked from davi-rodrigues/NAVanalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExportTables.wl
338 lines (282 loc) · 14.3 KB
/
ExportTables.wl
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
(* ::Title:: *)
(*Export individual fits as tsv files*)
(* ::Author:: *)
(*Davi C. Rodrigues*)
(*Nov/ 2022*)
(* ::Section:: *)
(*Prelude*)
pathBaseDirectory = NotebookDirectory[];
pathOutputDirectory = FileNameJoin[{pathBaseDirectory, "Output"}];
pathAuxDirectory = FileNameJoin[{pathBaseDirectory, "AuxiliaryData"}];
SetDirectory @ pathBaseDirectory;
Block[{Print}, Needs @ "NAVbaseCode`"];
Get @ "NAVauxiliaryFunctions.wl";
SetDirectory @ pathOutputDirectory;
(* ::Section:: *)
(*Definitions*)
exportNFWtable := Block[
{
results, header, resultsData, resultsDataRAR, colRs, colRho, colYD, colYB,
colChi2eff, colChi2, colN, dataExportAux0, listRsn, dataExportAux1, dataExport
},
results = Get[FileNameJoin[{pathAuxDirectory, "NFW-GY-05-06-v2-MAGMAtableResults.m"}]];
header = First @ results;
resultsData = Drop[results, 1];
resultsDataRAR = Delete[resultsData, GalaxiesOutsideRAR]; (*153 galaxies*)
colRs = First @ Flatten @ Position[header, "rS"];
colRho = First @ Flatten @ Position[header, "logRhoS"];
colYD = First @ Flatten @ Position[header, "YD"];
colYB = First @ Flatten @ Position[header, "YB"];
colChi2eff = First @ Flatten @ Position[header, "Chi2"];
colChi2 = First @ Flatten @ Position[header, "V-Chi2"];
colN = First @ Flatten @ Position[header, "N.data points"];
dataExportAux0 = resultsDataRAR[[All, {1, colRs, colRho, colYD, colYB, colChi2, colChi2eff, colN}]];
listRsn = resultsDataRAR[[All, colRs]] / (rmax153 /@ Range @ 153);
dataExportAux1 = Join[dataExportAux0\[Transpose], {listRsn\[Transpose]}]\[Transpose]; (* dataExportAux0 with a column for Rsn*)
dataExport = dataExportAux1[[All, {1, 2, 9, 3, 4, 5, 6, 7, 8}]]; (*Reorder the columns*)
PrependTo[dataExport, {"Galaxy", "rs", "rsn", "log rhos", "YD", "YB", "Chi2", "Chi2eff", "N.Data"}];
Export["dataExportAux.tsv", dataExport, Alignment-> Left, "TextDelimiters"-> None];
Export["headerAux.txt",
{
"# Normalized additional velocity distribution: ",
"# testing the radial profile of dark matter halos and MOND.",
"# by D. C. Rodrigues, A. Hernandez-Arboleda, A. Wojnar",
"# ",
"# NFW individual fits for 153 SPARC galaxies with Gaussian priors on YD and YB.",
"# 1st column: galaxy name.",
"# 2nd column: scale radius (rs) [kpc].",
"# 3rd column: normalized scale radius (rsn = rs / rmax).",
"# 4th column: logarithm of the density rho_s (log rhos) [Msun / kpc^3].",
"# 5th column: stellar disk mass-to-light ratio (YD).",
"# 6th column: stellar bulge mass-to-light ratio (YB).",
"# 7th column: minimum chi-squared value (Chi2) (- 2 log likelihood + constant).",
"# 8th column: minimum effective chi-squared value (- 2 log posterior + constant).",
"# 9th column: number of data points for the galaxy circular velocity (N.Data).",
"# ",
"# "
}
];
Run["cat headerAux.txt dataExportAux.tsv > NFWindividualFits.tsv"];
DeleteFile["headerAux.txt"];
DeleteFile["dataExportAux.tsv"];
];
exportBurkertTable := Block[
{
results, header, resultsData, resultsDataRAR, colR, colRho, colYD, colYB,
colChi2eff, colChi2, colN, dataExportAux0, listRsn, dataExportAux1, dataExport
},
results = Get[FileNameJoin[{pathAuxDirectory, "Burkert-GY-05-06-MAGMAtableResults.m"}]];
header = First @ results;
resultsData = Drop[results, 1];
resultsDataRAR = Delete[resultsData, GalaxiesOutsideRAR]; (*153 galaxies*)
colR = First @ Flatten @ Position[header, "rc"];
colRho = First @ Flatten @ Position[header, "logRhoc"];
colYD = First @ Flatten @ Position[header, "YD"];
colYB = First @ Flatten @ Position[header, "YB"];
colChi2eff = First @ Flatten @ Position[header, "Chi2"];
colChi2 = First @ Flatten @ Position[header, "V-Chi2"];
colN = First @ Flatten @ Position[header, "N.data points"];
dataExportAux0 = resultsDataRAR[[All, {1, colR, colRho, colYD, colYB, colChi2, colChi2eff, colN}]];
listRsn = resultsDataRAR[[All, colR]] / (rmax153 /@ Range @ 153);
dataExportAux1 = Join[dataExportAux0\[Transpose], {listRsn\[Transpose]}]\[Transpose]; (* dataExportAux0 with a column for Rsn*)
dataExport = dataExportAux1[[All, {1, 2, 9, 3, 4, 5, 6, 7, 8}]]; (*Reorder the columns*)
PrependTo[dataExport, {"Galaxy", "rc", "rcn", "log rhos", "YD", "YB", "Chi2", "Chi2eff", "N.Data"}];
Export["dataExportAux.tsv", dataExport, Alignment-> Left, "TextDelimiters"-> None];
Export["headerAux.txt",
{
"# Normalized additional velocity distribution: ",
"# testing the radial profile of dark matter halos and MOND.",
"# by D. C. Rodrigues, A. Hernandez-Arboleda, A. Wojnar",
"# ",
"# Burkert individual fits for 153 SPARC galaxies with Gaussian priors on YD and YB.",
"# 1st column: galaxy name.",
"# 2nd column: core radius (rc) [kpc].",
"# 3rd column: normalized scale radius (rcn = rc / rmax).",
"# 4th column: logarithm of the density rho_c (log rhoc) [Msun / kpc^3].",
"# 5th column: stellar disk mass-to-light ratio (YD).",
"# 6th column: stellar bulge mass-to-light ratio (YB).",
"# 7th column: minimum chi-squared value (Chi2) (- 2 log likelihood + constant).",
"# 8th column: minimum effective chi-squared value (- 2 log posterior + constant).",
"# 9th column: number of data points for the galaxy circular velocity (N.Data).",
"# ",
"# "
}
];
Run["cat headerAux.txt dataExportAux.tsv > BurkertIndividualFits.tsv"];
DeleteFile["headerAux.txt"];
DeleteFile["dataExportAux.tsv"];
];
exportArctanTable := Block[
{
results, header, resultsData, resultsDataRAR, colR, colRho, colYD, colYB,
colChi2eff, colChi2, colN, dataExportAux0, listRsn, dataExportAux1, dataExport
},
results = Get[FileNameJoin[{pathAuxDirectory, "arctan-GY-1-MAGMAtableResults.m"}]];
header = First @ results;
resultsDataRAR = Drop[results, 1]; (*The original table for Arctan is already for the RAR sample*)
colR = First @ Flatten @ Position[header, "Rt"];
colRho = First @ Flatten @ Position[header, "Vc"];
colYD = First @ Flatten @ Position[header, "YD"];
colYB = First @ Flatten @ Position[header, "YB"];
colChi2eff = First @ Flatten @ Position[header, "Chi2"];
colChi2 = First @ Flatten @ Position[header, "V-Chi2"];
colN = First @ Flatten @ Position[header, "N.data points"];
dataExportAux0 = resultsDataRAR[[All, {1, colR, colRho, colYD, colYB, colChi2, colChi2eff, colN}]];
listRsn = resultsDataRAR[[All, colR]] / (rmax153 /@ Range @ 153);
dataExportAux1 = Join[dataExportAux0\[Transpose], {listRsn\[Transpose]}]\[Transpose]; (* dataExportAux0 with a column for Rsn*)
dataExport = dataExportAux1[[All, {1, 2, 9, 3, 4, 5, 6, 7, 8}]]; (*Reorder the columns*)
PrependTo[dataExport, {"Galaxy", "rt", "rtn", "Vc", "YD", "YB", "Chi2", "Chi2eff", "N.Data"}];
Export["dataExportAux.tsv", dataExport, Alignment-> Left, "TextDelimiters"-> None];
Export["headerAux.txt",
{
"# Normalized additional velocity distribution: ",
"# testing the radial profile of dark matter halos and MOND.",
"# by D. C. Rodrigues, A. Hernandez-Arboleda, A. Wojnar",
"# ",
"# Arctan_1 individual fits for 153 SPARC galaxies with Gaussian priors on YD and YB.",
"# 1st column: galaxy name.",
"# 2nd column: rt value [kpc].",
"# 3rd column: normalized scale radius (rtn = rt / rmax).",
"# 4th column: Vc value [km/s].",
"# 5th column: stellar disk mass-to-light ratio (YD).",
"# 6th column: stellar bulge mass-to-light ratio (YB).",
"# 7th column: minimum chi-squared value (Chi2) (- 2 log likelihood + constant).",
"# 8th column: minimum effective chi-squared value (- 2 log posterior + constant).",
"# 9th column: number of data points for the galaxy circular velocity (N.Data).",
"# ",
"# "
}
];
Run["cat headerAux.txt dataExportAux.tsv > ArctanIndividualFits.tsv"];
DeleteFile["headerAux.txt"];
DeleteFile["dataExportAux.tsv"];
];
exportArctanHalfTable := Block[
{
results, header, resultsData, resultsDataRAR, colR, colRho, colYD, colYB,
colChi2eff, colChi2, colN, dataExportAux0, listRsn, dataExportAux1, dataExport
},
results = Get[FileNameJoin[{pathAuxDirectory, "arctanHalf-GY-1-MAGMAtableResults.m"}]];
header = First @ results;
resultsDataRAR = Drop[results, 1]; (*The original table for Arctan is already for the RAR sample*)
colR = First @ Flatten @ Position[header, "Rt"];
colRho = First @ Flatten @ Position[header, "Vc"];
colYD = First @ Flatten @ Position[header, "YD"];
colYB = First @ Flatten @ Position[header, "YB"];
colChi2eff = First @ Flatten @ Position[header, "Chi2"];
colChi2 = First @ Flatten @ Position[header, "V-Chi2"];
colN = First @ Flatten @ Position[header, "N.data points"];
dataExportAux0 = resultsDataRAR[[All, {1, colR, colRho, colYD, colYB, colChi2, colChi2eff, colN}]];
listRsn = resultsDataRAR[[All, colR]] / (rmax153 /@ Range @ 153);
dataExportAux1 = Join[dataExportAux0\[Transpose], {listRsn\[Transpose]}]\[Transpose]; (* dataExportAux0 with a column for Rsn*)
dataExport = dataExportAux1[[All, {1, 2, 9, 3, 4, 5, 6, 7, 8}]]; (*Reorder the columns*)
PrependTo[dataExport, {"Galaxy", "rt", "rtn", "Vc", "YD", "YB", "Chi2", "Chi2eff", "N.Data"}];
Export["dataExportAux.tsv", dataExport, Alignment-> Left, "TextDelimiters"-> None];
Export["headerAux.txt",
{
"# Normalized additional velocity distribution: ",
"# testing the radial profile of dark matter halos and MOND.",
"# by D. C. Rodrigues, A. Hernandez-Arboleda, A. Wojnar",
"# ",
"# Arctan_1/2 individual fits for 153 SPARC galaxies with Gaussian priors on YD and YB.",
"# 1st column: galaxy name.",
"# 2nd column: rt value [kpc].",
"# 3rd column: normalized scale radius (rtn = rt / rmax).",
"# 4th column: Vc value [km/s].",
"# 5th column: stellar disk mass-to-light ratio (YD).",
"# 6th column: stellar bulge mass-to-light ratio (YB).",
"# 7th column: minimum chi-squared value (Chi2) (- 2 log likelihood + constant).",
"# 8th column: minimum effective chi-squared value (- 2 log posterior + constant).",
"# 9th column: number of data points for the galaxy circular velocity (N.Data).",
"# ",
"# "
}
];
Run["cat headerAux.txt dataExportAux.tsv > ArctanHalfIndividualFits.tsv"];
DeleteFile["headerAux.txt"];
DeleteFile["dataExportAux.tsv"];
];
exportMONDtable := Block[
{
results, header, resultsData, resultsDataRAR, colR, colRho, colYD, colYB,
colChi2eff, colChi2, colN, dataExportAux0, listRsn, dataExportAux1, dataExport
},
results = Get @ FileNameJoin @ {pathAuxDirectory, "MONDRAR-Fxa0-GY-05-06-MAGMAtableResults.m"};
header = First @ results;
resultsDataRAR = Drop[results, 1]; (*The original table for MOND is already for the RAR sample*)
colYD = First @ Flatten @ Position[header, "YD"];
colYB = First @ Flatten @ Position[header, "YB"];
colChi2eff = First @ Flatten @ Position[header, "Chi2"];
colChi2 = First @ Flatten @ Position[header, "V-Chi2"];
colN = First @ Flatten @ Position[header, "N.data points"];
dataExport = resultsDataRAR[[All, {1, colYD, colYB, colChi2, colChi2eff, colN}]];
PrependTo[dataExport, {"Galaxy", "YD", "YB", "Chi2", "Chi2eff", "N.Data"}];
Export["dataExportAux.tsv", dataExport, Alignment-> Left, "TextDelimiters"-> None];
Export["headerAux.txt",
{
"# Normalized additional velocity distribution: ",
"# testing the radial profile of dark matter halos and MOND.",
"# by D. C. Rodrigues, A. Hernandez-Arboleda, A. Wojnar",
"# ",
"# MOND individual fits for 153 SPARC galaxies with Gaussian priors on YD and YB.",
"# 1st column: galaxy name.",
"# 2nd column: stellar disk mass-to-light ratio (YD).",
"# 3rd column: stellar bulge mass-to-light ratio (YB).",
"# 4th column: minimum chi-squared value (Chi2) (- 2 log likelihood + constant).",
"# 5th column: minimum effective chi-squared value (- 2 log posterior + constant).",
"# 6th column: number of data points for the galaxy circular velocity (N.Data).",
"# ",
"# "
}
];
Run["cat headerAux.txt dataExportAux.tsv > MONDindividualFits.tsv"];
DeleteFile["headerAux.txt"];
DeleteFile["dataExportAux.tsv"];
];
exportMONDgdTable := Block[
{
results, header, resultsData, resultsDataRAR, coldf2, colR, colRho, colYD, colYB,
colChi2eff, colChi2, colN, dataExportAux0, listRsn, dataExportAux1, dataExport
},
results = Get @ FileNameJoin @ {pathAuxDirectory, "MONDRAR-Fxa0-GY-05-06-GD-MAGMAtableResults.m"};
header = First @ results;
resultsDataRAR = Drop[results, 1]; (*The original table for MOND is already for the RAR sample*)
coldf2 = First @ Flatten @ Position[header, "df2"];
colYD = First @ Flatten @ Position[header, "YD"];
colYB = First @ Flatten @ Position[header, "YB"];
colChi2eff = First @ Flatten @ Position[header, "Chi2"];
colChi2 = First @ Flatten @ Position[header, "V-Chi2"];
colN = First @ Flatten @ Position[header, "N.data points"];
dataExport = resultsDataRAR[[All, {1, colYD, colYB, coldf2, colChi2, colChi2eff, colN}]];
PrependTo[dataExport, {"Galaxy", "YD", "YB", "deltaD", "Chi2", "Chi2eff", "N.Data"}];
Export["dataExportAux.tsv", dataExport, Alignment-> Left, "TextDelimiters"-> None];
Export["headerAux.txt",
{
"# Normalized additional velocity distribution: ",
"# testing the radial profile of dark matter halos and MOND.",
"# by D. C. Rodrigues, A. Hernandez-Arboleda, A. Wojnar",
"# ",
"# MOND_dist individual fits for 153 SPARC galaxies with Gaussian priors on YD, YB and on the distance.",
"# 1st column: galaxy name.",
"# 2nd column: stellar disk mass-to-light ratio (YD).",
"# 3rd column: stellar bulge mass-to-light ratio (YB).",
"# 4th column: multiplicative factor that changes the galaxy distance.",
"# 4th column: minimum chi-squared value (Chi2) (- 2 log likelihood + constant).",
"# 5th column: minimum effective chi-squared value (- 2 log posterior + constant).",
"# 6th column: number of data points for the galaxy circular velocity (N.Data).",
"# ",
"# "
}
];
Run["cat headerAux.txt dataExportAux.tsv > MONDgdIndividualFits.tsv"];
DeleteFile["headerAux.txt"];
DeleteFile["dataExportAux.tsv"];
];
(* ::Section:: *)
(*Executing*)
exportNFWtable;
exportBurkertTable;
exportArctanTable;
exportArctanHalfTable;
exportMONDtable;
exportMONDgdTable;