Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Detection eddies
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IPSL
LMD
DPAO
Detection eddies
Commits
33ed4cac
Commit
33ed4cac
authored
1 year ago
by
Lionel GUEZ
Browse files
Options
Downloads
Patches
Plain Diff
Allow shell wildcard in template
This is useful because, for the year 2021, the last part of Aviso file names varies.
parent
ae59accd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Inst_eddies/inst_eddies_Aviso.py
+15
-1
15 additions, 1 deletion
Inst_eddies/inst_eddies_Aviso.py
with
15 additions
and
1 deletion
Inst_eddies/inst_eddies_Aviso.py
+
15
−
1
View file @
33ed4cac
...
@@ -10,6 +10,7 @@ import sys
...
@@ -10,6 +10,7 @@ import sys
from
dateutil
import
parser
from
dateutil
import
parser
import
netCDF4
import
netCDF4
import
inst_eddies
import
inst_eddies
import
glob
def
filename_generator
(
first_file
,
first_date
,
last_date
,
template
):
def
filename_generator
(
first_file
,
first_date
,
last_date
,
template
):
dirname
=
path
.
dirname
(
first_file
)
dirname
=
path
.
dirname
(
first_file
)
...
@@ -23,6 +24,18 @@ def filename_generator(first_file, first_date, last_date, template):
...
@@ -23,6 +24,18 @@ def filename_generator(first_file, first_date, last_date, template):
basename
=
my_date
.
strftime
(
template
)
basename
=
my_date
.
strftime
(
template
)
nc_file
=
path
.
join
(
dirname
,
basename
)
nc_file
=
path
.
join
(
dirname
,
basename
)
# The template may contain a wild card as long as there is no
# more than one file matching it. A missing file is ok and
# will be dealt with in inst_eddies.py.
path_list
=
glob
.
glob
(
nc_file
)
if
len
(
path_list
)
==
1
:
nc_file
=
path_list
[
0
]
elif
len
(
path_list
)
>=
2
:
sys
.
exit
(
"
inst_eddies_Aviso.py:filename_generator: more than one
"
"
file matching template
"
)
argparser
=
argparse
.
ArgumentParser
()
argparser
=
argparse
.
ArgumentParser
()
argparser
.
add_argument
(
"
first_file
"
,
argparser
.
add_argument
(
"
first_file
"
,
help
=
"
NetCDF file containing SSH and velocity at a
"
help
=
"
NetCDF file containing SSH and velocity at a
"
...
@@ -31,7 +44,8 @@ argparser.add_argument("slice", type = int,
...
@@ -31,7 +44,8 @@ argparser.add_argument("slice", type = int,
help
=
"
slice number to create
"
)
help
=
"
slice number to create
"
)
argparser
.
add_argument
(
"
--template
"
,
argparser
.
add_argument
(
"
--template
"
,
help
=
"
template of basename with date.strftime format
"
help
=
"
template of basename with date.strftime format
"
"
codes, only used for several dates
"
)
"
codes (and possible shell wildcards), only used for
"
"
several dates
"
)
argparser
.
add_argument
(
"
-l
"
,
"
--last_date
"
,
help
=
"
%%Y-%%m-%%d
"
)
argparser
.
add_argument
(
"
-l
"
,
"
--last_date
"
,
help
=
"
%%Y-%%m-%%d
"
)
argparser
.
add_argument
(
"
-b
"
,
"
--bbox
"
,
nargs
=
4
,
type
=
float
,
argparser
.
add_argument
(
"
-b
"
,
"
--bbox
"
,
nargs
=
4
,
type
=
float
,
metavar
=
(
"
xmin
"
,
"
xmax
"
,
"
ymin
"
,
"
ymax
"
))
metavar
=
(
"
xmin
"
,
"
xmax
"
,
"
ymin
"
,
"
ymax
"
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment