Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
intercal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Collocation
intercal
Commits
01d5169e
Commit
01d5169e
authored
10 years ago
by
Greg Quinn
Browse files
Options
Downloads
Patches
Plain Diff
Add AIRS support for SNO extraction
parent
68d98ade
No related branches found
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
intercal/airs.py
+39
-0
39 additions, 0 deletions
intercal/airs.py
intercal/main.py
+20
-11
20 additions, 11 deletions
intercal/main.py
with
59 additions
and
11 deletions
intercal/airs.py
0 → 100644
+
39
−
0
View file @
01d5169e
import
numpy
as
np
import
pyhdf.HDF
import
pyhdf.SD
import
pyhdf.VS
class
AirsGranule
(
object
):
num_fors_per_scan
=
90
num_fovs_per_for
=
1
has_imaginary_radiance
=
False
num_files
=
1
def
__init__
(
self
,
filename
):
self
.
sd
=
pyhdf
.
SD
.
SD
(
filename
)
self
.
wavenumber
=
self
.
read_wavenumber
(
filename
)
def
read_wavenumber
(
self
,
filename
):
num_channels
=
2378
nested_list
=
pyhdf
.
HDF
.
HDF
(
filename
).
vstart
().
attach
(
'
nominal_freq
'
).
read
(
num_channels
)
return
np
.
array
(
nested_list
).
flatten
()
@property
def
num_scans
(
self
):
return
self
.
sd
.
datasets
()[
'
radiances
'
][
1
][
0
]
def
read_latitude
(
self
,
latitude
):
latitude
[:,:,
0
]
=
self
.
sd
.
select
(
'
Latitude
'
)[:]
def
read_longitude
(
self
,
longitude
):
longitude
[:,:,
0
]
=
self
.
sd
.
select
(
'
Longitude
'
)[:]
def
read_radiance
(
self
,
radiance
,
imaginary
):
if
imaginary
:
raise
ValueError
(
'
no imaginary radiances for AIRS
'
)
radiance
[:,:,
0
,:]
=
self
.
sd
.
select
(
'
radiances
'
)[:]
This diff is collapsed.
Click to expand it.
intercal/main.py
+
20
−
11
View file @
01d5169e
...
@@ -6,6 +6,7 @@ import os
...
@@ -6,6 +6,7 @@ import os
import
h5py
import
h5py
import
numpy
as
np
import
numpy
as
np
from
.airs
import
AirsGranule
from
.cris
import
CrisGranule
from
.cris
import
CrisGranule
from
.iasi
import
IasiGranule
from
.iasi
import
IasiGranule
from
.super_granule
import
SuperGranule
from
.super_granule
import
SuperGranule
...
@@ -14,13 +15,14 @@ from .util import gcdist
...
@@ -14,13 +15,14 @@ from .util import gcdist
def
_parse_args
():
def
_parse_args
():
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
metop_time
'
,
type
=
parse_datetime
)
parser
.
add_argument
(
'
platform_1
'
)
parser
.
add_argument
(
'
npp_time
'
,
type
=
parse_datetime
)
parser
.
add_argument
(
'
time_1
'
,
type
=
parse_datetime
)
parser
.
add_argument
(
'
platform_2
'
)
parser
.
add_argument
(
'
time_2
'
,
type
=
parse_datetime
)
parser
.
add_argument
(
'
latitude
'
,
type
=
float
)
parser
.
add_argument
(
'
latitude
'
,
type
=
float
)
parser
.
add_argument
(
'
longitude
'
,
type
=
float
)
parser
.
add_argument
(
'
longitude
'
,
type
=
float
)
parser
.
add_argument
(
'
max_distance
'
,
type
=
float
)
parser
.
add_argument
(
'
max_distance
'
,
type
=
float
)
parser
.
add_argument
(
'
iasi_platform
'
,
choices
=
[
'
metop-a
'
,
'
metop-b
'
])
parser
.
add_argument
(
'
sensor
'
,
choices
=
[
'
airs
'
,
'
cris
'
,
'
iasi
'
])
parser
.
add_argument
(
'
sensor
'
,
choices
=
[
'
cris
'
,
'
iasi
'
])
parser
.
add_argument
(
'
files
'
,
nargs
=
'
+
'
,
metavar
=
'
file
'
)
parser
.
add_argument
(
'
files
'
,
nargs
=
'
+
'
,
metavar
=
'
file
'
)
return
parser
.
parse_args
()
return
parser
.
parse_args
()
...
@@ -30,7 +32,7 @@ def parse_datetime(s):
...
@@ -30,7 +32,7 @@ def parse_datetime(s):
def
_create_granule
(
sensor
,
files
):
def
_create_granule
(
sensor
,
files
):
granule_cls
=
{
'
cris
'
:
CrisGranule
,
'
iasi
'
:
IasiGranule
}[
sensor
]
granule_cls
=
{
'
airs
'
:
AirsGranule
,
'
cris
'
:
CrisGranule
,
'
iasi
'
:
IasiGranule
}[
sensor
]
return
SuperGranule
(
granule_cls
,
files
)
return
SuperGranule
(
granule_cls
,
files
)
def
_filter_by_proximity
(
granule
,
lat
,
lon
,
max_distance
):
def
_filter_by_proximity
(
granule
,
lat
,
lon
,
max_distance
):
...
@@ -86,9 +88,15 @@ def unix_time(t):
...
@@ -86,9 +88,15 @@ def unix_time(t):
def
output_file_name
(
args
):
def
output_file_name
(
args
):
earlier_time
=
min
(
args
.
metop_time
,
args
.
npp_time
)
earlier_time
=
min
(
args
.
time_1
,
args
.
time_2
)
return
'
sno_{}_npp_{}_{}.h5
'
.
format
(
args
.
iasi_platform
.
lower
(),
args
.
sensor
.
lower
(),
return
'
sno_{}_{}_{}_{}.h5
'
.
format
(
platform_tag
(
args
.
platform_1
).
lower
(),
earlier_time
.
strftime
(
'
%Y-%m-%dT%H-%M
'
))
platform_tag
(
args
.
platform_2
).
lower
(),
args
.
sensor
.
lower
(),
earlier_time
.
strftime
(
'
%Y-%m-%dT%H-%M
'
))
def
platform_tag
(
platform
):
tags
=
{
'
AQUA
'
:
'
Aqua
'
,
'
METOP-A
'
:
'
Metop-A
'
,
'
METOP-B
'
:
'
Metop-B
'
,
'
SUOMI NPP
'
:
'
NPP
'
}
return
tags
[
platform
]
def
main
():
def
main
():
...
@@ -103,9 +111,10 @@ def main():
...
@@ -103,9 +111,10 @@ def main():
_process_spectra
(
_process_spectra
(
granule
,
granule
.
imaginary_radiance
,
scan_idx
,
for_idx
,
fov_idx
,
granule
,
granule
.
imaginary_radiance
,
scan_idx
,
for_idx
,
fov_idx
,
output_file
,
'
Imaginary
'
)
output_file
,
'
Imaginary
'
)
output_file
.
create_dataset
(
'
Metop-{}_Time
'
.
format
(
args
.
iasi_platform
[
-
1
].
upper
()),
output_file
.
create_dataset
(
'
{}_Time
'
.
format
(
platform_tag
(
args
.
platform_1
)),
data
=
unix_time
(
args
.
metop_time
))
data
=
unix_time
(
args
.
time_1
))
output_file
.
create_dataset
(
'
NPP_Time
'
,
data
=
unix_time
(
args
.
npp_time
))
output_file
.
create_dataset
(
'
{}_Time
'
.
format
(
platform_tag
(
args
.
platform_2
)),
data
=
unix_time
(
args
.
time_2
))
output_file
.
create_dataset
(
'
SNO_Latitude
'
,
data
=
args
.
latitude
)
output_file
.
create_dataset
(
'
SNO_Latitude
'
,
data
=
args
.
latitude
)
output_file
.
create_dataset
(
'
SNO_Longitude
'
,
data
=
args
.
longitude
)
output_file
.
create_dataset
(
'
SNO_Longitude
'
,
data
=
args
.
longitude
)
output_file
.
create_dataset
(
'
Input_Files
'
,
data
=
[
os
.
path
.
basename
(
f
)
for
f
in
args
.
files
])
output_file
.
create_dataset
(
'
Input_Files
'
,
data
=
[
os
.
path
.
basename
(
f
)
for
f
in
args
.
files
])
...
...
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