Skip to content
Snippets Groups Projects
Commit e62a030f authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Polish

parent 4411c857
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,9 @@ SHPC_anti and SHPC_cyclo. The mat files are assumed to be in v7.3
before being read in Python. The data in each input file is the set of
detected instantaneous eddies at a given date. The second, optional,
argument of this script is the final date processed. The Matlab script
inst_eddies.m must be in the current directory at run-time.
inst_eddies.m must be in the current directory at run-time. If the adt
file contains variables `id_anti_cell` and `id_cyclo_cell` then we
also read `node_id_param.json`.
"""
......@@ -154,6 +156,14 @@ matlab_data = sio.loadmat("adt_v6.mat", squeeze_me = True)
filter_ghosts = "id_cyclo_cell" in matlab_data
if filter_ghosts:
# We take into account ghost eddies in the Matlab adt file. Some
# eddies are duplicated in global adt files, at the border of the
# longitude domain. We should not use these ghost eddies. So
# R\'emi has added variables `id_anti_cell` and `id_cyclo_cell` in
# adt files. They contain Matlab node indices, n_prime,
# intersparsed with NaN values. We want to check that these node
# indices are correct so we compute our own n_prime from the date
# of the adt file. For this we need d_init and e_overestim.
with open("node_id_param.json") as f: node_id_param = json.load(f)
n1 = (d - node_id_param["d_init"]) * node_id_param["e_overestim"] + 1
# (same starting node id for both orientations)
......@@ -198,6 +208,10 @@ while True:
for factory in factories:
if filter_ghosts:
id_array = ma.fix_invalid(matlab_data[factory["id"]])
# This could be skipped, it is just a verification
# that there is no mistake in the Matlab variable
# factory["id"]:
id_array = np.rint(id_array).astype(int)
n_eddies = id_array.count() # excluding ghosts
equal_range \
......
#!/usr/bin/env python3
"""This script reads the eddy graph from Matlab v6 files
id_child_*.mat and N_eddies.mat, for a given orientation, and
writes the graph to a new file in edgelist format. It also reads
date_num.mat.
id_child_*.mat and N_eddies.mat, for a given orientation, and writes
the graph to a new file in edgelist format. It also reads
date_num.mat.
"""
import scipy.io as sio
import csv
import sys
import json
import datetime
import numpy as np
......@@ -37,8 +36,8 @@ if __name__ == "__main__":
for i in range(n_files):
print(f"Loading id_child_{i}.mat...")
part_id_child \
= sio.loadmat(f"id_child_{i}.mat", squeeze_me=True)["part_id_child"]
part_id_child = sio.loadmat(f"id_child_{i}.mat", squeeze_me = True)\
["part_id_child"]
# part_id_child is a numpy array with shape (e_overestim, chunk)
# where chunk is lower than or equal to the number of dates in the
# original Matlab files.
......
#!/usr/bin/env python3
"""This script loads the graph of segments, with cost functions and
"""This script loads the graph of segments, with cost functions, and
identifies trajectories.
Inputs: the graph of segments produced by Graph-tool (gt or graphml
Input: the graph of segments produced by Graph-tool (in gt or graphml
format). Output: trajectories as lists of segments and as lists of
instantaneous eddies, in JSon files.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment