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
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
00111a19
Commit
00111a19
authored
2 years ago
by
Nick Bearson
Browse files
Options
Downloads
Patches
Plain Diff
moving more input handling out of grid_setup; prep-work for calling the gridder once per minute
parent
83b42a46
No related branches found
No related tags found
1 merge request
!26
group inputs by minute and process accordingly
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gridded_glm/libexec/_minute_gridder.py
+13
-11
13 additions, 11 deletions
gridded_glm/libexec/_minute_gridder.py
with
13 additions
and
11 deletions
gridded_glm/libexec/_minute_gridder.py
+
13
−
11
View file @
00111a19
...
@@ -185,26 +185,21 @@ def get_outpath_base(args):
...
@@ -185,26 +185,21 @@ def get_outpath_base(args):
return
dsname
return
dsname
def
grid_setup
(
args
,
work_dir
=
os
.
getcwd
()):
def
grid_setup
(
glm_files
,
args
,
work_dir
=
os
.
getcwd
()):
# When passed None for the minimum event or group counts, the gridder will skip
# When passed None for the minimum event or group counts, the gridder will skip
# the check, saving a bit of time.
# the check, saving a bit of time.
min_events
=
None
min_events
=
None
min_groups
=
None
min_groups
=
None
for
f
in
args
.
filenames
:
if
not
os
.
path
.
exists
(
f
):
log
.
error
(
"
Tried to grid file that does not exist: {}
"
.
format
(
f
))
exit
(
1
)
if
args
.
goes_sector
==
"
meso
"
and
(
args
.
ctr_lat
==
None
or
args
.
ctr_lon
==
None
):
if
args
.
goes_sector
==
"
meso
"
and
(
args
.
ctr_lat
==
None
or
args
.
ctr_lon
==
None
):
log
.
error
(
"
sector
'
meso
'
requires --ctr-lat & --ctr-lon
"
)
log
.
error
(
"
sector
'
meso
'
requires --ctr-lat & --ctr-lon
"
)
exit
(
1
)
exit
(
1
)
try
:
try
:
start_time
,
end_time
=
get_start_end
(
args
.
filenam
es
)
start_time
,
end_time
=
get_start_end
(
glm_fil
es
)
except
:
except
:
log
.
error
(
"
Could not parse start & end times from one or more of the files provided:
"
)
log
.
error
(
"
Could not parse start & end times from one or more of the files provided:
"
)
log
.
error
(
"
,
"
.
join
(
args
.
filenam
es
))
log
.
error
(
"
,
"
.
join
(
glm_fil
es
))
exit
(
1
)
exit
(
1
)
base_date
=
datetime
(
start_time
.
year
,
start_time
.
month
,
start_time
.
day
)
base_date
=
datetime
(
start_time
.
year
,
start_time
.
month
,
start_time
.
day
)
...
@@ -212,7 +207,7 @@ def grid_setup(args, work_dir=os.getcwd()):
...
@@ -212,7 +207,7 @@ def grid_setup(args, work_dir=os.getcwd()):
outputpath
=
os
.
path
.
join
(
work_dir
,
get_outpath_base
(
args
))
# GLMTools expects a template in addition to the path
outputpath
=
os
.
path
.
join
(
work_dir
,
get_outpath_base
(
args
))
# GLMTools expects a template in addition to the path
goes_position
=
get_goes_position
(
args
.
filenam
es
)
goes_position
=
get_goes_position
(
glm_fil
es
)
resln
=
get_resolution
(
args
)
resln
=
get_resolution
(
args
)
view
=
get_GOESR_grid
(
position
=
goes_position
,
view
=
get_GOESR_grid
(
position
=
goes_position
,
...
@@ -276,7 +271,7 @@ def grid_setup(args, work_dir=os.getcwd()):
...
@@ -276,7 +271,7 @@ def grid_setup(args, work_dir=os.getcwd()):
if
(
proj_name
==
'
pixel_grid
'
)
or
(
proj_name
==
'
geos
'
):
if
(
proj_name
==
'
pixel_grid
'
)
or
(
proj_name
==
'
geos
'
):
grid_kwargs
[
'
pixel_coords
'
]
=
fixed_grid
grid_kwargs
[
'
pixel_coords
'
]
=
fixed_grid
grid_kwargs
[
'
ellipse_rev
'
]
=
-
1
# -1 (default) = infer from date in each GLM file
grid_kwargs
[
'
ellipse_rev
'
]
=
-
1
# -1 (default) = infer from date in each GLM file
return
gridder
,
args
.
filenam
es
,
start_time
,
end_time
,
grid_kwargs
return
gridder
,
glm_fil
es
,
start_time
,
end_time
,
grid_kwargs
def
get_cspp_gglm_version
():
def
get_cspp_gglm_version
():
...
@@ -318,6 +313,7 @@ if __name__ == '__main__':
...
@@ -318,6 +313,7 @@ if __name__ == '__main__':
log
.
info
(
"
Starting GLM Gridding
"
)
log
.
info
(
"
Starting GLM Gridding
"
)
log
.
debug
(
"
Starting script with: %s
"
,
sys
.
argv
)
log
.
debug
(
"
Starting script with: %s
"
,
sys
.
argv
)
# handle the realtime flag
if
args
.
realtime
:
if
args
.
realtime
:
if
len
(
args
.
filenames
)
!=
1
:
if
len
(
args
.
filenames
)
!=
1
:
log
.
error
(
"
realtime mode only accepts one input file
"
)
log
.
error
(
"
realtime mode only accepts one input file
"
)
...
@@ -331,6 +327,12 @@ if __name__ == '__main__':
...
@@ -331,6 +327,12 @@ if __name__ == '__main__':
exit
(
0
)
exit
(
0
)
args
.
filenames
=
fileglob
args
.
filenames
=
fileglob
# check that all of our inputs exist
for
f
in
args
.
filenames
:
if
not
os
.
path
.
exists
(
f
):
log
.
error
(
"
Tried to grid file that does not exist: {}
"
.
format
(
f
))
exit
(
1
)
# set up output dir
# set up output dir
os
.
makedirs
(
args
.
output_dir
,
exist_ok
=
True
)
os
.
makedirs
(
args
.
output_dir
,
exist_ok
=
True
)
...
@@ -341,7 +343,7 @@ if __name__ == '__main__':
...
@@ -341,7 +343,7 @@ if __name__ == '__main__':
atexit
.
register
(
shutil
.
rmtree
,
tempdir_path
)
atexit
.
register
(
shutil
.
rmtree
,
tempdir_path
)
# do the gridding
# do the gridding
gridder
,
glm_filenames
,
start_time
,
end_time
,
grid_kwargs
=
grid_setup
(
args
,
work_dir
=
tempdir_path
)
gridder
,
glm_filenames
,
start_time
,
end_time
,
grid_kwargs
=
grid_setup
(
args
.
filenames
,
args
,
work_dir
=
tempdir_path
)
gridder_return
=
gridder
(
glm_filenames
,
start_time
,
end_time
,
**
grid_kwargs
)
gridder_return
=
gridder
(
glm_filenames
,
start_time
,
end_time
,
**
grid_kwargs
)
gridded_files
=
[]
gridded_files
=
[]
...
...
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