Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grid SEPTREFHUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
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
VIPS
Models
GRID
Grid SEPTREFHUM
Commits
747128b6
Commit
747128b6
authored
1 year ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Check weatherdata source files for timesteps. Close a file.
parent
950dba94
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
SEPTREFHUM.py
+9
-0
9 additions, 0 deletions
SEPTREFHUM.py
with
9 additions
and
0 deletions
SEPTREFHUM.py
+
9
−
0
View file @
747128b6
...
...
@@ -73,6 +73,14 @@ for file_path in weatherdata_files:
# Only process files from the three last days (if this is not a work from scratch)
if
start_date
is
not
None
and
wh_sum_date
<
start_date
:
continue
# Check that the file has at least 23 timesteps
with
nc
.
Dataset
(
file_path
,
'
r
'
)
as
weatherdata_file
:
file_timesteps
=
len
(
weatherdata_file
.
variables
[
"
time
"
])
if
file_timesteps
<
23
:
print
(
f
"
{
file_path
}
has
{
file_timesteps
}
timesteps. Skipping it.
"
)
continue
# Produce daily files with WH_SUM, which is the number of "Wet hours" (WH) for a given day
# WH is defined as RR > 0.2 || UM > 88.0
wh_sum_date_str
=
wh_sum_date
.
strftime
(
"
%Y-%m-%d
"
)
...
...
@@ -98,6 +106,7 @@ for timestep in timesteps:
print
(
f
"
ERROR: Missing weather data between
{
previous_timestep_str
}
and
{
timestep_str
}
. Exiting.
"
,
file
=
sys
.
stderr
)
exit
(
1
)
previous_timestep
=
timestep
wh_daysum
.
close
()
# From here, no additive calculation; we calculate from the beginning of the w_daysum.nc file every time.
...
...
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