Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CTDAS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
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
Tsurata, Aki
CTDAS
Commits
9246a8ec
Commit
9246a8ec
authored
14 years ago
by
Peters, Wouter
Browse files
Options
Downloads
Patches
Plain Diff
changed StateToGrid
parent
72cc4102
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
da/ct/tools.py
+5
-11
5 additions, 11 deletions
da/ct/tools.py
with
5 additions
and
11 deletions
da/ct/tools.py
+
5
−
11
View file @
9246a8ec
...
...
@@ -15,25 +15,19 @@ import datetime
identifier
=
'
CarbonTracker CO2
'
def
StateToGrid
(
DaInfo
,
values
,
reverse
=
False
,
avg
=
False
):
def
StateToGrid
(
values
,
regionmap
,
reverse
=
False
,
avg
=
False
):
"""
This method converts parameters from a CarbonTracker StateVector object to a gridded map of linear multiplication values. These
can subsequently be used in the transport model code to multiply/manipulate fluxes
"""
import
Nio
mapfile
=
os
.
path
.
join
(
DaInfo
.
da_settings
[
'
datadir
'
],
DaInfo
.
da_settings
[
'
regionsfile
'
])
ncf
=
Nio
.
open_file
(
mapfile
,
'
r
'
)
regionmap
=
ncf
.
variables
[
'
budget_region
'
].
get_value
()
dummy
=
ncf
.
close
()
import
numpy
as
np
nregions
=
regionmap
.
max
()
# dictionary for region <-> map conversions
regs
=
{}
for
r
in
arange
(
1
,
nregions
+
1
):
for
r
in
np
.
arange
(
1
,
nregions
+
1
):
sel
=
(
regionmap
.
flat
==
r
).
nonzero
()
if
len
(
sel
[
0
])
>
0
:
regs
[
r
]
=
sel
...
...
@@ -43,7 +37,7 @@ def StateToGrid(DaInfo,values,reverse=False,avg=False):
"""
project 1x1 degree map onto ecoregions
"""
result
=
zeros
(
nregions
,
float
)
result
=
np
.
zeros
(
nregions
,
float
)
for
k
,
v
in
regionselect
.
iteritems
():
if
avg
:
result
[
k
-
1
]
=
values
.
ravel
().
take
(
v
).
mean
()
...
...
@@ -55,7 +49,7 @@ def StateToGrid(DaInfo,values,reverse=False,avg=False):
"""
project ecoregion properties onto 1x1 degree map
"""
result
=
zeros
((
180
,
360
,),
float
)
result
=
np
.
zeros
((
180
,
360
,),
float
)
for
k
,
v
in
regionselect
.
iteritems
():
result
.
put
(
v
,
values
[
k
-
1
])
...
...
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