tilupy 0.1.3__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tilupy might be problematic. Click here for more details.

Files changed (34) hide show
  1. {tilupy-0.1.3/src/tilupy.egg-info → tilupy-0.1.4}/PKG-INFO +2 -2
  2. {tilupy-0.1.3 → tilupy-0.1.4}/pyproject.toml +2 -2
  3. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/cmd.py +30 -26
  4. {tilupy-0.1.3 → tilupy-0.1.4/src/tilupy.egg-info}/PKG-INFO +2 -2
  5. tilupy-0.1.4/tests/test_shaltop.py +106 -0
  6. tilupy-0.1.3/tests/test_shaltop.py +0 -66
  7. {tilupy-0.1.3 → tilupy-0.1.4}/LICENSE +0 -0
  8. {tilupy-0.1.3 → tilupy-0.1.4}/MANIFEST.in +0 -0
  9. {tilupy-0.1.3 → tilupy-0.1.4}/README.md +0 -0
  10. {tilupy-0.1.3 → tilupy-0.1.4}/data/frankslide/rasters/Frankslide_pile.asc +0 -0
  11. {tilupy-0.1.3 → tilupy-0.1.4}/data/frankslide/rasters/Frankslide_topography.asc +0 -0
  12. {tilupy-0.1.3 → tilupy-0.1.4}/setup.cfg +0 -0
  13. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/__init__.py +0 -0
  14. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/calibration.py +0 -0
  15. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/compare.py +0 -0
  16. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/download_data.py +0 -0
  17. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/initdata.py +0 -0
  18. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/models/__init__.py +0 -0
  19. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/models/ravaflow/__init__.py +0 -0
  20. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/models/ravaflow/initsimus.py +0 -0
  21. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/models/ravaflow/read.py +0 -0
  22. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/models/shaltop/__init__.py +0 -0
  23. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/models/shaltop/initsimus.py +0 -0
  24. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/models/shaltop/read.py +0 -0
  25. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/notations.py +0 -0
  26. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/plot.py +0 -0
  27. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/raster.py +0 -0
  28. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/read.py +0 -0
  29. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy/utils.py +0 -0
  30. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy.egg-info/SOURCES.txt +0 -0
  31. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy.egg-info/dependency_links.txt +0 -0
  32. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy.egg-info/entry_points.txt +0 -0
  33. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy.egg-info/requires.txt +0 -0
  34. {tilupy-0.1.3 → tilupy-0.1.4}/src/tilupy.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tilupy
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Thin-layer models unified processing tool
5
5
  Author-email: Marc Peruzzetto <m.peruzzetto@brgm.fr>
6
6
  License: CeCILL-C FREE SOFTWARE LICENSE AGREEMENT
@@ -524,7 +524,7 @@ Keywords: thin-layer,shallow-water,display,simulation,model,processing,benchmark
524
524
  Classifier: License :: CeCILL-C Free Software License Agreement (CECILL-C)
525
525
  Classifier: Programming Language :: Python
526
526
  Classifier: Programming Language :: Python :: 3
527
- Requires-Python: >=3.10
527
+ Requires-Python: >=3.8
528
528
  Description-Content-Type: text/markdown
529
529
  Provides-Extra: test
530
530
  Provides-Extra: dev
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "tilupy"
9
- version = "0.1.3"
9
+ version = "0.1.4"
10
10
  description = "Thin-layer models unified processing tool"
11
11
  readme = "README.md"
12
12
  authors = [{ name = "Marc Peruzzetto", email = "m.peruzzetto@brgm.fr" }]
