ladim 2.0.4__py3-none-any.whl → 2.0.6__py3-none-any.whl

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.
ladim/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
- __version__ = '2.0.4'
1
+ __version__ = '2.0.6'
2
2
 
3
3
  from .main import main, run
ladim/__main__.py CHANGED
@@ -1,2 +1,2 @@
1
1
  from . import run
2
- run()
2
+ run()
ladim/config.py CHANGED
@@ -73,7 +73,7 @@ def convert_1_to_2(c):
73
73
  if 'numerics' in c:
74
74
  if 'dt' in c['numerics']:
75
75
  dt_value, dt_unit = c['numerics']['dt']
76
- dt_sec = np.timedelta64(dt_value, dt_unit).astype('timedelta64[s]').astype('int64')
76
+ dt_sec = int(np.timedelta64(dt_value, dt_unit).astype('timedelta64[s]').astype(int))
77
77
 
78
78
  out['version'] = 2
79
79
 
@@ -86,13 +86,17 @@ def convert_1_to_2(c):
86
86
 
87
87
  out['grid'] = {}
88
88
  out['grid']['file'] = dict_get(c, [
89
+ 'gridforce.first_file',
89
90
  'files.grid_file', 'gridforce.grid_file',
90
91
  'files.input_file', 'gridforce.input_file'])
91
92
  out['grid']['legacy_module'] = dict_get(c, 'gridforce.module', '') + '.Grid'
92
93
  out['grid']['start_time'] = np.datetime64(dict_get(c, 'time_control.start_time', '1970'), 's')
94
+ out['grid']['subgrid'] = dict_get(c, 'gridforce.subgrid', None)
93
95
 
94
96
  out['forcing'] = {}
95
97
  out['forcing']['file'] = dict_get(c, ['gridforce.input_file', 'files.input_file'])
98
+ out['forcing']['first_file'] = dict_get(c, 'gridforce.first_file', "")
99
+ out['forcing']['last_file'] = dict_get(c, 'gridforce.last_file', "")
96
100
  out['forcing']['legacy_module'] = dict_get(c, 'gridforce.module', '') + '.Forcing'
97
101
  out['forcing']['start_time'] = np.datetime64(dict_get(c, 'time_control.start_time', '1970'), 's')
98
102
  out['forcing']['stop_time'] = np.datetime64(dict_get(c, 'time_control.stop_time', '1970'), 's')
ladim/forcing.py CHANGED
@@ -2,19 +2,15 @@ from .model import Model, Module
2
2
 
3
3
 
4
4
  class Forcing(Module):
5
- def __init__(self, model: Model):
6
- super().__init__(model)
7
-
8
5
  def velocity(self, X, Y, Z, tstep=0.0):
9
6
  raise NotImplementedError
10
7
 
11
8
 
12
9
  class RomsForcing(Forcing):
13
- def __init__(self, model: Model, file, variables=None, **conf):
10
+ def __init__(self, file, variables=None, **conf):
14
11
  """
15
12
  Forcing module which uses output data from the ROMS ocean model
16
13
 
17
- :param model: Parent model
18
14
  :param file: Glob pattern for the input files
19
15
  :param variables: A mapping of variable names to interpolation
20
16
  specifications. Each interpolaction specification consists of 0-4
@@ -34,17 +30,17 @@ class RomsForcing(Forcing):
34
30
 
35
31
  :param conf: Legacy config dict
36
32
  """
37
- super().__init__(model)
38
-
39
33
  # Apply default interpolation configs
40
34
  variables = variables or dict()
41
35
  default_vars = dict(u="xt", v="yt", w="zt", temp="xyzt", salt="xyzt")
42
36
  self.variables = {**default_vars, **variables}
43
37
 
44
- grid_ref = GridReference(model)
38
+ grid_ref = GridReference()
45
39
  legacy_conf = dict(
46
40
  gridforce=dict(
47
41
  input_file=file,
42
+ first_file=conf.get('first_file', ""),
43
+ last_file=conf.get('last_file', ""),
48
44
  ),
49
45
  ibm_forcing=conf.get('ibm_forcing', []),
50
46
  start_time=conf.get('start_time', None),
@@ -65,17 +61,19 @@ class RomsForcing(Forcing):
65
61
  # self.U = self.forcing.U
66
62
  # self.V = self.forcing.V
67
63
 
68
- def update(self):
69
- elapsed = self.model.solver.time - self.model.solver.start
70
- t = elapsed // self.model.solver.step
64
+ def update(self, model: Model):
65
+ elapsed = model.solver.time - model.solver.start
66
+ t = elapsed // model.solver.step
71
67
 
68
+ # noinspection PyProtectedMember
69
+ self.forcing._grid.modules = model
72
70
  self.forcing.update(t)
73
71
 
74
72
  # Update state variables by sampling the field
75
- x, y, z = self.model.state['X'], self.model.state['Y'], self.model.state['Z']
73
+ x, y, z = model.state['X'], model.state['Y'], model.state['Z']
76
74
  for v in self.variables:
77
- if v in self.model.state:
78
- self.model.state[v] = self.field(x, y, z, v)
75
+ if v in model.state:
76
+ model.state[v] = self.field(x, y, z, v)
79
77
 
80
78
  def velocity(self, X, Y, Z, tstep=0.0):
81
79
  return self.forcing.velocity(X, Y, Z, tstep=tstep)
@@ -88,8 +86,8 @@ class RomsForcing(Forcing):
88
86
 
89
87
 
90
88
  class GridReference:
91
- def __init__(self, modules: Model):
92
- self.modules = modules
89
+ def __init__(self):
90
+ self.modules = None
93
91
 
94
92
  def __getattr__(self, item):
95
93
  return getattr(self.modules.grid.grid, item)