Skip to content

Commit 1dbd1b3

Browse files
committed
New architecture of appplication
1 parent 974b219 commit 1dbd1b3

File tree

11 files changed

+738
-289
lines changed

11 files changed

+738
-289
lines changed

setup.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,28 @@
2525
packages=find_packages("src"),
2626
package_dir={"": "src"},
2727
scripts=[
28-
"src/scripts/GridFiltering",
2928
"src/scripts/EddyId",
3029
"src/scripts/EddySubSetter",
3130
"src/scripts/EddyTranslate",
3231
"src/scripts/EddyTracking",
3332
"src/scripts/EddyFinalTracking",
3433
"src/scripts/EddyMergeCorrespondances",
35-
"src/scripts/ZarrDump",
3634
"src/scripts/GUIEddy",
3735
],
3836
zip_safe=False,
3937
entry_points=dict(
4038
console_scripts=[
41-
"MergeEddies = py_eddy_tracker.appli:merge_eddies",
42-
"EddyNetworkGroup = py_eddy_tracker.network:build_network",
43-
"EddyAnim = py_eddy_tracker.appli:anim"
39+
# grid
40+
"GridFiltering = py_eddy_tracker.appli.grid:grid_filtering",
41+
# eddies
42+
"MergeEddies = py_eddy_tracker.appli.eddies:merge_eddies",
43+
# network
44+
"EddyNetworkGroup = py_eddy_tracker.appli.network:build_network",
45+
"EddyNetworkBuildPath = py_eddy_tracker.appli.network:divide_network",
46+
# anim/gui
47+
"EddyAnim = py_eddy_tracker.appli.gui:anim",
48+
# misc
49+
"ZarrDump = py_eddy_tracker.appli.misc:zarrdump",
4450
]
4551
),
4652
package_data={

src/py_eddy_tracker/appli/__init__.py

Whitespace-only changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
===========================================================================
4+
This file is part of py-eddy-tracker.
5+
6+
py-eddy-tracker is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
py-eddy-tracker is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with py-eddy-tracker. If not, see <http://www.gnu.org/licenses/>.
18+
19+
Copyright (c) 2014-2020 by Evan Mason
20+
21+
===========================================================================
22+
"""
23+
from netCDF4 import Dataset
24+
from .. import EddyParser
25+
from ..observations.tracking import TrackEddiesObservations
26+
27+
28+
def merge_eddies():
29+
parser = EddyParser("Merge eddies")
30+
parser.add_argument("filename", nargs="+", help="all file to merge")
31+
parser.add_argument("out", help="output file")
32+
parser.add_argument(
33+
"--add_rotation_variable", help="add rotation variables", action="store_true"
34+
)
35+
parser.add_argument(
36+
"--include_var", nargs="+", type=str, help="use only listed variable"
37+
)
38+
args = parser.parse_args()
39+
40+
if args.include_var is None:
41+
with Dataset(args.filename[0]) as h:
42+
args.include_var = h.variables.keys()
43+
44+
obs = TrackEddiesObservations.load_file(
45+
args.filename[0], raw_data=True, include_vars=args.include_var
46+
)
47+
if args.add_rotation_variable:
48+
obs = obs.add_rotation_type()
49+
for filename in args.filename[1:]:
50+
other = TrackEddiesObservations.load_file(
51+
filename, raw_data=True, include_vars=args.include_var
52+
)
53+
if args.add_rotation_variable:
54+
other = other.add_rotation_type()
55+
obs = obs.merge(other)
56+
obs.write_file(filename=args.out)

src/py_eddy_tracker/appli/grid.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
===========================================================================
4+
This file is part of py-eddy-tracker.
5+
6+
py-eddy-tracker is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
py-eddy-tracker is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with py-eddy-tracker. If not, see <http://www.gnu.org/licenses/>.
18+
19+
Copyright (c) 2014-2020 by Evan Mason
20+
21+
===========================================================================
22+
"""
23+
from .. import EddyParser
24+
from ..dataset.grid import RegularGridDataset
25+
26+
27+
def grid_parser():
28+
parser = EddyParser("Grid filtering")
29+
parser.add_argument("filename")
30+
parser.add_argument("grid")
31+
parser.add_argument("longitude")
32+
parser.add_argument("latitude")
33+
parser.add_argument("filename_out")
34+
parser.add_argument(
35+
"--cut_wavelength",
36+
default=500,
37+
type=float,
38+
help="Wavelength for mesoscale filter in km",
39+
)
40+
parser.add_argument("--filter_order", default=3, type=int)
41+
parser.add_argument("--low", action="store_true")
42+
parser.add_argument(
43+
"--extend",
44+
default=0,
45+
type=float,
46+
help="Keep pixel compute by filtering on mask",
47+
)
48+
return parser
49+
50+
51+
def grid_filtering():
52+
args = grid_parser().parse_args()
53+
54+
h = RegularGridDataset(args.filename, args.longitude, args.latitude)
55+
if args.low:
56+
h.bessel_low_filter(
57+
args.grid, args.cut_wavelength, order=args.filter_order, extend=args.extend
58+
)
59+
else:
60+
h.bessel_high_filter(
61+
args.grid, args.cut_wavelength, order=args.filter_order, extend=args.extend
62+
)
63+
h.write(args.filename_out)

src/py_eddy_tracker/appli.py renamed to src/py_eddy_tracker/appli/gui.py

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,12 @@
2323

2424
from numpy import arange, empty
2525
from matplotlib import pyplot
26-
from netCDF4 import Dataset
2726
from matplotlib.collections import LineCollection
2827
from datetime import datetime
29-
from py_eddy_tracker.poly import create_vertice
30-
from py_eddy_tracker.generic import flatten_line_matrix
31-
from py_eddy_tracker import EddyParser
32-
from py_eddy_tracker.observations.tracking import TrackEddiesObservations
33-
34-
35-
def merge_eddies():
36-
parser = EddyParser("Merge eddies")
37-
parser.add_argument("filename", nargs="+", help="all file to merge")
38-
parser.add_argument("out", help="output file")
39-
parser.add_argument(
40-
"--add_rotation_variable", help="add rotation variables", action="store_true"
41-
)
42-
parser.add_argument(
43-
"--include_var", nargs="+", type=str, help="use only listed variable"
44-
)
45-
args = parser.parse_args()
46-
47-
if args.include_var is None:
48-
with Dataset(args.filename[0]) as h:
49-
args.include_var = h.variables.keys()
50-
51-
obs = TrackEddiesObservations.load_file(
52-
args.filename[0], raw_data=True, include_vars=args.include_var
53-
)
54-
if args.add_rotation_variable:
55-
obs = obs.add_rotation_type()
56-
for filename in args.filename[1:]:
57-
other = TrackEddiesObservations.load_file(
58-
filename, raw_data=True, include_vars=args.include_var
59-
)
60-
if args.add_rotation_variable:
61-
other = other.add_rotation_type()
62-
obs = obs.merge(other)
63-
obs.write_file(filename=args.out)
28+
from ..poly import create_vertice
29+
from ..generic import flatten_line_matrix
30+
from .. import EddyParser
31+
from ..observations.tracking import TrackEddiesObservations
6432

6533

6634
class Anim:

src/py_eddy_tracker/appli/misc.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
===========================================================================
4+
This file is part of py-eddy-tracker.
5+
6+
py-eddy-tracker is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
py-eddy-tracker is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with py-eddy-tracker. If not, see <http://www.gnu.org/licenses/>.
18+
19+
Copyright (c) 2014-2020 by Evan Mason
20+
21+
===========================================================================
22+
"""
23+
import argparse
24+
import zarr
25+
26+
27+
def zarr_header_parser():
28+
parser = argparse.ArgumentParser("Zarr header")
29+
parser.add_argument("dataset")
30+
return parser
31+
32+
33+
def zarrdump():
34+
args = zarr_header_parser().parse_args()
35+
print(args.dataset)
36+
for v in zarr.open(args.dataset).values():
37+
print(v.info)

0 commit comments

Comments
 (0)