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
Admin message
Gitlab has been updated. More info
here
and
there
.
Show more breadcrumbs
IPSL
LMD
DPAO
Detection eddies
Commits
f36dca6c
Commit
f36dca6c
authored
3 years ago
by
Lionel GUEZ
Browse files
Options
Downloads
Patches
Plain Diff
Create script to generate iterator of Aviso files
parent
1c29f87a
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
+57
-0
57 additions, 0 deletions
Inst_eddies/inst_eddies_Aviso.py
with
57 additions
and
0 deletions
Inst_eddies/inst_eddies_Aviso.py
0 → 100755
+
57
−
0
View file @
f36dca6c
#!/usr/bin/env python3
"""
We are assuming that all input NetCDF files are in the same
directory and that the time coordinate is in days since 1950-1-1.
"""
import
argparse
import
datetime
from
os
import
path
import
sys
from
dateutil
import
parser
import
netCDF4
import
inst_eddies
def
filename_generator
(
first_file
,
first_date
,
last_date
,
template
,
dirname
):
nc_file
=
first_file
my_date
=
first_date
while
True
:
yield
nc_file
my_date
+=
datetime
.
timedelta
(
1
)
if
my_date
>
last_date
:
break
basename
=
my_date
.
strftime
(
template
)
nc_file
=
path
.
join
(
dirname
,
basename
)
argparser
=
argparse
.
ArgumentParser
()
argparser
.
add_argument
(
"
first_file
"
,
help
=
"
NetCDF file containing SSH and velocity at a
"
"
single date
"
)
argparser
.
add_argument
(
"
--template
"
,
help
=
"
template of basename with date format, only
"
"
used for several dates
"
)
argparser
.
add_argument
(
"
-l
"
,
"
--last_date
"
,
help
=
"
%%Y-%%m-%%d
"
)
argparser
.
add_argument
(
"
-b
"
,
"
--bbox
"
,
nargs
=
4
,
type
=
float
,
metavar
=
(
"
xmin
"
,
"
xmax
"
,
"
ymin
"
,
"
ymax
"
))
args
=
argparser
.
parse_args
()
# Get the first date from the time coordinate in the NetCDF file:
with
netCDF4
.
Dataset
(
args
.
first_file
)
as
f
:
d
=
f
[
"
time
"
][:].
item
()
d
=
round
(
d
)
first_date
=
datetime
.
date
(
1950
,
1
,
1
)
+
datetime
.
timedelta
(
d
)
#--
dirname
=
path
.
dirname
(
args
.
first_file
)
if
args
.
last_date
:
last_date
=
parser
.
parse
(
args
.
last_date
).
date
()
if
last_date
>
first_date
and
not
args
.
template
:
sys
.
exit
(
"
template option required for several dates
"
)
else
:
last_date
=
first_date
inst_eddies
.
loop_inst_eddies
(
filename_generator
(
args
.
first_file
,
first_date
,
last_date
,
args
.
template
,
dirname
),
args
.
bbox
,
d
)
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