Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csppfetch
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
cspp_geo
csppfetch
Commits
c20d0286
Commit
c20d0286
authored
3 years ago
by
Alan De Smet
Browse files
Options
Downloads
Patches
Plain Diff
Add total report on statistics
(And delete a bunch of dead code I could have sworn I removed earlier)
parent
3a837f64
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
example/aitf-update-cache
+10
-60
10 additions, 60 deletions
example/aitf-update-cache
with
10 additions
and
60 deletions
example/aitf-update-cache
+
10
−
60
View file @
c20d0286
...
...
@@ -84,83 +84,33 @@ def parse_args():
return
args
def
print_download_report
(
name
,
stats
):
print
(
name
)
print
(
"
\n
"
.
join
([
"
"
+
x
for
x
in
stats
.
report
()]))
def
main
():
#add_console_logging()
args
=
parse_args
()
stats
=
DownloadStatistics
()
sst
stats
=
DownloadStatistics
()
aitfancil
.
SST
.
update_cache
(
args
.
dir
,
start_time
=
args
.
oldest
,
end_time
=
args
.
newest
,
download_stats
=
stats
,
download_stats
=
sst
stats
,
)
print
(
"
\n
"
.
join
(
stats
.
report
())
)
print
_download_report
(
"
SST Download Summary
"
,
sststats
)
stats
=
DownloadStatistics
()
gfs
stats
=
DownloadStatistics
()
aitfancil
.
GFS
.
update_cache
(
args
.
dir
,
start_time
=
args
.
oldest
,
end_time
=
args
.
newest
,
download_stats
=
stats
,
download_stats
=
gfs
stats
,
)
print
(
"
\n
"
.
join
(
stats
.
report
())
)
print
_download_report
(
"
GFS Download Summary
"
,
gfsstats
)
print_download_report
(
"
Total Download Summary
"
,
sststats
+
gfsstats
)
return
0
last_time
=
""
_date
=
dt
.
date
(
2010
,
1
,
10
)
for
hour
in
range
(
0
,
24
):
minute
=
0
second
=
0
_time
=
dt
.
time
(
hour
,
minute
,
second
)
d
=
dt
.
datetime
.
combine
(
_date
,
_time
)
fslist
=
GFS
.
get_filesets_for_time
(
d
)
line
=
""
for
i
,
v
in
enumerate
(
fslist
):
if
len
(
v
.
urls_to_files
)
!=
2
:
raise
RuntimeError
(
f
"
I expect all of these to be 2 long, is len
{
v
.
urls_to_files
}
long
"
)
datetimes
=
[
parse_datetime_from_gfs_filename
(
x
)
for
x
in
v
.
urls_to_files
.
values
()
]
if
datetimes
[
0
]
!=
datetimes
[
1
]:
raise
RuntimeError
(
"
I expect all I expect GFS items in a single FileSet to be for the same timestamp. They are {datetimes}
"
)
delta
=
(
datetimes
[
0
].
date
()
-
_date
).
days
if
float
(
int
(
delta
))
!=
delta
:
raise
RuntimeError
(
"
I expected difference to be in whole hours
"
)
f1
=
list
(
v
.
urls_to_files
.
values
())[
0
][
-
2
:]
f2
=
list
(
v
.
urls_to_files
.
values
())[
1
][
-
2
:]
line
+=
(
f
"
{
int
(
delta
)
:
2
d
}
"
+
f
"
{
datetimes
[
0
].
hour
:
2
d
}
:
"
+
datetimes
[
0
].
strftime
(
"
%M
"
)
+
f
"
F
{
f1
}
F
{
f2
}
/
"
)
#import re
#def p(x): " ".join(re.findall(r'pgrb(\d\d):', x))
#b = [x for x in v.urls_to_files.values()]
#print(" ",i,b)
if
last_time
!=
line
:
print
(
str
(
d
.
time
())
+
line
)
last_time
=
line
sys
.
stderr
.
write
(
"
early abort for testing
\n
"
)
sys
.
exit
(
1
)
with
tempfile
.
TemporaryDirectory
()
as
example_dir
:
test_date
=
dt
.
datetime
(
2019
,
5
,
27
,
12
,
0
,
0
)
first
=
csppfetch
.
DownloadStatistics
()
sst
.
download_for_time
(
test_date
,
example_dir
,
download_stats
=
first
)
os
.
path
.
exists
(
example_dir
+
"
/avhrr-only-v2.20190527_preliminary.nc
"
)
print
(
"
First download:
"
,
first
)
second
=
csppfetch
.
DownloadStatistics
()
sst
.
download_for_time
(
test_date
,
example_dir
,
download_stats
=
second
)
print
(
"
Second download:
"
,
second
)
return
0
if
__name__
==
'
__main__
'
:
sys
.
exit
(
main
())
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