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
VERIFY
CIF
Commits
f468bc79
Commit
f468bc79
authored
Jul 07, 2020
by
Espen Sollum
Browse files
Merge branch 'espen' of git.nilu.no:VERIFY/CIF into espen
parents
bad00a30
acac354f
Changes
6
Hide whitespace changes
Inline
Side-by-side
pycif/plugins/controlvects/standard/__init__.py
View file @
f468bc79
...
...
@@ -94,3 +94,4 @@ def ini_data(plugin, **kwargs):
# Initializing the product of chi by B^(1/2), only if components specified
if
hasattr
(
plugin
,
'components'
):
init_bprod
(
plugin
,
**
kwargs
)
pycif/plugins/controlvects/standard/background_xb.py
0 → 100644
View file @
f468bc79
import
numpy
as
np
from
scipy
import
ndimage
from
pycif.utils
import
dates
from
.utils.dimensions
import
hresol2dim
,
vresol2dim
from
.utils.scalemaps
import
map2scale
,
vmap2vaggreg
import
xarray
as
xr
def
background_xb
(
cntrlv
,
**
kwargs
):
"""Extends the prior control vector to include background components.
Is called if the obsvect has a background plugin.
Args:
cntrlv (Plugin): definition of the control vector.
datei (datetime): initial date of the inversion window
datei (datetime): end date of the inversion window
"""
datei
=
getattr
(
cntrlv
,
'datei'
)
datef
=
getattr
(
cntrlv
,
'datef'
)
# If no definition is specified for the control vector in the Yaml,
# return empty control vector
if
not
hasattr
(
cntrlv
,
'components'
):
return
cntrlv
# Else, carry on initializing
components
=
cntrlv
.
components
for
comp
in
components
.
attributes
:
component
=
getattr
(
components
,
comp
)
for
trcr
in
component
.
parameters
.
attributes
:
tracer
=
getattr
(
component
.
parameters
,
trcr
)
# Keeping a pointer to the correct location in the whole control
# tracer.xpointer = cntrlv.dim
# Updating dimension
# Time stamp for initial mixing ratio scalars
cinidim
=
cntrlv
.
background
.
ntcini
*
cntrlv
.
background
.
ncini
# ESO: update tracer.dim?
# tracer.dim = tracer.ndates * tracer.hresoldim * tracer.vresoldim
# tracer.dim += cinidim
cntrlv
.
dim
+=
cinidim
# Filling Xbb and uncertainties
xbb
=
np
.
ones
(
cinidim
)
stdb
=
np
.
ones
(
cinidim
)
*
\
float
(
cntrlv
.
background
.
cini_err
)
# Appending local xb to the control vector
cntrlv
.
xb
=
np
.
append
(
cntrlv
.
xb
,
xbb
)
cntrlv
.
std
=
np
.
append
(
cntrlv
.
std
,
stdb
)
# Extending chi
# TODO: this is temporary solution to deal with background opt.
# would also need to change tracer.chi_dim etc.
cntrlv
.
chi
=
np
.
append
(
cntrlv
.
chi
,
np
.
zeros
(
cinidim
))
cntrlv
.
chi_dim
+=
cinidim
# Finished initializing controlvect
cntrlv
.
background
.
updated_controlvect
=
True
return
cntrlv
pycif/plugins/controlvects/standard/init_bprod.py
View file @
f468bc79
...
...
@@ -114,7 +114,9 @@ def init_bprod(cntrlv, options={}, **kwargs):
errscalar
=
glob_err
/
toterr
#cntrlv.std = cntrlv.std*errscalar**2
verbose
(
"Total error scaled by "
+
str
(
errscalar
))
# TODO: rework this based on most recent flexinvert version
verbose
(
"errsum "
+
str
(
errsum
))
# TODO: rework this based on most recent flexinvert version,
# including using xerr (time avg error)
...
...
pycif/plugins/controlvects/standard/init_xb.py
View file @
f468bc79
...
...
@@ -151,5 +151,5 @@ def init_xb(cntrlv, **kwargs):
# Appending local xb to the control vector
cntrlv
.
xb
=
np
.
append
(
cntrlv
.
xb
,
xb
)
cntrlv
.
std
=
np
.
append
(
cntrlv
.
std
,
std
)
return
cntrlv
pycif/plugins/obsoperators/fp/obsoper.py
View file @
f468bc79
...
...
@@ -81,13 +81,13 @@ def obsoper(self, inputs, mode,
fp_header_glob
=
model
.
utils
.
flexpart_header
.
Flexpartheader
()
fp_header_glob
.
read_header
(
os
.
path
.
join
(
model
.
run_dir_glob
,
obsvect
.
datastore
.
head
(
1
)[
'station'
][
0
].
upper
(),
os
.
path
.
join
(
model
.
run_dir_glob
,
obsvect
.
datastore
.
head
(
1
)[
'station'
][
0
].
decode
().
upper
(),
subdir
,
'header'
))
if
model
.
plugin
.
nested
:
fp_header_nest
=
model
.
utils
.
flexpart_header
.
Flexpartheader
()
fp_header_nest
.
read_header
(
os
.
path
.
join
(
model
.
run_dir_nest
,
obsvect
.
datastore
.
head
(
1
)[
'station'
][
0
].
upper
(),
os
.
path
.
join
(
model
.
run_dir_nest
,
obsvect
.
datastore
.
head
(
1
)[
'station'
][
0
].
decode
().
upper
(),
subdir
,
'header_nest'
))
# Trajectory life time
...
...
@@ -150,9 +150,9 @@ def obsoper(self, inputs, mode,
station
=
row
.
station
runsubdir_nest
=
os
.
path
.
join
(
model
.
run_dir_nest
,
station
.
upper
(),
subdir
)
model
.
run_dir_nest
,
station
.
decode
().
upper
(),
subdir
)
runsubdir_glob
=
os
.
path
.
join
(
model
.
run_dir_glob
,
station
.
upper
(),
subdir
)
model
.
run_dir_glob
,
station
.
decode
().
upper
(),
subdir
)
file_date
=
row
.
Index
.
strftime
(
'%Y%m%d%H%M%S'
)
...
...
pycif/plugins/obsvects/standard/init_background.py
View file @
f468bc79
...
...
@@ -74,7 +74,8 @@ def init_background(obsvect, **kwargs):
# Subdirectory for FLEXPART grid_initial files
subdir
=
row
.
Index
.
strftime
(
"%Y%m"
)
station
=
row
.
station
# station = row.station
station
=
row
.
station
.
decode
()
runsubdir_glob
=
os
.
path
.
join
(
model
.
run_dir_glob
,
station
.
upper
(),
subdir
)
file_date
=
row
.
Index
.
strftime
(
'%Y%m%d%H%M%S'
)
...
...
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