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
4b1a2352
Commit
4b1a2352
authored
Jan 07, 2022
by
Elise Potier
Browse files
options for new CAMS version
parent
aaf8938c
Changes
3
Hide whitespace changes
Inline
Side-by-side
pycif/plugins/datastreams/fields/netcdf_cams/__init__.py
View file @
4b1a2352
"""
Read CAMS products
Option to define pressure coordinate names depending on CAMS version
"""
from
.get_domain
import
get_domain
from
.fetch
import
fetch
from
.read
import
read
...
...
@@ -6,3 +12,13 @@ _name = "CAMS"
_version
=
"netcdf"
_fullname
=
"CAMS netcdf files"
input_arguments
=
{
"aibi_name"
:
{
"doc"
:
"to choose ai bi vertical coordinate names"
" instead of hyam and hybm"
,
"default"
:
False
,
"accepted"
:
bool
},
}
pycif/plugins/datastreams/fields/netcdf_cams/get_domain.py
View file @
4b1a2352
...
...
@@ -61,8 +61,12 @@ def get_domain(ref_dir, ref_file, input_dates, target_dir, tracer=None):
latc
=
np
.
linspace
(
lat_min
-
dy
/
2.
,
lat_max
+
dy
/
2.
,
nlat
+
1
)
# Read vertical information in domain_file
sigma_a
=
nc
[
"hyam"
].
values
sigma_b
=
nc
[
"hybm"
].
values
if
tracer
.
aibi_name
:
sigma_a
=
nc
[
"ap"
].
values
sigma_b
=
nc
[
"bp"
].
values
else
:
sigma_a
=
nc
[
"hyam"
].
values
sigma_b
=
nc
[
"hybm"
].
values
nlevs
=
sigma_a
.
size
# Initializes domain
...
...
pycif/plugins/datastreams/fields/netcdf_cams/read.py
View file @
4b1a2352
import
datetime
import
calendar
import
os
import
pandas
as
pd
import
numpy
as
np
...
...
@@ -50,21 +51,25 @@ def read(
opened_file
=
dd_file
ntimes
=
ds
.
dims
[
"time"
]
freq
=
dd
[
0
].
days_in_month
*
24
/
ntimes
#freq = dd[0].days_in_month * 24 / ntimes
freq
=
(
calendar
.
mdays
[
dd
[
0
].
month
]
+
(
dd
[
0
].
month
==
2
and
calendar
.
isleap
(
dd
[
0
].
year
)))
*
24
/
ntimes
print
(
"to check with february"
)
print
(
dd
[
0
].
month
)
print
(
calendar
.
mdays
[
dd
[
0
].
month
]
+
(
dd
[
0
].
month
==
2
and
calendar
.
isleap
(
dd
[
0
].
year
)))
date_index
=
int
((
dd
[
0
]
-
ddi
)
/
datetime
.
timedelta
(
hours
=
freq
))
# bottom of the atmosphere = at the beginning of the table
lat
=
ds
[
'latitude'
]
conc
=
ds
[
var2extract
].
values
[
date_index
]
if
lat
[
1
]
<
lat
[
0
]:
if
lat
[
1
]
<
lat
[
0
]
and
conc
.
ndim
==
4
:
conc
=
conc
[:,
:,
::
-
1
,
:]
elif
lat
[
1
]
<
lat
[
0
]
and
conc
.
ndim
==
3
:
conc
=
conc
[
:,
::
-
1
,
:]
xout
.
append
(
conc
)
xmod
=
xr
.
DataArray
(
np
.
array
(
xout
),
coords
=
{
"time"
:
np
.
array
(
dates
)[:,
0
]},
dims
=
(
"time"
,
"lev"
,
"lat"
,
"lon"
),
)
return
xmod
Write
Preview
Markdown
is supported
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