Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
NearRealTimeCTDAS
CTDAS
Commits
2afc6235
Commit
2afc6235
authored
Jun 11, 2013
by
Peters, Wouter
Browse files
update of names of functions in io
parent
3eca0791
Changes
1
Hide whitespace changes
Inline
Side-by-side
gridded/da/analysis/expand_fluxes.py
View file @
2afc6235
...
...
@@ -93,7 +93,7 @@ def save_weekly_avg_1x1_data(dacycle, statevector):
#
filename
=
os
.
path
.
join
(
dacycle
[
'dir.output'
],
'flux1x1_%s_%s.nc'
%
(
startdate
.
strftime
(
'%Y%m%d%H'
),
enddate
.
strftime
(
'%Y%m%d%H'
)))
file
=
io
.
CT_R
ead
(
filename
,
'read'
)
file
=
io
.
ct_r
ead
(
filename
,
'read'
)
bio
=
np
.
array
(
file
.
get_variable
(
dacycle
.
dasystem
[
'background.co2.bio.flux'
]))
ocean
=
np
.
array
(
file
.
get_variable
(
dacycle
.
dasystem
[
'background.co2.ocean.flux'
]))
fire
=
np
.
array
(
file
.
get_variable
(
dacycle
.
dasystem
[
'background.co2.fires.flux'
]))
...
...
@@ -272,7 +272,7 @@ def save_weekly_avg_state_data(dacycle, statevector):
#
filename
=
os
.
path
.
join
(
dacycle
[
'dir.output'
],
'flux1x1_%s_%s.nc'
%
(
startdate
.
strftime
(
'%Y%m%d%H'
),
enddate
.
strftime
(
'%Y%m%d%H'
)))
file
=
io
.
CT_R
ead
(
filename
,
'read'
)
file
=
io
.
ct_r
ead
(
filename
,
'read'
)
bio
=
np
.
array
(
file
.
get_variable
(
dacycle
.
dasystem
[
'background.co2.bio.flux'
]))
ocean
=
np
.
array
(
file
.
get_variable
(
dacycle
.
dasystem
[
'background.co2.ocean.flux'
]))
fire
=
np
.
array
(
file
.
get_variable
(
dacycle
.
dasystem
[
'background.co2.fires.flux'
]))
...
...
@@ -469,7 +469,7 @@ def save_weekly_avg_tc_data(dacycle, statevector):
ncf
=
io
.
CT_CDF
(
saveas
,
'write'
)
dimdate
=
ncf
.
add_date_dim
()
dimidateformat
=
ncf
.
add_date_dim_format
()
dimregs
=
ncf
.
A
dd
R
egion
D
im
(
type
=
'tc'
)
dimregs
=
ncf
.
a
dd
_r
egion
_d
im
(
type
=
'tc'
)
#
# set title and tell GMT that we are using "pixel registration"
#
...
...
@@ -491,7 +491,7 @@ def save_weekly_avg_tc_data(dacycle, statevector):
logging
.
error
(
"Needed input file (%s) does not exist yet, please create file first, returning..."
%
infile
)
return
None
ncf_in
=
io
.
CT_R
ead
(
infile
,
'read'
)
ncf_in
=
io
.
ct_r
ead
(
infile
,
'read'
)
# Transform data one by one
...
...
@@ -599,7 +599,7 @@ def save_weekly_avg_ext_tc_data(dacycle):
ncf
=
io
.
CT_CDF
(
saveas
,
'write'
)
dimdate
=
ncf
.
add_date_dim
()
dimidateformat
=
ncf
.
add_date_dim_format
()
dimregs
=
ncf
.
A
dd
R
egion
D
im
(
type
=
'tc_ext'
)
dimregs
=
ncf
.
a
dd
_r
egion
_d
im
(
type
=
'tc_ext'
)
#
# set title and tell GMT that we are using "pixel registration"
#
...
...
@@ -616,7 +616,7 @@ def save_weekly_avg_ext_tc_data(dacycle):
logging
.
error
(
"Needed input file (%s) does not exist yet, please create file first, returning..."
%
infile
)
return
None
ncf_in
=
io
.
CT_R
ead
(
infile
,
'read'
)
ncf_in
=
io
.
ct_r
ead
(
infile
,
'read'
)
# Transform data one by one
...
...
@@ -743,7 +743,7 @@ def save_weekly_avg_agg_data(dacycle, region_aggregate='olson'):
elif
region_aggregate
==
"transcom"
:
regionmask
=
tc
.
transcommask
dimname
=
'tc'
dimregs
=
ncf
.
A
dd
R
egion
D
im
(
type
=
'tc'
)
dimregs
=
ncf
.
a
dd
_r
egion
_d
im
(
type
=
'tc'
)
elif
region_aggregate
==
"country"
:
...
...
@@ -808,7 +808,7 @@ def save_weekly_avg_agg_data(dacycle, region_aggregate='olson'):
logging
.
error
(
"Needed input file (%s) does not exist yet, please create file first, returning..."
%
infile
)
return
None
ncf_in
=
io
.
CT_R
ead
(
infile
,
'read'
)
ncf_in
=
io
.
ct_r
ead
(
infile
,
'read'
)
# Transform data one by one
...
...
@@ -930,7 +930,7 @@ def save_time_avg_data(dacycle, infile, avg='monthly'):
else
:
pass
file
=
io
.
CT_R
ead
(
infile
,
'read'
)
file
=
io
.
ct_r
ead
(
infile
,
'read'
)
datasets
=
file
.
variables
.
keys
()
date
=
file
.
get_variable
(
'date'
)
globatts
=
file
.
ncattrs
()
...
...
@@ -1023,7 +1023,7 @@ if __name__ == "__main__":
logging
.
root
.
setLevel
(
logging
.
DEBUG
)
dacycle
=
CycleControl
(
args
=
{
'rc'
:
'../../ctdas-od-gfed2-
nam1x1
-obspack-full
-gridded
.rc'
})
dacycle
=
CycleControl
(
args
=
{
'rc'
:
'../../ctdas-od-gfed2-
glb6x4
-obspack-full.rc'
})
dacycle
.
initialize
()
dacycle
.
parse_times
()
...
...
@@ -1035,23 +1035,17 @@ if __name__ == "__main__":
statevector
.
initialize
(
dacycle
)
while
dacycle
[
'time.end'
]
<
dacycle
[
'time.finish'
]:
savedas_1x1
=
save_weekly_avg_1x1_data
(
dacycle
,
statevector
)
savedas_state
=
save_weekly_avg_state_data
(
dacycle
,
statevector
)
savedas_tc
=
save_weekly_avg_tc_data
(
dacycle
,
statevector
)
savedas_tcext
=
save_weekly_avg_ext_tc_data
(
dacycle
)
savedas_olson
=
save_weekly_avg_agg_data
(
dacycle
,
region_aggregate
=
'olson'
)
savedas_transcom
=
save_weekly_avg_agg_data
(
dacycle
,
region_aggregate
=
'transcom'
)
savedas_country
=
save_weekly_avg_agg_data
(
dacycle
,
region_aggregate
=
'country'
)
save_weekly_avg_1x1_data
(
dacycle
,
statevector
)
save_weekly_avg_state_data
(
dacycle
,
statevector
)
save_weekly_avg_tc_data
(
dacycle
,
statevector
)
save_weekly_avg_ext_tc_data
(
dacycle
)
save_weekly_avg_agg_data
(
dacycle
,
region_aggregate
=
'olson'
)
save_weekly_avg_agg_data
(
dacycle
,
region_aggregate
=
'transcom'
)
save_weekly_avg_agg_data
(
dacycle
,
region_aggregate
=
'country'
)
dacycle
.
advance_cycle_times
()
statevector
=
None
# free memory
for
avg
in
[
'monthly'
,
'yearly'
,
'longterm'
]:
savedas_1x1
=
save_time_avg_data
(
dacycle
,
savedas_1x1
,
avg
)
savedas_state
=
save_time_avg_data
(
dacycle
,
savedas_state
,
avg
)
savedas_tc
=
save_time_avg_data
(
dacycle
,
savedas_tc
,
avg
)
savedas_tcext
=
save_time_avg_data
(
dacycle
,
savedas_tcext
,
avg
)
sys
.
exit
(
0
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment