Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MetObs
AossCeilo
Commits
70b5c76f
Verified
Commit
70b5c76f
authored
Mar 02, 2021
by
David Hoese
Browse files
Remove legacy netcdf generation
parent
9406c4a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
aossceilo/tidy.py
View file @
70b5c76f
...
...
@@ -24,7 +24,7 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved.
import
os
,
sys
,
logging
from
datetime
import
datetime
,
timedelta
# from aossceilo import quicklook
from
aossceilo
import
nc
#
from aossceilo import nc
from
aossceilo
import
CONFIG
as
c
from
metobscommon.util
import
raw_manager
rel
=
raw_manager
.
relativedir
...
...
@@ -66,26 +66,26 @@ CEILO_DIR_FORMAT = c.CEILO_DIR_FORMAT
# os.symlink( rel(latest_dir, filename), tmppath )
# os.rename( tmppath, linkpath )
def
create_nc
(
when
=
None
):
"""run external nc_gen module with proper arguments to create a new netCDF
file.
"""
when
=
when
or
datetime
.
now
()
# Run for past 3 days
begin
=
when
-
timedelta
(
days
=
2
)
# Create temp nc files in cache location
temp_created_files
=
nc
.
make_ceilo_files
(
begin
=
begin
,
end
=
when
,
basedir
=
None
,
site
=
site
,
description
=
description
)
# Check that some files were created
if
not
temp_created_files
:
LOG
.
warning
(
"No new nc files were created"
)
return
# Rename temp files to original files
created_files
=
[
os
.
path
.
join
(
d
,
f
[
1
:])
for
d
,
f
in
[
os
.
path
.
split
(
x
)
for
x
in
temp_created_files
]
]
for
t
,
f
in
zip
(
temp_created_files
,
created_files
):
if
os
.
path
.
exists
(
f
):
os
.
remove
(
f
)
os
.
rename
(
t
,
f
)
# Link latest files
link_latest_file
(
c
.
get_latest_dir
(),
created_files
[
0
],
data_type
=
"nc"
)
#
def create_nc(when=None):
#
"""run external nc_gen module with proper arguments to create a new netCDF
#
file.
#
"""
#
when = when or datetime.now()
#
# Run for past 3 days
#
begin = when - timedelta(days=2)
#
# Create temp nc files in cache location
#
temp_created_files = nc.make_ceilo_files(begin=begin, end=when, basedir=None, site=site, description=description)
#
# Check that some files were created
#
if not temp_created_files:
#
LOG.warning("No new nc files were created")
#
return
#
# Rename temp files to original files
#
created_files = [ os.path.join(d,f[1:]) for d,f in [ os.path.split(x) for x in temp_created_files ] ]
#
for t,f in zip(temp_created_files, created_files):
#
if os.path.exists(f): os.remove(f)
#
os.rename(t,f)
#
# Link latest files
#
link_latest_file(c.get_latest_dir(), created_files[0], data_type="nc")
def
file_dirs
(
when
=
None
,
data_type
=
'ascii'
):
""" yield camera-name, incoming-dir, raw_dir, cache_dir, latest_dir for a given datetime object (default now)
...
...
@@ -231,10 +231,10 @@ run "%prog help" to list commands
# """
# create_quicklook(when=date)
#
def
nc
(
*
args
):
"""Create multiple nc files for (date - 2 days) to date.
"""
create_nc
(
date
)
#
def nc(*args):
#
"""Create multiple nc files for (date - 2 days) to date.
#
"""
#
create_nc(date)
def
help
(
command
=
None
):
"""print command help or list of commands
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment