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
ash
ash-iasi
Commits
41eefaae
Commit
41eefaae
authored
Sep 29, 2020
by
Espen Sollum
Browse files
Fixed some tabs
parent
3dd554b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin/IASITools.py
View file @
41eefaae
...
...
@@ -259,46 +259,46 @@ class Scene(object):
# The program will usually hang here if bufr file is corrupt
try
:
bfr
=
bufr
.
codes_bufr_new_from_file
(
f
)
if
bfr
is
None
:
break
bufr
.
codes_set
(
bfr
,
'unpack'
,
1
)
lat
.
append
(
bufr
.
codes_get_array
(
bfr
,
"latitude"
))
lon
.
append
(
bufr
.
codes_get_array
(
bfr
,
"longitude"
))
self
.
yyyy
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"year"
))
self
.
MM
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"month"
))
self
.
dd
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"day"
))
self
.
hh
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"hour"
))
self
.
mm
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"minute"
))
self
.
ss
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"second"
))
# ESO: It appears the scale factor data has dimension 10
# http://oiswww.eumetsat.org/WEBOPS/eps-pg/IASI-L1/IASIL1-PG-9L1Format.htm#Cgiadr-scalefactors
# We use the 5 first numbers (the 5 last seem to contain fill values/garbage),
# corresponding to values [3:7] in the start/end channel arrays
sf
.
append
(
bufr
.
codes_get_array
(
bfr
,
"channelScaleFactor"
))
stc
.
append
(
bufr
.
codes_get_array
(
bfr
,
"startChannel"
))
enc
.
append
(
bufr
.
codes_get_array
(
bfr
,
"endChannel"
))
# height.append(bufr.codes_get_array(bfr, "heightOfStation"))
# Heigth obtained this way is of size Nscanlines, so:
hhh
=
bufr
.
codes_get_array
(
bfr
,
"heightOfStation"
)
height
.
append
(
[
hhh
]
*
self
.
Nspectra
)
sza
.
append
(
bufr
.
codes_get_array
(
bfr
,
"satelliteZenithAngle"
))
# see Arve's comment about 8700 points in the file vs 8461 spectral points.
# Eccodes library seems to find less than 8700 for some scan lines.
# swath.append(bufr.codes_get_array(bfr,"scaledIasiRadiance"))
# swath_tmp=[]
# swath_tmp.append(bufr.codes_get_array(bfr,"scaledIasiRadiance"))
swath_tmp
=
(
bufr
.
codes_get_array
(
bfr
,
"scaledIasiRadiance"
))
swath
.
append
(
swath_tmp
[
0
:
self
.
Nwvls
*
self
.
Nspectra
])
cnt
+=
1
# delete handle
bufr
.
codes_release
(
bfr
)
if
bfr
is
None
:
break
bufr
.
codes_set
(
bfr
,
'unpack'
,
1
)
lat
.
append
(
bufr
.
codes_get_array
(
bfr
,
"latitude"
))
lon
.
append
(
bufr
.
codes_get_array
(
bfr
,
"longitude"
))
self
.
yyyy
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"year"
))
self
.
MM
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"month"
))
self
.
dd
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"day"
))
self
.
hh
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"hour"
))
self
.
mm
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"minute"
))
self
.
ss
.
extend
(
bufr
.
codes_get_array
(
bfr
,
"second"
))
# ESO: It appears the scale factor data has dimension 10
# http://oiswww.eumetsat.org/WEBOPS/eps-pg/IASI-L1/IASIL1-PG-9L1Format.htm#Cgiadr-scalefactors
# We use the 5 first numbers (the 5 last seem to contain fill values/garbage),
# corresponding to values [3:7] in the start/end channel arrays
sf
.
append
(
bufr
.
codes_get_array
(
bfr
,
"channelScaleFactor"
))
stc
.
append
(
bufr
.
codes_get_array
(
bfr
,
"startChannel"
))
enc
.
append
(
bufr
.
codes_get_array
(
bfr
,
"endChannel"
))
# height.append(bufr.codes_get_array(bfr, "heightOfStation"))
# Heigth obtained this way is of size Nscanlines, so:
hhh
=
bufr
.
codes_get_array
(
bfr
,
"heightOfStation"
)
height
.
append
(
[
hhh
]
*
self
.
Nspectra
)
sza
.
append
(
bufr
.
codes_get_array
(
bfr
,
"satelliteZenithAngle"
))
# see Arve's comment about 8700 points in the file vs 8461 spectral points.
# Eccodes library seems to find less than 8700 for some scan lines.
# swath.append(bufr.codes_get_array(bfr,"scaledIasiRadiance"))
# swath_tmp=[]
# swath_tmp.append(bufr.codes_get_array(bfr,"scaledIasiRadiance"))
swath_tmp
=
(
bufr
.
codes_get_array
(
bfr
,
"scaledIasiRadiance"
))
swath
.
append
(
swath_tmp
[
0
:
self
.
Nwvls
*
self
.
Nspectra
])
cnt
+=
1
# delete handle
bufr
.
codes_release
(
bfr
)
except
Exception
as
e
:
print
(
"ERROR reading file "
,
fn
)
return
-
1
...
...
@@ -1295,60 +1295,60 @@ class Scene(object):
if
verbose
:
print
(
"ReadNetCDF: fn:"
,
fn
)
try
:
if
(
type
(
fn
)
!=
list
):
ncfile
=
Dataset
(
fn
,
'r'
)
if
verbose
:
print
(
ncfile
.
variables
)
self
.
lats
=
ncfile
.
variables
[
'lat'
][:]
self
.
lons
=
ncfile
.
variables
[
'lon'
][:]
self
.
ascan
=
ncfile
.
variables
[
'ascan'
][:]
self
.
atrack
=
ncfile
.
variables
[
'atrack'
][:]
self
.
dBT
=
ncfile
.
variables
[
'dBT'
][:]
self
.
npoints
=
len
(
self
.
lats
)
# These variables are possibly missing
try
:
self
.
SEVIRI_dBT
=
ncfile
.
variables
[
'SEVIRI_dBT'
][:]
self
.
AshML
=
ncfile
.
variables
[
'ML'
][:]
self
.
AshRe
=
ncfile
.
variables
[
'Re'
][:]
self
.
corr
=
ncfile
.
variables
[
'corr'
][:]
self
.
rms
=
ncfile
.
variables
[
'rms'
][:]
self
.
IceIWC
=
ncfile
.
variables
[
'IceIWC'
][:]
self
.
IceCloudTop
=
ncfile
.
variables
[
'IceCloudTop'
][:]
self
.
typenr
=
ncfile
.
variables
[
'typenr'
][:]
except
:
pass
if
AVHRRinfo
:
self
.
AVHRRBT4std
=
ncfile
.
variables
[
'AVHRRBT4std'
][:]
ncfile
.
close
()
else
:
for
i
,
f
in
enumerate
(
fn
):
ncfile
=
Dataset
(
f
,
'r'
)
if
i
==
0
:
self
.
lats
=
ncfile
.
variables
[
'lat'
][:]
self
.
lons
=
ncfile
.
variables
[
'lon'
][:]
self
.
ascan
=
ncfile
.
variables
[
'ascan'
][:]
self
.
atrack
=
ncfile
.
variables
[
'atrack'
][:]
self
.
dBT
=
ncfile
.
variables
[
'dBT'
][:]
else
:
self
.
lats
=
np
.
concatenate
((
self
.
lats
,
ncfile
.
variables
[
'lat'
][:]))
self
.
lons
=
np
.
concatenate
((
self
.
lons
,
ncfile
.
variables
[
'lon'
][:]))
self
.
ascan
=
np
.
concatenate
((
self
.
ascan
,
ncfile
.
variables
[
'ascan'
][:]))
self
.
atrack
=
np
.
concatenate
((
self
.
atrack
,
ncfile
.
variables
[
'atrack'
][:]))
self
.
dBT
=
np
.
concatenate
((
self
.
dBT
,
ncfile
.
variables
[
'dBT'
][:]))
ncfile
.
close
()
self
.
npoints
=
len
(
self
.
lats
)
except
Exception
as
e
:
print
(
"Exception: "
,
e
)
return
try
:
if
(
type
(
fn
)
!=
list
):
ncfile
=
Dataset
(
fn
,
'r'
)
if
verbose
:
print
(
ncfile
.
variables
)
self
.
lats
=
ncfile
.
variables
[
'lat'
][:]
self
.
lons
=
ncfile
.
variables
[
'lon'
][:]
self
.
ascan
=
ncfile
.
variables
[
'ascan'
][:]
self
.
atrack
=
ncfile
.
variables
[
'atrack'
][:]
self
.
dBT
=
ncfile
.
variables
[
'dBT'
][:]
self
.
npoints
=
len
(
self
.
lats
)
# These variables are possibly missing
try
:
self
.
SEVIRI_dBT
=
ncfile
.
variables
[
'SEVIRI_dBT'
][:]
self
.
AshML
=
ncfile
.
variables
[
'ML'
][:]
self
.
AshRe
=
ncfile
.
variables
[
'Re'
][:]
self
.
corr
=
ncfile
.
variables
[
'corr'
][:]
self
.
rms
=
ncfile
.
variables
[
'rms'
][:]
self
.
IceIWC
=
ncfile
.
variables
[
'IceIWC'
][:]
self
.
IceCloudTop
=
ncfile
.
variables
[
'IceCloudTop'
][:]
self
.
typenr
=
ncfile
.
variables
[
'typenr'
][:]
except
:
pass
if
AVHRRinfo
:
self
.
AVHRRBT4std
=
ncfile
.
variables
[
'AVHRRBT4std'
][:]
ncfile
.
close
()
else
:
for
i
,
f
in
enumerate
(
fn
):
ncfile
=
Dataset
(
f
,
'r'
)
if
i
==
0
:
self
.
lats
=
ncfile
.
variables
[
'lat'
][:]
self
.
lons
=
ncfile
.
variables
[
'lon'
][:]
self
.
ascan
=
ncfile
.
variables
[
'ascan'
][:]
self
.
atrack
=
ncfile
.
variables
[
'atrack'
][:]
self
.
dBT
=
ncfile
.
variables
[
'dBT'
][:]
else
:
self
.
lats
=
np
.
concatenate
((
self
.
lats
,
ncfile
.
variables
[
'lat'
][:]))
self
.
lons
=
np
.
concatenate
((
self
.
lons
,
ncfile
.
variables
[
'lon'
][:]))
self
.
ascan
=
np
.
concatenate
((
self
.
ascan
,
ncfile
.
variables
[
'ascan'
][:]))
self
.
atrack
=
np
.
concatenate
((
self
.
atrack
,
ncfile
.
variables
[
'atrack'
][:]))
self
.
dBT
=
np
.
concatenate
((
self
.
dBT
,
ncfile
.
variables
[
'dBT'
][:]))
ncfile
.
close
()
self
.
npoints
=
len
(
self
.
lats
)
except
Exception
as
e
:
print
(
"Exception: "
,
e
)
return
def
WriteNetcdf
(
self
,
fn
,
AVHRRinfo
=
False
,
verbose
=
False
):
...
...
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