Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cspp-geo-gridded-glm
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor 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
cspp_geo
cspp-geo-gridded-glm
Commits
6d2b0861
Commit
6d2b0861
authored
2 years ago
by
Nick Bearson
Browse files
Options
Downloads
Patches
Plain Diff
prevent tile files from having 'units' attributes longer than 26 characters
parent
255fea52
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
gridded_glm/libexec/_minute_gridder.py
+15
-3
15 additions, 3 deletions
gridded_glm/libexec/_minute_gridder.py
with
15 additions
and
3 deletions
gridded_glm/libexec/_minute_gridder.py
+
15
−
3
View file @
6d2b0861
...
@@ -300,7 +300,7 @@ def get_cspp_gglm_version():
...
@@ -300,7 +300,7 @@ def get_cspp_gglm_version():
return
"
unknown
"
return
"
unknown
"
def
add_
gglm
_attrs
(
netcdf_filename
,
input_filenames
):
def
add_
cspp
_attrs
(
netcdf_filename
,
input_filenames
):
try
:
try
:
nc
=
Dataset
(
netcdf_filename
,
'
a
'
)
nc
=
Dataset
(
netcdf_filename
,
'
a
'
)
setattr
(
nc
,
'
cspp_geo_gglm_version
'
,
get_cspp_gglm_version
())
setattr
(
nc
,
'
cspp_geo_gglm_version
'
,
get_cspp_gglm_version
())
...
@@ -310,6 +310,17 @@ def add_gglm_attrs(netcdf_filename, input_filenames):
...
@@ -310,6 +310,17 @@ def add_gglm_attrs(netcdf_filename, input_filenames):
except
:
except
:
log
.
error
(
"
could not add CSPP Geo GGLM attributes to {}
"
.
format
(
netcdf_filename
))
log
.
error
(
"
could not add CSPP Geo GGLM attributes to {}
"
.
format
(
netcdf_filename
))
def
awipsify_file_attributes
(
netcdf_filename
):
try
:
nc
=
Dataset
(
netcdf_filename
,
'
a
'
)
for
var
in
nc
.
variables
:
if
hasattr
(
var
,
'
units
'
):
# AWIPS requires the units attribute to be 26 characters or less
setattr
(
var
,
'
units
'
,
getattr
(
var
,
'
units
'
)[
0
:
26
])
nc
.
close
()
except
:
log
.
error
(
"
could not tweak attributes on tile file {}
"
.
format
(
netcdf_filename
))
def
alarm_handler
(
signum
,
frame
):
def
alarm_handler
(
signum
,
frame
):
raise
OSError
(
"
Timeout exceeded!
"
)
raise
OSError
(
"
Timeout exceeded!
"
)
...
@@ -352,7 +363,7 @@ if __name__ == '__main__':
...
@@ -352,7 +363,7 @@ if __name__ == '__main__':
# we need to add attributes here due to an issue where satpy (or its dependencies) are
# we need to add attributes here due to an issue where satpy (or its dependencies) are
# holding the input gridded file open until the process exits
# holding the input gridded file open until the process exits
for
f
in
gridded_files
:
for
f
in
gridded_files
:
add_
gglm
_attrs
(
f
,
glm_filenames
)
add_
cspp
_attrs
(
f
,
glm_filenames
)
# (optionally) do tiling
# (optionally) do tiling
if
args
.
create_tiles
:
if
args
.
create_tiles
:
...
@@ -394,7 +405,8 @@ if __name__ == '__main__':
...
@@ -394,7 +405,8 @@ if __name__ == '__main__':
tiled_path
=
os
.
path
.
join
(
tempdir_path
,
'
{}_GLM-L2-GLM*-M?_G??_T??_*.nc
'
.
format
(
args
.
system_environment_prefix_tiles
))
tiled_path
=
os
.
path
.
join
(
tempdir_path
,
'
{}_GLM-L2-GLM*-M?_G??_T??_*.nc
'
.
format
(
args
.
system_environment_prefix_tiles
))
tiled_files
=
glob
(
tiled_path
)
tiled_files
=
glob
(
tiled_path
)
for
f
in
tiled_files
:
for
f
in
tiled_files
:
add_gglm_attrs
(
f
,
glm_filenames
)
add_cspp_attrs
(
f
,
glm_filenames
)
awipsify_file_attributes
(
f
)
shutil
.
move
(
f
,
os
.
path
.
join
(
args
.
output_dir
,
os
.
path
.
basename
(
f
)))
shutil
.
move
(
f
,
os
.
path
.
join
(
args
.
output_dir
,
os
.
path
.
basename
(
f
)))
for
f
in
gridded_files
:
for
f
in
gridded_files
:
shutil
.
move
(
f
,
os
.
path
.
join
(
args
.
output_dir
,
os
.
path
.
basename
(
f
)))
shutil
.
move
(
f
,
os
.
path
.
join
(
args
.
output_dir
,
os
.
path
.
basename
(
f
)))
...
...
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