Skip to content

Commit

Permalink
some minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ealonsogzl committed Jun 12, 2024
1 parent 7cfc6da commit e000888
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
8 changes: 4 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
save_int_forcing = True
# If restart_forcing, the forcing will be read from the intermediate files of
# a previous run
restart_forcing = False
restart_forcing = True
# if real_time, it will be possible to run MuSA from initial condition files,
# These files are ensemble objects, generated by a previous run, or by a
# very advanced user. Init files are saved in real_time_restart_path,
Expand Down Expand Up @@ -123,9 +123,9 @@
nprocess = 8

# number of cells to be solved per processor at each iteration
cells_per_process = None
cells_per_process = None # None is 1
# maximun number of seconds each pool is killed before try again
timeout = None
timeout = None # None is inf

aws_lat = 4735225.54 # Latitude in case of point_scale
aws_lon = 710701.28 # Longitude in case of point_scale
Expand All @@ -149,7 +149,7 @@
dist_algo = 'euclidean'
# distance_mat_calc Enables calculating the distance matrix, iterativelly
# as an sparse distance matrix, using KDtree or in the regular way
# (memory consuming). It is slow but can save a lot of memory
# (memory consuming).
distance_mat_calc = 'Regular' # Regular, Sparse, KDtree
# Optionally perform dimension reduction to try to avoid nonPD
dimension_reduction = 'None' # LMDS, PCA or None
Expand Down
16 changes: 8 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def MuSA():
continue

# create prior Ensembles
inputs = [grid[ids, 0], grid[ids, 1],
[ini_DA_window] * grid.shape[0],
inputs = [list(grid[ids, 0]), list(grid[ids, 1]),
[ini_DA_window] * sum(ids),
[step] * sum(ids),
[gsc_count] * sum(ids)]

Expand All @@ -181,7 +181,7 @@ def MuSA():
# add info to log
logging.info(f'step: {step} - j: {j}')

inputs = [grid[ids, 0], grid[ids, 1],
inputs = [list(grid[ids, 0]), list(grid[ids, 1]),
[step] * sum(ids), [j]*sum(ids)]

ifn.safe_pool(spM.spatial_assim, inputs, nprocess)
Expand Down Expand Up @@ -230,10 +230,10 @@ def MuSA():
continue

# create prior Ensembles
inputs = [grid[:, 0], grid[:, 1],
[ini_DA_window] * grid.shape[0],
[step] * grid.shape[0],
[gsc_count] * grid.shape[0]]
inputs = [list(grid[ids, 0]), list(grid[ids, 1]),
[ini_DA_window] * sum(ids),
[step] * sum(ids),
[gsc_count] * sum(ids)]

ifn.safe_pool(spM.create_ensemble_cell, inputs, nprocess)

Expand All @@ -247,7 +247,7 @@ def MuSA():
# add info to log
logging.info(f'step: {step} - j: {j}')

inputs = [grid[:, 0], grid[:, 1],
inputs = [list(grid[:, 0]), list(grid[:, 1]),
[step] * grid.shape[0],
[j] * grid.shape[0]]

Expand Down
5 changes: 5 additions & 0 deletions modules/fsm_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ def model_compile_HPC(HPC_task_id):
fsm_path = cfg.fsm_src_path
file_name = os.path.join(fsm_path, "FSM2")

# if binary exist, pass to avoid breaking HPC job arrays
fsm_filename = os.path.join(cfg.fsm_src_path, "FSM2")
if os.path.isfile(fsm_filename):
return None

if HPC_task_id == 0:
model_compile()
else:
Expand Down
7 changes: 6 additions & 1 deletion modules/internal_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def pre_cheks():
'supports simulations generated from '
'Spatial_propagation simulation.')
if cfg.timeout and cfg.MPI:
warnings.warn("timeout is ignored MPI")
warnings.warn("timeout is ignored with MPI")

if cfg.parallelization == "HPC.array" and cfg.numerical_model == "FSM2":
fsm_filename = os.path.join(cfg.fsm_src_path, "FSM2")
if os.path.isfile(fsm_filename):
warnings.warn("FSM binary exists, reusing compile options")


def last_line(filename):
Expand Down
2 changes: 2 additions & 0 deletions modules/spatialMuSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def get_topo_arr():
dem = nc.Dataset(dem)

dem_arr = dem.variables[nc_dem_varname][:]
dem_arr = dem_arr.filled(np.nan) # from numpy.ma to numpy
dem_arr = fill_nan_arr(dem_arr)

# Grid spacing
Expand Down Expand Up @@ -559,6 +560,7 @@ def get_rho(prior_id):
# NOTE: this masks the current cell, but the current cell
# is added anyway when the neig is created
tmp_dis[tmp_dis == 0.] = np.nan
tmp_dis[n] = 0. # put 0 in diagonal

distnc[:, n] = tmp_dis
f.close()
Expand Down

0 comments on commit e000888

Please sign in to comment.