Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AossTower
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
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
MetObs
AossTower
Commits
0d669f5d
Commit
0d669f5d
authored
8 years ago
by
kgao
Browse files
Options
Downloads
Patches
Plain Diff
Added time_offset variable and fixed time variable
Mixed up time and time_offset time now seconds since epoch
parent
c0418f94
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aosstower/level_a0/nc.py
+15
-10
15 additions, 10 deletions
aosstower/level_a0/nc.py
with
15 additions
and
10 deletions
aosstower/level_a0/nc.py
+
15
−
10
View file @
0d669f5d
...
@@ -21,8 +21,6 @@ def writeDimensions(ncFile):
...
@@ -21,8 +21,6 @@ def writeDimensions(ncFile):
ncFile
.
createDimension
(
'
time
'
,
None
)
ncFile
.
createDimension
(
'
time
'
,
None
)
ncFile
.
createDimension
(
'
strlen
'
,
256
)
ncFile
.
createDimension
(
'
strlen
'
,
256
)
print
(
ncFile
)
return
ncFile
return
ncFile
def
createVariables
(
ncFile
,
firstStamp
,
chunksizes
,
zlib
):
def
createVariables
(
ncFile
,
firstStamp
,
chunksizes
,
zlib
):
...
@@ -37,19 +35,22 @@ def createVariables(ncFile, firstStamp, chunksizes, zlib):
...
@@ -37,19 +35,22 @@ def createVariables(ncFile, firstStamp, chunksizes, zlib):
bts
=
firstStamp
.
strftime
(
'
%Y-%m-%d 00:00:00Z
'
)
bts
=
firstStamp
.
strftime
(
'
%Y-%m-%d 00:00:00Z
'
)
#time long name
#time long name
tln
=
'
time offset from
midnight UTC
'
tln
=
'
time offset from
base_time
'
#time units
#time units
tu
=
'
seconds since
'
+
firstStamp
.
strftime
(
'
%Y-%m-%d 00:00:00Z
'
)
tu
=
'
seconds since
'
+
firstStamp
.
strftime
(
'
%Y-%m-%d 00:00:00Z
'
)
coordinates
=
{
coordinates
=
{
#fields: type, dimension, fill
e, positive
, valid_min, std_name, longname, units, valid_max, cf_role, axis
#fields: type, dimension, fill, valid_min, std_name, longname, units, valid_max, cf_role, axis
'
lon
'
:
[
np
.
float32
,
None
,
float
(
-
999
),
'
-180L
'
,
'
longitude
'
,
None
,
'
degrees_east
'
,
'
180L
'
,
None
],
'
lon
'
:
[
np
.
float32
,
None
,
float
(
-
999
),
'
-180L
'
,
'
longitude
'
,
None
,
'
degrees_east
'
,
'
180L
'
,
None
],
'
lat
'
:
[
np
.
float32
,
None
,
float
(
-
999
),
'
-90L
'
,
'
latitude
'
,
None
,
'
degrees_north
'
,
'
90L
'
,
None
],
'
lat
'
:
[
np
.
float32
,
None
,
float
(
-
999
),
'
-90L
'
,
'
latitude
'
,
None
,
'
degrees_north
'
,
'
90L
'
,
None
],
'
alt
'
:
[
np
.
float32
,
None
,
float
(
-
999
),
None
,
'
height
'
,
'
vertical distance
'
,
'
m
'
,
None
,
None
],
'
alt
'
:
[
np
.
float32
,
None
,
float
(
-
999
),
None
,
'
height
'
,
'
vertical distance
'
,
'
m
'
,
None
,
None
],
'
base_time
'
:
[
np
.
float32
,
None
,
float
(
-
999
),
None
,
'
time
'
,
btln
,
btu
,
None
,
None
],
'
base_time
'
:
[
np
.
float32
,
None
,
float
(
-
999
),
None
,
'
time
'
,
btln
,
btu
,
None
,
None
],
'
time
'
:
[
np
.
float32
,
'
time
'
,
float
(
-
999
),
None
,
'
time
'
,
tln
,
tu
,
None
,
None
],
'
time_offset
'
:
[
np
.
float32
,
'
time
'
,
float
(
-
999
),
None
,
'
time
'
,
tln
,
tu
,
None
,
None
],
'
station_name
'
:
[
'
c
'
,
'
strlen
'
,
'
-
'
,
None
,
None
,
'
station name
'
,
None
,
None
,
'
timeseries_id
'
]
'
station_name
'
:
[
'
c
'
,
'
strlen
'
,
'
-
'
,
None
,
None
,
'
station name
'
,
None
,
None
,
'
timeseries_id
'
],
'
time
'
:
[
np
.
float32
,
'
time
'
,
float
(
-
999
),
None
,
None
,
"
Time offset from epoch
"
,
"
seconds since 1970-01-01 00:00:00Z
"
,
None
,
None
,
None
]
}
}
for
key
in
coordinates
:
for
key
in
coordinates
:
...
@@ -57,7 +58,7 @@ def createVariables(ncFile, firstStamp, chunksizes, zlib):
...
@@ -57,7 +58,7 @@ def createVariables(ncFile, firstStamp, chunksizes, zlib):
if
(
attr
[
1
]):
if
(
attr
[
1
]):
if
attr
[
1
]
==
'
strlen
'
:
if
attr
[
1
]
==
'
strlen
'
:
if
chunksizes
[
0
]
>
256
:
if
(
chunksizes
)
and
chunksizes
[
0
]
>
256
:
variable
=
ncFile
.
createVariable
(
key
,
attr
[
0
],
dimensions
=
(
attr
[
1
]),
fill_value
=
attr
[
2
],
zlib
=
zlib
,
chunksizes
=
[
256
])
variable
=
ncFile
.
createVariable
(
key
,
attr
[
0
],
dimensions
=
(
attr
[
1
]),
fill_value
=
attr
[
2
],
zlib
=
zlib
,
chunksizes
=
[
256
])
else
:
else
:
...
@@ -165,7 +166,8 @@ def writeVars(ncFile, frame):
...
@@ -165,7 +166,8 @@ def writeVars(ncFile, frame):
fileVar
=
ncFile
.
variables
fileVar
=
ncFile
.
variables
fileVar
[
'
base_time
'
].
assignValue
(
baseTimeValue
)
fileVar
[
'
base_time
'
].
assignValue
(
baseTimeValue
)
fileVar
[
'
time
'
][:]
=
timeNumpy
fileVar
[
'
time_offset
'
][:]
=
timeNumpy
fileVar
[
'
time
'
][:]
=
timeNumpy
+
baseTimeValue
#write coordinate var values to file
#write coordinate var values to file
#alt might not be right, need to verify
#alt might not be right, need to verify
...
@@ -200,7 +202,11 @@ def writeVars(ncFile, frame):
...
@@ -200,7 +202,11 @@ def writeVars(ncFile, frame):
# @param output filename - filename of the netcdf file
# @param output filename - filename of the netcdf file
def
createGiantNetCDF
(
start
,
end
,
inputFiles
,
outputName
,
zlib
,
chunkSize
,
no_empty
):
def
createGiantNetCDF
(
start
,
end
,
inputFiles
,
outputName
,
zlib
,
chunkSize
,
no_empty
):
chunksizes
=
[
chunkSize
]
if
(
chunkSize
):
chunksizes
=
[
chunkSize
]
else
:
chunksizes
=
None
frame
=
getData
(
inputFiles
,
no_empty
)
frame
=
getData
(
inputFiles
,
no_empty
)
...
@@ -288,7 +294,6 @@ def main():
...
@@ -288,7 +294,6 @@ def main():
level
=
levels
[
min
(
3
,
args
.
verbosity
)]
level
=
levels
[
min
(
3
,
args
.
verbosity
)]
logging
.
basicConfig
(
level
=
level
)
logging
.
basicConfig
(
level
=
level
)
print
(
args
)
if
(
args
.
start_time
and
args
.
end_time
):
if
(
args
.
start_time
and
args
.
end_time
):
createGiantNetCDF
(
args
.
start_time
,
args
.
end_time
,
args
.
input_files
,
args
.
output
[
0
],
args
.
zlib
,
args
.
chunk_size
,
args
.
no_empty
)
createGiantNetCDF
(
args
.
start_time
,
args
.
end_time
,
args
.
input_files
,
args
.
output
[
0
],
args
.
zlib
,
args
.
chunk_size
,
args
.
no_empty
)
...
...
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