@@ -20,7 +20,7 @@ keywords = ["thin-layer", "shallow-water", "display", "simulation", "model", "pr
20
20
  dependencies = [
21
21
  "seaborn", "requests",
22
22
  ]
23
- requires-python = ">=3.10"
23
+ requires-python = ">=3.8"
24
24
 
25
25
  [project.optional-dependencies]
26
26
  test = ["pytest"]
@@ -11,60 +11,63 @@ import tilupy.read
11
11
  import os
12
12
  import argparse
13
13
  import glob
14
-
14
+
15
15
 
16
16
  def process_results(fn_name, model, res_name, folder=None, param_files=None,
17
17
  kwargs_read=None, **kwargs_fn):
18
-
18
+
19
19
  assert(model is not None)
20
-
20
+
21
21
  if folder is None:
22
22
  folder = os.getcwd()
23
-
23
+
24
24
  if param_files is None:
25
25
  param_files = '*.txt'
26
-
26
+
27
27
  print(folder, param_files)
28
-
29
- param_files = glob.glob(param_files, root_dir=folder)
30
-
28
+
29
+ param_files = glob.glob(os.path.join(folder, param_files))
30
+
31
31
  if len(param_files) == 0:
32
32
  print('No parameter file matching param_files pattern was found')
33
33
  return
34
-
34
+
35
35
  if kwargs_read is None:
36
36
  kwargs_read = dict()
37
-
38
- kw_read = dict(folder_base=folder)
37
+
38
+ kw_read = dict(folder_base=folder)
39
39
  kw_read.update(kwargs_read)
40
-
40
+
41
41
  for param_file in param_files:
42
42
  print_str = 'Processing simulation {:s}, {:s} {:s} .....'
43
43
  print(print_str.format(param_file, fn_name, res_name))
44
44
  kw_read['file_params'] = param_file
45
45
  res = tilupy.read.get_results(model, **kw_read)
46
46
  getattr(res, fn_name)(res_name, **kwargs_fn)
47
-
48
- def to_raster(model=None, res_name='h', param_files=None, folder=None,
47
+
48
+
49
+ def to_raster(model=None, res_name='h', param_files=None, folder=None,
49
50
  kwargs_read=None, **kwargs):
50
-
51
+
51
52
  kw = dict(fmt='asc')
52
53
  kw.update(kwargs)
53
-
54
+
54
55
  process_results('save', model, res_name,
55
56
  folder=folder, param_files=param_files,
56
57
  kwargs_read=kwargs_read, **kw)
57
-
58
- def plot_results(model=None, res_name='h', param_files=None, folder=None,
58
+
59
+
60
+ def plot_results(model=None, res_name='h', param_files=None, folder=None,
59
61
  kwargs_read=None, **kwargs):
60
-
62
+
61
63
  kw = dict(save=True)
62
64
  kw.update(kwargs)
63
-
65
+
64
66
  process_results('plot', model, res_name,
65
67
  folder=folder, param_files=param_files,
66
68
  kwargs_read=kwargs_read, **kwargs)
67
-
69
+
70
+
68
71
  def _get_parser(prog, description):
69
72
  parser = argparse.ArgumentParser(prog=prog,
70
73
  description=description,
@@ -80,6 +83,7 @@ def _get_parser(prog, description):
80
83
  default=None, type=str)
81
84
  return parser
82
85
 
86
+
83
87
  def _tilupy_plot():
84
88
  parser = _get_parser('tilupy_plot', 'Plot thin-layer simulation results')
85
89
  parser.add_argument('--fmt', help=("Plot output format "
@@ -100,7 +104,8 @@ def _tilupy_plot():
100
104
  )
101
105
  args = parser.parse_args()
102
106
  plot_results(**vars(args))
103
-
107
+
108
+
104
109
  def _tilupy_to_raster():
105
110
  parser = _get_parser('tilupy_to_raster',
106
111
  'Convert simulation results to rasters')
@@ -111,11 +116,10 @@ def _tilupy_to_raster():
111
116
  args = parser.parse_args()
112
117
  # plot_results(parser.model, parser.res_name)
113
118
  to_raster(**vars(args))
114
-
115
-
119
+
120
+
116
121
  if __name__ == '__main__':
117
-
122
+
118
123
  # folder = 'd:/Documents/peruzzetto/tmp/test_shaltop/7p30e04_m3/coulomb'
119
124
  # plot_results('shaltop', 'h_max', '*18p00.txt', folder=folder)
120
125
  _tilupy_plot()
121
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tilupy
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Thin-layer models unified processing tool
5
5
  Author-email: Marc Peruzzetto <m.peruzzetto@brgm.fr>
6
6
  License: CeCILL-C FREE SOFTWARE LICENSE AGREEMENT
@@ -524,7 +524,7 @@ Keywords: thin-layer,shallow-water,display,simulation,model,processing,benchmark
524
524
  Classifier: License :: CeCILL-C Free Software License Agreement (CECILL-C)
525
525
  Classifier: Programming Language :: Python
526
526
  Classifier: Programming Language :: Python :: 3
527
- Requires-Python: >=3.10
527
+ Requires-Python: >=3.8
528
528
  Description-Content-Type: text/markdown
529
529
  Provides-Extra: test
530
530
  Provides-Extra: dev
@@ -0,0 +1,106 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Wed Jul 19 15:39:38 2023
4
+
5
+ @author: peruzzetto
6
+ """
7
+
8
+ import os
9
+ import shutil
10
+
11
+ import tilupy.models.shaltop.initsimus as shinit
12
+ import tilupy.cmd
13
+
14
+
15
+ def test_shaltop_raster_to_input(folder_data):
16
+
17
+ folder_simus = os.path.join(folder_data, 'frankslide', 'shaltop')
18
+
19
+ raster_topo = os.path.join(folder_data, 'frankslide', 'rasters',
20
+ 'Frankslide_topography.asc')
21
+
22
+ file_topo_sh = os.path.join(folder_simus, 'topography.d')
23
+
24
+ if os.path.isfile(file_topo_sh):
25
+ os.remove(file_topo_sh)
26
+
27
+ shinit.raster_to_shaltop_txtfile(raster_topo, file_topo_sh)
28
+
29
+ raster_pile = os.path.join(folder_data, 'frankslide', 'rasters',
30
+ 'Frankslide_pile.asc')
31
+ file_mass_sh = os.path.join(folder_simus, 'init_mass.d')
32
+
33
+ if os.path.isfile(file_mass_sh):
34
+ os.remove(file_mass_sh)
35
+
36
+ shinit.raster_to_shaltop_txtfile(raster_pile, file_mass_sh)
37
+
38
+ assert os.path.isfile(file_topo_sh) & os.path.isfile(file_mass_sh)
39
+
40
+
41
+ def test_shaltop_make_read_param_file(folder_data):
42
+
43
+ params = dict(nx=201, ny=201,
44
+ per=201*20,
45
+ pery=201*20,
46
+ # Simulation maximum time in seconds (not comutation time)
47
+ tmax=20,
48
+ dt_im=10, # Time interval (s) between snapshots recordings
49
+ file_z_init='topography.d', # Name of topography input file
50
+ file_m_init='init_mass.d', # name of init mass input file
51
+ initz=0, # Topography is read from file
52
+ ipr=0, # Initial mass is read from file
53
+ hinit_vert=1, # Initial is given as vertical thicknesses and
54
+ # must be converted to thicknesses normal to topography
55
+ eps0=1e-13, # Minimum value for thicknesses and velocities
56
+ # choice of rheology (Coulomb with constant basal friction)
57
+ icomp=1,
58
+ # Min x value (used for plots after simulation is over)
59
+ x0=1000,
60
+ y0=2000) # Min y value (used for plots after simulation is over)
61
+
62
+ deltas = [15, 20, 25]
63
+ folder_simus = os.path.join(folder_data, 'frankslide', 'shaltop')
64
+ files_created = True
65
+
66
+ for delta in deltas:
67
+ params_txt = 'delta_{:05.2f}'.format(delta).replace('.', 'p')
68
+ param_file_path = os.path.join(folder_simus, params_txt + '.txt')
69
+ if os.path.isfile(param_file_path):
70
+ os.remove(param_file_path)
71
+ # Specify folder where outputs are stored
72
+ params['folder_output'] = params_txt
73
+ params['delta1'] = delta # Specify the friction coefficient
74
+ # Write parameter file
75
+ shinit.write_params_file(params, directory=folder_simus,
76
+ file_name=params_txt + '.txt')
77
+
78
+ files_created = files_created & os.path.isfile(param_file_path)
79
+ if not files_created:
80
+ break
81
+
82
+ assert files_created
83
+
84
+
85
+ def test_shaltop_plot_results(folder_data):
86
+
87
+ folder_simus = os.path.join(folder_data, 'frankslide', 'shaltop')
88
+ params_files = 'delta_*p00.txt'
89
+ folder_ress = [os.path.join(folder_data, 'frankslide', 'shaltop',
90
+ 'delta_{:d}p00'.format(delta), 'plots')
91
+ for delta in [15, 20, 25]]
92
+ for folder in folder_ress:
93
+ if os.path.isdir(folder):
94
+ shutil.rmtree(folder)
95
+ tilupy.cmd.plot_results('shaltop', 'h', params_files, folder_simus,
96
+ save=True, display_plot=False,
97
+ figsize=(10/2.54, 10/2.54))
98
+ files_plots = ['h_0000.png', 'h_0001.png', 'h_0002.png']
99
+
100
+ all_files_created = True
101
+ for folder in folder_ress:
102
+ for file in files_plots:
103
+ file_path = os.path.join(folder, file)
104
+ all_files_created = all_files_created & os.path.isfile(file_path)
105
+
106
+ assert all_files_created
@@ -1,66 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Wed Jul 19 15:39:38 2023
4
-
5
- @author: peruzzetto
6
- """
7
-
8
- import os
9
-
10
- import tilupy.models.shaltop.initsimus as shinit
11
-
12
-
13
- def test_shaltop_raster_to_input(folder_data):
14
-
15
- raster_topo = os.path.join(folder_data, 'frankslide', 'rasters',
16
- 'Frankslide_topography.asc')
17
-
18
- folder_simus = os.path.join(folder_data, 'frankslide', 'shaltop')
19
-
20
- file_topo_sh = os.path.join(folder_simus, 'topography.d')
21
-
22
- if os.path.isfile(file_topo_sh):
23
- os.remove(file_topo_sh)
24
-
25
- shinit.raster_to_shaltop_txtfile(raster_topo, file_topo_sh)
26
-
27
- assert os.path.isfile(file_topo_sh)
28
-
29
- def test_shaltop_make_read_param_file(folder_data):
30
-
31
- params = dict(nx=201, ny=201,
32
- per=201*20,
33
- pery=201*20,
34
- tmax=100, # Simulation maximum time in seconds (not comutation time)
35
- dt_im=10, # Time interval (s) between snapshots recordings
36
- file_z_init = 'topography.d', # Name of topography input file
37
- file_m_init = 'init_mass.d',# name of init mass input file
38
- initz=0, # Topography is read from file
39
- ipr=0, # Initial mass is read from file
40
- hinit_vert=1, # Initial is given as vertical thicknesses and
41
- # must be converted to thicknesses normal to topography
42
- eps0=1e-13, #Minimum value for thicknesses and velocities
43
- icomp=1, # choice of rheology (Coulomb with constant basal friction)
44
- x0=1000, # Min x value (used for plots after simulation is over)
45
- y0=2000) # Min y value (used for plots after simulation is over)
46
-
47
- deltas = [15, 20, 25]
48
- folder_simus = os.path.join(folder_data, 'frankslide', 'shaltop')
49
- files_created = True
50
-
51
- for delta in deltas:
52
- params_txt = 'delta_{:05.2f}'.format(delta).replace('.', 'p')
53
- param_file_path = os.path.join(folder_simus,params_txt + '.txt')
54
- if os.path.isfile(param_file_path):
55
- os.remove(param_file_path)
56
- params['folder_output'] = params_txt # Specify folder where outputs are stored
57
- params['delta1'] = delta # Specify the friction coefficient
58
- #Write parameter file
59
- shinit.write_params_file(params, directory=folder_simus,
60
- file_name=params_txt + '.txt')
61
-
62
- files_created = files_created & os.path.isfile(param_file_path)
63
- if not files_created:
64
- break
65
-
66
- assert files_created
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes