Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gdd-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
dawn
gdd-server
Merge requests
!3
Cron job
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Cron job
cron-job
into
master
Overview
0
Commits
2
Pipelines
0
Changes
4
Merged
Tucker Gary Siegel
requested to merge
cron-job
into
master
4 years ago
Overview
0
Commits
2
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
b4ad6dd3
2 commits,
4 years ago
4 files
+
185
−
64
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
preprocess.py deleted
100644 → 0
+
0
−
58
Options
import
gdal
import
numpy
as
np
import
xarray
as
xr
import
random
def
to_freedom_units
(
data
):
return
(
data
*
9
/
5
)
+
32
def
ReadBilFile
(
bil
):
gdal
.
GetDriverByName
(
'
EHdr
'
).
Register
()
img
=
gdal
.
Open
(
bil
)
band
=
img
.
GetRasterBand
(
1
)
data
=
band
.
ReadAsArray
()
return
data
if
__name__
==
'
__main__
'
:
import
glob
years
=
list
(
range
(
2020
,
2020
+
1
))
for
y
in
years
:
print
(
y
)
all_
=
[]
print
(
"
data/PRISM/tmin/PRISM_tmin_stable_4kmD2_%s0101_%s1231/*.bil
"
%
(
y
,
y
))
for
file
in
sorted
(
list
(
glob
.
glob
(
"
data/PRISM/tmin/PRISM_tmin_stable_4kmD2_%s0101_%s1231_bil/*.bil
"
%
(
y
,
y
)))):
# print (file)
a
=
ReadBilFile
(
file
)
a
[
a
==
-
9999
]
=
np
.
nan
a
=
np
.
flipud
(
a
)
all_
.
append
(
a
)
all_
=
np
.
stack
(
all_
)
all_
=
to_freedom_units
(
all_
)
tmin
=
xr
.
Variable
([
'
date
'
,
'
row
'
,
'
col
'
],
all_
,
attrs
=
{
"
long_name
"
:
"
min temperature in f
"
}).
chunk
({
"
date
"
:
-
1
}).
astype
(
np
.
dtype
(
np
.
float32
))
all_
=
[]
print
(
"
data/PRISM/tmax/PRISM_tmax_stable_4kmD2_%s0101_%s1231/*.bil
"
%
(
y
,
y
))
for
file
in
sorted
(
list
(
glob
.
glob
(
"
data/PRISM/tmax/PRISM_tmax_stable_4kmD2_%s0101_%s1231_bil/*.bil
"
%
(
y
,
y
)))):
# print (file)
a
=
ReadBilFile
(
file
)
a
[
a
==
-
9999
]
=
np
.
nan
a
=
np
.
flipud
(
a
)
all_
.
append
(
a
)
all_
=
np
.
stack
(
all_
)
all_
=
to_freedom_units
(
all_
)
tmax
=
xr
.
Variable
([
'
date
'
,
'
row
'
,
'
col
'
],
all_
,
attrs
=
{
"
long_name
"
:
"
max temperature in f
"
}).
chunk
({
"
date
"
:
-
1
}).
astype
(
np
.
dtype
(
np
.
float32
))
data
=
xr
.
Dataset
(
{
"
tmax
"
:
tmax
,
"
tmin
"
:
tmin
},
)
print
(
data
)
data
.
to_netcdf
(
"
data/temps_%s.nc
"
%
y
)
Loading