-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathPlotKnickpointAnalysis.py
419 lines (334 loc) · 30 KB
/
PlotKnickpointAnalysis.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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
#=============================================================================
# Script to plot the knickpoint data produced with the LSDTT knickpoint picking algorithm
#
# Authors:
# Boris Gailleton, Fiona J. Clubb
#=============================================================================
#=============================================================================
# IMPORT MODULES
#=============================================================================
# set backend to run on server
import matplotlib
matplotlib.use('Agg')
#from __future__ import print_function
import sys
import os
import datetime
from LSDPlottingTools import LSDMap_BasicMaps as BP
from LSDMapFigure import PlottingHelpers as Helper
from LSDPlottingTools import LSDMap_KnickpointPlotting as KP
from LSDPlottingTools import LSDMap_ChiPlotting as CP
from LSDPlottingTools import LSDMap_LithoPlotting as LP
#=============================================================================
# This is just a welcome screen that is displayed if no arguments are provided.
#=============================================================================
def print_welcome():
print("\n\n=======================================================================")
print("Hello! I'm going to plot some knickpoints stuffs for you.")
print("You will need to tell me which directory to look in.")
print("Use the -wd flag to define the working directory.")
print("If you don't do this I will assume the data is in the same directory as this script.")
print("I also need to know the common prefix of all your files generated whith LSDTopoTool")
print("For help type:")
print(" python PlotknickpointAnalysis.py -h\n")
print("=======================================================================\n\n ")
#=============================================================================
# This is the main function that runs the whole thing
#=============================================================================
def main(argv):
# If there are no arguments, send to the welcome screen
if not len(sys.argv) > 1:
full_paramfile = print_welcome()
sys.exit()
# Get the arguments
import argparse
parser = argparse.ArgumentParser()
# The location of the data files
parser.add_argument("-dir", "--base_directory", type=str, help="The base directory that contains your data files. If this isn't defined I'll assume it's the same as the current directory.")
parser.add_argument("-fname", "--fname_prefix", type=str, help="The prefix of your DEM WITHOUT EXTENSION!!! This must be supplied or you will get an error.")
# Basin and source selection
# Basins selection
parser.add_argument("-basin_keys", "--basin_keys",type=str,default = "", help = "This is a comma delimited string that gets the list of basins you want for the plotting. Default = all basins")
# Sources selection
parser.add_argument("-source_keys", "--source_keys",type=str,default = "", help = "This is a comma delimited string that gets the list of sources you want for the plotting. Default = all sources")
parser.add_argument("-min_sl", "--min_source_length", type=float , default = 0, help = "This is a minimum length for the river to plot, if you want to only plot the river profile of the main rivers for example. Default = 0 (no restrictions)")
parser.add_argument("-main_stem", "--isolate_main_stem", type=bool , default =False, help = "set to True to only keep the main stem of each basins")
# These control the format of your figures
parser.add_argument("-fmt", "--FigFormat", type=str, default='png', help="Set the figure format for the plots. Default is png")
parser.add_argument("-size", "--size_format", type=str, default='ESURF', help="Set the size format for the figure. Can be 'big' (16 inches wide), 'geomorphology' (6.25 inches wide), or 'ESURF' (4.92 inches wide) (defualt esurf).")
# ALL
parser.add_argument("-all", "--AllAnalysis", type=bool, default = False, help="Turn on to have fun")
parser.add_argument("-allD", "--AllAnalysisDebug", type=bool, default = False, help="Turn on to have even more fun")
# Mchi_related
parser.add_argument("-mcstd", "--mchi_map_std", type=bool, default = False, help="Turn to True to plot a standart M_chi map on an HS. Small reminder, Mchi = Ksn if calculated with A0 = 1.")
parser.add_argument("-mcbk", "--mchi_map_black", type=bool, default = False, help="Turn to True to plot a standart M_chi map on Black background. Small reminder, Mchi = Ksn if calculated with A0 = 1.")
parser.add_argument("-minmc", "--min_mchi_map", type=float, default = 0, help="mininum value for the scale of your m_chi maps, default 0")
parser.add_argument("-maxmc", "--max_mchi_map", type=float, default = 0, help="maximum value for the scale of your m_chi maps, default auto")
parser.add_argument("-almc", "--alpha_mchi", type=float, default = 0, help="alpha_value for the background mchi raster")
#knickpint related
parser.add_argument("-ksnPs", "--ksn_per_source", type=bool, default = False, help="Print one figure per source key selected, with ksn -> f(chi & flow_distance) in the folder .../river_plots/. it displays the ksn out of Mudd et al., 2014 method, and the TVD one out of the *insert algorithm name*")
parser.add_argument("-rivplot", "--river_profile", type=bool, default = False, help="Print one figure per source key selected, with elevation -> f(chi & flow_distance) in the folder .../river_plots/. it displays river profiles in a chi and distance spaces")
parser.add_argument("-basplot", "--basin_plot", type=bool, default = False, help="Print one figure per basins key selected, with elevation -> f(chi & flow_distance) in the folder .../river_plots/. it displays river profiles in a chi and distance spaces")
parser.add_argument("-rasplot", "--raster_plots", type = bool, default = False, help="Print raster plots with knickpoints on top of ksn in the folder .../raster_plots/")
parser.add_argument("-rasplot_ld", "--raster_plots_large_dataset", type = bool, default = False, help="Print raster plots with knickpoints on top of ksn in the folder .../raster_plots/")
parser.add_argument("-statplot", "--statistical_plots", type = bool, default = False, help="Print a bunch of statistics about the knickpoints in the folder .../raster_plots/")
parser.add_argument("-stradivarius", "--multi_violin_plots", type = bool, default = False, help="Print a bunch of statistical distribution against elevation, chi, ... for the selected knickpoints")
parser.add_argument("-clas","--classical_plot", type = bool, default = False, help = "Automatically print a set of basin-wide river profile and maps of knickpoints in their different expressions.")
parser.add_argument("-clasriv","--classical_plot_per_river", type = bool, default = False, help = "Automatically print a set of river profiles with knickpoints in their different expressions. WARNINGS: can create a huge number of plot, you should sort your rivers before.")
# Others
parser.add_argument("-nbh", "--n_bin_hist", type = int, default = 0, help = "Customization of the number of bin you want for the general histogram. Default is an automatic in-built selection from numpy")
parser.add_argument("-cov", "--cut_off_val", type = str, default = "0,0,0,0", help = "Cutoff value for the knickpoint magnitude (the drop/increase of ksn). Default is 0 (no cut)")
parser.add_argument("-kal", "--kalib", type = bool, default = False, help = "Don't use that.")
parser.add_argument("-segelev", "--print_segmented_elevation", type = bool, default = False, help = "This print the segmented elevation on the top of the river profiles, in transparent black. Useful to check segment boundaries and adjust target_nodes parameter. Default False.")
parser.add_argument("-extent_rast_cmap", "--manual_extent_colormap_knickpoint_raster", type = str, default = "", help = "This print the segmented elevation on the top of the river profiles, in transparent black. Useful to check segment boundaries and adjust target_nodes parameter. Default False.")
parser.add_argument("-size_kp_map", "--size_kp_map", type = bool, default = True, help = "This print the segmented elevation on the top of the river profiles, in transparent black. Useful to check segment boundaries and adjust target_nodes parameter. Default False.")
parser.add_argument("-max_hist", "--maximum_extent_for_histogram", type = int, default = 0, help = "This print the segmented elevation on the top of the river profiles, in transparent black. Useful to check segment boundaries and adjust target_nodes parameter. Default False.")
parser.add_argument("-lith_rast","--lithologic_raster", type = bool, default = False, help = "switch on if you have a _LITHRAST raster, it will plot a hillshade colored by lithologic unit")
parser.add_argument("-save","--save_output", type = bool, default = False, help = "switch on if you have the willingness to save your selected knickpoints in a new csv file named prefix_output.csv")
parser.add_argument("-coeff_size_kp", "--kp_coeff_size", type = float, default = 30, help = "qualitative size of knickpoints on river profile. Default 10, increase or decrease to adapt the size of the triangles")
parser.add_argument("-fixed_size_kp_min_max_river", "--fixed_size_kp_min_max_river", type = str, default = "", help = "qualitative size of knickpoints on river profile. Default 50, increase or decrease to adapt the size of the triangles")
parser.add_argument("-normelev_rel", "--normalise_elevation_to_outlet_relative", type = bool, default = False, help = "Normalize the elevation for each watershed, considering the outlet points as 0, but without changing the relief.")
parser.add_argument("-normelev_abs", "--normalise_elevation_to_outlet_absolute", type = bool, default = False, help = "Normalize the elevation for each watershed, considering the outlet points as 0 and the maximum to 1.")
parser.add_argument("-unicol_kp", "--unicolor_for_knickpoint_map", type = str, default = None, help = "use this flag to force a uni color for knickpoints on map. It has to be a matplotlib color code (simplest way is to use html colorcode like #AABB47)")
parser.add_argument("-GS", "--general_size",type=str,default = "", help = "This is a comma delimited string used to scale your knickpoints relatively: min_value,min_size,max_value,max_size. see documentation for explanations")
args = parser.parse_args()
# Housekeeping for filenames and directory names
if not args.fname_prefix:
if not args.parallel:
print("WARNING! You haven't supplied your DEM name. Please specify this with the flag '-fname'")
sys.exit()
# get the base directory
if args.base_directory:
this_dir = args.base_directory
# check if you remembered a / at the end of your path_name
if not this_dir.endswith(os.sep):
print("You forgot the separator at the end of the directory, appending...")
this_dir = this_dir+os.sep
else:
this_dir = os.getcwd()
# Processing the basin/source keys selection
print("I am reading the basin/source key selection and checking your parameters...")
if len(args.basin_keys) == 0:
print("No basins found, I will plot all of them")
these_basin_keys = []
else:
these_basin_keys = [int(item) for item in args.basin_keys.split(',')]
print("The basins I will plot are:")
print(these_basin_keys)
if len(args.source_keys) == 0:
print("No sources found, I will plot all of them")
these_source_keys = []
else:
these_source_keys = [int(item) for item in args.source_keys.split(',')]
print("The sources preselected are:")
print(these_source_keys)
if len(args.fixed_size_kp_min_max_river) != 2:
min_max_kp_river = []
else:
min_max_kp_river = [float(item) for item in args.min_max_kp_river.split(',')]
print("You are recasting the size for all your knickpoints triangles plotted on the river_plots:")
print(min_max_kp_river)
if len(args.manual_extent_colormap_knickpoint_raster) > 0:
manual_cmap_extent_raster_plot = [float(item) for item in args.manual_extent_colormap_knickpoint_raster.split(',')]
print("You choose a manual colorbar for plotting:")
print(manual_cmap_extent_raster_plot)
else:
manual_cmap_extent_raster_plot = []
if(args.maximum_extent_for_histogram>0):
ext_dseg_hist = [0,args.maximum_extent_for_histogram]
ext_dksn_hist = [-args.maximum_extent_for_histogram,args.maximum_extent_for_histogram]
else:
ext_dseg_hist = []
ext_dksn_hist = []
if len(args.general_size) == 0:
print("Sizing the knickpoints automatically")
general_size_kp = []
else:
general_size_kp = [float(item) for item in args.general_size.split(',')]
print(general_size_kp)
print("Getting your cut off values...")
if(args.cut_off_val != "auto"):
try:
covfefe = [float(item) for item in args.cut_off_val.replace(" ", "").split(',')]
print("ok.")
covfefe_t = [-covfefe[0],covfefe[1],-10000,covfefe[2]]
covfefe = covfefe_t
except ValueError:
print("Something went wrong - I am defaulting the values")
covfefe = [0,0,-10000,0]
print("cut off values:")
print(covfefe)
else:
covfefe = "auto"
print("I will choose automatically the cut-off values, based on the quartiles")
# Processing the size choice
try:
size = [float(item) for item in args.size_format.split(',')]
except ValueError:
size = args.size_format
if not args.fname_prefix:
print("WARNING! You haven't supplied your DEM name. Please specify this with the flag '-fname'")
sys.exit()
print("Done")
# Normalisation???
if(args.normalise_elevation_to_outlet_absolute and args.normalise_elevation_to_outlet_relative):
print("Erm, you cannot normaliSe your elevation in relatively absolute or absolutely relative way! you have to choose.")
quit()
elif(args.normalise_elevation_to_outlet_absolute):
normalisation = "absolute"
elif(args.normalise_elevation_to_outlet_relative):
normalisation = "relative"
else:
normalisation = None
print("Loading the dataset:")
KI = KP.KP_plotting(this_dir,args.fname_prefix, basin_key = these_basin_keys, source_key = these_source_keys, min_length = args.min_source_length,
cut_off_val = covfefe, main_stem = args.isolate_main_stem, normalisation = normalisation, size_kp = general_size_kp, coeff_size = args.kp_coeff_size)
if(args.AllAnalysisDebug):
args.AllAnalysis = True
args.ksn_per_source = True
if(args.AllAnalysis):
args.statistical_plots = True
args.river_profile = True
args.raster_plots = True
# args.raster_plots_large_dataset = True
args.basin_plot = True
# Plotting hte knickpoints
if(args.statistical_plots):
if(int(args.n_bin_hist) == 0):
n_b = "auto"
else:
n_b = int(args.n_bin_hist)
KI.print_histogram(size = size, format = args.FigFormat, n_bin = n_b,x_extents = ext_dksn_hist)
KI.print_histogram(size = size, format = args.FigFormat, n_bin = n_b, data = "delta_segelev",x_extents = ext_dseg_hist)
KI.print_box_and_whisker(size = size, format = args.FigFormat, label_size = 8, binning = 'source_key', facecolor = "white", grid = True)
KI.print_box_and_whisker(size = size, format = args.FigFormat, label_size = 8, binning = 'basin_key', facecolor = "white", grid = True)
if(args.ksn_per_source):
print("Printing a set of ksn values with the knickpoints and their magnitude in a Chi distance")
KI.print_ksn_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, title = "auto", label_size = 8, facecolor = 'white', legend = True)
# KI.print_ksn_profile(size = size, format = args.FigFormat, x_axis = "chi",y_axis = "segmented_elevation", knickpoint = True, title = "auto", label_size = 8, facecolor = 'white', legend = True)
# print("Printing a set of ksn values with the knickpoints and their magnitude in a Flow distance")
# KI.print_ksn_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, title = "auto", label_size = 8, facecolor = 'white', legend = True)
if(args.river_profile):
print("Printing river profiles in chi spaces")
KI.print_river_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, title = "auto", label_size = 8, facecolor = 'white', kalib = args.kalib,
print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river)
print("Printing river profiles in flow distance")
KI.print_river_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, title = "auto", label_size = 8, facecolor = 'white', kalib = args.kalib,
print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river)
print("Printing river profiles for the entire basins")
if(args.classical_plot):
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = False, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = False, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = False, pos = True, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = False, pos = True, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = False, pos = False, step = True)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = False, pos = False, step = True)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = True, step = True)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = True, step = True)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = True, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "basin_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = True, step = False)
KI.print_classic_map(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = False, scale_points = True, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib, neg = True, pos = False, step = False)
KI.print_classic_map(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = False, scale_points = True, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib, neg = False, pos = True, step = False)
KI.print_classic_map(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = False, scale_points = True, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib, neg = False, pos = False, step = True)
KI.print_classic_map(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = False, scale_points = True, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib, neg = True, pos = True, step = False)
KI.print_classic_map(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = False, scale_points = True, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib, neg = True, pos = True, step = True)
if(args.classical_plot_per_river):
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = False, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = False, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = False, pos = True, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = False, pos = True, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = False, pos = False, step = True)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = False, pos = False, step = True)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = True, step = True)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = True, step = True)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = True, step = False)
KI.print_classic_basin_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, label_size = 8, facecolor = 'white', kalib = args.kalib,
binning = "source_key", print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, neg = True, pos = True, step = False)
if (args.basin_plot):
KI.print_river_profile(size = size, format = args.FigFormat, x_axis = "flow_distance", knickpoint = True, title = "auto", label_size = 8, facecolor = 'white', binning = "basin_key",
kalib = args.kalib, print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, up_set = 15)
KI.print_river_profile(size = size, format = args.FigFormat, x_axis = "chi", knickpoint = True, title = "auto", label_size = 8, facecolor = 'white', binning = "basin_key",
kalib = args.kalib, print_seg_elev = args.print_segmented_elevation, size_recasting = min_max_kp_river, up_set = 15)
if(args.raster_plots):
KI.print_map_topo(size = size, format = args.FigFormat,label_size = 8, return_fig = False, extent_cmap = [], kalib = False)
KI.print_map_of_kp(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = False, scale_points = True, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib)
KI.print_map_of_kp(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = True, scale_points = True, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib)
if(args.raster_plots_large_dataset):
KI.print_map_of_kp(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = False, scale_points = False, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib)
KI.print_map_of_kp(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = True, scale_points = False, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib)
if(args.multi_violin_plots):
KI.stradivarius_analysis(size = size, format = args.FigFormat)
# Preparing the min_max color for mchi maps
if(args.max_mchi_map <= args.min_mchi_map):
colo = []
else:
colo = [args.min_mchi_map,args.max_mchi_map]
if(args.lithologic_raster):
dict_file = LP.litho_pre_check(this_dir,"", fname = args.fname_prefix)
LP.MakeRasterLithoBasinMap(this_dir, args.fname_prefix, args.fname_prefix+"_LITHRAST", dict_file["lithodict"], size_format= size, FigFormat=args.FigFormat,
m_chi = True, mancol = colo, log_scale_river = True, minmax_m_chi = [0.01,1])
cml = LP.getLithoColorMap(args.fname_prefix, this_dir)
KI.print_map_of_kp(unicolor_kp = args.unicolor_for_knickpoint_map,size = size, format = args.FigFormat, black_bg = False, scale_points = False, label_size = 6,
size_kp = args.size_kp_map, extent_cmap = manual_cmap_extent_raster_plot, kalib = args.kalib, cml = cml, lith_raster = True)
if(args.save_output):
KI.save_output_csv()
# Preparing the min_max color for mchi maps
if(args.max_mchi_map <= args.min_mchi_map):
colo = []
else:
colo = [args.min_mchi_map,args.max_mchi_map]
if args.mchi_map_std:
CP.map_Mchi_standard(this_dir, args.fname_prefix, size_format=args.size_format, FigFormat=args.FigFormat,source_list = these_source_keys, basin_list = these_basin_keys, log = False,
colmanscal = colo, knickpoint = True, alpha_background = args.alpha_mchi)
if args.mchi_map_black:
CP.map_Mchi_standard(this_dir, args.fname_prefix, size_format=args.size_format, FigFormat=args.FigFormat,source_list = these_source_keys, basin_list = these_basin_keys, log = False,
colmanscal = colo, bkbg = True, knickpoint = True, alpha_background = args.alpha_mchi)
# This part saves the different parameters you used, in case you want to reproduce your results and do not remember what you've used.
print("log of your parameters into the file %s" %(this_dir+"log_PlotKnickpoint_Analysis.txt"))
f=open(this_dir+"log_PlotKnickpoint_Analysis.txt", "a+")
f.write("#########################################################################")
f.write(os.linesep)
f.write(os.linesep)
f.write("Ran on the %s " %(datetime.datetime.now()) )
f.write(os.linesep)
for arg in vars(args):
f.write("%s : %s " %(arg, getattr(args, arg)))
f.write(os.linesep)
f.write(os.linesep)
f.write(os.linesep)
f.write(os.linesep)
f.close()
print("Done!")
if os.name == 'nt':
print("You're running this on windows, note that (i) Linux is increadibly faster and (ii) native windows text editor will misread your log text file, open it with another software (e.g. Brackets or SublimeText)")
#=============================================================================
if __name__ == "__main__":
main(sys.argv[1:])